class Potion::StaticFile

Attributes

content[RW]
output_path[RW]
path[RW]
relative_output_path[RW]
site[RW]

Public Class Methods

new(path, site) click to toggle source
# File lib/potion/static_file.rb, line 5
def initialize(path, site)
  @path = path
  @site = site
  @content = File.open(path) {|stream| stream.read }
  @relative_output_path = @path.gsub(@site.base_path, "").gsub("_posts/", "")
  @output_path = File.join(@site.destination_path, @relative_output_path)
end

Public Instance Methods

==(other) click to toggle source
# File lib/potion/static_file.rb, line 13
def ==(other)
  self.class.name == other.class.name &&
  @path == other.path && 
  @site == other.site
end
render() click to toggle source
# File lib/potion/static_file.rb, line 19
def render
  @site.class.extensions.each do |extension|
    extension.new.process(self)
  end
  
  @content
end
write() click to toggle source
# File lib/potion/static_file.rb, line 27
def write
  FileUtils.mkdir_p(File.split(@output_path)[0])
  File.open(@output_path, "w+") do |stream|
    stream.puts self.render
  end
end