optimize-js 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 915f704285fce599270dc45534481e0ae1bc8bb1
4
- data.tar.gz: d81dd20291c07af188f0bc7ffaae32a5a2f4a35a
3
+ metadata.gz: f6e94f7d70d435d2aa88e38dad070121faa1e9a4
4
+ data.tar.gz: 4864ce820894cd9fe44007b9f98195583982b528
5
5
  SHA512:
6
- metadata.gz: 94068f2bdf737177e24d7b3f4f77da29855f73e585b529e954ab645190591464b777a08a99da94d5b7ce64ecd6c988bddc9fdf79346f7d623c7283c46bb391e4
7
- data.tar.gz: 3eb6f9f753f36fdff6810af70b116bee9f97a61f5ec71faa1aa693975e77afc93bcbd5b2956eb5df3638e1c9dfcf675367f5a9e98da7aeec6577c8db1a6a32fd
6
+ metadata.gz: 2d36e60193c79e776bb75e74968544c5cc413b6c68b3ca78bdad8695e5a35a275a095926d72af3b2681fa9da51b6e1a78091f00241a745b3ceb7b8e802436a4e
7
+ data.tar.gz: 136820a3d75ff31cbe98bc2cadeae64044556304d6db332b2761b1b0f8591caf0370aa734953c49d4e5d263db61e6f3b0cd9710b49a618a3c840b501dc31bd67
data/Appraisals CHANGED
@@ -1,18 +1,22 @@
1
1
  appraise 'rails-3' do
2
2
  gem 'rails', '~> 3'
3
3
  gem 'sprockets', '~> 2'
4
+ gem 'uglifier'
4
5
  end
5
6
 
6
7
  appraise 'rails-4-with-sprockets-2' do
7
8
  gem 'rails', '~> 4'
8
9
  gem 'sprockets', '~> 3'
10
+ gem 'uglifier'
9
11
  end
10
12
 
11
13
  appraise 'rails-4-with-sprockets-3' do
12
14
  gem 'rails', '~> 4'
13
15
  gem 'sprockets', '~> 3'
16
+ gem 'uglifier'
14
17
  end
15
18
 
16
19
  appraise 'rails-5' do
17
20
  gem 'rails', '~> 5'
21
+ gem 'uglifier'
18
22
  end
data/Gemfile CHANGED
@@ -3,3 +3,5 @@
3
3
 
4
4
  source 'https://rubygems.org'
5
5
  gemspec
6
+ gem 'rails', '~> 4.2'
7
+ gem 'uglifier'
@@ -1,22 +1,115 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optimize-js (1.0)
4
+ optimize-js (1.0.1)
5
5
  execjs (>= 1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ actionmailer (4.2.7.1)
11
+ actionpack (= 4.2.7.1)
12
+ actionview (= 4.2.7.1)
13
+ activejob (= 4.2.7.1)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.7.1)
17
+ actionview (= 4.2.7.1)
18
+ activesupport (= 4.2.7.1)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.7.1)
24
+ activesupport (= 4.2.7.1)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.7.1)
30
+ activesupport (= 4.2.7.1)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.7.1)
33
+ activesupport (= 4.2.7.1)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.7.1)
36
+ activemodel (= 4.2.7.1)
37
+ activesupport (= 4.2.7.1)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.7.1)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
10
45
  appraisal (2.1.0)
11
46
  bundler
12
47
  rake
13
48
  thor (>= 0.14.0)
49
+ arel (6.0.3)
50
+ builder (3.2.2)
51
+ concurrent-ruby (1.0.3)
52
+ erubis (2.7.0)
14
53
  execjs (2.7.0)
54
+ globalid (0.3.7)
55
+ activesupport (>= 4.1.0)
56
+ i18n (0.7.0)
57
+ json (1.8.3)
58
+ loofah (2.0.3)
59
+ nokogiri (>= 1.5.9)
60
+ mail (2.6.4)
61
+ mime-types (>= 1.16, < 4)
62
+ mime-types (3.1)
63
+ mime-types-data (~> 3.2015)
64
+ mime-types-data (3.2016.0521)
65
+ mini_portile2 (2.1.0)
66
+ minitest (5.10.1)
67
+ nokogiri (1.6.8.1)
68
+ mini_portile2 (~> 2.1.0)
15
69
  power_assert (0.3.1)
70
+ rack (1.6.5)
71
+ rack-test (0.6.3)
72
+ rack (>= 1.0)
73
+ rails (4.2.7.1)
74
+ actionmailer (= 4.2.7.1)
75
+ actionpack (= 4.2.7.1)
76
+ actionview (= 4.2.7.1)
77
+ activejob (= 4.2.7.1)
78
+ activemodel (= 4.2.7.1)
79
+ activerecord (= 4.2.7.1)
80
+ activesupport (= 4.2.7.1)
81
+ bundler (>= 1.3.0, < 2.0)
82
+ railties (= 4.2.7.1)
83
+ sprockets-rails
84
+ rails-deprecated_sanitizer (1.0.3)
85
+ activesupport (>= 4.2.0.alpha)
86
+ rails-dom-testing (1.0.7)
87
+ activesupport (>= 4.2.0.beta, < 5.0)
88
+ nokogiri (~> 1.6.0)
89
+ rails-deprecated_sanitizer (>= 1.0.1)
90
+ rails-html-sanitizer (1.0.3)
91
+ loofah (~> 2.0)
92
+ railties (4.2.7.1)
93
+ actionpack (= 4.2.7.1)
94
+ activesupport (= 4.2.7.1)
95
+ rake (>= 0.8.7)
96
+ thor (>= 0.18.1, < 2.0)
16
97
  rake (10.5.0)
98
+ sprockets (3.7.1)
99
+ concurrent-ruby (~> 1.0)
100
+ rack (> 1, < 3)
101
+ sprockets-rails (3.2.0)
102
+ actionpack (>= 4.0)
103
+ activesupport (>= 4.0)
104
+ sprockets (>= 3.0.0)
17
105
  test-unit (3.1.9)
18
106
  power_assert
19
107
  thor (0.19.4)
108
+ thread_safe (0.3.5)
109
+ tzinfo (1.2.2)
110
+ thread_safe (~> 0.1)
111
+ uglifier (3.0.4)
112
+ execjs (>= 0.3.0, < 3)
20
113
 
21
114
  PLATFORMS
22
115
  ruby
@@ -25,8 +118,10 @@ DEPENDENCIES
25
118
  appraisal (~> 2.1)
26
119
  bundler (~> 1.7)
27
120
  optimize-js!
121
+ rails (~> 4.2)
28
122
  rake (~> 10.0)
29
123
  test-unit (~> 3.1)
124
+ uglifier
30
125
 
31
126
  BUNDLED WITH
32
127
  1.13.2
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3"
6
+ gem "uglifier"
6
7
  gem "sprockets", "~> 2"
7
8
 
8
9
  gemspec :path => "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- optimize-js (1.0)
4
+ optimize-js (1.0.1)
5
5
  execjs (>= 1)
6
6
 
7
7
  GEM
@@ -91,6 +91,8 @@ GEM
91
91
  polyglot
92
92
  polyglot (>= 0.3.1)
93
93
  tzinfo (0.3.52)
94
+ uglifier (3.0.4)
95
+ execjs (>= 0.3.0, < 3)
94
96
 
95
97
  PLATFORMS
96
98
  ruby
@@ -103,6 +105,7 @@ DEPENDENCIES
103
105
  rake (~> 10.0)
104
106
  sprockets (~> 2)
105
107
  test-unit (~> 3.1)
108
+ uglifier
106
109
 
107
110
  BUNDLED WITH
108
111
  1.13.2
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4"
6
+ gem "uglifier"
6
7
  gem "sprockets", "~> 3"
7
8
 
8
9
  gemspec :path => "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- optimize-js (1.0)
4
+ optimize-js (1.0.1)
5
5
  execjs (>= 1)
6
6
 
7
7
  GEM
@@ -108,6 +108,8 @@ GEM
108
108
  thread_safe (0.3.5)
109
109
  tzinfo (1.2.2)
110
110
  thread_safe (~> 0.1)
111
+ uglifier (3.0.4)
112
+ execjs (>= 0.3.0, < 3)
111
113
 
112
114
  PLATFORMS
113
115
  ruby
@@ -120,6 +122,7 @@ DEPENDENCIES
120
122
  rake (~> 10.0)
121
123
  sprockets (~> 3)
122
124
  test-unit (~> 3.1)
125
+ uglifier
123
126
 
124
127
  BUNDLED WITH
125
128
  1.13.2
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4"
6
+ gem "uglifier"
6
7
  gem "sprockets", "~> 3"
7
8
 
8
9
  gemspec :path => "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- optimize-js (1.0)
4
+ optimize-js (1.0.1)
5
5
  execjs (>= 1)
6
6
 
7
7
  GEM
@@ -108,6 +108,8 @@ GEM
108
108
  thread_safe (0.3.5)
109
109
  tzinfo (1.2.2)
110
110
  thread_safe (~> 0.1)
111
+ uglifier (3.0.4)
112
+ execjs (>= 0.3.0, < 3)
111
113
 
112
114
  PLATFORMS
113
115
  ruby
@@ -120,6 +122,7 @@ DEPENDENCIES
120
122
  rake (~> 10.0)
121
123
  sprockets (~> 3)
122
124
  test-unit (~> 3.1)
125
+ uglifier
123
126
 
124
127
  BUNDLED WITH
125
128
  1.13.2
@@ -3,5 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5"
6
+ gem "uglifier"
6
7
 
7
8
  gemspec :path => "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- optimize-js (1.0)
4
+ optimize-js (1.0.1)
5
5
  execjs (>= 1)
6
6
 
7
7
  GEM
@@ -110,6 +110,8 @@ GEM
110
110
  thread_safe (0.3.5)
111
111
  tzinfo (1.2.2)
112
112
  thread_safe (~> 0.1)
113
+ uglifier (3.0.4)
114
+ execjs (>= 0.3.0, < 3)
113
115
  websocket-driver (0.6.4)
114
116
  websocket-extensions (>= 0.1.0)
115
117
  websocket-extensions (0.1.2)
@@ -124,6 +126,7 @@ DEPENDENCIES
124
126
  rails (~> 5)
125
127
  rake (~> 10.0)
126
128
  test-unit (~> 3.1)
129
+ uglifier
127
130
 
128
131
  BUNDLED WITH
129
132
  1.13.2
@@ -25,4 +25,5 @@ module OptimizeJS
25
25
  end
26
26
  end
27
27
 
28
+ require 'optimize-js/sprockets-patch'
28
29
  require 'optimize-js/railtie' if defined?(Rails)
@@ -16,8 +16,10 @@ class OptimizeJS::Railtie < Rails::Railtie
16
16
 
17
17
  initializer 'sprockets.optimize_js', group: :all, after: 'sprockets.environment' do |app|
18
18
  configure_assets(app) do |env|
19
- # Sprockets 2, 3, and 4
20
- env.register_bundle_processor 'application/javascript', OptimizeJS::SprocketsProcessor
19
+ unless app.config.assets.compile
20
+ env.register_bundle_processor 'application/javascript', OptimizeJS::SprocketsProcessor
21
+ end
21
22
  end
22
23
  end
23
24
  end
25
+
@@ -0,0 +1,19 @@
1
+ def OptimizeJS.patch_sprockets_js_compressor(base)
2
+ base.instance_exec do
3
+ alias_method :original_js_compressor=, :js_compressor=
4
+
5
+ define_method :js_compressor= do |compressor|
6
+ unregister_bundle_processor 'application/javascript', OptimizeJS::SprocketsProcessor
7
+ send(:original_js_compressor=, compressor)
8
+ register_bundle_processor 'application/javascript', OptimizeJS::SprocketsProcessor
9
+ end
10
+ end
11
+ end
12
+
13
+ begin
14
+ require 'sprockets/compressing'
15
+ OptimizeJS.patch_sprockets_js_compressor Sprockets::Compressing
16
+ rescue LoadError
17
+ require 'sprockets/processing'
18
+ OptimizeJS.patch_sprockets_js_compressor Sprockets::Processing
19
+ end
@@ -9,7 +9,7 @@ class OptimizeJS::SprocketsProcessor
9
9
  @source = block.call
10
10
  end
11
11
 
12
- def render(context, empty_hash_wtf)
12
+ def render(context, _)
13
13
  self.class.run(@filename, @source, context)
14
14
  end
15
15
 
@@ -2,6 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module OptimizeJS
5
- GEM_VERSION = '1.0.1'
5
+ GEM_VERSION = '1.0.2'
6
6
  JS_VERSION = '1.0.2'
7
7
  end
@@ -1 +1,4 @@
1
- !function() {}();
1
+ // =require_self
2
+ // =require application/foo
3
+
4
+ !function() { console.log('application.js'); }();
@@ -0,0 +1 @@
1
+ !function() { console.log('foo.js'); }();
@@ -19,9 +19,13 @@ class RailsIntegrationTest < Test::Unit::TestCase
19
19
  app = create_rails_application
20
20
  app.initialize!
21
21
  task = create_sprockets_task(app)
22
-
23
22
  task.instance_exec { manifest.compile(assets) }
24
- assert_equal app.assets['application.js'].to_s.strip, '!(function() {})();'
23
+
24
+ expected = <<-JAVASCRIPT.strip
25
+ !(function(){console.log("application.js")})(),!(function(){console.log("foo.js")})();
26
+ JAVASCRIPT
27
+
28
+ assert_equal expected, app.assets['application.js'].to_s.strip
25
29
  end
26
30
 
27
31
  def setup
@@ -46,8 +50,10 @@ private
46
50
  config.assets.enabled = true
47
51
  config.assets.gzip = false
48
52
  config.assets.paths = [Rails.root.join('test/fixtures/javascripts').to_s]
49
- config.assets.precompile = %w( 'application.js' )
50
- config.paths['public'] = Rails.root.join('tmp').to_s
53
+ config.assets.precompile = %w( application.js )
54
+ config.assets.js_compressor = :uglifier
55
+ config.assets.compress = true
56
+ config.paths['public'] = [Rails.root.join('tmp').to_s]
51
57
  config.active_support.deprecation = :stderr
52
58
  end
53
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimize-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-10 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -106,11 +106,13 @@ files:
106
106
  - gemfiles/rails_5.gemfile.lock
107
107
  - lib/optimize-js.rb
108
108
  - lib/optimize-js/railtie.rb
109
+ - lib/optimize-js/sprockets-patch.rb
109
110
  - lib/optimize-js/sprockets-processor.rb
110
111
  - lib/optimize-js/version.rb
111
112
  - optimize-js.gemspec
112
113
  - optimize-js.web.min.js
113
114
  - test/fixtures/javascripts/application.js
115
+ - test/fixtures/javascripts/application/foo.js
114
116
  - test/test-optimize-js.rb
115
117
  - test/test-rails-integration.rb
116
118
  - test/test-sprockets-integration.rb
@@ -140,6 +142,7 @@ specification_version: 4
140
142
  summary: Ruby wrapper and Rails asset pipeline integration for optimize-js.
141
143
  test_files:
142
144
  - test/fixtures/javascripts/application.js
145
+ - test/fixtures/javascripts/application/foo.js
143
146
  - test/test-optimize-js.rb
144
147
  - test/test-rails-integration.rb
145
148
  - test/test-sprockets-integration.rb