Class: Henshin::Static

Inherits:
Object
  • Object
show all
Defined in:
lib/henshin/static.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, site) ⇒ Static

Returns a new instance of Static.



7
8
9
10
11
# File 'lib/henshin/static.rb', line 7

def initialize( path, site )
  @path = path
  @site = site
  @content = File.read(path)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/henshin/static.rb', line 5

def content
  @content
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/henshin/static.rb', line 5

def path
  @path
end

#siteObject

Returns the value of attribute site.



5
6
7
# File 'lib/henshin/static.rb', line 5

def site
  @site
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/henshin/static.rb', line 27

def inspect
  "#<Static:#{@path}>"
end

#writeObject

Writes the file to the correct place



15
16
17
18
19
# File 'lib/henshin/static.rb', line 15

def write
  FileUtils.mkdir_p(self.write_path.dirname)
  file = File.new(self.write_path, "w")
  file.puts(@content)
end

#write_pathPathname

Returns path to write the file.

Returns:



22
23
24
25
# File 'lib/henshin/static.rb', line 22

def write_path
  rel = @path.relative_path_from(@site.root)
  @site.target + File.join(@site.base, rel)[1..-1]
end