jekyll-jsminify 0.1.0 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-jsminify.rb +72 -38
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd4d245b467844fc511539a60558a28b2214690
4
- data.tar.gz: 5273c738d274fd6c46089ae4449528e0bff05f3d
3
+ metadata.gz: 598be9e77cedac448142d21375d5cdf0b1d76749
4
+ data.tar.gz: ade14f98043a18087c1635997d34039b9dbd6562
5
5
  SHA512:
6
- metadata.gz: 81433bad7c8105615a4a5c8daa96521f9f76150bcf64a6a4ccbe59b99f5ac40e4414e4d2b0bb35ed832fd35fbef24c0daefdbe6d0d29236c7a4941c903ec0e89
7
- data.tar.gz: 69ef2b73f36bd270da88f7011ffb6234da719f2ce80f6af0dcadc5cee1a85c5d9e442f81cca69eb7e6590d1a8131f4338507b0a0ea00efdc90c15c1f1b7294d2
6
+ metadata.gz: 2e654bfb3052c6e460fef1a454b5611c5da17c56709475b6df4e048316562c05eaa838fca6386dbeea8ee6789486e97c919d68c7eb58dbccfc103034c2798bd7
7
+ data.tar.gz: 137cfbf2897ed8533a6c8e523a3f2a277aba6572b772e3356c8d610299c4f80cb3f4668429f3b9a01c3c2c680c195321d901dab75389275f27c064727898ab8b
@@ -1,31 +1,53 @@
1
1
  require 'uglifier'
2
2
 
3
- DEFAULT_UGLIFY_OPTS = {
4
- "jsminify" => {
5
- :comments => :none
6
- }
7
- }
3
+ module Jekyll
4
+ module Converters
5
+ module Minify
6
+ def self.symbolize_keys(hash)
7
+ return { } if hash.nil?
8
+ hash.inject({}){|result, (key, value)|
9
+ new_key = case key
10
+ when String then key.to_sym
11
+ else key
12
+ end
13
+ new_value = case value
14
+ when Hash then symbolize_keys(value)
15
+ else value
16
+ end
17
+ result[new_key] = new_value
18
+ result
19
+ }
20
+ end
21
+ end
22
+ end
23
+ end
8
24
 
9
25
  module Jekyll
10
26
  module Converters
11
- class JSMinify < Converter
12
- safe true
13
- priority :lowest
27
+ module Minify
28
+ class JSMinify < Converter
29
+ safe true
30
+ priority :lowest
14
31
 
15
- def initialize(config={})
16
- @config = DEFAULT_UGLIFY_OPTS.merge config
17
- end
32
+ def initialize(config={})
33
+ config['jsminify'] = Minify::symbolize_keys(config['jsminify'])
34
+ @config = config.dup
35
+ end
18
36
 
19
- def matches(ext)
20
- ext.downcase == ".js"
21
- end
22
37
 
23
- def output_ext(ext)
24
- ".js"
25
- end
38
+ def matches(ext)
39
+ ext.downcase == ".js"
40
+ end
26
41
 
27
- def convert(content)
28
- Uglifier.new(@config['jsminify']).compile content
42
+ def output_ext(ext)
43
+ ".js"
44
+ end
45
+
46
+ def convert(content)
47
+ config = @config['jsminify'] || {}
48
+ return content if config[:do_not_compress] == true
49
+ Uglifier.new(config).compile content
50
+ end
29
51
  end
30
52
  end
31
53
  end
@@ -33,29 +55,41 @@ end
33
55
 
34
56
  module Jekyll
35
57
  module Converters
36
- class CSMinify < CoffeeScript
37
- safe true
38
- priority :lowest
58
+ module Minify
59
+ class CSMinify < CoffeeScript
60
+ safe true
61
+ priority :lowest
39
62
 
40
- def initialize(config={})
41
- @config = DEFAULT_UGLIFY_OPTS.merge config
42
- end
63
+ def initialize(config={})
64
+ config['jsminify'] = Minify::symbolize_keys(config['jsminify'])
65
+ @config = config.dup
66
+ end
43
67
 
44
- def matches(ext)
45
- ext.downcase == ".coffee"
46
- end
68
+ def matches(ext)
69
+ ext.downcase == ".coffee"
70
+ end
47
71
 
48
- def output_ext(ext)
49
- super
50
- end
72
+ def output_ext(ext)
73
+ super
74
+ end
75
+
76
+ def convert(content)
77
+ config = @config['jsminify'] || {}
78
+
79
+ # can't figure out why sometimes, CS comes down here, and sometimes,
80
+ # proper JS. Also can't figure out how to scope to just SyntaxError.
81
+ # some timing issue?
82
+ begin
83
+ return super if config[:do_not_compress] == true
84
+ rescue
85
+ return content if config[:do_not_compress] == true
86
+ end
51
87
 
52
- def convert(content)
53
- # can't figure out why sometimes, CS comes down here, and sometimes,
54
- # proper JS. Also can't figure out how to scope to just SyntaxError.
55
- begin
56
- Uglifier.new(@config['jsminify']).compile super
57
- rescue
58
- Uglifier.new(@config['jsminify']).compile content
88
+ begin
89
+ Uglifier.new(config).compile super
90
+ rescue
91
+ Uglifier.new(config).compile content
92
+ end
59
93
  end
60
94
  end
61
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-jsminify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uglifier