jekyll-minifier 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-minifier.rb +30 -40
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f729043a0054503093c8e126a540bd82de1a8fee
4
- data.tar.gz: 7f773d1693a79bdb8b01c7dc51457d927ac8c8f5
3
+ metadata.gz: 690376260d708ba2e3c75f1fdfb62c23e22088ce
4
+ data.tar.gz: 9f9427561871fb3033ccc03100ea77ae88f9dbac
5
5
  SHA512:
6
- metadata.gz: 4996868248e8553b1b6f049e1ab7a0e69586c2d10209a12cf84d71d7aa3b6435ba12fbc4b660df5a9ed379ab7466e238545ff991bd18b9e3a5d25f8f59c28884
7
- data.tar.gz: f883c558fe9b8ef769ef6dea203ce28653d003985ab3a4855aae96820d4adae1cfcb8974515ef8bd38f049e1895cb82d0fb1f45dbf0f111c68aafd783449f3ab
6
+ metadata.gz: ac45fa2e056cc047507c8b44c55db903a32883fa52f44500daa518e9dfb40d66a7663f8cf4a591f475fd69ef94170eae17aa0a9ae20c88fdfe858dde4a18ef65
7
+ data.tar.gz: 2f5bb191245db340d2c586cb7e742f092154f6e5424ef466d4358671b9383beb61460f50901ef2087fe9d7576332638829d6ee2c84d7b90c4573d7af4e36d300
@@ -4,24 +4,6 @@ require 'cssminify2'
4
4
 
5
5
  module Jekyll
6
6
  module Compressor
7
- def exclude?(dest, dest_path)
8
- res = false
9
- file_name = dest_path.slice(dest.length+1..dest_path.length)
10
- exclude = @site.config['jekyll-minifier'] && @site.config['jekyll-minifier']['exclude']
11
- if exclude
12
- if exclude.is_a? String
13
- exclude = [exclude]
14
- end
15
- exclude.each do |e|
16
- if e == file_name || File.fnmatch(e, file_name)
17
- res = true
18
- break
19
- end
20
- end
21
- end
22
- res
23
- end
24
-
25
7
  def output_file(dest, content)
26
8
  FileUtils.mkdir_p(File.dirname(dest))
27
9
  File.open(dest, 'w') do |f|
@@ -37,28 +19,25 @@ module Jekyll
37
19
  opts = @site.config['jekyll-minifier']
38
20
 
39
21
  if ( !opts.nil? )
40
- # Convert keys to symboles
41
- opts.keys.each { |key| opts[(key.to_sym rescue key) || key] = opts.delete(key) }
42
-
43
- args[:remove_spaces_inside_tags] = opts[:remove_spaces_inside_tags] if opts.has_key?(:remove_spaces_inside_tags)
44
- args[:remove_multi_spaces] = opts[:remove_multi_spaces] if opts.has_key?(:remove_multi_spaces)
45
- args[:remove_comments] = opts[:remove_comments] if opts.has_key?(:remove_comments)
46
- args[:remove_intertag_spaces] = opts[:remove_intertag_spaces] if opts.has_key?(:remove_intertag_spaces)
47
- args[:remove_quotes] = opts[:remove_quotes] if opts.has_key?(:remove_quotes)
48
- args[:compress_css] = opts[:compress_css] if opts.has_key?(:compress_css)
49
- args[:compress_javascript] = opts[:compress_javascript] if opts.has_key?(:compress_javascript)
50
- args[:simple_doctype] = opts[:simple_doctype] if opts.has_key?(:simple_doctype)
51
- args[:remove_script_attributes] = opts[:remove_script_attributes] if opts.has_key?(:remove_script_attributes)
52
- args[:remove_style_attributes] = opts[:remove_style_attributes] if opts.has_key?(:remove_style_attributes)
53
- args[:remove_link_attributes] = opts[:remove_link_attributes] if opts.has_key?(:remove_link_attributes)
54
- args[:remove_form_attributes] = opts[:remove_form_attributes] if opts.has_key?(:remove_form_attributes)
55
- args[:remove_input_attributes] = opts[:remove_input_attributes] if opts.has_key?(:remove_input_attributes)
56
- args[:remove_javascript_protocol] = opts[:remove_javascript_protocol] if opts.has_key?(:remove_javascript_protocol)
57
- args[:remove_http_protocol] = opts[:remove_http_protocol] if opts.has_key?(:remove_http_protocol)
58
- args[:remove_https_protocol] = opts[:remove_https_protocol] if opts.has_key?(:remove_https_protocol)
59
- args[:preserve_line_breaks] = opts[:preserve_line_breaks] if opts.has_key?(:preserve_line_breaks)
60
- args[:simple_boolean_attributes] = opts[:simple_boolean_attributes] if opts.has_key?(:simple_boolean_attributes)
61
- args[:compress_js_templates] = opts[:compress_js_templates] if opts.has_key?(:compress_js_templates)
22
+ args[:remove_spaces_inside_tags] = opts['remove_spaces_inside_tags'] if opts.has_key?('remove_spaces_inside_tags')
23
+ args[:remove_multi_spaces] = opts['remove_multi_spaces'] if opts.has_key?('remove_multi_spaces')
24
+ args[:remove_comments] = opts['remove_comments'] if opts.has_key?('remove_comments')
25
+ args[:remove_intertag_spaces] = opts['remove_intertag_spaces'] if opts.has_key?('remove_intertag_spaces')
26
+ args[:remove_quotes] = opts['remove_quotes'] if opts.has_key?('remove_quotes')
27
+ args[:compress_css] = opts['compress_css'] if opts.has_key?('compress_css')
28
+ args[:compress_javascript] = opts['compress_javascript'] if opts.has_key?('compress_javascript')
29
+ args[:simple_doctype] = opts['simple_doctype'] if opts.has_key?('simple_doctype')
30
+ args[:remove_script_attributes] = opts['remove_script_attributes'] if opts.has_key?('remove_script_attributes')
31
+ args[:remove_style_attributes] = opts['remove_style_attributes'] if opts.has_key?('remove_style_attributes')
32
+ args[:remove_link_attributes] = opts['remove_link_attributes'] if opts.has_key?('remove_link_attributes')
33
+ args[:remove_form_attributes] = opts['remove_form_attributes'] if opts.has_key?('remove_form_attributes')
34
+ args[:remove_input_attributes] = opts['remove_input_attributes'] if opts.has_key?('remove_input_attributes')
35
+ args[:remove_javascript_protocol] = opts['remove_javascript_protocol'] if opts.has_key?('remove_javascript_protocol')
36
+ args[:remove_http_protocol] = opts['remove_http_protocol'] if opts.has_key?('remove_http_protocol')
37
+ args[:remove_https_protocol] = opts['remove_https_protocol'] if opts.has_key?('remove_https_protocol')
38
+ args[:preserve_line_breaks] = opts['preserve_line_breaks'] if opts.has_key?('preserve_line_breaks')
39
+ args[:simple_boolean_attributes] = opts['simple_boolean_attributes'] if opts.has_key?('simple_boolean_attributes')
40
+ args[:compress_js_templates] = opts['compress_js_templates'] if opts.has_key?('compress_js_templates')
62
41
  args[:preserve_patterns] += [/<\?php.*?\?>/im] if opts[:preserve_php] == true
63
42
 
64
43
  # Potential to add patterns from YAML
@@ -78,6 +57,17 @@ module Jekyll
78
57
  compressor = CSSminify2.new
79
58
  output_file(path, compressor.compress(content))
80
59
  end
60
+
61
+ private
62
+
63
+ def exclude?(dest, dest_path)
64
+ file_name = dest_path.slice(dest.length+1..dest_path.length)
65
+ exclude.any? { |e| e == file_name || File.fnmatch(e, file_name) }
66
+ end
67
+
68
+ def exclude
69
+ @exclude ||= Array(@site.config.dig('jekyll-minifier', 'exclude'))
70
+ end
81
71
  end
82
72
 
83
73
  class Document
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-minifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - DigitalSparky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll