jekyll-assets 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +48 -0
- data/Gemfile +4 -4
- data/Rakefile +5 -3
- data/lib/jekyll-assets/bootstrap.rb +6 -7
- data/lib/jekyll-assets/bourbon.rb +0 -1
- data/lib/jekyll-assets/compass.rb +2 -4
- data/lib/jekyll-assets/neat.rb +0 -1
- data/lib/jekyll/assets_plugin/asset_path.rb +1 -9
- data/lib/jekyll/assets_plugin/configuration.rb +18 -24
- data/lib/jekyll/assets_plugin/environment.rb +4 -12
- data/lib/jekyll/assets_plugin/filters.rb +1 -5
- data/lib/jekyll/assets_plugin/patches/asset_patch.rb +6 -23
- data/lib/jekyll/assets_plugin/patches/bundled_asset_patch.rb +1 -5
- data/lib/jekyll/assets_plugin/patches/context_patch.rb +2 -7
- data/lib/jekyll/assets_plugin/patches/index_patch.rb +2 -7
- data/lib/jekyll/assets_plugin/patches/processed_asset_patch.rb +19 -18
- data/lib/jekyll/assets_plugin/patches/site_patch.rb +11 -22
- data/lib/jekyll/assets_plugin/renderer.rb +7 -16
- data/lib/jekyll/assets_plugin/tag.rb +1 -6
- data/lib/jekyll/assets_plugin/version.rb +1 -1
- data/spec/lib/jekyll-assets/bootstrap_spec.rb +10 -10
- data/spec/lib/jekyll-assets/bourbon_spec.rb +0 -1
- data/spec/lib/jekyll-assets/compass_spec.rb +0 -1
- data/spec/lib/jekyll-assets/neat_spec.rb +0 -1
- data/spec/lib/jekyll/assets_plugin/configuration_spec.rb +30 -18
- data/spec/lib/jekyll/assets_plugin/environment_spec.rb +2 -3
- data/spec/lib/jekyll/assets_plugin/filters_spec.rb +8 -6
- data/spec/lib/jekyll/assets_plugin/patches/site_patch_spec.rb +13 -22
- data/spec/lib/jekyll/assets_plugin/renderer_spec.rb +8 -13
- data/spec/lib/jekyll/assets_plugin/tag_spec.rb +8 -6
- data/spec/spec_helper.rb +3 -7
- data/spec/support/fixtures_path.rb +2 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c10ed0e80b3a4beea2ca55d84e3fb90d0308a70
|
4
|
+
data.tar.gz: 3a4da62d35bac89038896162f6d78d367fd1c869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70e33d032f3aca16cb6d64ade3de4fb52138d46f0592be6e6f389bcc81085deb704dff05a9374ec570a78ea62c9835dc52b0f3e7d51ea712053fc00e2c8079e
|
7
|
+
data.tar.gz: 2bb58025391bef810dec0a607ef783c7899b332bb50b37773f73fdc88864bfee3d10781893a0e65f2cb74f962b62ffed6e338e211da9520f5249c906c485b3a3
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Avoid long parameter lists
|
2
|
+
ParameterLists:
|
3
|
+
Max: 3
|
4
|
+
CountKeywordArgs: true
|
5
|
+
|
6
|
+
MethodLength:
|
7
|
+
CountComments: false
|
8
|
+
Max: 15
|
9
|
+
|
10
|
+
ClassLength:
|
11
|
+
CountComments: false
|
12
|
+
Max: 100
|
13
|
+
|
14
|
+
CyclomaticComplexity:
|
15
|
+
Max: 6
|
16
|
+
|
17
|
+
EmptyLineBetweenDefs:
|
18
|
+
AllowAdjacentOneLineDefs: true
|
19
|
+
|
20
|
+
BlockNesting:
|
21
|
+
Max: 3
|
22
|
+
|
23
|
+
HashSyntax:
|
24
|
+
EnforcedStyle: hash_rockets
|
25
|
+
|
26
|
+
Encoding:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
StringLiterals:
|
30
|
+
EnforcedStyle: double_quotes
|
31
|
+
|
32
|
+
BracesAroundHashParameters:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Documentation:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
39
|
+
TrivialAccessors:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
# New lambda syntax is UGLY, don't enforce it
|
43
|
+
Lambda:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
AllCops:
|
47
|
+
Includes:
|
48
|
+
- Gemfile
|
data/Gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
+
gem "rubocop"
|
3
4
|
|
4
5
|
group :test do
|
5
|
-
gem
|
6
|
-
gem
|
6
|
+
gem "coveralls", :require => false
|
7
|
+
gem "simplecov", :require => false
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
10
|
# Specify your gem's dependencies in jekyll-assets.gemspec
|
11
11
|
gemspec
|
data/Rakefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rspec/core/rake_task"
|
3
2
|
|
3
|
+
require "rspec/core/rake_task"
|
4
4
|
RSpec::Core::RakeTask.new
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
require "rubocop/rake_task"
|
7
|
+
Rubocop::RakeTask.new
|
8
|
+
|
9
|
+
task :default => [:spec, :rubocop]
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require "sprockets"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
1
|
+
require "sprockets"
|
2
|
+
|
3
|
+
bootstrap = Gem::Specification.find_by_name("bootstrap-sass").gem_dir
|
4
|
+
%w(fonts javascripts stylesheets).each do |asset|
|
5
|
+
Sprockets.append_path File.join(bootstrap, "vendor", "assets", asset)
|
6
|
+
end
|
data/lib/jekyll-assets/neat.rb
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module AssetsPlugin
|
3
3
|
class AssetPath
|
4
|
-
|
5
4
|
attr_writer :anchor, :query
|
6
5
|
|
7
|
-
|
8
|
-
def initialize asset
|
6
|
+
def initialize(asset)
|
9
7
|
asset.bundle!
|
10
8
|
@asset = asset
|
11
9
|
end
|
12
10
|
|
13
|
-
|
14
11
|
def cachebust
|
15
12
|
@cachebust ||= @asset.site.assets_config.cachebust
|
16
13
|
end
|
17
14
|
|
18
|
-
|
19
15
|
def path
|
20
16
|
:hard == cachebust && @asset.digest_path || @asset.logical_path
|
21
17
|
end
|
22
18
|
|
23
|
-
|
24
19
|
def query
|
25
20
|
query = []
|
26
21
|
|
@@ -30,16 +25,13 @@ module Jekyll
|
|
30
25
|
"?#{query.join '&'}" unless query.empty?
|
31
26
|
end
|
32
27
|
|
33
|
-
|
34
28
|
def anchor
|
35
29
|
"##{@anchor}" if @anchor
|
36
30
|
end
|
37
31
|
|
38
|
-
|
39
32
|
def to_s
|
40
33
|
"#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
|
41
34
|
end
|
42
|
-
|
43
35
|
end
|
44
36
|
end
|
45
37
|
end
|
@@ -1,27 +1,28 @@
|
|
1
1
|
# stdlib
|
2
2
|
require "ostruct"
|
3
3
|
|
4
|
-
|
5
4
|
module Jekyll
|
6
5
|
module AssetsPlugin
|
7
6
|
class Configuration
|
8
7
|
DEFAULTS = {
|
9
8
|
:dirname => "assets",
|
10
|
-
:sources => %w{_assets/javascripts
|
9
|
+
:sources => %w{ _assets/javascripts
|
10
|
+
_assets/stylesheets
|
11
|
+
_assets/images },
|
11
12
|
:js_compressor => nil,
|
12
13
|
:css_compressor => nil,
|
13
14
|
:cachebust => :hard,
|
14
15
|
:cache => false,
|
15
16
|
:gzip => %w{ text/css application/javascript },
|
16
|
-
:debug => false
|
17
|
+
:debug => false,
|
18
|
+
:version => 1
|
17
19
|
}.freeze
|
18
20
|
|
19
|
-
|
20
|
-
def initialize config = {}
|
21
|
+
def initialize(config = {})
|
21
22
|
@data = OpenStruct.new DEFAULTS.merge(config)
|
22
23
|
|
23
|
-
@data.sources = [
|
24
|
-
@data.dirname = @data.dirname.gsub(
|
24
|
+
@data.sources = [@data.sources] if @data.sources.is_a? String
|
25
|
+
@data.dirname = @data.dirname.gsub(%r{^/+|/+$}, "")
|
25
26
|
|
26
27
|
compress = OpenStruct.new @data.compress
|
27
28
|
|
@@ -30,62 +31,55 @@ module Jekyll
|
|
30
31
|
@data.cache ||= @data.cache_assets
|
31
32
|
|
32
33
|
# if baseurl not given - autoguess base on dirname
|
33
|
-
@data.baseurl ||= "/#{@data.dirname}/".squeeze
|
34
|
+
@data.baseurl ||= "/#{@data.dirname}/".squeeze "/"
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
37
|
def baseurl
|
38
38
|
@data.baseurl.chomp "/"
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
41
|
def js_compressor
|
43
42
|
compressor @data.js_compressor
|
44
43
|
end
|
45
44
|
|
46
|
-
|
47
45
|
def css_compressor
|
48
46
|
compressor @data.css_compressor
|
49
47
|
end
|
50
48
|
|
51
|
-
|
52
49
|
def cachebust
|
53
50
|
return :none if none?(@data.cachebust)
|
54
|
-
return @data.cachebust.to_sym if @data.cachebust.to_s
|
55
|
-
|
51
|
+
return @data.cachebust.to_sym if @data.cachebust.to_s[/^(soft|hard)$/]
|
52
|
+
fail "Unknown cachebust strategy: #{@data.cachebust}"
|
56
53
|
end
|
57
54
|
|
58
|
-
|
59
55
|
def cache_assets?
|
60
56
|
!!@data.cache
|
61
57
|
end
|
62
58
|
|
63
|
-
|
64
59
|
def cache_path
|
65
60
|
@data.cache.is_a?(String) ? @data.cache : ".jekyll-assets-cache"
|
66
61
|
end
|
67
62
|
|
68
|
-
|
69
63
|
def gzip
|
70
64
|
return @data.gzip if @data.gzip.is_a? Array
|
71
65
|
@data.gzip ? DEFAULTS[:gzip] : []
|
72
66
|
end
|
73
67
|
|
68
|
+
def version
|
69
|
+
@data.version
|
70
|
+
end
|
74
71
|
|
75
|
-
def method_missing
|
72
|
+
def method_missing(name, *args, &block)
|
76
73
|
@data.send name, *args, &block
|
77
74
|
end
|
78
75
|
|
76
|
+
private
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
def none? val
|
78
|
+
def none?(val)
|
84
79
|
val.to_s.empty? || "none" == val.to_s.downcase
|
85
80
|
end
|
86
81
|
|
87
|
-
|
88
|
-
def compressor val
|
82
|
+
def compressor(val)
|
89
83
|
none?(val) ? nil : val.to_sym
|
90
84
|
end
|
91
85
|
end
|
@@ -1,26 +1,21 @@
|
|
1
1
|
# stdlib
|
2
2
|
require "pathname"
|
3
3
|
|
4
|
-
|
5
4
|
# 3rd-party
|
6
5
|
require "sprockets"
|
7
6
|
|
8
|
-
|
9
7
|
module Jekyll
|
10
8
|
module AssetsPlugin
|
11
9
|
class Environment < Sprockets::Environment
|
12
|
-
|
13
10
|
class AssetNotFound < StandardError
|
14
|
-
def initialize
|
11
|
+
def initialize(path)
|
15
12
|
super "Couldn't find file '#{path}'"
|
16
13
|
end
|
17
14
|
end
|
18
15
|
|
19
|
-
|
20
16
|
attr_reader :site
|
21
17
|
|
22
|
-
|
23
|
-
def initialize site
|
18
|
+
def initialize(site)
|
24
19
|
super site.source
|
25
20
|
|
26
21
|
@site = site
|
@@ -43,16 +38,13 @@ module Jekyll
|
|
43
38
|
context_class.send :include, Patches::ContextPatch
|
44
39
|
end
|
45
40
|
|
46
|
-
|
47
41
|
def cache_path
|
48
42
|
Pathname.new(@site.source).join @site.assets_config.cache_path
|
49
43
|
end
|
50
44
|
|
51
|
-
|
52
|
-
|
53
|
-
super or raise AssetNotFound, path
|
45
|
+
def find_asset(path, *args)
|
46
|
+
super || fail(AssetNotFound, path)
|
54
47
|
end
|
55
|
-
|
56
48
|
end
|
57
49
|
end
|
58
50
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# internal
|
2
|
-
require
|
3
|
-
|
2
|
+
require "jekyll/assets_plugin/renderer"
|
4
3
|
|
5
4
|
module Jekyll
|
6
5
|
module AssetsPlugin
|
7
6
|
module Filters
|
8
|
-
|
9
7
|
%w{ asset asset_path image javascript stylesheet }.each do |name|
|
10
8
|
module_eval <<-RUBY, __FILE__, __LINE__
|
11
9
|
def #{name} path # def stylesheet logical_path
|
@@ -14,10 +12,8 @@ module Jekyll
|
|
14
12
|
end # end
|
15
13
|
RUBY
|
16
14
|
end
|
17
|
-
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
21
18
|
|
22
|
-
|
23
19
|
Liquid::Template.register_filter Jekyll::AssetsPlugin::Filters
|
@@ -1,66 +1,53 @@
|
|
1
1
|
# 3rd-party
|
2
2
|
require "sprockets"
|
3
3
|
|
4
|
-
|
5
4
|
module Jekyll
|
6
5
|
module AssetsPlugin
|
7
6
|
module Patches
|
8
7
|
module AssetPatch
|
9
|
-
|
10
|
-
def self.included base
|
8
|
+
def self.included(base)
|
11
9
|
base.send :extend, ClassMethods
|
12
10
|
base.send :include, InstanceMethods
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
13
|
module ClassMethods
|
17
|
-
|
18
14
|
def mtimes
|
19
|
-
@mtimes ||=
|
15
|
+
@mtimes ||= {}
|
20
16
|
end
|
21
|
-
|
22
17
|
end
|
23
18
|
|
24
|
-
|
25
19
|
module InstanceMethods
|
26
|
-
|
27
20
|
attr_reader :site
|
28
21
|
|
29
|
-
|
30
22
|
def jekyll_assets
|
31
23
|
[]
|
32
24
|
end
|
33
25
|
|
34
|
-
|
35
26
|
def bundle!
|
36
27
|
site.bundle_asset! self if site
|
37
28
|
self
|
38
29
|
end
|
39
30
|
|
40
|
-
|
41
|
-
def destination dest
|
31
|
+
def destination(dest)
|
42
32
|
File.join dest, site.assets_config.dirname, filename
|
43
33
|
end
|
44
34
|
|
45
|
-
|
46
35
|
def filename
|
47
36
|
case cachebust = site.assets_config.cachebust
|
48
37
|
when :none, :soft then logical_path
|
49
38
|
when :hard then digest_path
|
50
|
-
else
|
39
|
+
else fail "Unknown cachebust strategy: #{cachebust.inspect}"
|
51
40
|
end
|
52
41
|
end
|
53
42
|
|
54
|
-
|
55
43
|
def modified?
|
56
44
|
self.class.mtimes[pathname.to_s] != mtime.to_i
|
57
45
|
end
|
58
46
|
|
59
|
-
|
60
|
-
def write dest
|
47
|
+
def write(dest)
|
61
48
|
dest_path = destination dest
|
62
49
|
|
63
|
-
return false if File.exist?(dest_path)
|
50
|
+
return false if File.exist?(dest_path) && !modified?
|
64
51
|
self.class.mtimes[pathname.to_s] = mtime.to_i
|
65
52
|
|
66
53
|
write_to dest_path
|
@@ -69,17 +56,13 @@ module Jekyll
|
|
69
56
|
true
|
70
57
|
end
|
71
58
|
|
72
|
-
|
73
59
|
def gzip?
|
74
60
|
site.assets_config.gzip.include? content_type
|
75
61
|
end
|
76
|
-
|
77
62
|
end
|
78
|
-
|
79
63
|
end
|
80
64
|
end
|
81
65
|
end
|
82
66
|
end
|
83
67
|
|
84
|
-
|
85
68
|
Sprockets::Asset.send :include, Jekyll::AssetsPlugin::Patches::AssetPatch
|