jekyll-assets 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.7.1 (2013-08-17)
2
+
3
+ * Minor bugfix of AssetPath and small code refactoring.
4
+
5
+
1
6
  ### 0.7.0 (2013-08-11)
2
7
 
3
8
  * Adds `debug` mode that outputs multiple scripts/styles instead of bundling
@@ -2,34 +2,29 @@ module Jekyll
2
2
  module AssetsPlugin
3
3
  class AssetPath
4
4
 
5
- attr_reader :asset
5
+ attr_writer :anchor, :query
6
6
 
7
7
 
8
- def initialize site, pathname, *args
9
- pathname, _, @anchor = pathname.rpartition "#" if pathname["#"]
10
- pathname, _, @query = pathname.rpartition "?" if pathname["?"]
11
-
12
- @asset = site.assets[pathname, *args]
13
- @site = site
14
-
15
- site.bundle_asset! asset
8
+ def initialize asset
9
+ asset.bundle!
10
+ @asset = asset
16
11
  end
17
12
 
18
13
 
19
14
  def cachebust
20
- @cachebust ||= @site.assets_config.cachebust
15
+ @cachebust ||= @asset.site.assets_config.cachebust
21
16
  end
22
17
 
23
18
 
24
19
  def path
25
- :hard == cachebust && asset.digest_path || asset.logical_path
20
+ :hard == cachebust && @asset.digest_path || @asset.logical_path
26
21
  end
27
22
 
28
23
 
29
24
  def query
30
25
  query = []
31
26
 
32
- query << "cb=#{asset.digest}" if :soft == cachebust
27
+ query << "cb=#{@asset.digest}" if :soft == cachebust
33
28
  query << @query if @query
34
29
 
35
30
  "?#{query.join '&'}" unless query.empty?
@@ -42,7 +37,7 @@ module Jekyll
42
37
 
43
38
 
44
39
  def to_s
45
- "#{@site.assets_config.baseurl}/#{path}#{query}#{anchor}"
40
+ "#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
46
41
  end
47
42
 
48
43
  end
@@ -32,6 +32,12 @@ module Jekyll
32
32
  end
33
33
 
34
34
 
35
+ def bundle!
36
+ site.bundle_asset! self if site
37
+ self
38
+ end
39
+
40
+
35
41
  def destination dest
36
42
  File.join dest, site.assets_config.dirname, filename
37
43
  end
@@ -36,8 +36,14 @@ module Jekyll
36
36
  end
37
37
 
38
38
 
39
- def asset_path *args
40
- AssetPath.new(self, *args).to_s
39
+ def asset_path pathname, *args
40
+ pathname, _, anchor = pathname.rpartition "#" if pathname["#"]
41
+ pathname, _, query = pathname.rpartition "?" if pathname["?"]
42
+
43
+ AssetPath.new(assets[pathname, *args]).tap{ |ap|
44
+ ap.anchor = anchor
45
+ ap.query = query
46
+ }.to_s
41
47
  end
42
48
 
43
49
 
@@ -24,27 +24,24 @@ module Jekyll
24
24
 
25
25
  def render_javascript
26
26
  @path << ".js" if File.extname(@path).empty?
27
-
28
- if @site.assets_config.debug
29
- return @site.assets[@path].to_a.map{ |a|
30
- JAVASCRIPT % @site.asset_path(a.logical_path, :bundle => false)
31
- }.join("\n")
32
- end
33
-
34
- JAVASCRIPT % render_asset_path
27
+ render_tag JAVASCRIPT
35
28
  end
36
29
 
37
30
 
38
31
  def render_stylesheet
39
32
  @path << ".css" if File.extname(@path).empty?
33
+ render_tag STYLESHEET
34
+ end
35
+
36
+
37
+ protected
40
38
 
41
- if @site.assets_config.debug
42
- return @site.assets[@path].to_a.map{ |a|
43
- STYLESHEET % @site.asset_path(a.logical_path, :bundle => false)
44
- }.join("\n")
45
- end
46
39
 
47
- STYLESHEET % render_asset_path
40
+ def render_tag template
41
+ asset = @site.assets[@path]
42
+ (@site.assets_config.debug ? asset.to_a : [asset]).map{ |a|
43
+ template % AssetPath.new(a).to_s
44
+ }.join("\n")
48
45
  end
49
46
 
50
47
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module AssetsPlugin
3
- VERSION = "0.7.0"
3
+ VERSION = "0.7.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-11 00:00:00.000000000 Z
12
+ date: 2013-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -249,7 +249,7 @@ rubyforge_project:
249
249
  rubygems_version: 1.8.23
250
250
  signing_key:
251
251
  specification_version: 3
252
- summary: jekyll-assets-0.7.0
252
+ summary: jekyll-assets-0.7.1
253
253
  test_files:
254
254
  - spec/fixtures/.gitignore
255
255
  - spec/fixtures/_assets/app.css.erb