Class: Jekyll::Minibundle::BundleFile
- Inherits:
-
Object
- Object
- Jekyll::Minibundle::BundleFile
show all
- Includes:
- AssetFileOperations
- Defined in:
- lib/jekyll/minibundle/bundle_file.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#static_file!, #write_destination
Constructor Details
#initialize(config) ⇒ BundleFile
Returns a new instance of BundleFile.
18
19
20
21
22
23
24
25
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 18
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']
end
|
Class Method Details
.clear_cache ⇒ Object
10
11
12
13
14
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 10
def self.clear_cache
@@mtimes = {}
@@writes_after_mtime_updates = Hash.new false
@@asset_bundles = {}
end
|
Instance Method Details
#asset_destination_path ⇒ Object
38
39
40
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 38
def asset_destination_path
"#{@destination_path}-#{asset_stamp}.#{@type}"
end
|
#destination(site_destination_dir) ⇒ Object
42
43
44
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 42
def destination(site_destination_dir)
File.join site_destination_dir, asset_destination_path
end
|
#destination_written_after_mtime_update? ⇒ Boolean
54
55
56
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 54
def destination_written_after_mtime_update?
@@writes_after_mtime_updates[asset_destination_canonical_path]
end
|
#markup ⇒ Object
27
28
29
30
31
32
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 27
def markup
rebundle_assets if modified?
AssetTagMarkup.make_markup @type, asset_destination_path, @attributes
end
|
#modified? ⇒ Boolean
50
51
52
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 50
def modified?
@@mtimes[asset_destination_canonical_path] != mtime
end
|
#mtime ⇒ Object
46
47
48
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 46
def mtime
@assets.map { |f| File.stat(f).mtime.to_i }.max
end
|
#path ⇒ Object
34
35
36
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 34
def path
asset_bundle.path
end
|
#write(site_destination_dir) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/jekyll/minibundle/bundle_file.rb', line 58
def write(site_destination_dir)
if File.exists?(destination(site_destination_dir)) && destination_written_after_mtime_update?
false
else
write_destination site_destination_dir
@@writes_after_mtime_updates[asset_destination_canonical_path] = true
true
end
end
|