Class: Jekyll::Minibundle::BundleFile
- Inherits:
-
Object
- Object
- Jekyll::Minibundle::BundleFile
show all
- Includes:
- AssetFileOperations
- Defined in:
- lib/jekyll/minibundle/bundle_file.rb
Instance Method Summary
collapse
#static_file!, #write_destination
Constructor Details
#initialize(config) ⇒ BundleFile
Returns a new instance of BundleFile.
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 10
def initialize(config)
@type = config['type']
@site_source_dir = config['site_dir']
asset_source_dir = File.join @site_source_dir, config['source_dir']
@assets = config['assets'].map { |asset_path| File.join asset_source_dir, "#{asset_path}.#{@type}" }
@destination_path = config['destination_path']
@attributes = config['attributes']
@stamped_at = nil
@is_modified = false
end
|
Instance Method Details
#asset_destination_path ⇒ Object
40
41
42
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 40
def asset_destination_path
"#{@destination_path}-#{asset_stamp}.#{@type}"
end
|
#destination(site_destination_dir) ⇒ Object
44
45
46
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 44
def destination(site_destination_dir)
File.join site_destination_dir, asset_destination_path
end
|
#markup ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 21
def markup
if modified?
@stamped_at = mtime
@is_modified = true
@_asset_stamp = nil
asset_bundle.make_bundle
else
@is_modified = false
end
AssetTagMarkup.make_markup @type, asset_destination_path, @attributes
end
|
#modified? ⇒ Boolean
52
53
54
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 52
def modified?
@stamped_at != mtime
end
|
#mtime ⇒ Object
48
49
50
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 48
def mtime
@assets.map { |f| File.stat(f).mtime.to_i }.max
end
|
#path ⇒ Object
36
37
38
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 36
def path
asset_bundle.path
end
|
#write(site_destination_dir) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 56
def write(site_destination_dir)
if File.exists?(destination(site_destination_dir)) && !@is_modified
false
else
write_destination site_destination_dir
true
end
end
|