jekyll-minibundle 1.4.1 → 1.4.2
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/CHANGELOG.md +10 -0
- data/Rakefile +2 -2
- data/jekyll-minibundle.gemspec +2 -43
- data/lib/jekyll/minibundle/bundle_file.rb +1 -2
- data/lib/jekyll/minibundle/development_file_collection.rb +1 -1
- data/lib/jekyll/minibundle/stamp_file.rb +1 -2
- data/lib/jekyll/minibundle/version.rb +1 -1
- data/test/fixture/site/assets/{styles/reset.css → site.css} +0 -0
- data/test/integration/minibundle_development_mode_test.rb +36 -28
- data/test/integration/minibundle_production_mode_test.rb +49 -23
- data/test/integration/ministamp_test.rb +23 -14
- data/test/integration/static_files_as_asset_sources_test.rb +16 -1
- data/test/unit/asset_file_registry_test.rb +8 -11
- data/test/unit/asset_tag_markup_test.rb +1 -1
- data/test/unit/bundle_file_test.rb +48 -9
- data/test/unit/stamp_file_test.rb +32 -3
- metadata +4 -5
- data/RELEASING.txt +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb4db2142f8fea9e137638a9f81fcf1673b0076c
|
4
|
+
data.tar.gz: 391293041abe19a1f143b28c6592fe2932bbac2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23acbd135fc4100e284bb059a98c18dc981deb0dd83e0a7ee9aaba52bab6b8188f2fb2121ace3970086292db53053518e3633ff4b73d0f63406f7017dd07395
|
7
|
+
data.tar.gz: 56506b2a3bafebeef270f7630a69ff8c7ba08ed87ee33f13d595487b05e5804843a429d7f1382600c718006b4e03683d8824671395aeb04f108c3ede05868c2e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 1.4.2 / 2013-12-28
|
2
|
+
|
3
|
+
* Ensure touching asset source triggers destination write. This was an
|
4
|
+
unintentional edge case earlier. Now the behavior of touching the
|
5
|
+
asset source is consistent with when changing the contents of the
|
6
|
+
source.
|
7
|
+
* Separate tags produced by `minibundle` in development mode with
|
8
|
+
newlines
|
9
|
+
* Clarify tests, increase coverage
|
10
|
+
|
1
11
|
# 1.4.1 / 2013-12-27
|
2
12
|
|
3
13
|
* Add missing files to gem package
|
data/Rakefile
CHANGED
@@ -30,8 +30,8 @@ namespace :gem do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
desc 'Install the software as a gem'
|
33
|
-
task :install
|
34
|
-
sh %{gem install #{gem_name}-#{Jekyll::Minibundle::VERSION}}
|
33
|
+
task :install do
|
34
|
+
sh %{gem install #{gem_name}-#{Jekyll::Minibundle::VERSION}.gem}
|
35
35
|
end
|
36
36
|
|
37
37
|
desc 'Uninstall the gem'
|
data/jekyll-minibundle.gemspec
CHANGED
@@ -21,52 +21,11 @@ minification tool (not even other gems).
|
|
21
21
|
CHANGELOG.md
|
22
22
|
LICENSE.txt
|
23
23
|
README.md
|
24
|
-
RELEASING.txt
|
25
24
|
Rakefile
|
26
25
|
jekyll-minibundle.gemspec
|
27
|
-
|
28
|
-
lib/jekyll/minibundle/asset_bundle.rb
|
29
|
-
lib/jekyll/minibundle/asset_file_operations.rb
|
30
|
-
lib/jekyll/minibundle/asset_file_paths.rb
|
31
|
-
lib/jekyll/minibundle/asset_file_registry.rb
|
32
|
-
lib/jekyll/minibundle/asset_stamp.rb
|
33
|
-
lib/jekyll/minibundle/asset_tag_markup.rb
|
34
|
-
lib/jekyll/minibundle/bundle_file.rb
|
35
|
-
lib/jekyll/minibundle/development_file.rb
|
36
|
-
lib/jekyll/minibundle/development_file_collection.rb
|
37
|
-
lib/jekyll/minibundle/environment.rb
|
38
|
-
lib/jekyll/minibundle/mini_bundle_block.rb
|
39
|
-
lib/jekyll/minibundle/mini_stamp_tag.rb
|
40
|
-
lib/jekyll/minibundle/stamp_file.rb
|
41
|
-
lib/jekyll/minibundle/version.rb
|
42
|
-
}
|
26
|
+
} + `git ls-files -- lib`.split("\n")
|
43
27
|
|
44
|
-
s.test_files =
|
45
|
-
test/fixture/site/_assets/scripts/app.js
|
46
|
-
test/fixture/site/_assets/scripts/dependency.js
|
47
|
-
test/fixture/site/_assets/styles/common.css
|
48
|
-
test/fixture/site/_assets/styles/reset.css
|
49
|
-
test/fixture/site/_bin/remove_comments
|
50
|
-
test/fixture/site/_bin/with_count
|
51
|
-
test/fixture/site/_config.yml
|
52
|
-
test/fixture/site/_layouts/default.html
|
53
|
-
test/fixture/site/_plugins/minibundle.rb
|
54
|
-
test/fixture/site/_tmp/site.css
|
55
|
-
test/fixture/site/about.html
|
56
|
-
test/fixture/site/assets/styles/reset.css
|
57
|
-
test/fixture/site/index.html
|
58
|
-
test/integration/minibundle_development_mode_test.rb
|
59
|
-
test/integration/minibundle_production_mode_test.rb
|
60
|
-
test/integration/ministamp_test.rb
|
61
|
-
test/integration/static_files_as_asset_sources_test.rb
|
62
|
-
test/support/fixture_config.rb
|
63
|
-
test/support/test_case.rb
|
64
|
-
test/unit/asset_bundle_test.rb
|
65
|
-
test/unit/asset_file_registry_test.rb
|
66
|
-
test/unit/asset_tag_markup_test.rb
|
67
|
-
test/unit/bundle_file_test.rb
|
68
|
-
test/unit/stamp_file_test.rb
|
69
|
-
}
|
28
|
+
s.test_files = `git ls-files -- test`.split("\n")
|
70
29
|
|
71
30
|
s.add_development_dependency 'jekyll', '~> 1.4.2'
|
72
31
|
s.add_development_dependency 'minitest', '~> 5.2.0'
|
@@ -26,8 +26,6 @@ module Jekyll::Minibundle
|
|
26
26
|
@is_modified = true
|
27
27
|
@_asset_stamp = nil
|
28
28
|
asset_bundle.make_bundle
|
29
|
-
else
|
30
|
-
@is_modified = false
|
31
29
|
end
|
32
30
|
|
33
31
|
AssetTagMarkup.make_markup @type, asset_destination_path, @attributes
|
@@ -58,6 +56,7 @@ module Jekyll::Minibundle
|
|
58
56
|
false
|
59
57
|
else
|
60
58
|
write_destination site_destination_dir
|
59
|
+
@is_modified = false
|
61
60
|
true
|
62
61
|
end
|
63
62
|
end
|
@@ -27,8 +27,6 @@ module Jekyll::Minibundle
|
|
27
27
|
@stamped_at = mtime
|
28
28
|
@is_modified = true
|
29
29
|
@_asset_stamp = nil
|
30
|
-
else
|
31
|
-
@is_modified = false
|
32
30
|
end
|
33
31
|
|
34
32
|
asset_destination_path
|
@@ -39,6 +37,7 @@ module Jekyll::Minibundle
|
|
39
37
|
false
|
40
38
|
else
|
41
39
|
write_destination site_destination_dir
|
40
|
+
@is_modified = false
|
42
41
|
true
|
43
42
|
end
|
44
43
|
end
|
File without changes
|
@@ -20,7 +20,7 @@ module Jekyll::Minibundle::Test
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def test_copies_css_assets_to_destination_dir
|
24
24
|
with_precompiled_site :development do
|
25
25
|
EXPECTED_CSS_ASSET_PATHS.each do |path|
|
26
26
|
expect_file_exists_and_is_equal_to(destination_path(path), site_fixture_path(CSS_BUNDLE_SOURCE_DIR, File.basename(path)))
|
@@ -28,7 +28,7 @@ module Jekyll::Minibundle::Test
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_copies_js_assets_to_destination_dir
|
32
32
|
with_precompiled_site :development do
|
33
33
|
EXPECTED_JS_ASSET_PATHS.each do |path|
|
34
34
|
expect_file_exists_and_is_equal_to(destination_path(path), site_fixture_path(JS_BUNDLE_SOURCE_DIR, File.basename(path)))
|
@@ -36,33 +36,41 @@ module Jekyll::Minibundle::Test
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
[
|
40
|
+
{desc: "changing", action: ->(source) { File.write source, 'h1 {}' }},
|
41
|
+
{desc: "touching", action: ->(source) { FileUtils.touch source }}
|
42
|
+
].each do |spec|
|
43
|
+
define_method :"test_#{spec[:desc]}_css_asset_source_rewrites_destination" do
|
44
|
+
with_site do
|
45
|
+
generate_site :development
|
46
|
+
destination = destination_path CSS_BUNDLE_DESTINATION_PATH, 'common.css'
|
47
|
+
org_mtime = mtime_of destination
|
48
|
+
source = source_path CSS_BUNDLE_SOURCE_DIR, 'common.css'
|
49
|
+
ensure_file_mtime_changes { spec[:action].call(source) }
|
50
|
+
generate_site :development, clear_cache: false
|
51
|
+
|
52
|
+
assert_equal File.read(destination), File.read(source)
|
53
|
+
assert_operator mtime_of(destination), :>, org_mtime
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
[
|
59
|
+
{desc: "changing", action: ->(source) { File.write source, '(function() {})()' }},
|
60
|
+
{desc: "touching", action: ->(source) { FileUtils.touch source }}
|
61
|
+
].each do |spec|
|
62
|
+
define_method :"test_#{spec[:desc]}_js_asset_source_rewrites_destination" do
|
63
|
+
with_site do
|
64
|
+
generate_site :development
|
65
|
+
destination = destination_path JS_BUNDLE_DESTINATION_PATH, 'app.js'
|
66
|
+
org_mtime = mtime_of destination
|
67
|
+
source = source_path JS_BUNDLE_SOURCE_DIR, 'app.js'
|
68
|
+
ensure_file_mtime_changes { spec[:action].call(source) }
|
69
|
+
generate_site :development, clear_cache: false
|
70
|
+
|
71
|
+
assert_equal File.read(destination), File.read(source)
|
72
|
+
assert_operator mtime_of(destination), :>, org_mtime
|
73
|
+
end
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
@@ -87,7 +95,7 @@ module Jekyll::Minibundle::Test
|
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
90
|
-
def
|
98
|
+
def test_does_not_require_bundling_commands
|
91
99
|
with_site do
|
92
100
|
with_env 'JEKYLL_MINIBUNDLE_CMD_CSS' => nil, 'JEKYLL_MINIBUNDLE_CMD_JS' => nil do
|
93
101
|
generate_site :development
|
@@ -96,7 +104,7 @@ module Jekyll::Minibundle::Test
|
|
96
104
|
end
|
97
105
|
end
|
98
106
|
|
99
|
-
def
|
107
|
+
def test_does_not_rewrite_destination_when_nonsource_files_change
|
100
108
|
with_site do
|
101
109
|
generate_site :development
|
102
110
|
expected_js_path = destination_path JS_BUNDLE_DESTINATION_PATH, 'app.js'
|
@@ -32,40 +32,40 @@ module Jekyll::Minibundle::Test
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def test_copies_css_asset_bundle_to_destination_dir
|
36
36
|
with_precompiled_site :production do
|
37
37
|
assert File.exists?(destination_path(EXPECTED_CSS_BUNDLE_PATH))
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def test_copies_js_asset_bundle_to_destination_dir
|
42
42
|
with_precompiled_site :production do
|
43
43
|
assert File.exists?(destination_path(EXPECTED_JS_BUNDLE_PATH))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def test_concatenates_css_asset_bundle_in_configured_order
|
48
48
|
with_precompiled_site :production do
|
49
49
|
bundle = File.read(destination_path(EXPECTED_CSS_BUNDLE_PATH))
|
50
50
|
assert_operator bundle.index('html { margin: 0; }'), :<, bundle.index('p { margin: 0; }')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def test_concatenates_js_asset_bundle_in_configured_order
|
55
55
|
with_precompiled_site :production do
|
56
56
|
bundle = File.read(destination_path(EXPECTED_JS_BUNDLE_PATH))
|
57
57
|
assert_operator bundle.index('root.dependency = {};'), :<, bundle.index('root.app = {};')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def test_inserts_semicolons_between_js_assets
|
62
62
|
with_precompiled_site :production do
|
63
63
|
bundle = File.read(destination_path(EXPECTED_JS_BUNDLE_PATH))
|
64
64
|
assert_match(%r|}\)\(window\)\n;\n\(function|, bundle)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
68
|
+
def test_minifies_css_asset_bundle
|
69
69
|
with_precompiled_site :production do
|
70
70
|
source_contents_size = source_assets_size(CSS_BUNDLE_SOURCE_DIR, %w{reset common}, 'css')
|
71
71
|
destination_contents_size = File.read(destination_path(EXPECTED_CSS_BUNDLE_PATH)).size
|
@@ -73,7 +73,7 @@ module Jekyll::Minibundle::Test
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
76
|
+
def test_minifies_js_asset_bundle
|
77
77
|
with_precompiled_site :production do
|
78
78
|
source_contents_size = source_assets_size(JS_BUNDLE_SOURCE_DIR, %w{dependency app}, 'js')
|
79
79
|
destination_contents_size = File.read(destination_path(EXPECTED_JS_BUNDLE_PATH)).size
|
@@ -81,39 +81,65 @@ module Jekyll::Minibundle::Test
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
def
|
84
|
+
def test_changing_css_asset_source_rewrites_destination
|
85
85
|
with_site do
|
86
86
|
generate_site :production
|
87
|
-
|
88
|
-
assert File.exists?(destination_path(EXPECTED_CSS_BUNDLE_PATH))
|
89
|
-
|
87
|
+
org_mtime = mtime_of destination_path(EXPECTED_CSS_BUNDLE_PATH)
|
90
88
|
ensure_file_mtime_changes { File.write source_path(CSS_BUNDLE_SOURCE_DIR, 'common.css'), 'h1 {}' }
|
91
89
|
generate_site :production, clear_cache: false
|
92
90
|
|
93
91
|
refute File.exists?(destination_path(EXPECTED_CSS_BUNDLE_PATH))
|
94
92
|
|
95
|
-
|
93
|
+
new_destination = 'assets/site-9fd3995d6f0fce425db81c3691dfe93f.css'
|
96
94
|
|
97
|
-
assert_equal
|
98
|
-
assert File.exists?(destination_path(
|
95
|
+
assert_equal new_destination, find_css_path_from_index
|
96
|
+
assert File.exists?(destination_path(new_destination))
|
97
|
+
assert_operator mtime_of(destination_path(new_destination)), :>, org_mtime
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
102
|
-
def
|
101
|
+
def test_changing_js_asset_source_rewrites_destination
|
103
102
|
with_site do
|
104
103
|
generate_site :production
|
105
|
-
|
106
|
-
assert File.exists?(destination_path(EXPECTED_JS_BUNDLE_PATH))
|
107
|
-
|
104
|
+
org_mtime = mtime_of destination_path(EXPECTED_JS_BUNDLE_PATH)
|
108
105
|
ensure_file_mtime_changes { File.write source_path(JS_BUNDLE_SOURCE_DIR, 'app.js'), '(function() {})()' }
|
109
106
|
generate_site :production, clear_cache: false
|
110
107
|
|
111
108
|
refute File.exists?(destination_path(EXPECTED_JS_BUNDLE_PATH))
|
112
109
|
|
113
|
-
|
110
|
+
new_destination = 'assets/site-375a0b430b0c5555d0edd2205d26c04d.js'
|
111
|
+
|
112
|
+
assert_equal new_destination, find_js_path_from_index
|
113
|
+
assert File.exists?(destination_path(new_destination))
|
114
|
+
assert_operator mtime_of(destination_path(new_destination)), :>, org_mtime
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_touching_css_asset_source_rewrites_destination
|
119
|
+
with_site do
|
120
|
+
generate_site :production
|
121
|
+
destination = EXPECTED_CSS_BUNDLE_PATH
|
122
|
+
org_mtime = mtime_of destination_path(destination)
|
123
|
+
ensure_file_mtime_changes { FileUtils.touch source_path(CSS_BUNDLE_SOURCE_DIR, 'common.css') }
|
124
|
+
generate_site :production, clear_cache: false
|
125
|
+
|
126
|
+
assert_equal destination, find_css_path_from_index
|
127
|
+
assert File.exists?(destination_path(destination))
|
128
|
+
assert_operator mtime_of(destination_path(destination)), :>, org_mtime
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_touching_js_asset_source_rewrites_destination
|
133
|
+
with_site do
|
134
|
+
generate_site :production
|
135
|
+
destination = EXPECTED_JS_BUNDLE_PATH
|
136
|
+
org_mtime = mtime_of destination_path(destination)
|
137
|
+
ensure_file_mtime_changes { FileUtils.touch source_path(JS_BUNDLE_SOURCE_DIR, 'app.js') }
|
138
|
+
generate_site :production, clear_cache: false
|
114
139
|
|
115
|
-
assert_equal
|
116
|
-
assert File.exists?(destination_path(
|
140
|
+
assert_equal destination, find_js_path_from_index
|
141
|
+
assert File.exists?(destination_path(destination))
|
142
|
+
assert_operator mtime_of(destination_path(destination)), :>, org_mtime
|
117
143
|
end
|
118
144
|
end
|
119
145
|
|
@@ -138,7 +164,7 @@ module Jekyll::Minibundle::Test
|
|
138
164
|
end
|
139
165
|
end
|
140
166
|
|
141
|
-
def
|
167
|
+
def test_bundles_assets_only_once_at_startup
|
142
168
|
with_site do
|
143
169
|
with_env 'JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count do
|
144
170
|
generate_site :production
|
@@ -147,7 +173,7 @@ module Jekyll::Minibundle::Test
|
|
147
173
|
end
|
148
174
|
end
|
149
175
|
|
150
|
-
def
|
176
|
+
def test_does_not_rebundle_assets_when_nonsource_files_change
|
151
177
|
with_site do
|
152
178
|
with_env 'JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count do
|
153
179
|
generate_site :production
|
@@ -8,22 +8,18 @@ module Jekyll::Minibundle::Test
|
|
8
8
|
def test_asset_destination_path_has_no_stamp_in_development_mode
|
9
9
|
with_precompiled_site :development do
|
10
10
|
assert_equal STAMP_DESTINATION_PATH, find_css_path_from_index
|
11
|
+
assert File.exists?(destination_path(STAMP_DESTINATION_PATH))
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
15
|
def test_asset_destination_path_has_stamp_in_production_mode
|
15
16
|
with_precompiled_site :production do
|
16
17
|
assert_equal STAMP_DESTINATION_FINGERPRINT_PATH, find_css_path_from_index
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_asset_file_is_copied_to_destination_dir
|
21
|
-
with_precompiled_site :production do
|
22
18
|
assert File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
|
-
def
|
22
|
+
def test_contents_of_asset_destination_are_equal_to_source
|
27
23
|
with_precompiled_site :production do
|
28
24
|
source_contents = File.read site_fixture_path(STAMP_SOURCE_PATH)
|
29
25
|
destination_contents = File.read destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
|
@@ -31,21 +27,34 @@ module Jekyll::Minibundle::Test
|
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
|
-
def
|
30
|
+
def test_changing_asset_source_rewrites_destination
|
35
31
|
with_site do
|
36
32
|
generate_site :production
|
37
|
-
|
38
|
-
assert File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
39
|
-
|
33
|
+
org_mtime = mtime_of destination_path(STAMP_DESTINATION_FINGERPRINT_PATH)
|
40
34
|
ensure_file_mtime_changes { File.write source_path(STAMP_SOURCE_PATH), 'h1 {}' }
|
41
35
|
generate_site :production, clear_cache: false
|
42
36
|
|
43
37
|
refute File.exists?(destination_path(STAMP_DESTINATION_FINGERPRINT_PATH))
|
44
38
|
|
45
|
-
|
39
|
+
new_destination = 'assets/screen-0f5dbd1e527a2bee267e85007b08d2a5.css'
|
40
|
+
|
41
|
+
assert_equal new_destination, find_css_path_from_index
|
42
|
+
assert File.exists?(destination_path(new_destination))
|
43
|
+
assert_operator mtime_of(destination_path(new_destination)), :>, org_mtime
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_touching_asset_source_rewrites_destination
|
48
|
+
with_site do
|
49
|
+
generate_site :production
|
50
|
+
destination = STAMP_DESTINATION_FINGERPRINT_PATH
|
51
|
+
org_mtime = mtime_of destination_path(destination)
|
52
|
+
ensure_file_mtime_changes { FileUtils.touch source_path(STAMP_SOURCE_PATH) }
|
53
|
+
generate_site :production, clear_cache: false
|
46
54
|
|
47
|
-
assert_equal
|
48
|
-
assert File.exists?(destination_path(
|
55
|
+
assert_equal destination, find_css_path_from_index
|
56
|
+
assert File.exists?(destination_path(destination))
|
57
|
+
assert_operator mtime_of(destination_path(destination)), :>, org_mtime
|
49
58
|
end
|
50
59
|
end
|
51
60
|
|
@@ -65,7 +74,7 @@ module Jekyll::Minibundle::Test
|
|
65
74
|
end
|
66
75
|
end
|
67
76
|
|
68
|
-
def
|
77
|
+
def test_does_not_rewrite_destination_when_nonsource_files_change
|
69
78
|
with_site do
|
70
79
|
generate_site :production
|
71
80
|
expected_path = destination_path STAMP_DESTINATION_FINGERPRINT_PATH
|
@@ -1,7 +1,22 @@
|
|
1
1
|
require 'support/test_case'
|
2
|
+
require 'support/fixture_config'
|
2
3
|
|
3
4
|
module Jekyll::Minibundle::Test
|
4
5
|
class StaticFilesAsAssetSourcesTest < TestCase
|
6
|
+
include FixtureConfig
|
7
|
+
|
8
|
+
def test_asset_and_static_files_with_same_destination_paths_can_coexist
|
9
|
+
with_precompiled_site :production do
|
10
|
+
actual = Dir[destination_path('assets/site*.*')].sort
|
11
|
+
expected = [
|
12
|
+
destination_path('assets/site.css'),
|
13
|
+
destination_path(EXPECTED_CSS_BUNDLE_PATH),
|
14
|
+
destination_path(EXPECTED_JS_BUNDLE_PATH)
|
15
|
+
].sort
|
16
|
+
assert_equal expected, actual
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
[:development, :production].each do |env|
|
6
21
|
define_method :"test_ministamp_allows_using_static_file_as_asset_source_in_#{env}_mode" do
|
7
22
|
with_site do
|
@@ -43,7 +58,7 @@ module Jekyll::Minibundle::Test
|
|
43
58
|
find_and_gsub_in_file(source_path('_layouts/default.html'), 'source_dir: _assets/scripts', 'source_dir: assets')
|
44
59
|
generate_site :production
|
45
60
|
|
46
|
-
asset_files = Dir[destination_path('assets
|
61
|
+
asset_files = Dir[destination_path('assets/site-*.js')]
|
47
62
|
|
48
63
|
assert_equal 1, asset_files.size
|
49
64
|
assert_equal dep_contents, File.read(destination_path('assets/dependency.js'))
|
@@ -1,25 +1,22 @@
|
|
1
1
|
require 'support/test_case'
|
2
|
-
require 'support/fixture_config'
|
3
2
|
require 'jekyll/minibundle/asset_file_registry'
|
4
3
|
|
5
4
|
module Jekyll::Minibundle::Test
|
6
5
|
class AssetFileRegistryTest < TestCase
|
7
|
-
include FixtureConfig
|
8
|
-
|
9
6
|
def setup
|
10
7
|
AssetFileRegistry.clear
|
11
8
|
end
|
12
9
|
|
13
|
-
def
|
14
|
-
first = AssetFileRegistry.stamp_file
|
15
|
-
second = AssetFileRegistry.stamp_file
|
10
|
+
def test_returns_same_stamp_file_instance_for_same_destination_path
|
11
|
+
first = AssetFileRegistry.stamp_file '_assets/src1.css', 'assets/dest.css'
|
12
|
+
second = AssetFileRegistry.stamp_file '_assets/src2.css', 'assets/dest.css'
|
16
13
|
assert_same first, second
|
17
14
|
assert_equal 1, asset_file_registry_size
|
18
15
|
end
|
19
16
|
|
20
|
-
def
|
21
|
-
first = AssetFileRegistry.bundle_file bundle_config
|
22
|
-
second = AssetFileRegistry.bundle_file bundle_config
|
17
|
+
def test_returns_same_bundle_file_instance_for_same_destination_path_and_type
|
18
|
+
first = AssetFileRegistry.bundle_file bundle_config.merge({'assets' => %w{a1 a2}})
|
19
|
+
second = AssetFileRegistry.bundle_file bundle_config.merge({'assets' => %w{b1 b2}})
|
23
20
|
assert_same first, second
|
24
21
|
assert_equal 1, asset_file_registry_size
|
25
22
|
end
|
@@ -36,9 +33,9 @@ module Jekyll::Minibundle::Test
|
|
36
33
|
{
|
37
34
|
'type' => :css,
|
38
35
|
'site_dir' => '.',
|
39
|
-
'source_dir' =>
|
36
|
+
'source_dir' => '_assets/styles',
|
40
37
|
'assets' => %w{dependency app},
|
41
|
-
'destination_path' =>
|
38
|
+
'destination_path' => 'assets/site',
|
42
39
|
'attributes' => {}
|
43
40
|
}
|
44
41
|
end
|
@@ -3,7 +3,7 @@ require 'jekyll/minibundle/asset_tag_markup'
|
|
3
3
|
|
4
4
|
module Jekyll::Minibundle::Test
|
5
5
|
class AssetTagMarkupTest < TestCase
|
6
|
-
def
|
6
|
+
def test_escapes_attribute_values
|
7
7
|
attributes = { media: 'screen, projection', extra: '">attack<br' }
|
8
8
|
actual = AssetTagMarkup.make_markup :css, 'http://localhost', attributes
|
9
9
|
expected = %{<link rel="stylesheet" href="http://localhost" media="screen, projection" extra="">attack<br">}
|
@@ -6,17 +6,10 @@ module Jekyll::Minibundle::Test
|
|
6
6
|
class BundleFileTest < TestCase
|
7
7
|
include FixtureConfig
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_calling_markup_determines_fingerprint_and_destination_write
|
10
10
|
with_site do
|
11
11
|
with_env 'JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count do
|
12
|
-
bundle_file = BundleFile.new
|
13
|
-
'type' => :js,
|
14
|
-
'site_dir' => '.',
|
15
|
-
'source_dir' => JS_BUNDLE_SOURCE_DIR,
|
16
|
-
'assets' => %w{dependency app},
|
17
|
-
'destination_path' => JS_BUNDLE_DESTINATION_PATH,
|
18
|
-
'attributes' => {}
|
19
|
-
})
|
12
|
+
bundle_file = BundleFile.new bundle_config
|
20
13
|
source = source_path JS_BUNDLE_SOURCE_DIR, 'app.js'
|
21
14
|
old_destination = destination_path EXPECTED_JS_BUNDLE_PATH
|
22
15
|
org_markup, last_markup = nil
|
@@ -53,5 +46,51 @@ module Jekyll::Minibundle::Test
|
|
53
46
|
end
|
54
47
|
end
|
55
48
|
end
|
49
|
+
|
50
|
+
def test_many_consecutive_markup_calls_trigger_one_destination_write
|
51
|
+
with_site do
|
52
|
+
with_env 'JEKYLL_MINIBUNDLE_CMD_JS' => cmd_to_remove_comments_and_count do
|
53
|
+
bundle_file = BundleFile.new bundle_config
|
54
|
+
source = source_path JS_BUNDLE_SOURCE_DIR, 'app.js'
|
55
|
+
destination = destination_path EXPECTED_JS_BUNDLE_PATH
|
56
|
+
org_markup, last_markup = nil
|
57
|
+
|
58
|
+
capture_io do
|
59
|
+
org_markup = bundle_file.markup
|
60
|
+
bundle_file.markup
|
61
|
+
bundle_file.write '_site'
|
62
|
+
end
|
63
|
+
|
64
|
+
org_mtime = mtime_of destination
|
65
|
+
|
66
|
+
assert_equal 1, get_cmd_count
|
67
|
+
|
68
|
+
ensure_file_mtime_changes { FileUtils.touch source }
|
69
|
+
|
70
|
+
capture_io do
|
71
|
+
last_markup = bundle_file.markup
|
72
|
+
bundle_file.markup
|
73
|
+
bundle_file.write '_site'
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_equal org_markup, last_markup
|
77
|
+
assert_operator mtime_of(destination), :>, org_mtime
|
78
|
+
assert_equal 2, get_cmd_count
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def bundle_config
|
86
|
+
{
|
87
|
+
'type' => :js,
|
88
|
+
'site_dir' => '.',
|
89
|
+
'source_dir' => JS_BUNDLE_SOURCE_DIR,
|
90
|
+
'assets' => %w{dependency app},
|
91
|
+
'destination_path' => JS_BUNDLE_DESTINATION_PATH,
|
92
|
+
'attributes' => {}
|
93
|
+
}
|
94
|
+
end
|
56
95
|
end
|
57
96
|
end
|
@@ -6,10 +6,9 @@ module Jekyll::Minibundle::Test
|
|
6
6
|
class StampFileTest < TestCase
|
7
7
|
include FixtureConfig
|
8
8
|
|
9
|
-
def
|
9
|
+
def test_calling_markup_determines_fingerprint_and_destination_write
|
10
10
|
with_site do
|
11
|
-
|
12
|
-
stamp_file = StampFile.new(STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH, &basenamer)
|
11
|
+
stamp_file = StampFile.new(STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH, &stamp_basenamer)
|
13
12
|
|
14
13
|
source = source_path STAMP_SOURCE_PATH
|
15
14
|
old_destination = destination_path STAMP_DESTINATION_FINGERPRINT_PATH
|
@@ -38,5 +37,35 @@ module Jekyll::Minibundle::Test
|
|
38
37
|
assert_equal File.read(source), File.read(new_destination)
|
39
38
|
end
|
40
39
|
end
|
40
|
+
|
41
|
+
def test_many_consecutive_markup_calls_trigger_one_destination_write
|
42
|
+
with_site do
|
43
|
+
stamp_file = StampFile.new(STAMP_SOURCE_PATH, STAMP_DESTINATION_PATH, &stamp_basenamer)
|
44
|
+
|
45
|
+
source = source_path STAMP_SOURCE_PATH
|
46
|
+
destination = destination_path STAMP_DESTINATION_FINGERPRINT_PATH
|
47
|
+
|
48
|
+
org_markup = stamp_file.markup
|
49
|
+
stamp_file.markup
|
50
|
+
stamp_file.write '_site'
|
51
|
+
org_mtime = mtime_of destination
|
52
|
+
|
53
|
+
ensure_file_mtime_changes { FileUtils.touch source }
|
54
|
+
|
55
|
+
last_markup = stamp_file.markup
|
56
|
+
stamp_file.markup
|
57
|
+
stamp_file.write '_site'
|
58
|
+
|
59
|
+
assert_equal org_markup, last_markup
|
60
|
+
assert_operator mtime_of(destination), :>, org_mtime
|
61
|
+
assert_equal File.read(source), File.read(destination)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def stamp_basenamer
|
68
|
+
->(base, ext, stamper) { "#{base}-#{stamper.call}#{ext}" }
|
69
|
+
end
|
41
70
|
end
|
42
71
|
end
|
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.
|
4
|
+
version: 1.4.2
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- CHANGELOG.md
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
|
-
- RELEASING.txt
|
84
83
|
- Rakefile
|
85
84
|
- jekyll-minibundle.gemspec
|
86
85
|
- lib/jekyll/minibundle.rb
|
@@ -109,7 +108,7 @@ files:
|
|
109
108
|
- test/fixture/site/_plugins/minibundle.rb
|
110
109
|
- test/fixture/site/_tmp/site.css
|
111
110
|
- test/fixture/site/about.html
|
112
|
-
- test/fixture/site/assets/
|
111
|
+
- test/fixture/site/assets/site.css
|
113
112
|
- test/fixture/site/index.html
|
114
113
|
- test/integration/minibundle_development_mode_test.rb
|
115
114
|
- test/integration/minibundle_production_mode_test.rb
|
@@ -163,7 +162,7 @@ test_files:
|
|
163
162
|
- test/fixture/site/_plugins/minibundle.rb
|
164
163
|
- test/fixture/site/_tmp/site.css
|
165
164
|
- test/fixture/site/about.html
|
166
|
-
- test/fixture/site/assets/
|
165
|
+
- test/fixture/site/assets/site.css
|
167
166
|
- test/fixture/site/index.html
|
168
167
|
- test/integration/minibundle_development_mode_test.rb
|
169
168
|
- test/integration/minibundle_production_mode_test.rb
|
data/RELEASING.txt
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
In order to release, do
|
2
|
-
|
3
|
-
$EDITOR lib/jekyll/minibundle/version.rb # update version number
|
4
|
-
$EDITOR CHANGELOG.md # describe a summary of changes since last release
|
5
|
-
git diff # review the changes
|
6
|
-
bundle exec rake gem:build # check that tests pass
|
7
|
-
git add -p
|
8
|
-
git commit -m 'Release <version>'
|
9
|
-
git tag <version>
|
10
|
-
git push --tags origin master
|
11
|
-
gem push jekyll-minibundle-<version>.gem
|