jekyll-minibundle 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -2
- data/README.md +26 -21
- data/RELEASING.txt +1 -1
- data/Rakefile +19 -6
- data/lib/jekyll/minibundle/asset_bundle.rb +1 -1
- data/lib/jekyll/minibundle/asset_file_operations.rb +3 -7
- data/lib/jekyll/minibundle/asset_file_paths.rb +1 -1
- data/lib/jekyll/minibundle/bundle_file.rb +15 -35
- data/lib/jekyll/minibundle/development_file.rb +3 -8
- data/lib/jekyll/minibundle/mini_bundle_block.rb +3 -12
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +2 -12
- data/lib/jekyll/minibundle/stamp_file.rb +9 -14
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/_assets/scripts/app.js +1 -1
- data/test/fixture/site/_assets/scripts/dependency.js +1 -1
- data/test/fixture/site/_assets/styles/common.css +1 -1
- data/test/fixture/site/_assets/styles/reset.css +1 -1
- data/test/fixture/site/_tmp/site.css +1 -0
- data/test/fixture/site/index.html +2 -29
- data/test/integration/minibundle_development_mode_test.rb +6 -6
- data/test/integration/minibundle_production_mode_test.rb +2 -2
- data/test/integration/ministamp_test.rb +11 -7
- data/test/support/fixture_config.rb +1 -1
- data/test/support/test_case.rb +1 -1
- data/test/unit/bundle_file_test.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e710ae4041aa12d52354bcfe4d26cede0a7f8c11
|
4
|
+
data.tar.gz: d50a377c564e3186c790203e8c90d71a02c66cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dadbb64b20d2000b3f02285ed43b9d69ebcfd46201f62a034ec08cd7d24cf645cd2415265a05af1d7dc0d6c65438cf61ed1c657cd4abd02f53daff0a221d76c7
|
7
|
+
data.tar.gz: b214ee8464dc1f7ac95da50cbbf3635491fc9f990b167add78ef6f956e421770d9b8391d4b2e9572ce8f735c64eb9c796a4e08326f6b8c7d4d21c01deb851f78
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
# 1.4.0 / 2013-12-27
|
2
|
+
|
3
|
+
* Fix bug causing exception to be thrown when `ministamp` or
|
4
|
+
`minibundle` is called twice with same asset source argument. Allow
|
5
|
+
handling asset source files that are already static files in Jekyll
|
6
|
+
(remove the restriction introduced in 1.3.0). (@agrigg)
|
7
|
+
|
1
8
|
# 1.3.0 / 2013-12-25
|
2
9
|
|
3
10
|
* Disallow handling asset source files that are already static files
|
4
|
-
in Jekyll
|
5
|
-
|
11
|
+
in Jekyll. Otherwise, we would potentially get to inconsistencies in
|
12
|
+
Jekyll's watch mode. See "Jekyll static file restriction" in
|
13
|
+
README.md. (@agrigg)
|
6
14
|
* Upgrade development dependencies
|
7
15
|
|
8
16
|
# 1.2.0 / 2013-09-29
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Jekyll Minibundle plugin
|
2
2
|
|
3
|
-
A straightforward asset bundling plugin for
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
A straightforward asset bundling plugin for [Jekyll][Jekyll],
|
4
|
+
utilizing external minification tool of your choice. It provides asset
|
5
|
+
concatenation for bundling and asset fingerprinting with MD5 digest
|
6
|
+
for cache busting. There are no other runtime dependencies besides the
|
7
|
+
minification tool (not even other gems).
|
8
8
|
|
9
|
-
Tested with Ruby MRI 1.9.3 and 2.
|
9
|
+
Tested with Ruby MRI 1.9.3, 2.0, and 2.1. Ruby 1.8 is *not* supported.
|
10
10
|
|
11
11
|
The plugin works with Jekyll's watch (auto-regeneration) mode.
|
12
12
|
|
@@ -53,6 +53,9 @@ this line:
|
|
53
53
|
require 'jekyll/minibundle'
|
54
54
|
```
|
55
55
|
|
56
|
+
You must allow Jekyll to use custom plugins. In
|
57
|
+
[Jekyll's configuration][JekyllConf], do not enable `safe` setting.
|
58
|
+
|
56
59
|
## Asset fingerprinting
|
57
60
|
|
58
61
|
Asset fingerprinting is intended to be used together with
|
@@ -135,27 +138,26 @@ attributes:
|
|
135
138
|
And then specify the command for launching bundling in
|
136
139
|
`$JEKYLL_MINIBUNDLE_CMD_CSS` environment variable.
|
137
140
|
|
138
|
-
##
|
141
|
+
## Recommended directory layout
|
139
142
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
nicely with Jekyll's watch (auto-regeneration) mode.
|
143
|
+
It's recommended that you exclude the files you use as asset sources
|
144
|
+
from Jekyll itself. Otherwise, you end up with duplicate files in the
|
145
|
+
output directory.
|
144
146
|
|
145
|
-
For example, the following snippet
|
146
|
-
|
147
|
+
For example, in the following snippet we're using `assets/src.css` as
|
148
|
+
asset source to `ministamp` tag:
|
147
149
|
|
148
150
|
``` html
|
149
151
|
<link href="{% ministamp assets/src.css assets/dest.css %}" rel="stylesheet" media="screen, projection">
|
150
152
|
```
|
151
153
|
|
152
|
-
|
153
|
-
`dest-<md5
|
154
|
-
you probably
|
154
|
+
By default, Jekyll includes this file to the output directory. As a
|
155
|
+
result, there will be both `src.css` and `dest-<md5>.css` files in
|
156
|
+
`_site/assets/` directory, which you probably do not want.
|
155
157
|
|
156
|
-
|
157
|
-
|
158
|
-
|
158
|
+
In order to avoid this, exclude the asset source file from
|
159
|
+
Jekyll. Because Jekyll excludes directories beginning with underscore
|
160
|
+
character (`_`), consider the following directory layout:
|
159
161
|
|
160
162
|
* `_assets/` for JS and CSS assets handled by the plugin that are in
|
161
163
|
version control
|
@@ -163,8 +165,8 @@ assets:
|
|
163
165
|
are not in version control (for example, Compass output files)
|
164
166
|
* `assets/` for images and other assets handled by Jekyll directly
|
165
167
|
|
166
|
-
See [Jekyll configuration]
|
167
|
-
|
168
|
+
See [Jekyll configuration][JekyllConf] for more about excluding files
|
169
|
+
and directories.
|
168
170
|
|
169
171
|
## Development mode
|
170
172
|
|
@@ -186,3 +188,6 @@ See the contents of `test/fixture/site` directory.
|
|
186
188
|
# License
|
187
189
|
|
188
190
|
MIT. See `LICENSE.txt`.
|
191
|
+
|
192
|
+
[Jekyll]: http://jekyllrb.com/
|
193
|
+
[JekyllConf]: http://jekyllrb.com/docs/configuration/
|
data/RELEASING.txt
CHANGED
@@ -3,7 +3,7 @@ In order to release, do
|
|
3
3
|
$EDITOR lib/jekyll/minibundle/version.rb # update version number
|
4
4
|
$EDITOR CHANGELOG.md # describe a summary of changes since last release
|
5
5
|
git diff # review the changes
|
6
|
-
rake gem:build
|
6
|
+
bundle exec rake gem:build # check that tests pass
|
7
7
|
git add -p
|
8
8
|
git commit -m 'Release <version>'
|
9
9
|
git tag <version>
|
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'rake/clean'
|
2
3
|
require 'shellwords'
|
3
4
|
|
@@ -12,6 +13,12 @@ def get_minibundle_env(overrides = {})
|
|
12
13
|
}.merge(overrides)
|
13
14
|
end
|
14
15
|
|
16
|
+
def run_jekyll_in_fixture_site(command)
|
17
|
+
Dir.chdir 'test/fixture/site'
|
18
|
+
FileUtils.rm_rf '_site'
|
19
|
+
sh get_minibundle_env, "jekyll #{command}"
|
20
|
+
end
|
21
|
+
|
15
22
|
namespace :gem do
|
16
23
|
gem_name = 'jekyll-minibundle'
|
17
24
|
|
@@ -46,12 +53,18 @@ task :test do
|
|
46
53
|
sh env, cmd
|
47
54
|
end
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
Dir.chdir 'test/fixture/site'
|
52
|
-
sh(get_minibundle_env, 'jekyll')
|
53
|
-
end
|
56
|
+
namespace :fixture do
|
57
|
+
CLEAN.include 'test/fixture/site/_site'
|
54
58
|
|
55
|
-
|
59
|
+
desc 'Generate fixture site'
|
60
|
+
task :build do
|
61
|
+
run_jekyll_in_fixture_site 'build'
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'Generate fixture site in watch mode'
|
65
|
+
task :watch do
|
66
|
+
run_jekyll_in_fixture_site 'build --watch'
|
67
|
+
end
|
68
|
+
end
|
56
69
|
|
57
70
|
task :default => :test
|
@@ -3,13 +3,9 @@ require 'fileutils'
|
|
3
3
|
module Jekyll::Minibundle
|
4
4
|
module AssetFileOperations
|
5
5
|
def static_file!(site)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def check_no_existing_static_file(static_files)
|
11
|
-
found = static_files.find { |f| f.path == path }
|
12
|
-
raise "Minibundle cannot handle static file already handled by Jekyll: #{path}" if found
|
6
|
+
unless site.static_files.include? self
|
7
|
+
site.static_files << self
|
8
|
+
end
|
13
9
|
end
|
14
10
|
|
15
11
|
def write_destination(site_destination_dir)
|
@@ -7,14 +7,6 @@ module Jekyll::Minibundle
|
|
7
7
|
class BundleFile
|
8
8
|
include AssetFileOperations
|
9
9
|
|
10
|
-
def self.clear_cache
|
11
|
-
@@mtimes = {}
|
12
|
-
@@writes_after_rebundling = Hash.new false
|
13
|
-
@@asset_bundles = {}
|
14
|
-
end
|
15
|
-
|
16
|
-
clear_cache
|
17
|
-
|
18
10
|
def initialize(config)
|
19
11
|
@type = config['type']
|
20
12
|
@site_source_dir = config['site_dir']
|
@@ -22,12 +14,22 @@ module Jekyll::Minibundle
|
|
22
14
|
@assets = config['assets'].map { |asset_path| File.join asset_source_dir, "#{asset_path}.#{@type}" }
|
23
15
|
@destination_path = config['destination_path']
|
24
16
|
@attributes = config['attributes']
|
17
|
+
@stamped_at = nil
|
18
|
+
@is_modified = false
|
25
19
|
end
|
26
20
|
|
27
21
|
def markup
|
28
22
|
# we must rebundle here, if at all, in order to make sure the
|
29
23
|
# markup and generated file have the same fingerprint
|
30
|
-
|
24
|
+
if modified?
|
25
|
+
@stamped_at = mtime
|
26
|
+
@is_modified = true
|
27
|
+
@_asset_stamp = nil
|
28
|
+
asset_bundle.make_bundle
|
29
|
+
else
|
30
|
+
@is_modified = false
|
31
|
+
end
|
32
|
+
|
31
33
|
AssetTagMarkup.make_markup @type, asset_destination_path, @attributes
|
32
34
|
end
|
33
35
|
|
@@ -35,11 +37,6 @@ module Jekyll::Minibundle
|
|
35
37
|
asset_bundle.path
|
36
38
|
end
|
37
39
|
|
38
|
-
def check_no_existing_static_file(static_files)
|
39
|
-
existing = @assets & static_files.map(&:path)
|
40
|
-
raise "Minibundle cannot handle static file already handled by Jekyll: #{existing.first}" unless existing.empty?
|
41
|
-
end
|
42
|
-
|
43
40
|
def asset_destination_path
|
44
41
|
"#{@destination_path}-#{asset_stamp}.#{@type}"
|
45
42
|
end
|
@@ -53,43 +50,26 @@ module Jekyll::Minibundle
|
|
53
50
|
end
|
54
51
|
|
55
52
|
def modified?
|
56
|
-
|
53
|
+
@stamped_at != mtime
|
57
54
|
end
|
58
55
|
|
59
56
|
def write(site_destination_dir)
|
60
|
-
if File.exists?(destination(site_destination_dir)) &&
|
57
|
+
if File.exists?(destination(site_destination_dir)) && !@is_modified
|
61
58
|
false
|
62
59
|
else
|
63
60
|
write_destination site_destination_dir
|
64
|
-
@@writes_after_rebundling[asset_destination_canonical_path] = true
|
65
61
|
true
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
69
65
|
private
|
70
66
|
|
71
|
-
def asset_destination_canonical_path
|
72
|
-
"#{@destination_path}.#{@type}"
|
73
|
-
end
|
74
|
-
|
75
67
|
def asset_stamp
|
76
|
-
@
|
68
|
+
@_asset_stamp ||= AssetStamp.from_file path
|
77
69
|
end
|
78
70
|
|
79
71
|
def asset_bundle
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
def rebundle_assets
|
84
|
-
p = asset_destination_canonical_path
|
85
|
-
@@writes_after_rebundling[p] = false
|
86
|
-
@@mtimes[p] = mtime
|
87
|
-
@asset_stamp = nil
|
88
|
-
asset_bundle.make_bundle
|
89
|
-
end
|
90
|
-
|
91
|
-
def destination_written_after_rebundling?
|
92
|
-
@@writes_after_rebundling[asset_destination_canonical_path]
|
72
|
+
@_asset_bundle ||= AssetBundle.new(@type, @assets, @site_source_dir)
|
93
73
|
end
|
94
74
|
end
|
95
75
|
end
|
@@ -6,25 +6,20 @@ module Jekyll::Minibundle
|
|
6
6
|
include AssetFileOperations
|
7
7
|
include AssetFilePaths
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
attr_reader :asset_source_path, :asset_destination_dir, :asset_destination_basename
|
9
|
+
attr_reader :asset_source_path, :asset_destination_dir, :asset_destination_basename, :stamped_at
|
12
10
|
|
13
11
|
def initialize(asset_source_path, asset_destination_path)
|
14
12
|
@asset_source_path = asset_source_path
|
15
13
|
@asset_destination_dir = File.dirname asset_destination_path
|
16
14
|
@asset_destination_basename = File.basename asset_destination_path
|
17
|
-
|
18
|
-
|
19
|
-
def last_mtime_of(path)
|
20
|
-
@@mtimes[path]
|
15
|
+
@stamped_at = nil
|
21
16
|
end
|
22
17
|
|
23
18
|
def write(site_destination_dir)
|
24
19
|
if destination_exists?(site_destination_dir) && !modified?
|
25
20
|
false
|
26
21
|
else
|
27
|
-
|
22
|
+
@stamped_at = mtime
|
28
23
|
write_destination site_destination_dir
|
29
24
|
true
|
30
25
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'jekyll/minibundle/
|
3
|
-
require 'jekyll/minibundle/development_file_collection'
|
4
|
-
require 'jekyll/minibundle/environment'
|
2
|
+
require 'jekyll/minibundle/asset_file_registry'
|
5
3
|
|
6
4
|
module Jekyll::Minibundle
|
7
5
|
class MiniBundleBlock < Liquid::Block
|
@@ -12,7 +10,8 @@ module Jekyll::Minibundle
|
|
12
10
|
|
13
11
|
def render(context)
|
14
12
|
site = context.registers[:site]
|
15
|
-
|
13
|
+
config = get_current_config YAML.load(super), site
|
14
|
+
file = AssetFileRegistry.bundle_file config
|
16
15
|
file.static_file! site
|
17
16
|
file.markup
|
18
17
|
end
|
@@ -33,14 +32,6 @@ module Jekyll::Minibundle
|
|
33
32
|
merge(user_config).
|
34
33
|
merge({ 'type' => @type, 'site_dir' => site.source })
|
35
34
|
end
|
36
|
-
|
37
|
-
def get_file(config)
|
38
|
-
if Environment.development?
|
39
|
-
DevelopmentFileCollection.new config
|
40
|
-
else
|
41
|
-
BundleFile.new config
|
42
|
-
end
|
43
|
-
end
|
44
35
|
end
|
45
36
|
end
|
46
37
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'jekyll/minibundle/
|
1
|
+
require 'jekyll/minibundle/asset_file_registry'
|
2
2
|
|
3
3
|
module Jekyll::Minibundle
|
4
4
|
class MiniStampTag < Liquid::Tag
|
@@ -9,20 +9,10 @@ module Jekyll::Minibundle
|
|
9
9
|
|
10
10
|
def render(context)
|
11
11
|
site = context.registers[:site]
|
12
|
-
file =
|
12
|
+
file = AssetFileRegistry.stamp_file File.join(site.source, @asset_source), @asset_destination
|
13
13
|
file.static_file! site
|
14
14
|
file.markup
|
15
15
|
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def get_basenamer
|
20
|
-
if Environment.development?
|
21
|
-
->(base, ext, _) { base + ext }
|
22
|
-
else
|
23
|
-
->(base, ext, stamper) { "#{base}-#{stamper.call}#{ext}" }
|
24
|
-
end
|
25
|
-
end
|
26
16
|
end
|
27
17
|
end
|
28
18
|
|
@@ -7,9 +7,7 @@ module Jekyll::Minibundle
|
|
7
7
|
include AssetFileOperations
|
8
8
|
include AssetFilePaths
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
attr_reader :asset_source_path, :asset_destination_dir
|
10
|
+
attr_reader :asset_source_path, :asset_destination_dir, :stamped_at
|
13
11
|
|
14
12
|
def initialize(asset_source_path, asset_destination_path, &basenamer)
|
15
13
|
@basenamer = basenamer
|
@@ -17,7 +15,8 @@ module Jekyll::Minibundle
|
|
17
15
|
@asset_destination_dir = File.dirname asset_destination_path
|
18
16
|
@asset_destination_extension = File.extname asset_destination_path
|
19
17
|
@asset_destination_base_prefix = File.basename(asset_destination_path)[0 .. -(@asset_destination_extension.size + 1)]
|
20
|
-
@
|
18
|
+
@stamped_at = nil
|
19
|
+
@is_modified = false
|
21
20
|
end
|
22
21
|
|
23
22
|
def markup
|
@@ -25,22 +24,18 @@ module Jekyll::Minibundle
|
|
25
24
|
# to make sure the markup and generated file have the same
|
26
25
|
# fingerprint
|
27
26
|
if modified?
|
28
|
-
@
|
29
|
-
|
30
|
-
@
|
27
|
+
@stamped_at = mtime
|
28
|
+
@is_modified = true
|
29
|
+
@_asset_stamp = nil
|
31
30
|
else
|
32
|
-
@
|
31
|
+
@is_modified = false
|
33
32
|
end
|
34
33
|
|
35
34
|
asset_destination_path
|
36
35
|
end
|
37
36
|
|
38
|
-
def last_mtime_of(path)
|
39
|
-
@@mtimes[path]
|
40
|
-
end
|
41
|
-
|
42
37
|
def write(site_destination_dir)
|
43
|
-
if destination_exists?(site_destination_dir) && !@
|
38
|
+
if destination_exists?(site_destination_dir) && !@is_modified
|
44
39
|
false
|
45
40
|
else
|
46
41
|
write_destination site_destination_dir
|
@@ -55,7 +50,7 @@ module Jekyll::Minibundle
|
|
55
50
|
end
|
56
51
|
|
57
52
|
def asset_stamp
|
58
|
-
@
|
53
|
+
@_asset_stamp ||= AssetStamp.from_file(path)
|
59
54
|
end
|
60
55
|
end
|
61
56
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
/*
|
1
|
+
/* asset file, handled by Minibundle */
|
2
2
|
p { margin: 0; }
|
@@ -1,2 +1,2 @@
|
|
1
|
-
/*
|
1
|
+
/* asset file, handled by Minibundle */
|
2
2
|
html { margin: 0; }
|
@@ -1,31 +1,4 @@
|
|
1
1
|
---
|
2
|
-
layout:
|
2
|
+
layout: default
|
3
|
+
title: Index
|
3
4
|
---
|
4
|
-
|
5
|
-
<!DOCTYPE html>
|
6
|
-
<html>
|
7
|
-
<head>
|
8
|
-
<link rel="stylesheet" href="{% ministamp _tmp/site.css assets/screen.css %}" media="screen">
|
9
|
-
{% minibundle css %}
|
10
|
-
source_dir: _assets/styles
|
11
|
-
destination_path: assets/site
|
12
|
-
assets:
|
13
|
-
- reset
|
14
|
-
- common
|
15
|
-
attributes:
|
16
|
-
id: my-styles
|
17
|
-
media: projection
|
18
|
-
{% endminibundle %}
|
19
|
-
</head>
|
20
|
-
<body>
|
21
|
-
{% minibundle js %}
|
22
|
-
source_dir: _assets/scripts
|
23
|
-
destination_path: assets/site
|
24
|
-
assets:
|
25
|
-
- dependency
|
26
|
-
- app
|
27
|
-
attributes:
|
28
|
-
id: my-scripts
|
29
|
-
{% endminibundle %}
|
30
|
-
</body>
|
31
|
-
</html>
|
@@ -45,7 +45,7 @@ module Jekyll::Minibundle::Test
|
|
45
45
|
|
46
46
|
refute_equal File.read(destination), File.read(source)
|
47
47
|
|
48
|
-
generate_site :development
|
48
|
+
generate_site :development, clear_cache: false
|
49
49
|
|
50
50
|
assert_equal File.read(destination), File.read(source)
|
51
51
|
end
|
@@ -60,7 +60,7 @@ module Jekyll::Minibundle::Test
|
|
60
60
|
|
61
61
|
refute_equal File.read(destination), File.read(source)
|
62
62
|
|
63
|
-
generate_site :development
|
63
|
+
generate_site :development, clear_cache: false
|
64
64
|
|
65
65
|
assert_equal File.read(destination), File.read(source)
|
66
66
|
end
|
@@ -77,8 +77,8 @@ module Jekyll::Minibundle::Test
|
|
77
77
|
assert_equal 'assets/site/common.css', find_css_paths_from_index.last
|
78
78
|
assert_equal 'assets/site/app.js', find_js_paths_from_index.last
|
79
79
|
|
80
|
-
find_and_gsub_in_file source_path('
|
81
|
-
generate_site :development
|
80
|
+
find_and_gsub_in_file source_path('_layouts/default.html'), 'destination_path: assets/site', 'destination_path: /assets/site'
|
81
|
+
generate_site :development, clear_cache: false
|
82
82
|
|
83
83
|
assert File.exists?(expected_css_path)
|
84
84
|
assert File.exists?(expected_js_path)
|
@@ -102,12 +102,12 @@ module Jekyll::Minibundle::Test
|
|
102
102
|
expected_js_path = destination_path JS_BUNDLE_DESTINATION_PATH, 'app.js'
|
103
103
|
org_mtime = mtime_of expected_js_path
|
104
104
|
ensure_file_mtime_changes { File.write source_path(JS_BUNDLE_SOURCE_DIR, 'dependency.js'), '(function() {})()' }
|
105
|
-
generate_site :development
|
105
|
+
generate_site :development, clear_cache: false
|
106
106
|
|
107
107
|
assert_equal org_mtime, mtime_of(expected_js_path)
|
108
108
|
|
109
109
|
ensure_file_mtime_changes { FileUtils.touch 'index.html' }
|
110
|
-
generate_site :development
|
110
|
+
generate_site :development, clear_cache: false
|
111
111
|
|
112
112
|
assert_equal org_mtime, mtime_of(expected_js_path)
|
113
113
|
end
|
@@ -128,8 +128,8 @@ module Jekyll::Minibundle::Test
|
|
128
128
|
assert_equal EXPECTED_CSS_BUNDLE_PATH, find_css_path_from_index
|
129
129
|
assert_equal EXPECTED_JS_BUNDLE_PATH, find_js_path_from_index
|
130
130
|
|
131
|
-
find_and_gsub_in_file source_path('
|
132
|
-
generate_site :production
|
131
|
+
find_and_gsub_in_file source_path('_layouts/default.html'), 'destination_path: assets/site', 'destination_path: /assets/site'
|
132
|
+
generate_site :production, clear_cache: false
|
133
133
|
|
134
134
|
assert File.exists?(expected_css_path)
|
135
135
|
assert File.exists?(expected_js_path)
|
@@ -34,11 +34,16 @@ module Jekyll::Minibundle::Test
|
|
34
34
|
def test_change_asset_file
|
35
35
|
with_site do
|
36
36
|
generate_site :production
|
37
|
+
|
37
38
|
assert File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
38
|
-
|
39
|
-
|
39
|
+
|
40
|
+
ensure_file_mtime_changes { File.write source_path(STAMP_SOURCE_PATH), 'h1 {}' }
|
41
|
+
generate_site :production, clear_cache: false
|
42
|
+
|
40
43
|
refute File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
44
|
+
|
41
45
|
expected_new_path = 'assets/screen-0f5dbd1e527a2bee267e85007b08d2a5.css'
|
46
|
+
|
42
47
|
assert_equal expected_new_path, find_css_path_from_index
|
43
48
|
assert File.exists?(destination_path(expected_new_path))
|
44
49
|
end
|
@@ -52,9 +57,8 @@ module Jekyll::Minibundle::Test
|
|
52
57
|
assert File.exists?(expected_path)
|
53
58
|
assert_equal STAMP_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
54
59
|
|
55
|
-
find_and_gsub_in_file(source_path('
|
56
|
-
|
57
|
-
generate_site :production
|
60
|
+
find_and_gsub_in_file(source_path('_layouts/default.html'), %r{assets/screen.css}, '/\0')
|
61
|
+
generate_site :production, clear_cache: false
|
58
62
|
|
59
63
|
assert File.exists?(expected_path)
|
60
64
|
assert_equal "/#{STAMP_DESTINATION_FINGERPRINT_PATH}", find_css_path_from_index
|
@@ -67,12 +71,12 @@ module Jekyll::Minibundle::Test
|
|
67
71
|
expected_path = destination_path STAMP_DESTINATION_FINGERPRINT_PATH
|
68
72
|
org_mtime = mtime_of expected_path
|
69
73
|
ensure_file_mtime_changes { File.write source_path(JS_BUNDLE_SOURCE_DIR, 'dependency.js'), '(function() {})()' }
|
70
|
-
generate_site :production
|
74
|
+
generate_site :production, clear_cache: false
|
71
75
|
|
72
76
|
assert_equal org_mtime, mtime_of(expected_path)
|
73
77
|
|
74
78
|
ensure_file_mtime_changes { FileUtils.touch 'index.html' }
|
75
|
-
generate_site :production
|
79
|
+
generate_site :production, clear_cache: false
|
76
80
|
|
77
81
|
assert_equal org_mtime, mtime_of(expected_path)
|
78
82
|
end
|
@@ -2,7 +2,7 @@ module Jekyll::Minibundle::Test
|
|
2
2
|
module FixtureConfig
|
3
3
|
STAMP_SOURCE_PATH = '_tmp/site.css'
|
4
4
|
STAMP_DESTINATION_PATH = 'assets/screen.css'
|
5
|
-
STAMP_DESTINATION_FINGERPRINT_PATH = 'assets/screen-
|
5
|
+
STAMP_DESTINATION_FINGERPRINT_PATH = 'assets/screen-d57c1404fe726e66d57128a1bd190cbb.css'
|
6
6
|
|
7
7
|
CSS_BUNDLE_DESTINATION_PATH = 'assets/site'
|
8
8
|
CSS_BUNDLE_SOURCE_DIR = '_assets/styles'
|
data/test/support/test_case.rb
CHANGED
@@ -104,7 +104,7 @@ module Jekyll::Minibundle::Test
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def _generate_site(test_options)
|
107
|
-
|
107
|
+
AssetFileRegistry.clear if test_options[:clear_cache]
|
108
108
|
|
109
109
|
capture_io do
|
110
110
|
Jekyll::Site.new(Jekyll.configuration(TestCase.site_generation_jekyll_options)).process
|
@@ -7,8 +7,6 @@ module Jekyll::Minibundle::Test
|
|
7
7
|
include FixtureConfig
|
8
8
|
|
9
9
|
def test_consistent_fingerprint_in_file_and_markup
|
10
|
-
BundleFile.clear_cache
|
11
|
-
|
12
10
|
with_site do
|
13
11
|
with_env 'JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count do
|
14
12
|
bundle_file = BundleFile.new({
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-minibundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tuomas Kareinen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|