jekyll-minibundle 1.4.3 → 1.4.4

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: 477c2a1ad9364dfb5457b7b2b7894d74a0d5dcf8
4
- data.tar.gz: 3212bf6bb364f63ad2e565c2eff35fed43c984b1
3
+ metadata.gz: 27c6e3e700c2d0f5767edcebbb8df218df565536
4
+ data.tar.gz: 1fc68af34209d4556fcb726088fca486a318a33a
5
5
  SHA512:
6
- metadata.gz: c563707b1fa6b8cb468b96b22e3bc5ac99ec11d6cf0ef7eb4d520af3a1909744ef6c18d9beb646939d5f72efb83d3b28912fe44a3e66e402ea144183e64a8d43
7
- data.tar.gz: bdf079e3b4af862ba04f19c17b1ec832cbfc4994af873ffefea3c7f500327a9ec2769d85eefc275810dd133417faaa99e95a2840b70cc32bacfb046b6b8a6216
6
+ metadata.gz: c68cdff97eecd9343ea90498ff73e0c04987ef7020ee360d0c9a7c74d28782877e996cedd3e8ab8d1cdfbc5a9279bc8b18842c34a62d5206ff7320b46a056563
7
+ data.tar.gz: 6f6873bc41f2bfde2e7d38b5e4091672fb3a59cff7d026e2d18580ea706527920c035c5b27d6833773ebdce9eeb2d4687b76aebab42b0b02317d00ac3613a230
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 1.4.4 / 2014-01-16
2
+
3
+ * Conserve memory when calculating fingerprint for an asset.
4
+ Previously, we read the whole asset file into memory and then
5
+ calculated the MD5 digest. This is bad for big assets. Now, we read
6
+ the file in chunks.
7
+
1
8
  # 1.4.3 / 2014-01-16
2
9
 
3
10
  * Do not leak read pipe file descriptor upon minifier command failure
data/Rakefile CHANGED
@@ -42,7 +42,7 @@ end
42
42
 
43
43
  desc 'Run tests; envars: tests=<test_path> to select a particular suite, debug=1 to require Pry and PP'
44
44
  task :test do
45
- glob = ENV['tests'] || 'test/{unit,integration}/*_test.rb'
45
+ glob = ENV.fetch('tests', 'test/{unit,integration}/*_test.rb')
46
46
  files = Dir[glob].
47
47
  map { |file| %r{^test/(.+)\.rb$}.match(file)[1] }.
48
48
  shelljoin
@@ -11,7 +11,7 @@ module Jekyll::Minibundle
11
11
  end
12
12
 
13
13
  def bundle_file(config)
14
- asset_destination_path = "#{config['destination_path']}.#{config['type']}"
14
+ asset_destination_path = "#{config.fetch('destination_path')}.#{config.fetch('type')}"
15
15
  @_instances[asset_destination_path] ||= register_bundle_file(config)
16
16
  end
17
17
 
@@ -3,7 +3,7 @@ require 'digest/md5'
3
3
  module Jekyll::Minibundle
4
4
  module AssetStamp
5
5
  def self.from_file(path)
6
- Digest::MD5.hexdigest(File.read(path))
6
+ Digest::MD5.file(path).hexdigest
7
7
  end
8
8
  end
9
9
  end
@@ -8,12 +8,12 @@ module Jekyll::Minibundle
8
8
  include AssetFileOperations
9
9
 
10
10
  def initialize(config)
11
- @type = config['type']
12
- @site_source_dir = config['site_dir']
13
- asset_source_dir = File.join(@site_source_dir, config['source_dir'])
14
- @assets = config['assets'].map { |asset_path| File.join(asset_source_dir, "#{asset_path}.#{@type}") }
15
- @destination_path = config['destination_path']
16
- @attributes = config['attributes']
11
+ @type = config.fetch('type')
12
+ @site_source_dir = config.fetch('site_dir')
13
+ asset_source_dir = File.join(@site_source_dir, config.fetch('source_dir'))
14
+ @assets = config.fetch('assets').map { |asset_path| File.join(asset_source_dir, "#{asset_path}.#{@type}") }
15
+ @destination_path = config.fetch('destination_path')
16
+ @attributes = config.fetch('attributes')
17
17
  @stamped_at = nil
18
18
  @is_modified = false
19
19
  end
@@ -4,18 +4,18 @@ require 'jekyll/minibundle/development_file'
4
4
  module Jekyll::Minibundle
5
5
  class DevelopmentFileCollection
6
6
  def initialize(config)
7
- @type = config['type']
8
- asset_source_dir = File.join(config['site_dir'], config['source_dir'])
9
- destination_path = config['destination_path']
7
+ @type = config.fetch('type')
8
+ asset_source_dir = File.join(config.fetch('site_dir'), config.fetch('source_dir'))
9
+ destination_path = config.fetch('destination_path')
10
10
 
11
- @files = config['assets'].map do |asset_path|
11
+ @files = config.fetch('assets').map do |asset_path|
12
12
  asset_basename = "#{asset_path}.#{@type}"
13
13
  asset_source = File.join(asset_source_dir, asset_basename)
14
14
  asset_destination = File.join(destination_path, asset_basename)
15
15
  DevelopmentFile.new(asset_source, asset_destination)
16
16
  end
17
17
 
18
- @attributes = config['attributes']
18
+ @attributes = config.fetch('attributes')
19
19
  end
20
20
 
21
21
  def static_file!(site)
@@ -3,9 +3,7 @@ module Jekyll::Minibundle
3
3
  class << self
4
4
  def command_for(type)
5
5
  key = "JEKYLL_MINIBUNDLE_CMD_#{type.upcase}"
6
- cmd = ENV[key]
7
- fail "You need to set command for minification in $#{key}" if !cmd
8
- cmd
6
+ ENV.fetch(key) { fail "You need to set command for minification in $#{key}" }
9
7
  end
10
8
 
11
9
  def development?
@@ -9,7 +9,7 @@ module Jekyll::Minibundle
9
9
  end
10
10
 
11
11
  def render(context)
12
- site = context.registers[:site]
12
+ site = context.registers.fetch(:site)
13
13
  config = get_current_config(YAML.load(super), site)
14
14
  file = AssetFileRegistry.bundle_file(config)
15
15
  file.static_file!(site)
@@ -8,7 +8,7 @@ module Jekyll::Minibundle
8
8
  end
9
9
 
10
10
  def render(context)
11
- site = context.registers[:site]
11
+ site = context.registers.fetch(:site)
12
12
  file = AssetFileRegistry.stamp_file(File.join(site.source, @asset_source), @asset_destination)
13
13
  file.static_file!(site)
14
14
  file.markup
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Minibundle
3
- VERSION = '1.4.3'
3
+ VERSION = '1.4.4'
4
4
  end
5
5
  end
@@ -54,13 +54,13 @@ module Jekyll::Minibundle::Test
54
54
  {desc: "changing", action: ->(source) { File.write(source, 'h1 {}') }},
55
55
  {desc: "touching", action: ->(source) { FileUtils.touch(source) }}
56
56
  ].each do |spec|
57
- define_method :"test_#{spec[:desc]}_css_asset_source_rewrites_destination" do
57
+ define_method :"test_#{spec.fetch(:desc)}_css_asset_source_rewrites_destination" do
58
58
  with_site do
59
59
  generate_site(:development)
60
60
  destination = destination_path(CSS_BUNDLE_DESTINATION_PATH, 'common.css')
61
61
  org_mtime = mtime_of(destination)
62
62
  source = source_path(CSS_BUNDLE_SOURCE_DIR, 'common.css')
63
- ensure_file_mtime_changes { spec[:action].call(source) }
63
+ ensure_file_mtime_changes { spec.fetch(:action).call(source) }
64
64
  generate_site(:development, clear_cache: false)
65
65
 
66
66
  assert_equal File.read(destination), File.read(source)
@@ -73,13 +73,13 @@ module Jekyll::Minibundle::Test
73
73
  {desc: "changing", action: ->(source) { File.write(source, '(function() {})()') }},
74
74
  {desc: "touching", action: ->(source) { FileUtils.touch(source) }}
75
75
  ].each do |spec|
76
- define_method :"test_#{spec[:desc]}_js_asset_source_rewrites_destination" do
76
+ define_method :"test_#{spec.fetch(:desc)}_js_asset_source_rewrites_destination" do
77
77
  with_site do
78
78
  generate_site(:development)
79
79
  destination = destination_path(JS_BUNDLE_DESTINATION_PATH, 'app.js')
80
80
  org_mtime = mtime_of(destination)
81
81
  source = source_path(JS_BUNDLE_SOURCE_DIR, 'app.js')
82
- ensure_file_mtime_changes { spec[:action].call(source) }
82
+ ensure_file_mtime_changes { spec.fetch(:action).call(source) }
83
83
  generate_site(:development, clear_cache: false)
84
84
 
85
85
  assert_equal File.read(destination), File.read(source)
@@ -108,7 +108,7 @@ module Jekyll::Minibundle::Test
108
108
  end
109
109
 
110
110
  def _generate_site(test_options)
111
- AssetFileRegistry.clear if test_options[:clear_cache]
111
+ AssetFileRegistry.clear if test_options.fetch(:clear_cache)
112
112
 
113
113
  capture_io do
114
114
  Jekyll::Site.new(Jekyll.configuration(TestCase.site_generation_jekyll_options)).process
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.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tuomas Kareinen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll