jekyll-minibundle 2.0.1 → 2.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13fbeab915d4a828821cdccab516572fd71f735f
4
- data.tar.gz: e549b653ee51a6542cd290f24b6c677100d5ad1c
3
+ metadata.gz: f0e8eb69fc25d07f84cdd00cebe04669a4f0a09c
4
+ data.tar.gz: 3469c040798e5add50f205cd0327d10d8083743a
5
5
  SHA512:
6
- metadata.gz: ebe97e47891f916457af596045cc900964d24599134cdcbee63011a8858cf0dd31f229a111ad72753c3df0eea30755a42873e84b828f4cea863f9e1dd5294be5
7
- data.tar.gz: a7882e6b3adc793ee44b52c3606f653f6b1728b9b7828612327f49ff471000fb31539eaf717ab63a1621f72e320216c466d63256f16082d421bbeeb18c799fff
6
+ metadata.gz: 4953977ee09c4cdaf507b1c1f6a231e7778be1c9a84843968bd7e471baf678a3a4edf601b71d61f3b178dc63d1b72271ed291c4b23961d93790aae28175a7f1c
7
+ data.tar.gz: edcfeee786bbb756434e9e7576936891681060f92d90544e2cbef2367a230966c99eb289e3e3c24109e4d8f2ff2d06e5507131c727793dc099aad514815520b2
@@ -1,3 +1,9 @@
1
+ # 2.1.0 / 2016-05-04
2
+
3
+ * Allow attributes without values. Useful for `async` attribute, for
4
+ example. Pull Request #7 by Sam (@codewisdom).
5
+ * Ensure attribute value conversion to string
6
+
1
7
  # 2.0.1 / 2016-04-06
2
8
 
3
9
  * Fix Jekyll version requirement check to be more reliable
data/README.md CHANGED
@@ -124,6 +124,7 @@ assets:
124
124
  - app
125
125
  attributes:
126
126
  id: my-scripts
127
+ async:
127
128
  {% endminibundle %}
128
129
  ```
129
130
 
@@ -140,14 +141,15 @@ minibundle:
140
141
  Output in the content file:
141
142
 
142
143
  ``` html
143
- <script src="/assets/site-8e764372a0dbd296033cb2a416f064b5.js" type="text/javascript" id="my-scripts"></script>
144
+ <script src="/assets/site-8e764372a0dbd296033cb2a416f064b5.js" type="text/javascript" id="my-scripts" async></script>
144
145
  ```
145
146
 
146
- You can pass custom attributes, like `id="my-scripts"` above, to the
147
- generated markup with `attributes` map inside the `minibundle` block.
147
+ You can pass custom attributes, like `id="my-scripts"` and `async`
148
+ above, to the generated markup with `attributes` map inside the
149
+ `minibundle` block.
148
150
 
149
- For bundling CSS assets, you use `css` as the argument to the
150
- `minibundle` block:
151
+ For bundling CSS assets, use `css` as the argument to the `minibundle`
152
+ block:
151
153
 
152
154
  ``` text
153
155
  {% minibundle css %}
@@ -20,7 +20,11 @@ module Jekyll::Minibundle
20
20
  end
21
21
 
22
22
  def make_attribute(name, value)
23
- %{ #{name}="#{CGI.escape_html(value)}"}
23
+ if value.nil?
24
+ %{ #{name}}
25
+ else
26
+ %{ #{name}="#{CGI.escape_html(value.to_s)}"}
27
+ end
24
28
  end
25
29
 
26
30
  def make_url(baseurl, path)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Minibundle
3
- VERSION = '2.0.1'.freeze
3
+ VERSION = '2.1.0'.freeze
4
4
  end
5
5
  end
@@ -22,6 +22,7 @@
22
22
  - app
23
23
  attributes:
24
24
  id: my-scripts
25
+ async:
25
26
  {% endminibundle %}
26
27
  </body>
27
28
  <title>{{ page.title }}</title>
@@ -29,8 +29,8 @@ module Jekyll::Minibundle::Test
29
29
 
30
30
  def test_js_assets_have_configured_attributes
31
31
  with_precompiled_site(:development) do
32
- elements = find_js_elements_from_index.map { |el| el['id'] }.uniq
33
- assert_equal ['my-scripts'], elements
32
+ elements = find_js_elements_from_index.map { |el| [el['id'], el['async']] }.uniq
33
+ assert_equal [['my-scripts', '']], elements
34
34
  end
35
35
  end
36
36
 
@@ -29,6 +29,7 @@ module Jekyll::Minibundle::Test
29
29
  with_precompiled_site(:production) do
30
30
  element = find_js_element_from_index
31
31
  assert_equal 'my-scripts', element['id']
32
+ assert_equal '', element['async']
32
33
  end
33
34
  end
34
35
 
@@ -240,6 +241,8 @@ module Jekyll::Minibundle::Test
240
241
 
241
242
  generate_site(:production, clear_cache: false)
242
243
 
244
+ sleep 1 # wait for unlinked temp files to actually disappear
245
+
243
246
  refute File.exist?(destination_path(JS_BUNDLE_DESTINATION_FINGERPRINT_PATH))
244
247
  assert File.exist?(destination_path("assets/site2-#{JS_BUNDLE_FINGERPRINT}.js"))
245
248
  assert_equal 1, (org_tempfiles - find_tempfiles).size
@@ -3,13 +3,31 @@ require 'jekyll/minibundle/asset_tag_markup'
3
3
 
4
4
  module Jekyll::Minibundle::Test
5
5
  class AssetTagMarkupTest < TestCase
6
- def test_escapes_attribute_values
6
+ def test_escape_attribute_value
7
7
  attributes = {media: 'screen, projection', extra: '">attack<br'}
8
8
  actual = AssetTagMarkup.make_markup(:css, '', '/asset.css', attributes)
9
9
  expected = %{<link rel="stylesheet" href="/asset.css" media="screen, projection" extra="&quot;&gt;attack&lt;br">}
10
10
  assert_equal expected, actual
11
11
  end
12
12
 
13
+ def test_output_just_attribute_name_for_nil_value
14
+ actual = AssetTagMarkup.make_markup(:css, '', '/asset.css', async: nil)
15
+ expected = %{<link rel="stylesheet" href="/asset.css" async>}
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ def test_convert_attribute_value_to_string
20
+ actual = AssetTagMarkup.make_markup(:css, '', '/asset.css', boolean: false)
21
+ expected = %{<link rel="stylesheet" href="/asset.css" boolean="false">}
22
+ assert_equal expected, actual
23
+ end
24
+
25
+ def test_output_empty_attribute_value
26
+ actual = AssetTagMarkup.make_markup(:css, '', '/asset.css', empty: '')
27
+ expected = %{<link rel="stylesheet" href="/asset.css" empty="">}
28
+ assert_equal expected, actual
29
+ end
30
+
13
31
  def test_raise_exception_if_unknown_type
14
32
  err = assert_raises(ArgumentError) do
15
33
  AssetTagMarkup.make_markup(:unknown, '', '/asset', {})
@@ -17,15 +35,15 @@ module Jekyll::Minibundle::Test
17
35
  assert_equal 'Unknown type for generating bundle markup: unknown, /asset', err.to_s
18
36
  end
19
37
 
20
- def test_joins_empty_baseurl_and_path
38
+ def test_join_empty_baseurl_and_path
21
39
  assert_equal %{<link rel="stylesheet" href="asset.css">}, AssetTagMarkup.make_markup(:css, '', 'asset.css', {})
22
40
  end
23
41
 
24
- def test_joins_nonempty_baseurl_and_path
42
+ def test_join_nonempty_baseurl_and_path
25
43
  assert_equal %{<link rel="stylesheet" href="/root/path/asset.css">}, AssetTagMarkup.make_markup(:css, '/root', 'path/asset.css', {})
26
44
  end
27
45
 
28
- def test_removes_extra_slash_between_baseurl_and_path
46
+ def test_remove_extra_slash_between_baseurl_and_path
29
47
  assert_equal %{<link rel="stylesheet" href="/asset.css">}, AssetTagMarkup.make_markup(:css, '/', '/asset.css', {})
30
48
  end
31
49
  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: 2.0.1
4
+ version: 2.1.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: 2016-04-06 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.6.2
178
+ rubygems_version: 2.6.4
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: A minimalistic asset bundling plugin for Jekyll