Class: IS::StaticFile
- Inherits:
-
Jekyll::StaticFile
- Object
- Jekyll::StaticFile
- IS::StaticFile
- Defined in:
- lib/is/static_file.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#content ⇒ Object
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #destination(dest) ⇒ Object
-
#initialize(site, target, name, source: nil, content: nil) ⇒ StaticFile
constructor
A new instance of StaticFile.
- #modified? ⇒ Boolean
- #path ⇒ Object
- #relative_path ⇒ Object
- #write(dest) ⇒ Object
Constructor Details
#initialize(site, target, name, source: nil, content: nil) ⇒ StaticFile
Returns a new instance of StaticFile.
12 13 14 15 16 17 18 19 20 |
# File 'lib/is/static_file.rb', line 12 def initialize site, target, name, source: nil, content: nil @site = site @target = target @name = name @source = source @content = content @base = File.dirname(@source || "/") super @site, @base, "", @name end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
10 11 12 |
# File 'lib/is/static_file.rb', line 10 def base @base end |
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/is/static_file.rb', line 9 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/is/static_file.rb', line 10 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
10 11 12 |
# File 'lib/is/static_file.rb', line 10 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/is/static_file.rb', line 10 def target @target end |
Instance Method Details
#destination(dest) ⇒ Object
26 27 28 |
# File 'lib/is/static_file.rb', line 26 def destination dest File.join dest, @target, @name end |
#modified? ⇒ Boolean
46 47 48 49 |
# File 'lib/is/static_file.rb', line 46 def modified? return super if @source !!@content end |
#path ⇒ Object
22 23 24 |
# File 'lib/is/static_file.rb', line 22 def path @source end |
#relative_path ⇒ Object
30 31 32 |
# File 'lib/is/static_file.rb', line 30 def relative_path File.join @target, @name end |
#write(dest) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/is/static_file.rb', line 34 def write dest return super(dest) if @source return false unless @content dest_path = destination dest FileUtils.mkdir_p(File.dirname(dest_path)) File.open dest_path, 'wb' do |io| io.write(@content || '') end true end |