html_minifier 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ before_script: "git submodule update --init --recursive"
7
7
  env:
8
8
  - EXECJS_RUNTIME=RubyRacer
9
9
  - EXECJS_RUNTIME=RubyRhino
10
+ - EXECJS_RUNTIME=Node
10
11
  matrix:
11
12
  exclude:
12
13
  - rvm: 1.8.7
data/Gemfile CHANGED
@@ -7,10 +7,12 @@ gemspec
7
7
  execjs_runtimes = {
8
8
  "RubyRacer" => "therubyracer",
9
9
  "RubyRhino" => "therubyrhino",
10
- "Mustang" => "mustang"
11
10
  }
12
11
 
13
12
  if ENV["EXECJS_RUNTIME"] && execjs_runtimes[ENV["EXECJS_RUNTIME"]]
14
13
  gem execjs_runtimes[ENV["EXECJS_RUNTIME"]], :group => :development
14
+ if execjs_runtimes[ENV["EXECJS_RUNTIME"]] == "therubyracer"
15
+ gem 'libv8', '~> 3.11.8', :group => :development
16
+ end
15
17
  end
16
18
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # HtmlMinifier
2
2
  [![Build Status](https://secure.travis-ci.org/stereobooster/html_minifier.png?branch=master)](http://travis-ci.org/stereobooster/html_minifier)
3
3
 
4
- Ruby wrapper for [html-minifier](https://github.com/kangax/html-minifier/).
4
+ Ruby wrapper for js library [html-minifier](https://github.com/kangax/html-minifier/). If you want pure ruby use [html_press](https://github.com/stereobooster/html_press)
5
5
 
6
6
  ## Installation
7
7
 
data/Rakefile CHANGED
@@ -14,15 +14,18 @@ Submodule::Task.new do |t|
14
14
  %w{htmlparser htmllint htmlminifier}.each do |i|
15
15
  js << File.open("src/#{i}.js", "r:UTF-8").read
16
16
  end
17
- js << File.open("tests/qunit.js", "r:UTF-8").read
17
+ js << File.open("tests/qunit.js", "r:UTF-8").read.gsub('}( (function() {return this;}.call()) ));', '}( this ));')
18
18
  js << File.open(File.expand_path("../spec/qunit_helper.js", __FILE__), "r:UTF-8").read
19
19
  %w{minify_test lint_test}.each do |i|
20
20
  js << File.open("tests/#{i}.js", "r:UTF-8").read
21
21
  end
22
22
 
23
+ js = js.join("\n")
24
+ js = "function globe(){#{js};return this};var global = new globe();"
25
+
23
26
  require "execjs"
24
- context = ExecJS.compile js.join("\n")
25
- result = context.exec "return QUnit.result();"
27
+ context = ExecJS.compile js
28
+ result = context.exec "return global.QUnit.result();"
26
29
  if result["fail"] > 0 && result["assertions"].respond_to?(:each)
27
30
  puts "Failures:"
28
31
  i = 1
@@ -5,7 +5,7 @@ require "html_minifier/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "html_minifier"
7
7
  s.version = HtmlMinifier::VERSION
8
- s.authors = ["slavic"]
8
+ s.authors = ["stereobooster"]
9
9
  s.email = ["stereobooster@gmail.com"]
10
10
  s.homepage = "https://github.com/stereobooster/html_minifier"
11
11
  s.summary = %q{Ruby wrapper for kangax js library html-minifier. If you want pure ruby use html_press}
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_development_dependency "rspec"
20
20
  s.add_development_dependency "submodule", ">= 0.1.0"
21
- s.add_runtime_dependency "rake"
21
+ s.add_development_dependency "rake"
22
22
 
23
23
  s.add_dependency "multi_json", ">= 1.3"
24
24
  s.add_dependency "execjs"
@@ -23,6 +23,7 @@ module HtmlMinifier
23
23
  js = %w{console htmlparser htmllint htmlminifier}.map do |i|
24
24
  File.open("#{SourceBasePath}/#{i}.js", "r:UTF-8").read
25
25
  end.join("\n")
26
+ js = "function globe(){#{js};return this};var global = new globe();"
26
27
  @context = ExecJS.compile(js)
27
28
  end
28
29
 
@@ -30,11 +31,12 @@ module HtmlMinifier
30
31
  source = source.respond_to?(:read) ? source.read : source.to_s
31
32
  js = []
32
33
  if @options.nil? then
33
- js << "var min = minify(#{MultiJson.dump(source)});"
34
+ js << "var min = global.minify(#{MultiJson.dump(source)});"
34
35
  else
35
- js << "var min = minify(#{MultiJson.dump(source)}, #{MultiJson.dump(@options)});"
36
+ js << "var min = global.minify(#{MultiJson.dump(source)}, #{MultiJson.dump(@options)});"
36
37
  end
37
- js << "return {min:min, logs:console.clear()};"
38
+ js << "return {min:min, logs:global.console.clear()};"
39
+
38
40
  result = @context.exec js.join("\n")
39
41
  if @log.respond_to?(:info)
40
42
  result["logs"].each do |i|
@@ -1,4 +1,4 @@
1
1
  module HtmlMinifier
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  SUBMODULE = "7032d3d3d97aabf0a2c96c8155ed077b455aca31"
4
4
  end
@@ -1,6 +1,6 @@
1
1
  (function (global) {
2
2
  var logs = [];
3
- global.console = {
3
+ global.console = {
4
4
  log: function (message) {
5
5
  logs.push(message);
6
6
  },
@@ -41,4 +41,4 @@
41
41
  return result;
42
42
  };
43
43
 
44
- }( QUnit ));
44
+ }( this.QUnit ));
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_minifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - slavic
8
+ - stereobooster
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000Z
12
+ date: 2012-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &27583416 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *27583416
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: submodule
27
- requirement: &27583116 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,21 +37,31 @@ dependencies:
32
37
  version: 0.1.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *27583116
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &27582864 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
42
52
  - !ruby/object:Gem::Version
43
53
  version: '0'
44
- type: :runtime
54
+ type: :development
45
55
  prerelease: false
46
- version_requirements: *27582864
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: multi_json
49
- requirement: &27582540 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '1.3'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *27582540
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '1.3'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: execjs
60
- requirement: &27582288 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *27582288
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  description: Ruby wrapper for kangax js library html-minifier. If you want pure ruby
70
95
  use html_press
71
96
  email:
@@ -107,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
132
  version: '0'
108
133
  segments:
109
134
  - 0
110
- hash: -88757407
135
+ hash: -889560111
111
136
  required_rubygems_version: !ruby/object:Gem::Requirement
112
137
  none: false
113
138
  requirements:
@@ -116,10 +141,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
141
  version: '0'
117
142
  segments:
118
143
  - 0
119
- hash: -88757407
144
+ hash: -889560111
120
145
  requirements: []
121
146
  rubyforge_project:
122
- rubygems_version: 1.8.15
147
+ rubygems_version: 1.8.24
123
148
  signing_key:
124
149
  specification_version: 3
125
150
  summary: Ruby wrapper for kangax js library html-minifier. If you want pure ruby use