rack-sprocketize 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.
data/README.md CHANGED
@@ -73,6 +73,8 @@ To pass options to the javascript compressor just use the `:compression_options`
73
73
  By default, the files are only compressed in a production environment. If for some reason you want them to always be compressed, pass the `:always_compress` option:
74
74
 
75
75
  use Rack::Sprocketize, :always_compress => true
76
+
77
+ Any files suffixed with `'.min'` or `'-min'` will not be compressed. For example, `'app/javascripts/jquery.min.js'` would not be re-compressed when it is sprocketized.
76
78
 
77
79
  ## Copyright
78
80
 
@@ -36,11 +36,15 @@ module Rack
36
36
  FileUtils.mkdir_p ::File.dirname(@output_path)
37
37
  ::File.open(@output_path, 'w') do |file|
38
38
  output = concat
39
- output = compress(output) if Sprocketize.always_compress?
39
+ output = compress(output) if Sprocketize.always_compress? && !already_compressed?
40
40
  file.write(output.strip)
41
41
  end
42
42
  end
43
43
 
44
+ def already_compressed?
45
+ ::File.basename(@source_file) =~ /(-|\.)min\.js/
46
+ end
47
+
44
48
  protected
45
49
 
46
50
  def compression_options(defaults = {})
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Sprocketize
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -165,6 +165,20 @@ describe Rack::Sprocketize do
165
165
  end
166
166
  end
167
167
  end
168
+
169
+ context 'with an already minified file' do
170
+ it 'does not compress the output' do
171
+ reveal_const :JSMin do
172
+ within_construct do |c|
173
+ c.file 'app/javascripts/main.min.js', '1'
174
+
175
+ JSMin.should_not_receive(:minify)
176
+ app(:always_compress => true).call(request)
177
+ File.read('public/javascripts/main.min.js').should == '1'
178
+ end
179
+ end
180
+ end
181
+ end
168
182
  end
169
183
 
170
184
  context 'in a production environment' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-sprocketize
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pete
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-07 00:00:00 -06:00
19
+ date: 2011-03-15 00:00:00 -05:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency