jekyll-jsminify 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-jsminify.rb +72 -38
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598be9e77cedac448142d21375d5cdf0b1d76749
|
4
|
+
data.tar.gz: ade14f98043a18087c1635997d34039b9dbd6562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e654bfb3052c6e460fef1a454b5611c5da17c56709475b6df4e048316562c05eaa838fca6386dbeea8ee6789486e97c919d68c7eb58dbccfc103034c2798bd7
|
7
|
+
data.tar.gz: 137cfbf2897ed8533a6c8e523a3f2a277aba6572b772e3356c8d610299c4f80cb3f4668429f3b9a01c3c2c680c195321d901dab75389275f27c064727898ab8b
|
data/lib/jekyll-jsminify.rb
CHANGED
@@ -1,31 +1,53 @@
|
|
1
1
|
require 'uglifier'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
27
|
+
module Minify
|
28
|
+
class JSMinify < Converter
|
29
|
+
safe true
|
30
|
+
priority :lowest
|
14
31
|
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
38
|
+
def matches(ext)
|
39
|
+
ext.downcase == ".js"
|
40
|
+
end
|
26
41
|
|
27
|
-
|
28
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
58
|
+
module Minify
|
59
|
+
class CSMinify < CoffeeScript
|
60
|
+
safe true
|
61
|
+
priority :lowest
|
39
62
|
|
40
|
-
|
41
|
-
|
42
|
-
|
63
|
+
def initialize(config={})
|
64
|
+
config['jsminify'] = Minify::symbolize_keys(config['jsminify'])
|
65
|
+
@config = config.dup
|
66
|
+
end
|
43
67
|
|
44
|
-
|
45
|
-
|
46
|
-
|
68
|
+
def matches(ext)
|
69
|
+
ext.downcase == ".coffee"
|
70
|
+
end
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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.
|
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-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uglifier
|