Class: Broadway::StaticFile

Inherits:
Object
  • Object
show all
Defined in:
lib/broadway/static_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ StaticFile

Initialize a new StaticFile.

+site+ is the Site
+base+ is the String path to the <source>
+dir+ is the String path between <source> and the file
+name+ is the String filename of the file

Returns <StaticFile>



12
13
14
15
16
# File 'lib/broadway/static_file.rb', line 12

def initialize(options = {})
  @site = options[:site]
  @path = options[:path]
  @dir  = @path.gsub(/#{@site.config[:source]}/, "").squeeze("/")
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/broadway/static_file.rb', line 4

def path
  @path
end

Instance Method Details

#inspectObject



27
28
29
# File 'lib/broadway/static_file.rb', line 27

def inspect
  "#<Broadway:StaticFile @path=#{self.path.inspect}>"
end

#write(dest) ⇒ Object

Write the static file to the destination directory.

+dest+ is the String path to the destination dir

Returns nothing



22
23
24
25
# File 'lib/broadway/static_file.rb', line 22

def write(dest)
  FileUtils.mkdir_p(File.join(dest, File.dirname(@dir)))
  FileUtils.cp(@path, File.join(dest, @dir))
end