smart_asset 0.5.11 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,9 +10,9 @@ Features
10
10
 
11
11
  Similar to <code>AssetPackager</code>, but with the following changes:
12
12
 
13
- * Uses file size and super fast hashing ([Murmur3](https://github.com/PeterScott/murmur3)) to determine if a new compressed package should be created
14
- * [uglify-js](https://github.com/mishoo/UglifyJS) for javascript compression
15
- * [clean-css](https://github.com/GoalSmashers/clean-css) for css compression
13
+ * Uses file size and hashing to determine if a new compressed package should be created
14
+ * Closure Compiler for javascript compression
15
+ * YUI Compressor for css compression
16
16
  * Framework agnostic (adapters provided for Rails 2, Rails 3, Sinatra, and Stasis)
17
17
 
18
18
  <a name="installation"></a>
@@ -26,12 +26,6 @@ Installation
26
26
  gem install smart_asset
27
27
  </pre>
28
28
 
29
- ### Install npm packages
30
-
31
- <pre>
32
- npm install uglify-js clean-css -g
33
- </pre>
34
-
35
29
  ### Install
36
30
 
37
31
  ### Rails 2
@@ -157,7 +151,7 @@ You may use environment variables with the <code>smart\_asset</code> command to
157
151
 
158
152
  <code>MODIFIED='12/1/2010 12:00'</code><br/>Use a default modified time other than Time.now for non-version controlled files
159
153
 
160
- <code>WARN=1</code><br/>Get compression warnings from UglifyJS
154
+ <code>WARN=1</code><br/>Get compression warnings
161
155
 
162
156
  #### Example:
163
157
 
Binary file
Binary file
@@ -73,20 +73,25 @@ class SmartAsset
73
73
  tmp = "#{dest}/tmp.#{ext}"
74
74
  File.open(tmp, 'w') { |f| f.write(data) }
75
75
  puts "\nCreating #{package}..."
76
- warning = ENV['WARN'] ? " -v" : nil
77
76
 
78
- unless @bin
79
- @bin = Dir.chdir(@root) { `npm bin`.strip }
80
- @bin = File.directory?(@bin) ? "#{@bin}/" : nil
81
- end
77
+ # Binary paths
78
+ bin = File.expand_path(File.dirname(__FILE__) + '/../bin')
79
+ compiler = bin + '/compiler.jar'
80
+ yui = bin + '/yui.jar'
82
81
 
83
82
  if ext == 'js'
84
- cmd = "#{@bin}uglifyjs --output #{package}#{warning} -nc #{tmp}"
83
+ warning = ENV['WARN'] ? nil : " --warning_level QUIET"
84
+ cmd = "java -jar #{compiler} --js #{tmp} --js_output_file #{package}#{warning}"
85
85
  elsif ext == 'css'
86
- cmd = "#{@bin}cleancss #{tmp} -o #{package}"
86
+ warning = ENV['WARN'] ? " -v" : nil
87
+ cmd = "java -jar #{yui} #{tmp} -o #{package}#{warning}"
87
88
  end
89
+
88
90
  puts cmd if ENV['DEBUG']
89
- `#{cmd}`
91
+ cmd_output = `#{cmd}`
92
+
93
+ raise "Error running `#{cmd}`:\n#{cmd_output}" unless $?.success?
94
+
90
95
  FileUtils.rm(tmp) unless ENV['DEBUG']
91
96
 
92
97
  # Fix YUI compression issue
@@ -242,4 +247,4 @@ end
242
247
 
243
248
  require "smart_asset/adapters/rails#{Rails.version[0..0]}" if defined?(Rails)
244
249
  require "smart_asset/adapters/sinatra" if defined?(Sinatra)
245
- require "smart_asset/adapters/stasis" if defined?(Stasis)
250
+ require "smart_asset/adapters/stasis" if defined?(Stasis)
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "smart_asset"
9
- s.version = '0.5.11'
9
+ s.version = '0.6.0'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = ["Winton Welsh"]
12
12
  s.email = ["mail@wintoni.us"]
@@ -1,2 +1,2 @@
1
- <script src="/packaged/541a83e3_package.js"></script>
2
- <link href="/packaged/63bae034_package.css" media="screen" rel="stylesheet" />
1
+ <script src="/packaged/382823ce_package.js"></script>
2
+ <link href="/packaged/fa00472f_package.css" media="screen" rel="stylesheet" />
data/spec/run CHANGED
@@ -16,13 +16,13 @@
16
16
  # puts "\n"
17
17
 
18
18
  ENV['RAILS'] = '3'
19
- ENV['RAILS_ENV'] = 'development'
20
- system "spec -f n -c spec"
19
+ # ENV['RAILS_ENV'] = 'development'
20
+ # system "spec -f n -c spec"
21
21
 
22
- # puts "\n"
22
+ puts "\n"
23
23
 
24
- # ENV['RAILS_ENV'] = 'production'
25
- # system "spec -f n -c spec"
24
+ ENV['RAILS_ENV'] = 'production'
25
+ system "spec -f n -c spec"
26
26
 
27
27
  # ENV.delete 'RAILS'
28
28
  # ENV.delete 'RAILS_ENV'
@@ -4,7 +4,7 @@ unless FrameworkFixture.framework
4
4
  describe SmartAsset do
5
5
 
6
6
  include SmartAsset::Helper
7
-
7
+
8
8
  before(:all) do
9
9
  @config = "spec/fixtures/assets.yml"
10
10
  @dest = "#{$root}/spec/fixtures/assets/compressed"
@@ -13,11 +13,11 @@ unless FrameworkFixture.framework
13
13
  package.js
14
14
  )
15
15
  @versions = %w(
16
- 63bae034
17
- 541a83e3
16
+ fa00472f
17
+ 382823ce
18
18
  )
19
19
  end
20
-
20
+
21
21
  describe :load_config do
22
22
 
23
23
  before(:all) do
@@ -79,7 +79,7 @@ unless FrameworkFixture.framework
79
79
  SmartAsset.sources.should == {"javascripts"=>"javascripts", "stylesheets"=>"stylesheets"}
80
80
  end
81
81
  end
82
-
82
+
83
83
  describe :binary do
84
84
  describe 'no compressed assets' do
85
85
 
@@ -203,7 +203,7 @@ unless FrameworkFixture.framework
203
203
  end
204
204
 
205
205
  it "should rewrite javascript package with underscore code first" do
206
- File.size(path = "#{@dest}/dbd79469_#{@files[1]}").should > 0
206
+ File.size(path = "#{@dest}/4922c055_#{@files[1]}").should > 0
207
207
  js = File.read(path)
208
208
  js.index('jQuery').should > js.index('VERSION')
209
209
  js.include?('jQuery').should == true
@@ -231,7 +231,7 @@ unless FrameworkFixture.framework
231
231
  end
232
232
 
233
233
  it "should rewrite javascript package with only jquery" do
234
- File.size(path = "#{@dest}/18f448b8_#{@files[1]}").should > 0
234
+ File.size(path = "#{@dest}/5b838e70_#{@files[1]}").should > 0
235
235
  js = File.read(path)
236
236
  js.include?('jQuery').should == true
237
237
  js.include?('VERSION').should == false
@@ -267,7 +267,7 @@ unless FrameworkFixture.framework
267
267
  before(:all) do
268
268
  @modified = Time.parse('12-01-2010 08:00:00 UTC')
269
269
  ENV['MODIFIED'] = @modified.to_s
270
- @package = "#{@dest}/c3939102_#{@files[1]}"
270
+ @package = "#{@dest}/73af2a89_#{@files[1]}"
271
271
  @untracked = "#{$root}/spec/fixtures/assets/javascripts/untracked.js"
272
272
 
273
273
  File.open(@untracked, 'w') { |f| f.write("var untracked = true;") }
@@ -299,7 +299,7 @@ unless FrameworkFixture.framework
299
299
  end
300
300
  end
301
301
  end
302
-
302
+
303
303
  describe :path do
304
304
 
305
305
  describe "development" do
metadata CHANGED
@@ -1,159 +1,161 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: smart_asset
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.11
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Winton Welsh
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-10 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2014-07-17 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: framework_fixture
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rack-test
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rack-test
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
- requirement: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
49
38
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
54
46
  type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
55
50
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: rails
64
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
65
52
  none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '3.0'
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
70
60
  type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rails
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '3.0'
78
- - !ruby/object:Gem::Dependency
79
- name: rspec
80
- requirement: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
81
66
  none: false
82
- requirements:
67
+ requirements:
83
68
  - - ~>
84
- - !ruby/object:Gem::Version
85
- version: '1.0'
69
+ - !ruby/object:Gem::Version
70
+ hash: 7
71
+ segments:
72
+ - 3
73
+ - 0
74
+ version: "3.0"
86
75
  type: :development
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
78
+ name: rspec
87
79
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
80
+ requirement: &id005 !ruby/object:Gem::Requirement
89
81
  none: false
90
- requirements:
82
+ requirements:
91
83
  - - ~>
92
- - !ruby/object:Gem::Version
93
- version: '1.0'
94
- - !ruby/object:Gem::Dependency
95
- name: sinatra
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: '1.0'
84
+ - !ruby/object:Gem::Version
85
+ hash: 15
86
+ segments:
87
+ - 1
88
+ - 0
89
+ version: "1.0"
102
90
  type: :development
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: sinatra
103
94
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
95
+ requirement: &id006 !ruby/object:Gem::Requirement
105
96
  none: false
106
- requirements:
97
+ requirements:
107
98
  - - ~>
108
- - !ruby/object:Gem::Version
109
- version: '1.0'
110
- - !ruby/object:Gem::Dependency
111
- name: stasis
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 0.2.0.pre
99
+ - !ruby/object:Gem::Version
100
+ hash: 15
101
+ segments:
102
+ - 1
103
+ - 0
104
+ version: "1.0"
118
105
  type: :development
106
+ version_requirements: *id006
107
+ - !ruby/object:Gem::Dependency
108
+ name: stasis
119
109
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
110
+ requirement: &id007 !ruby/object:Gem::Requirement
121
111
  none: false
122
- requirements:
123
- - - '='
124
- - !ruby/object:Gem::Version
112
+ requirements:
113
+ - - "="
114
+ - !ruby/object:Gem::Version
115
+ hash: -354405171
116
+ segments:
117
+ - 0
118
+ - 2
119
+ - 0
120
+ - pre
125
121
  version: 0.2.0.pre
126
- - !ruby/object:Gem::Dependency
122
+ type: :development
123
+ version_requirements: *id007
124
+ - !ruby/object:Gem::Dependency
127
125
  name: change
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :runtime
135
126
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
127
+ requirement: &id008 !ruby/object:Gem::Requirement
137
128
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ type: :runtime
137
+ version_requirements: *id008
142
138
  description: Smart asset packaging for Rails, Sinatra, and Stasis.
143
- email:
139
+ email:
144
140
  - mail@wintoni.us
145
- executables:
141
+ executables:
142
+ - compiler.jar
146
143
  - smart_asset
144
+ - yui.jar
147
145
  extensions: []
146
+
148
147
  extra_rdoc_files: []
149
- files:
148
+
149
+ files:
150
150
  - .gitignore
151
151
  - .travis.yml
152
152
  - Gemfile
153
153
  - LICENSE
154
154
  - README.md
155
155
  - Rakefile
156
+ - bin/compiler.jar
156
157
  - bin/smart_asset
158
+ - bin/yui.jar
157
159
  - lib/smart_asset.rb
158
160
  - lib/smart_asset/adapters/rails2.rb
159
161
  - lib/smart_asset/adapters/rails3.rb
@@ -161,7 +163,6 @@ files:
161
163
  - lib/smart_asset/adapters/stasis.rb
162
164
  - lib/smart_asset/helper.rb
163
165
  - lib/smart_asset/recipes.rb
164
- - package.json
165
166
  - recipes/smart_asset.rb
166
167
  - smart_asset.gemspec
167
168
  - spec/fixtures/all_frameworks/assets.yml
@@ -194,29 +195,38 @@ files:
194
195
  - spec/spec_helper.rb
195
196
  homepage: http://github.com/winton/smart_asset
196
197
  licenses: []
198
+
197
199
  post_install_message:
198
200
  rdoc_options: []
199
- require_paths:
201
+
202
+ require_paths:
200
203
  - lib
201
- required_ruby_version: !ruby/object:Gem::Requirement
204
+ required_ruby_version: !ruby/object:Gem::Requirement
202
205
  none: false
203
- requirements:
204
- - - ! '>='
205
- - !ruby/object:Gem::Version
206
- version: '0'
207
- required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ hash: 3
210
+ segments:
211
+ - 0
212
+ version: "0"
213
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
214
  none: false
209
- requirements:
210
- - - ! '>='
211
- - !ruby/object:Gem::Version
212
- version: '0'
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ hash: 3
219
+ segments:
220
+ - 0
221
+ version: "0"
213
222
  requirements: []
223
+
214
224
  rubyforge_project:
215
- rubygems_version: 1.8.24
225
+ rubygems_version: 1.8.15
216
226
  signing_key:
217
227
  specification_version: 3
218
228
  summary: Smart asset packaging for Rails, Sinatra, and Stasis
219
- test_files:
229
+ test_files:
220
230
  - spec/fixtures/all_frameworks/assets.yml
221
231
  - spec/fixtures/all_frameworks/test.html.erb
222
232
  - spec/fixtures/assets.yml
@@ -1,8 +0,0 @@
1
- {
2
- "name": "smart_asset",
3
- "version": "0.1.0",
4
- "dependencies": {
5
- "clean-css": "",
6
- "uglify-js": ""
7
- }
8
- }