jekyll-assets 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +13 -9
  3. data/README.md +36 -10
  4. data/Rakefile +40 -0
  5. data/lib/jekyll/assets.rb +13 -10
  6. data/lib/jekyll/assets/addons.rb +7 -6
  7. data/lib/jekyll/assets/addons/processors/liquid.rb +31 -0
  8. data/lib/jekyll/assets/addons/proxies/magick.rb +10 -8
  9. data/lib/jekyll/assets/config.rb +11 -8
  10. data/lib/jekyll/assets/env.rb +33 -17
  11. data/lib/jekyll/assets/hook.rb +17 -18
  12. data/lib/jekyll/assets/hooks.rb +13 -14
  13. data/lib/jekyll/assets/hooks/context_patches.rb +2 -2
  14. data/lib/jekyll/assets/hooks/helpers.rb +1 -1
  15. data/lib/jekyll/assets/hooks/jekyll/{asset_drops.rb → drops.rb} +1 -1
  16. data/lib/jekyll/assets/hooks/jekyll/setup.rb +13 -0
  17. data/lib/jekyll/assets/hooks/jekyll/{write_assets.rb → write.rb} +0 -0
  18. data/lib/jekyll/assets/hooks/sources.rb +2 -1
  19. data/lib/jekyll/assets/liquid.rb +3 -3
  20. data/lib/jekyll/assets/liquid/drop.rb +3 -3
  21. data/lib/jekyll/assets/liquid/filters.rb +5 -12
  22. data/lib/jekyll/assets/liquid/tag.rb +31 -37
  23. data/lib/jekyll/assets/liquid/tag/defaults.rb +2 -3
  24. data/lib/jekyll/assets/liquid/tag/defaults/image.rb +5 -5
  25. data/lib/jekyll/assets/liquid/tag/parser.rb +47 -55
  26. data/lib/jekyll/assets/liquid/tag/proxied_asset.rb +6 -10
  27. data/lib/jekyll/assets/liquid/tag/proxies.rb +19 -32
  28. data/lib/jekyll/assets/logger.rb +7 -6
  29. data/lib/jekyll/assets/patches.rb +4 -4
  30. data/lib/jekyll/assets/patches/kernel.rb +1 -1
  31. data/lib/jekyll/assets/version.rb +1 -1
  32. metadata +14 -14
  33. data/lib/jekyll/assets/hooks/jekyll/ignore.rb +0 -9
  34. data/lib/jekyll/assets/hooks/jekyll/initialize.rb +0 -7
@@ -2,8 +2,6 @@
2
2
  # Copyright: 2012-2015 - MIT License
3
3
  # Encoding: utf-8
4
4
 
5
- require "forwardable"
6
-
7
5
  module Jekyll
8
6
  module Assets
9
7
  module Liquid
@@ -61,10 +59,9 @@ module Jekyll
61
59
  #
62
60
 
63
61
  def digest_path
64
- name = asset.logical_path; ext = File.extname(name)
65
- "#{File.basename(name, ext)}-#{digest}#{
66
- ext
67
- }"
62
+ name = asset.logical_path
63
+ ext = File.extname(name)
64
+ "#{File.basename(name, ext)}-#{digest}#{ext}"
68
65
  end
69
66
 
70
67
  #
@@ -88,10 +85,9 @@ module Jekyll
88
85
 
89
86
  private
90
87
  def cache_file
91
- if File.file?(filename)
92
- @_cached = true else @_cached = false
93
- FileUtils.cp asset.filename, filename
94
- end
88
+ @_cached = File.file?(filename)
89
+ FileUtils.cp asset.filename, filename unless @_cached
90
+ @_cached
95
91
  end
96
92
  end
97
93
  end
@@ -7,18 +7,16 @@ module Jekyll
7
7
  module Liquid
8
8
  class Tag
9
9
  module Proxies
10
- def self.add_by_class(_class, name, tag, *args)
11
- names = [name, name.to_s, name.to_sym]
12
- tags = [tag].flatten.map { |v| [v.to_s, v, v.to_sym] }
13
- args = [args].flatten.map { |v| [v.to_s, v, v.to_sym] }
14
-
10
+ def self.add_by_class(class_, name, tag, *args)
11
+ proc_ = proc { |v| [v.to_s, v, v.to_sym] }
15
12
  all << {
16
- :name => names.uniq,
17
- :tags => tags.flatten.uniq,
18
- :args => args.flatten.uniq,
19
- :class => _class
13
+ :name => proc_.call(name).uniq,
14
+ :args => [args].flatten.map(&proc_).flatten.uniq,
15
+ :tags => [ tag].flatten.map(&proc_).flatten.uniq,
16
+ :class => class_
20
17
  }
21
- all
18
+
19
+ all
22
20
  end
23
21
 
24
22
  #
@@ -32,8 +30,7 @@ module Jekyll
32
30
  def self.keys
33
31
  all.select { |val| !val[:class].is_a?(Symbol) }.map do |val|
34
32
  val[:name]
35
- end. \
36
- flatten
33
+ end.flatten
37
34
  end
38
35
 
39
36
  #
@@ -41,8 +38,7 @@ module Jekyll
41
38
  def self.base_keys
42
39
  all.select { |val| val[:class].is_a?(Symbol) }.map do |val|
43
40
  val[:name]
44
- end. \
45
- flatten
41
+ end.flatten
46
42
  end
47
43
 
48
44
  #
@@ -54,15 +50,9 @@ module Jekyll
54
50
  #
55
51
 
56
52
  def self.get(name, tag = nil, arg = nil)
57
- if name && tag && arg
58
- get_by_name_and_tag_and_arg(
59
- name, tag, arg
60
- )
61
-
53
+ if name && tag && arg then get_by_name_and_tag_and_arg(name, tag, arg)
62
54
  elsif name && tag
63
- get_by_name_and_tag(
64
- name, tag
65
- )
55
+ get_by_name_and_tag(name, tag)
66
56
 
67
57
  else
68
58
  all.select do |val|
@@ -75,10 +65,8 @@ module Jekyll
75
65
 
76
66
  def self.get_by_name_and_tag_and_arg(name, tag, arg)
77
67
  all.select do |val|
78
- (val[:name].include?(name)) && \
79
- (val[:tags].include?(:all) || \
80
- val[:tags].include?(tag)) && \
81
- (val[:args].include?( arg))
68
+ val[:name].include?(name) && (val[:tags].include?(:all) || val[:tags] \
69
+ .include?(tag)) && val[:args].include?(arg)
82
70
  end
83
71
  end
84
72
 
@@ -86,9 +74,8 @@ module Jekyll
86
74
 
87
75
  def self.get_by_name_and_tag(name, tag)
88
76
  all.select do |val|
89
- (val[:name].include?(name)) &&
90
- (val[:tags].include?(:all) || \
91
- val[:tags].include?(tag))
77
+ val[:name].include?(name) && (val[:tags].include?(:all) || val[:tags] \
78
+ .include?(tag))
92
79
  end
93
80
  end
94
81
 
@@ -102,9 +89,9 @@ module Jekyll
102
89
 
103
90
  private
104
91
  def self.generate_class(name, tag, &block)
105
- _class = const_set(random_name, Class.new)
106
- _class. class_eval(&block)
107
- return _class, name, tag
92
+ class_ = const_set(random_name, Class.new)
93
+ class_.class_eval(&block)
94
+ return class_, name, tag
108
95
  end
109
96
 
110
97
  #
@@ -5,7 +5,8 @@
5
5
  module Jekyll
6
6
  module Assets
7
7
  class Logger
8
- Prefix="Jekyll Assets:"
8
+ PREFIX = "Jekyll Assets:"
9
+
9
10
  def log
10
11
  @_log ||= Jekyll.logger
11
12
  end
@@ -14,33 +15,33 @@ module Jekyll
14
15
 
15
16
  def warn(msg = nil, &block)
16
17
  msg = (block_given?? block.call : msg)
17
- log.warn(Prefix, msg)
18
+ log.warn(PREFIX, msg)
18
19
  end
19
20
 
20
21
  # Log Level: 1
21
22
 
22
23
  def error(msg = nil, &block)
23
24
  msg = (block_given?? block.call : msg)
24
- log.error(Prefix, msg)
25
+ log.error(PREFIX, msg)
25
26
  end
26
27
 
27
28
  # Log Level: 2
28
29
 
29
30
  def info(msg = nil, &block)
30
31
  msg = (block_given?? block.call : msg)
31
- log.info(Prefix, msg)
32
+ log.info(PREFIX, msg)
32
33
  end
33
34
 
34
35
  # Log Level: 3
35
36
 
36
37
  def debug(msg = nil, &block)
37
38
  msg = (block_given?? block.call : msg)
38
- log.debug(Prefix, msg)
39
+ log.debug(PREFIX, msg)
39
40
  end
40
41
 
41
42
  #
42
43
 
43
- def log_level=(*a)
44
+ def log_level=(*)
44
45
  raise RuntimeError, "Please set log levels on Jekyll.logger"
45
46
  end
46
47
  end
@@ -2,7 +2,7 @@
2
2
  # Copyright: 2012-2015 - MIT License
3
3
  # Encoding: utf-8
4
4
 
5
- require_relative "patches/jekyll/cleaner"
6
- require_relative "patches/sprockets/asset"
7
- require_relative "patches/jekyll/site"
8
- require_relative "patches/kernel"
5
+ require "jekyll/assets/patches/jekyll/cleaner"
6
+ require "jekyll/assets/patches/sprockets/asset"
7
+ require "jekyll/assets/patches/jekyll/site"
8
+ require "jekyll/assets/patches/kernel"
@@ -3,7 +3,7 @@
3
3
  # Encoding: utf-8
4
4
 
5
5
  module Kernel
6
- def has_javascript?
6
+ def javascript?
7
7
  require "execjs"
8
8
  if block_given?
9
9
  yield
@@ -4,6 +4,6 @@
4
4
 
5
5
  module Jekyll
6
6
  module Assets
7
- VERSION="2.0.3"
7
+ VERSION="2.1.0"
8
8
  end
9
9
  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: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-11-23 00:00:00.000000000 Z
13
+ date: 2015-12-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sprockets
@@ -69,33 +69,33 @@ dependencies:
69
69
  - !ruby/object:Gem::Version
70
70
  version: '3.0'
71
71
  - !ruby/object:Gem::Dependency
72
- name: nokogiri
72
+ name: tilt
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '1.6'
78
- type: :development
77
+ version: '2.0'
78
+ type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '1.6'
84
+ version: '2.0'
85
85
  - !ruby/object:Gem::Dependency
86
- name: envygeeks-coveralls
86
+ name: nokogiri
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '1.0'
91
+ version: '1.6'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '1.0'
98
+ version: '1.6'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: luna-rspec-formatters
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -148,6 +148,7 @@ files:
148
148
  - lib/jekyll/assets/addons/compass.rb
149
149
  - lib/jekyll/assets/addons/font_awesome.rb
150
150
  - lib/jekyll/assets/addons/js_es6.rb
151
+ - lib/jekyll/assets/addons/processors/liquid.rb
151
152
  - lib/jekyll/assets/addons/proxies/magick.rb
152
153
  - lib/jekyll/assets/cached.rb
153
154
  - lib/jekyll/assets/config.rb
@@ -160,10 +161,9 @@ files:
160
161
  - lib/jekyll/assets/hooks/context_patches.rb
161
162
  - lib/jekyll/assets/hooks/disable_erb.rb
162
163
  - lib/jekyll/assets/hooks/helpers.rb
163
- - lib/jekyll/assets/hooks/jekyll/asset_drops.rb
164
- - lib/jekyll/assets/hooks/jekyll/ignore.rb
165
- - lib/jekyll/assets/hooks/jekyll/initialize.rb
166
- - lib/jekyll/assets/hooks/jekyll/write_assets.rb
164
+ - lib/jekyll/assets/hooks/jekyll/drops.rb
165
+ - lib/jekyll/assets/hooks/jekyll/setup.rb
166
+ - lib/jekyll/assets/hooks/jekyll/write.rb
167
167
  - lib/jekyll/assets/hooks/logger.rb
168
168
  - lib/jekyll/assets/hooks/sources.rb
169
169
  - lib/jekyll/assets/hooks/sprockets.rb
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  version: '0'
205
205
  requirements: []
206
206
  rubyforge_project:
207
- rubygems_version: 2.4.5.1
207
+ rubygems_version: 2.5.0
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: Assets for Jekyll
@@ -1,9 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2012-2015 - MIT License
3
- # Encoding: utf-8
4
-
5
- Jekyll::Hooks.register :site, :after_reset do |jekyll|
6
- unless jekyll.config["exclude"].grep(/\A\.asset\-cache\/?/).size > 0
7
- jekyll.config["exclude"].push(".asset-cache/")
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2012-2015 - MIT License
3
- # Encoding: utf-8
4
-
5
- Jekyll::Hooks.register :site, :post_read do |jekyll|
6
- Jekyll::Assets::Env.new(jekyll)
7
- end