jekyll-minibundle 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +6 -0
- data/License.txt +19 -0
- data/Rakefile +20 -12
- data/Readme.md +7 -23
- data/lib/jekyll/minibundle/asset_bundle.rb +3 -1
- data/lib/jekyll/minibundle/asset_file_support.rb +2 -2
- data/lib/jekyll/minibundle/bundle_file.rb +11 -11
- data/lib/jekyll/minibundle/bundle_markup.rb +7 -1
- data/lib/jekyll/minibundle/mini_stamp_tag.rb +2 -2
- data/lib/jekyll/minibundle/stamp_file.rb +14 -15
- 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/integration/minibundle_test.rb +15 -10
- data/test/integration/ministamp_test.rb +4 -4
- data/test/support/test_case.rb +27 -13
- data/test/unit/asset_bundle_test.rb +35 -0
- data/test/unit/bundle_markup_test.rb +13 -0
- metadata +27 -7
data/History.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
### 0.2.0 / 2012-12-15
|
2
|
+
|
3
|
+
* Escape the values of custom attributes given in `minibundle` block
|
4
|
+
* Add semicolons between each JavaScript asset in bundling
|
5
|
+
* Show error in page output if asset bundling command failed
|
6
|
+
|
1
7
|
### 0.1.0 / 2012-12-07
|
2
8
|
|
3
9
|
* Add `ministamp` tag and `minibundle` block for Jekyll
|
data/License.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2012 Tuomas Kareinen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -2,9 +2,19 @@ require 'rake/clean'
|
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
4
|
require_relative 'lib/jekyll/minibundle/version'
|
5
|
-
|
5
|
+
|
6
|
+
def get_minibundle_env(overrides = {})
|
7
|
+
bundle_cmd = File.expand_path(File.join(File.dirname(__FILE__), 'test/fixture/site/_bin/remove_comments'))
|
8
|
+
{
|
9
|
+
'JEKYLL_MINIBUNDLE_CMD_JS' => bundle_cmd,
|
10
|
+
'JEKYLL_MINIBUNDLE_CMD_CSS' => bundle_cmd,
|
11
|
+
'RUBYLIB' => File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
|
12
|
+
}.merge(overrides)
|
13
|
+
end
|
6
14
|
|
7
15
|
namespace :gem do
|
16
|
+
gem_name = 'jekyll-minibundle'
|
17
|
+
|
8
18
|
CLEAN.include "#{gem_name}-*.gem"
|
9
19
|
|
10
20
|
desc 'Package the software as a gem'
|
@@ -25,19 +35,17 @@ end
|
|
25
35
|
|
26
36
|
desc 'Run tests'
|
27
37
|
task :test do
|
28
|
-
|
29
|
-
test_glob = 'integration/**/*_test.rb'
|
30
|
-
includes = ['lib', test_dir].join(':')
|
31
|
-
tests = Dir["#{test_dir}/#{test_glob}"].
|
38
|
+
tests = Dir['test/**/*_test.rb'].
|
32
39
|
map { |file| %r{^test/(.+)\.rb$}.match(file)[1] }.
|
33
40
|
shelljoin
|
34
|
-
test_cmd = %{bundle exec ruby -
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
test_cmd = %{bundle exec ruby -e 'ARGV.each { |f| require f }' #{tests}}
|
42
|
+
sh(get_minibundle_env('RUBYLIB' => 'lib:test'), test_cmd)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Generate fixture site for debugging'
|
46
|
+
task :debug do
|
47
|
+
Dir.chdir 'test/fixture/site'
|
48
|
+
sh(get_minibundle_env, 'jekyll')
|
41
49
|
end
|
42
50
|
|
43
51
|
CLEAN.include 'test/fixture/site/_site'
|
data/Readme.md
CHANGED
@@ -4,12 +4,14 @@ A minimalistic plugin for bundling assets to
|
|
4
4
|
[Jekyll](https://github.com/mojombo/jekyll)'s site generation
|
5
5
|
directory.
|
6
6
|
|
7
|
-
In addition to the plugin, you need your asset bundling
|
8
|
-
|
9
|
-
environment variable.
|
7
|
+
In addition to the plugin itself, you only need your asset bundling
|
8
|
+
tool of choice. The plugin needs no other configuration than setting
|
9
|
+
an environment variable. There are no gem dependencies.
|
10
10
|
|
11
11
|
Tested with Ruby MRI 1.9.3. Ruby 1.8 is *not* supported.
|
12
12
|
|
13
|
+
[![Build Status](https://secure.travis-ci.org/tkareine/jekyll-minibundle.png)](http://travis-ci.org/tkareine/jekyll-minibundle)
|
14
|
+
|
13
15
|
# Features
|
14
16
|
|
15
17
|
There are two features: asset stamping with MD5 digest over the
|
@@ -94,7 +96,7 @@ You can pass custom attributes to the generated markup with
|
|
94
96
|
|
95
97
|
Output:
|
96
98
|
|
97
|
-
<script
|
99
|
+
<script src="assets/site-8e764372a0dbd296033cb2a416f064b5.js" type="text/javascript" id="my-scripts"></script>
|
98
100
|
|
99
101
|
For bundling CSS assets, you use `css` as the argument to `minibundle` block:
|
100
102
|
|
@@ -117,22 +119,4 @@ See the contents of `test/fixture/site` directory.
|
|
117
119
|
|
118
120
|
# License
|
119
121
|
|
120
|
-
|
121
|
-
|
122
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
123
|
-
of this software and associated documentation files (the "Software"), to deal
|
124
|
-
in the Software without restriction, including without limitation the rights
|
125
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
126
|
-
copies of the Software, and to permit persons to whom the Software is
|
127
|
-
furnished to do so, subject to the following conditions:
|
128
|
-
|
129
|
-
The above copyright notice and this permission notice shall be included in
|
130
|
-
all copies or substantial portions of the Software.
|
131
|
-
|
132
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
133
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
134
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
135
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
136
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
137
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
138
|
-
THE SOFTWARE.
|
122
|
+
MIT. See `License.txt`.
|
@@ -18,6 +18,7 @@ module Jekyll::Minibundle
|
|
18
18
|
@assets.each do |asset|
|
19
19
|
puts " #{asset}"
|
20
20
|
IO.foreach(asset) { |line| wr.write line }
|
21
|
+
wr.puts ';' if @type == :js
|
21
22
|
end
|
22
23
|
end
|
23
24
|
self
|
@@ -40,7 +41,8 @@ module Jekyll::Minibundle
|
|
40
41
|
end
|
41
42
|
yield wr
|
42
43
|
wr.close
|
43
|
-
Process.waitpid2 pid
|
44
|
+
_, status = Process.waitpid2 pid
|
45
|
+
raise "Bundling #{@type} assets failed with exit status #{status.exitstatus}, command: #{cmd}" if status.exitstatus != 0
|
44
46
|
ensure
|
45
47
|
wr.close unless wr.closed?
|
46
48
|
end
|
@@ -7,8 +7,8 @@ module Jekyll::Minibundle
|
|
7
7
|
site.static_files << self unless static_file_exists
|
8
8
|
end
|
9
9
|
|
10
|
-
def write_destination(
|
11
|
-
destination_path = destination
|
10
|
+
def write_destination(site_destination_dir)
|
11
|
+
destination_path = destination site_destination_dir
|
12
12
|
FileUtils.mkdir_p File.dirname(destination_path)
|
13
13
|
FileUtils.cp path, destination_path
|
14
14
|
end
|
@@ -10,10 +10,10 @@ module Jekyll::Minibundle
|
|
10
10
|
|
11
11
|
def initialize(config)
|
12
12
|
@type = config['type']
|
13
|
-
@
|
14
|
-
|
15
|
-
@
|
16
|
-
@
|
13
|
+
@site_source_dir = config['site_dir']
|
14
|
+
asset_source_dir = File.join @site_source_dir, config['source_dir']
|
15
|
+
@assets = config['assets'].map { |asset_path| File.join asset_source_dir, "#{asset_path}.#{@type}" }
|
16
|
+
@asset_destination_path = config['destination_path']
|
17
17
|
@attributes = config['attributes']
|
18
18
|
update_mtime
|
19
19
|
end
|
@@ -23,11 +23,11 @@ module Jekyll::Minibundle
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def asset_path
|
26
|
-
"#{@
|
26
|
+
"#{@asset_destination_path}-#{asset_stamp}.#{@type}"
|
27
27
|
end
|
28
28
|
|
29
|
-
def destination(
|
30
|
-
File.join
|
29
|
+
def destination(site_destination_dir)
|
30
|
+
File.join site_destination_dir, asset_path
|
31
31
|
end
|
32
32
|
|
33
33
|
def mtime
|
@@ -38,14 +38,14 @@ module Jekyll::Minibundle
|
|
38
38
|
@@mtimes[path] != mtime
|
39
39
|
end
|
40
40
|
|
41
|
-
def write(
|
41
|
+
def write(site_destination_dir)
|
42
42
|
rebundle_assets if modified?
|
43
|
-
destination_path = destination
|
43
|
+
destination_path = destination site_destination_dir
|
44
44
|
|
45
45
|
return false if File.exist?(destination_path) and !modified?
|
46
46
|
|
47
47
|
update_mtime
|
48
|
-
write_destination
|
48
|
+
write_destination site_destination_dir
|
49
49
|
|
50
50
|
true
|
51
51
|
end
|
@@ -61,7 +61,7 @@ module Jekyll::Minibundle
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def asset_bundle
|
64
|
-
@asset_bundle ||= AssetBundle.new(@type, @assets, @
|
64
|
+
@asset_bundle ||= AssetBundle.new(@type, @assets, @site_source_dir).make_bundle
|
65
65
|
end
|
66
66
|
|
67
67
|
def rebundle_assets
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
1
3
|
module Jekyll::Minibundle
|
2
4
|
module BundleMarkup
|
3
5
|
def self.make_markup(type, path, attributes)
|
@@ -12,7 +14,11 @@ module Jekyll::Minibundle
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def self.make_attributes(attributes)
|
15
|
-
attributes.map { |name, value|
|
17
|
+
attributes.map { |name, value| make_attribute(name, value) }.join('')
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.make_attribute(name, value)
|
21
|
+
%{ #{name}="#{CGI.escape_html(value)}"}
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
@@ -4,12 +4,12 @@ module Jekyll::Minibundle
|
|
4
4
|
class MiniStampTag < Liquid::Tag
|
5
5
|
def initialize(tag_name, text, _tokens)
|
6
6
|
super
|
7
|
-
@
|
7
|
+
@asset_source, @asset_destination = text.split(/\s+/, 3)[0, 2]
|
8
8
|
end
|
9
9
|
|
10
10
|
def render(context)
|
11
11
|
site = context.registers[:site]
|
12
|
-
file = StampFile.new File.join(site.source, @
|
12
|
+
file = StampFile.new File.join(site.source, @asset_source), @asset_destination
|
13
13
|
file.static_file! site
|
14
14
|
file.asset_path
|
15
15
|
end
|
@@ -7,25 +7,24 @@ module Jekyll::Minibundle
|
|
7
7
|
|
8
8
|
@@mtimes = Hash.new
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
|
15
|
-
@destination_base_prefix = base[0 .. -(@destination_extension.size + 1)]
|
10
|
+
def initialize(asset_source_path, asset_destination_path)
|
11
|
+
@asset_source_path = asset_source_path
|
12
|
+
@asset_destination_dir = File.dirname asset_destination_path
|
13
|
+
@asset_destination_extension = File.extname asset_destination_path
|
14
|
+
@asset_destination_base_prefix = File.basename(asset_destination_path)[0 .. -(@asset_destination_extension.size + 1)]
|
16
15
|
update_mtime
|
17
16
|
end
|
18
17
|
|
19
18
|
def path
|
20
|
-
@
|
19
|
+
@asset_source_path
|
21
20
|
end
|
22
21
|
|
23
22
|
def asset_path
|
24
|
-
File.join @
|
23
|
+
File.join @asset_destination_dir, asset_destination_basename
|
25
24
|
end
|
26
25
|
|
27
|
-
def destination(
|
28
|
-
File.join
|
26
|
+
def destination(site_destination_dir)
|
27
|
+
File.join site_destination_dir, @asset_destination_dir, asset_destination_basename
|
29
28
|
end
|
30
29
|
|
31
30
|
def mtime
|
@@ -36,22 +35,22 @@ module Jekyll::Minibundle
|
|
36
35
|
@@mtimes[path] != mtime
|
37
36
|
end
|
38
37
|
|
39
|
-
def write(
|
38
|
+
def write(site_destination_dir)
|
40
39
|
clear_asset_stamp if modified?
|
41
|
-
destination_path = destination
|
40
|
+
destination_path = destination site_destination_dir
|
42
41
|
|
43
42
|
return false if File.exist?(destination_path) and !modified?
|
44
43
|
|
45
44
|
update_mtime
|
46
|
-
write_destination
|
45
|
+
write_destination site_destination_dir
|
47
46
|
|
48
47
|
true
|
49
48
|
end
|
50
49
|
|
51
50
|
private
|
52
51
|
|
53
|
-
def
|
54
|
-
"#{@
|
52
|
+
def asset_destination_basename
|
53
|
+
"#{@asset_destination_base_prefix}-#{asset_stamp}#{@asset_destination_extension}"
|
55
54
|
end
|
56
55
|
|
57
56
|
def asset_stamp
|
@@ -3,7 +3,7 @@ require 'support/test_case'
|
|
3
3
|
module Jekyll::Minibundle::Test
|
4
4
|
class MiniBundleTest < TestCase
|
5
5
|
EXPECTED_CSS_ASSET_PATH = 'assets/site-b2e0ecc1c100effc2c7353caad20c327.css'
|
6
|
-
EXPECTED_JS_ASSET_PATH = 'assets/site-
|
6
|
+
EXPECTED_JS_ASSET_PATH = 'assets/site-4782a1f67803038d4f8351051e67deb8.js'
|
7
7
|
|
8
8
|
def test_css_asset_bundle_has_configured_attributes
|
9
9
|
element = find_html_element_from_index(%{head link[href="#{EXPECTED_CSS_ASSET_PATH}"]}).first
|
@@ -27,44 +27,49 @@ module Jekyll::Minibundle::Test
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_css_asset_bundle_is_copied_to_destination_dir
|
30
|
-
assert File.exists?(
|
30
|
+
assert File.exists?(destination_path(EXPECTED_CSS_ASSET_PATH))
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_js_asset_bundle_is_copied_to_destination_dir
|
34
|
-
assert File.exists?(
|
34
|
+
assert File.exists?(destination_path(EXPECTED_JS_ASSET_PATH))
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_css_asset_bundle_is_concatenated_in_configured_order
|
38
|
-
bundle = File.read(
|
38
|
+
bundle = File.read(destination_path(EXPECTED_CSS_ASSET_PATH))
|
39
39
|
assert bundle.index('html { margin: 0; }') < bundle.index('p { margin: 0; }')
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_js_asset_bundle_is_concatenated_in_configured_order
|
43
|
-
bundle = File.read(
|
43
|
+
bundle = File.read(destination_path(EXPECTED_JS_ASSET_PATH))
|
44
44
|
assert bundle.index('root.dependency = {};') < bundle.index('root.app = {};')
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_js_asset_bundle_has_inserted_semicolons_between_assets
|
48
|
+
bundle = File.read(destination_path(EXPECTED_JS_ASSET_PATH))
|
49
|
+
assert_match(%r|}\)\(window\)\n;\n\(function|, bundle)
|
50
|
+
end
|
51
|
+
|
47
52
|
def test_css_asset_bundle_is_minified
|
48
53
|
source_contents_size = source_assets_size('_assets/styles', %w{reset common}, 'css')
|
49
|
-
destination_contents_size = File.read(
|
54
|
+
destination_contents_size = File.read(destination_path(EXPECTED_CSS_ASSET_PATH)).size
|
50
55
|
assert destination_contents_size < source_contents_size
|
51
56
|
end
|
52
57
|
|
53
58
|
def test_js_asset_bundle_is_minified
|
54
59
|
source_contents_size = source_assets_size('_assets/scripts', %w{dependency app}, 'js')
|
55
|
-
destination_contents_size = File.read(
|
60
|
+
destination_contents_size = File.read(destination_path(EXPECTED_JS_ASSET_PATH)).size
|
56
61
|
assert destination_contents_size < source_contents_size
|
57
62
|
end
|
58
63
|
|
59
64
|
private
|
60
65
|
|
61
66
|
def find_html_element_from_index(css)
|
62
|
-
find_html_element(
|
67
|
+
find_html_element(read_from_destination('index.html'), css)
|
63
68
|
end
|
64
69
|
|
65
|
-
def source_assets_size(
|
70
|
+
def source_assets_size(source_subdir, assets, type)
|
66
71
|
assets.
|
67
|
-
map { |f| File.read
|
72
|
+
map { |f| File.read source_path(source_subdir, "#{f}.#{type}") }.
|
68
73
|
join('').
|
69
74
|
size
|
70
75
|
end
|
@@ -5,17 +5,17 @@ module Jekyll::Minibundle::Test
|
|
5
5
|
EXPECTED_ASSET_PATH = 'assets/screen-390be921ee0eff063817bb5ef2954300.css'
|
6
6
|
|
7
7
|
def test_asset_path_has_stamp
|
8
|
-
actual = find_html_element(
|
8
|
+
actual = find_html_element(read_from_destination('index.html'), 'head link').first['href']
|
9
9
|
assert_equal EXPECTED_ASSET_PATH, actual
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_asset_file_is_copied_to_destination_dir
|
13
|
-
assert File.exists?(
|
13
|
+
assert File.exists?(destination_path(EXPECTED_ASSET_PATH))
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_asset_file_is_equal_to_source_file
|
17
|
-
source_contents = File.read
|
18
|
-
destination_contents = File.read
|
17
|
+
source_contents = File.read source_path('_tmp/site.css')
|
18
|
+
destination_contents = File.read destination_path(EXPECTED_ASSET_PATH)
|
19
19
|
assert_equal source_contents, destination_contents
|
20
20
|
end
|
21
21
|
end
|
data/test/support/test_case.rb
CHANGED
@@ -7,45 +7,59 @@ require 'jekyll/minibundle'
|
|
7
7
|
|
8
8
|
module Jekyll::Minibundle::Test
|
9
9
|
class TestCase < ::MiniTest::Unit::TestCase
|
10
|
-
|
10
|
+
include ::Jekyll::Minibundle
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
FIXTURE_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../fixture'))
|
13
|
+
SOURCE_DIR = File.join(FIXTURE_DIR, 'site')
|
14
|
+
|
15
|
+
def source_path(*args)
|
16
|
+
File.join(SOURCE_DIR, *args)
|
14
17
|
end
|
15
18
|
|
16
|
-
def
|
17
|
-
File.join(
|
19
|
+
def destination_path(*args)
|
20
|
+
File.join(_destination_dir, *args)
|
18
21
|
end
|
19
22
|
|
20
|
-
def
|
21
|
-
File.read
|
23
|
+
def read_from_destination(*args)
|
24
|
+
File.read destination_path(*args)
|
22
25
|
end
|
23
26
|
|
24
27
|
def find_html_element(file, css)
|
25
28
|
Nokogiri::HTML(file).css(css)
|
26
29
|
end
|
27
30
|
|
31
|
+
def with_env(env)
|
32
|
+
org_env = {}
|
33
|
+
env.each do |k, v|
|
34
|
+
org_env[k] = ENV[k]
|
35
|
+
ENV[k] = v
|
36
|
+
end
|
37
|
+
yield
|
38
|
+
ensure
|
39
|
+
org_env.each { |k, v| ENV[k] = v }
|
40
|
+
end
|
41
|
+
|
28
42
|
private
|
29
43
|
|
30
|
-
def
|
31
|
-
@@
|
44
|
+
def _destination_dir(&block)
|
45
|
+
@@_destination_dir ||= begin
|
32
46
|
dir = Dir.mktmpdir('jekyll-minibundle-test-')
|
33
47
|
at_exit do
|
34
48
|
FileUtils.rm_rf dir
|
35
|
-
puts "
|
49
|
+
puts "\nCleaned generated site for tests: #{dir}"
|
36
50
|
end
|
37
51
|
Dir.chdir(dir) { _generate_site dir }
|
38
|
-
puts "
|
52
|
+
puts "\nGenerated site for tests: #{dir}"
|
39
53
|
dir
|
40
54
|
end
|
41
55
|
end
|
42
56
|
|
43
57
|
def _generate_site(destination)
|
44
58
|
options = {
|
45
|
-
'source' =>
|
59
|
+
'source' => source_path,
|
46
60
|
'destination' => destination
|
47
61
|
}
|
48
|
-
Jekyll::Site.new(Jekyll.configuration(options)).process
|
62
|
+
capture_io { Jekyll::Site.new(Jekyll.configuration(options)).process }
|
49
63
|
end
|
50
64
|
end
|
51
65
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'support/test_case'
|
2
|
+
require 'jekyll/minibundle/asset_bundle'
|
3
|
+
|
4
|
+
module Jekyll::Minibundle::Test
|
5
|
+
class AssetBundleTest < TestCase
|
6
|
+
def test_raise_exception_if_bundle_command_fails
|
7
|
+
capture_io do
|
8
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => 'false') do
|
9
|
+
err = assert_raises(RuntimeError) { make_bundle }
|
10
|
+
assert_equal 'Bundling js assets failed with exit status 1, command: false', err.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_raise_exception_if_bundle_command_not_found
|
16
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => 'no-such-jekyll-minibundle-cmd') do
|
17
|
+
assert_raises(Errno::ENOENT) { make_bundle }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_raise_exception_if_bundle_command_not_configured
|
22
|
+
with_env('JEKYLL_MINIBUNDLE_CMD_JS' => nil) do
|
23
|
+
err = assert_raises(RuntimeError) { make_bundle }
|
24
|
+
assert_equal 'You need to set bundling command in $JEKYLL_MINIBUNDLE_CMD_JS', err.to_s
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def make_bundle
|
31
|
+
bundle = AssetBundle.new :js, [source_path('_assets/scripts/dependency.js')], source_path
|
32
|
+
bundle.make_bundle
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'support/test_case'
|
2
|
+
require 'jekyll/minibundle/bundle_markup'
|
3
|
+
|
4
|
+
module Jekyll::Minibundle::Test
|
5
|
+
class BundleMarkupTest < TestCase
|
6
|
+
def test_escape_attribute_value
|
7
|
+
attributes = { media: 'screen, projection', extra: '">attack<br' }
|
8
|
+
actual = BundleMarkup.make_markup :css, 'http://localhost', attributes
|
9
|
+
expected = %{<link rel="stylesheet" href="http://localhost" media="screen, projection" extra="">attack<br">}
|
10
|
+
assert_equal expected, actual
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-minibundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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: 2012-12-
|
12
|
+
date: 2012-12-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -59,12 +59,27 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.5.5
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 10.0.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 10.0.2
|
78
|
+
description: ! 'A minimalistic asset bundling plugin for Jekyll, requiring only your
|
65
79
|
|
80
|
+
bundling tool of choice (no other dependencies, not even other gems).
|
66
81
|
|
67
|
-
|
82
|
+
Provides asset bundling and filename stamping with MD5 digest.
|
68
83
|
|
69
84
|
'
|
70
85
|
email: tkareine@gmail.com
|
@@ -73,6 +88,7 @@ extensions: []
|
|
73
88
|
extra_rdoc_files: []
|
74
89
|
files:
|
75
90
|
- History.md
|
91
|
+
- License.txt
|
76
92
|
- Rakefile
|
77
93
|
- Readme.md
|
78
94
|
- lib/jekyll/minibundle.rb
|
@@ -95,6 +111,8 @@ files:
|
|
95
111
|
- test/fixture/site/index.html
|
96
112
|
- test/integration/minibundle_test.rb
|
97
113
|
- test/integration/ministamp_test.rb
|
114
|
+
- test/unit/asset_bundle_test.rb
|
115
|
+
- test/unit/bundle_markup_test.rb
|
98
116
|
- test/support/test_case.rb
|
99
117
|
homepage: https://github.com/tkareine/jekyll-minibundle
|
100
118
|
licenses:
|
@@ -125,7 +143,7 @@ rubyforge_project:
|
|
125
143
|
rubygems_version: 1.8.24
|
126
144
|
signing_key:
|
127
145
|
specification_version: 3
|
128
|
-
summary:
|
146
|
+
summary: A minimalistic asset bundling plugin for Jekyll
|
129
147
|
test_files:
|
130
148
|
- test/fixture/site/_assets/scripts/app.js
|
131
149
|
- test/fixture/site/_assets/scripts/dependency.js
|
@@ -137,5 +155,7 @@ test_files:
|
|
137
155
|
- test/fixture/site/index.html
|
138
156
|
- test/integration/minibundle_test.rb
|
139
157
|
- test/integration/ministamp_test.rb
|
158
|
+
- test/unit/asset_bundle_test.rb
|
159
|
+
- test/unit/bundle_markup_test.rb
|
140
160
|
- test/support/test_case.rb
|
141
161
|
has_rdoc:
|