Class: Broadway::StaticFile
- Inherits:
-
Object
- Object
- Broadway::StaticFile
- Defined in:
- lib/broadway/static_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StaticFile
constructor
Initialize a new StaticFile.
- #inspect ⇒ Object
-
#write(dest) ⇒ Object
Write the static file to the destination directory.
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( = {}) @site = [:site] @path = [:path] @dir = @path.gsub(/#{@site.config[:source]}/, "").squeeze("/") end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/broadway/static_file.rb', line 4 def path @path end |
Instance Method Details
#inspect ⇒ Object
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 |