crush 0.2.0 → 0.3.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.
@@ -1,20 +1,21 @@
1
1
  require "spec_helper"
2
- require "rainpress"
3
2
 
4
3
  describe Crush::Rainpress do
5
- specify { Crush::Rainpress.engine_name.should == "rainpress" }
4
+ specify { Crush::Rainpress.default_mime_type.should == "text/css" }
6
5
 
7
- it "is registered for '.js' files" do
8
- Crush.mappings["css"].should include(Crush::Rainpress)
9
- end
10
-
11
- it "minifies using Rainpress" do
6
+ it "compresses using Rainpress" do
12
7
  ::Rainpress.should_receive(:compress).with("hello", {}).and_return("world")
13
- Crush::Rainpress.new.compress("hello").should == "world"
8
+ Crush::Rainpress.compress("hello").should == "world"
14
9
  end
15
10
 
16
11
  it "sends options to Rainpress" do
17
12
  ::Rainpress.should_receive(:compress).with("hello", :foo => "bar")
18
13
  Crush::Rainpress.new(:foo => "bar").compress("hello")
19
14
  end
15
+
16
+ it "is registered with Tilt" do
17
+ ::Rainpress.should_receive(:compress).with("hello", {}).and_return("world")
18
+ Tilt.register Crush::Rainpress, "css"
19
+ Tilt.new("application.css").compress("hello").should == "world"
20
+ end
20
21
  end
@@ -1,18 +1,13 @@
1
1
  require "spec_helper"
2
- require "uglifier"
3
2
 
4
3
  describe Crush::Uglifier do
5
- specify { Crush::Uglifier.engine_name.should == "uglifier" }
4
+ specify { Crush::Uglifier.default_mime_type.should == "application/javascript" }
6
5
 
7
- it "is registered for '.js' files" do
8
- Crush.mappings["js"].should include(Crush::Uglifier)
9
- end
10
-
11
- it "minifies using Uglifier" do
6
+ it "compresses using Uglifier" do
12
7
  compressor = mock(:compressor)
13
8
  ::Uglifier.should_receive(:new).with({}).and_return(compressor)
14
9
  compressor.should_receive(:compile).with("hello").and_return("world")
15
- Crush::Uglifier.new.compress("hello").should == "world"
10
+ Crush::Uglifier.compress("hello").should == "world"
16
11
  end
17
12
 
18
13
  it "sends options to Uglifier" do
@@ -21,4 +16,12 @@ describe Crush::Uglifier do
21
16
  compressor.should_receive(:compile).with("hello").and_return("world")
22
17
  Crush::Uglifier.new(:foo => "bar").compress("hello")
23
18
  end
19
+
20
+ it "is works with Tilt" do
21
+ compressor = mock(:compressor)
22
+ ::Uglifier.should_receive(:new).with({}).and_return(compressor)
23
+ compressor.should_receive(:compile).with("hello").and_return("world")
24
+ Tilt.register Crush::Uglifier, "js"
25
+ Tilt.new("application.js").compress("hello").should == "world"
26
+ end
24
27
  end
@@ -1,18 +1,13 @@
1
1
  require "spec_helper"
2
- require "yui/compressor"
3
2
 
4
3
  describe Crush::YUI::JavaScriptCompressor do
5
- specify { Crush::YUI::JavaScriptCompressor.engine_name.should == "yui_js" }
4
+ specify { Crush::YUI::JavaScriptCompressor.default_mime_type.should == "application/javascript" }
6
5
 
7
- it "is registered for '.js' files" do
8
- Crush.mappings["js"].should include(Crush::YUI::JavaScriptCompressor)
9
- end
10
-
11
- it "minifies using YUI::JavaScriptCompressor" do
6
+ it "compresses using YUI::JavaScriptCompressor" do
12
7
  compressor = mock(:compressor)
13
8
  ::YUI::JavaScriptCompressor.should_receive(:new).with({}).and_return(compressor)
14
9
  compressor.should_receive(:compress).with("hello").and_return("world")
15
- Crush::YUI::JavaScriptCompressor.new.compress("hello").should == "world"
10
+ Crush::YUI::JavaScriptCompressor.compress("hello").should == "world"
16
11
  end
17
12
 
18
13
  it "sends options to YUI::JavaScriptCompressor" do
@@ -21,20 +16,24 @@ describe Crush::YUI::JavaScriptCompressor do
21
16
  compressor.should_receive(:compress).with("hello").and_return("world")
22
17
  Crush::YUI::JavaScriptCompressor.new(:foo => "bar").compress("hello")
23
18
  end
19
+
20
+ it "is registered with Tilt" do
21
+ compressor = mock(:compressor)
22
+ ::YUI::JavaScriptCompressor.should_receive(:new).with({}).and_return(compressor)
23
+ compressor.should_receive(:compress).with("hello").and_return("world")
24
+ Tilt.register Crush::YUI::JavaScriptCompressor, "js"
25
+ Tilt.new("application.js").compress("hello").should == "world"
26
+ end
24
27
  end
25
28
 
26
29
  describe Crush::YUI::CssCompressor do
27
- specify { Crush::YUI::CssCompressor.engine_name.should == "yui_css" }
30
+ specify { Crush::YUI::CssCompressor.default_mime_type.should == "text/css" }
28
31
 
29
- it "is registered for '.js' files" do
30
- Crush.mappings["css"].should include(Crush::YUI::CssCompressor)
31
- end
32
-
33
- it "minifies using YUI::CssCompressor" do
32
+ it "compresses using YUI::CssCompressor" do
34
33
  compressor = mock(:compressor)
35
34
  ::YUI::CssCompressor.should_receive(:new).with({}).and_return(compressor)
36
35
  compressor.should_receive(:compress).with("hello").and_return("world")
37
- Crush::YUI::CssCompressor.new.compress("hello").should == "world"
36
+ Crush::YUI::CssCompressor.compress("hello").should == "world"
38
37
  end
39
38
 
40
39
  it "sends options to YUI::CssCompressor" do
@@ -43,4 +42,12 @@ describe Crush::YUI::CssCompressor do
43
42
  compressor.should_receive(:compress).with("hello").and_return("world")
44
43
  Crush::YUI::CssCompressor.new(:foo => "bar").compress("hello")
45
44
  end
45
+
46
+ it "is registered with Tilt" do
47
+ compressor = mock(:compressor)
48
+ ::YUI::CssCompressor.should_receive(:new).with({}).and_return(compressor)
49
+ compressor.should_receive(:compress).with("hello").and_return("world")
50
+ Tilt.register Crush::YUI::CssCompressor, "css"
51
+ Tilt.new("application.css").compress("hello").should == "world"
52
+ end
46
53
  end
@@ -1,145 +1,49 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Crush do
4
- class MockCompressor
5
- def self.engine_name
6
- "mock"
4
+ describe ".register_js" do
5
+ it "registers all of the JavaScript engines with Tilt" do
6
+ Tilt.mappings.delete "js"
7
+ Crush.register_js
8
+ Tilt.mappings["js"].should == [
9
+ Crush::Uglifier,
10
+ Crush::Closure::Compiler,
11
+ Crush::YUI::JavaScriptCompressor,
12
+ Crush::Packr,
13
+ Crush::JSMin
14
+ ]
7
15
  end
8
-
9
- def self.engine_initialized?
10
- true
11
- end
12
-
13
- attr_reader :args, :block
14
- def initialize(*args, &block)
15
- @args = args
16
- @block = block
17
- end
18
- end
19
-
20
- class MockCompressor2 < MockCompressor
21
- def self.engine_name
22
- "mock2"
23
- end
24
-
25
- def self.engine_initialized?
26
- false
27
- end
28
- end
29
-
30
- before(:all) do
31
- Crush.register(MockCompressor, "mock", ".mck", "file.txt")
32
- Crush.register(MockCompressor, "mult", "mlt")
33
- Crush.register(MockCompressor2, "mult", "mlt")
34
16
  end
35
17
 
36
- describe ".mappings" do
37
- it "always returns an array" do
38
- Crush.mappings["none"].should == []
18
+ describe ".register_css" do
19
+ it "registers all of the CSS engines with Tilt" do
20
+ Tilt.mappings.delete "css"
21
+ Crush.register_css
22
+ Tilt.mappings["css"].should == [
23
+ Crush::YUI::CssCompressor,
24
+ Crush::Rainpress,
25
+ Crush::CSSMin
26
+ ]
39
27
  end
40
28
  end
41
29
 
42
30
  describe ".register" do
43
- it "stores engines" do
44
- Crush.mappings["mock"].should include(MockCompressor)
45
- Crush.mappings["mck"].should include(MockCompressor)
46
- Crush.mappings["file.txt"].should include(MockCompressor)
47
- end
48
-
49
- it "prefers the latest registered engines" do
50
- Crush.mappings["mult"].first.should == MockCompressor2
51
- end
52
- end
53
-
54
- describe ".registered?" do
55
- it "returns false if the extension is not registered" do
56
- Crush.registered?("none").should be_false
57
- end
58
-
59
- it "returns true if the given extension is registered" do
60
- Crush.registered?("mock").should be_true
61
- Crush.registered?(".mock").should be_true
62
- end
63
- end
64
-
65
- describe ".[]" do
66
- it "returns engines found by path when given strings" do
67
- Crush["mock"].should == MockCompressor
68
- Crush["application.js.mock"].should == MockCompressor
69
- Crush["some/path/file.txt"].should == MockCompressor
70
- end
71
-
72
- it "returns engines found by name when given symbols" do
73
- Crush[:mock].should == MockCompressor
74
- Crush[:mock2].should == MockCompressor2
75
- end
76
- end
77
-
78
- describe ".prefer" do
79
- it "reorders the engine engines so the given engine is returned" do
80
- Crush.prefer(MockCompressor)
81
- Crush["mult"].should == MockCompressor
82
- end
83
-
84
- it "accepts symbol names of the various engines" do
85
- Crush.prefer(:mock2)
86
- Crush["mult"].should == MockCompressor2
87
- end
88
-
89
- it "limits the preference to the given extensions" do
90
- Crush.prefer(:mock, "mlt")
91
- Crush["mult"].should == MockCompressor2
92
- Crush["mlt"].should == MockCompressor
93
- end
94
- end
95
-
96
- describe ".new" do
97
- it "creates a new engine if found" do
98
- compressor = Crush.new("application.mock", :key => "value") { "Hello World" }
99
- compressor.args.should =~ [ "application.mock", { :key => "value" } ]
100
- compressor.block.call.should == "Hello World"
101
- end
102
-
103
- it "raises an error if no engine is found" do
104
- expect { Crush.new("file.php") }.to raise_error(Crush::EngineNotFound)
105
- end
106
- end
107
-
108
- describe ".find_by_name" do
109
- it "returns nil if the engine could not be found" do
110
- Crush.find_by_name("none").should be_nil
111
- end
112
-
113
- it "returns the registered engine with the given name" do
114
- Crush.find_by_name("mock").should == MockCompressor
115
- Crush.find_by_name("mock2").should == MockCompressor2
116
- end
117
- end
118
-
119
- describe ".find_by_path" do
120
- it "returns nil when no engines are found" do
121
- Crush.find_by_path("none").should be_nil
122
- end
123
-
124
- it "returns engines matching exact extension names" do
125
- Crush.find_by_path("mock").should == MockCompressor
126
- end
127
-
128
- it "returns engines matching exact file extensions" do
129
- Crush.find_by_path(".MOCK").should == MockCompressor
130
- end
131
-
132
- it "returns engines matching multiple file extensions" do
133
- Crush.find_by_path("application.js.Mock").should == MockCompressor
134
- end
135
-
136
- it "returns engines matching filenames" do
137
- Crush.find_by_path("some/path/file.txt").should == MockCompressor
138
- end
139
-
140
- it "returns engines that are already initialized" do
141
- Crush.instance_variable_get("@preferred_engines").delete("mult")
142
- Crush.find_by_path("mult").should == MockCompressor
31
+ it "registers all of the engines with Tilt" do
32
+ Tilt.mappings.delete "js"
33
+ Tilt.mappings.delete "css"
34
+ Crush.register
35
+ Tilt.mappings["js"].should == [
36
+ Crush::Uglifier,
37
+ Crush::Closure::Compiler,
38
+ Crush::YUI::JavaScriptCompressor,
39
+ Crush::Packr,
40
+ Crush::JSMin
41
+ ]
42
+ Tilt.mappings["css"].should == [
43
+ Crush::YUI::CssCompressor,
44
+ Crush::Rainpress,
45
+ Crush::CSSMin
46
+ ]
143
47
  end
144
48
  end
145
49
  end
@@ -1,7 +1,4 @@
1
1
  require "rubygems"
2
- require "bundler/setup"
3
- Bundler.require
4
-
5
- RSpec.configure do |config|
6
-
7
- end
2
+ require "bundler"
3
+ Bundler.require :default, :development
4
+ require "yui/compressor"
metadata CHANGED
@@ -1,138 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crush
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
5
+ version: 0.3.0
11
6
  platform: ruby
12
7
  authors:
13
- - Pete
14
- - Browne
8
+ - Pete Browne
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
12
 
19
- date: 2011-06-06 00:00:00 Z
13
+ date: 2011-08-27 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
- name: rspec
16
+ name: tilt
23
17
  prerelease: false
24
18
  requirement: &id001 !ruby/object:Gem::Requirement
25
19
  none: false
26
20
  requirements:
27
21
  - - ~>
28
22
  - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 2
32
- - 6
33
- - 0
34
- version: 2.6.0
35
- type: :development
23
+ version: "1.3"
24
+ type: :runtime
36
25
  version_requirements: *id001
37
26
  - !ruby/object:Gem::Dependency
38
- name: jsmin
27
+ name: rspec
39
28
  prerelease: false
40
29
  requirement: &id002 !ruby/object:Gem::Requirement
41
30
  none: false
42
31
  requirements:
43
- - - ">="
32
+ - - ~>
44
33
  - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
34
+ version: "2.6"
49
35
  type: :development
50
36
  version_requirements: *id002
51
37
  - !ruby/object:Gem::Dependency
52
- name: packr
38
+ name: rake
53
39
  prerelease: false
54
40
  requirement: &id003 !ruby/object:Gem::Requirement
55
41
  none: false
56
42
  requirements:
57
43
  - - ">="
58
44
  - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
45
  version: "0"
63
46
  type: :development
64
47
  version_requirements: *id003
65
48
  - !ruby/object:Gem::Dependency
66
- name: uglifier
49
+ name: jsmin
67
50
  prerelease: false
68
51
  requirement: &id004 !ruby/object:Gem::Requirement
69
52
  none: false
70
53
  requirements:
71
54
  - - ">="
72
55
  - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
56
  version: "0"
77
57
  type: :development
78
58
  version_requirements: *id004
79
59
  - !ruby/object:Gem::Dependency
80
- name: closure-compiler
60
+ name: packr
81
61
  prerelease: false
82
62
  requirement: &id005 !ruby/object:Gem::Requirement
83
63
  none: false
84
64
  requirements:
85
65
  - - ">="
86
66
  - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
67
  version: "0"
91
68
  type: :development
92
69
  version_requirements: *id005
93
70
  - !ruby/object:Gem::Dependency
94
- name: yui-compressor
71
+ name: uglifier
95
72
  prerelease: false
96
73
  requirement: &id006 !ruby/object:Gem::Requirement
97
74
  none: false
98
75
  requirements:
99
76
  - - ">="
100
77
  - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
78
  version: "0"
105
79
  type: :development
106
80
  version_requirements: *id006
107
81
  - !ruby/object:Gem::Dependency
108
- name: cssmin
82
+ name: closure-compiler
109
83
  prerelease: false
110
84
  requirement: &id007 !ruby/object:Gem::Requirement
111
85
  none: false
112
86
  requirements:
113
87
  - - ">="
114
88
  - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
89
  version: "0"
119
90
  type: :development
120
91
  version_requirements: *id007
121
92
  - !ruby/object:Gem::Dependency
122
- name: rainpress
93
+ name: yui-compressor
123
94
  prerelease: false
124
95
  requirement: &id008 !ruby/object:Gem::Requirement
125
96
  none: false
126
97
  requirements:
127
98
  - - ">="
128
99
  - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
131
- - 0
132
100
  version: "0"
133
101
  type: :development
134
102
  version_requirements: *id008
135
- description: Crush is a generic interface, like Tilt, for the various compression engines in Ruby.
103
+ - !ruby/object:Gem::Dependency
104
+ name: cssmin
105
+ prerelease: false
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: "0"
112
+ type: :development
113
+ version_requirements: *id009
114
+ - !ruby/object:Gem::Dependency
115
+ name: rainpress
116
+ prerelease: false
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: "0"
123
+ type: :development
124
+ version_requirements: *id010
125
+ description: Crush is a set of Tilt templates for the various JavaScript and CSS compression libraries in Ruby.
136
126
  email: me@petebrowne.com
137
127
  executables: []
138
128
 
@@ -142,15 +132,19 @@ extra_rdoc_files: []
142
132
 
143
133
  files:
144
134
  - .gitignore
135
+ - .travis.yml
145
136
  - Gemfile
146
137
  - LICENSE
147
138
  - README.md
148
139
  - Rakefile
149
140
  - crush.gemspec
150
141
  - lib/crush.rb
142
+ - lib/crush/all.rb
151
143
  - lib/crush/closure.rb
144
+ - lib/crush/css.rb
152
145
  - lib/crush/cssmin.rb
153
146
  - lib/crush/engine.rb
147
+ - lib/crush/js.rb
154
148
  - lib/crush/jsmin.rb
155
149
  - lib/crush/packr.rb
156
150
  - lib/crush/rainpress.rb
@@ -180,26 +174,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
174
  requirements:
181
175
  - - ">="
182
176
  - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
177
  version: "0"
187
178
  required_rubygems_version: !ruby/object:Gem::Requirement
188
179
  none: false
189
180
  requirements:
190
181
  - - ">="
191
182
  - !ruby/object:Gem::Version
192
- hash: 3
193
- segments:
194
- - 0
195
183
  version: "0"
196
184
  requirements: []
197
185
 
198
186
  rubyforge_project: crush
199
- rubygems_version: 1.7.1
187
+ rubygems_version: 1.8.8
200
188
  signing_key:
201
189
  specification_version: 3
202
- summary: A generic interface to multiple Ruby compression engines.
190
+ summary: Tilt templates for various JavaScript and CSS compression libraries.
203
191
  test_files:
204
192
  - spec/crush/closure_spec.rb
205
193
  - spec/crush/cssmin_spec.rb