crush 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency "yui-compressor"
25
25
  s.add_development_dependency "cssmin"
26
26
  s.add_development_dependency "rainpress"
27
+ s.add_development_dependency "sass"
27
28
 
28
29
  s.files = `git ls-files`.split("\n")
29
30
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -10,6 +10,7 @@ module Crush
10
10
  autoload :JSMin, "crush/jsmin"
11
11
  autoload :Packr, "crush/packr"
12
12
  autoload :Rainpress, "crush/rainpress"
13
+ autoload :Sass, "crush/sass"
13
14
  autoload :Uglifier, "crush/uglifier"
14
15
  autoload :YUI, "crush/yui"
15
16
 
@@ -39,6 +40,7 @@ module Crush
39
40
  Tilt.register CSSMin, "css"
40
41
  Tilt.register Rainpress, "css"
41
42
  Tilt.register YUI::CssCompressor, "css"
43
+ Tilt.register Sass::Engine, "css"
42
44
  end
43
45
 
44
46
  # Registers all of the included engines
@@ -0,0 +1,35 @@
1
+ require "crush/engine"
2
+
3
+ module Crush
4
+ module Sass
5
+ # Engine implementation of the Sass::Engine
6
+ # CSS compressor. See:
7
+ #
8
+ # https://rubygems.org/gems/sass
9
+ class Engine < Crush::Engine
10
+ self.default_mime_type = "text/css"
11
+
12
+ DEFAULT_OPTIONS = {
13
+ :style => :compressed,
14
+ :syntax => :scss
15
+ }
16
+
17
+ def self.engine_initialized?
18
+ !!(defined?(::Sass) && defined?(::Sass::Engine))
19
+ end
20
+
21
+ def initialize_engine
22
+ require_template_library "sass"
23
+ end
24
+
25
+ def prepare
26
+ @engine = ::Sass::Engine.new DEFAULT_OPTIONS.dup.merge(options)
27
+ @output = nil
28
+ end
29
+
30
+ def evaluate(scope, locals, &block)
31
+ @output ||= @engine.render(data)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Crush
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe Crush::Sass::Engine do
4
+ specify { Crush::Sass::Engine.default_mime_type.should == "text/css" }
5
+
6
+ it "compresses using Sass::Engine" do
7
+ compressor = mock(:compressor)
8
+ ::Sass::Engine.should_receive(:new).with(:style => :compressed, :syntax => :scss).and_return(compressor)
9
+ compressor.should_receive(:render).with("hello").and_return("world")
10
+ Crush::Sass::Engine.compress("hello").should == "world"
11
+ end
12
+
13
+ it "sends options to Sass::Engine" do
14
+ compressor = mock(:compressor)
15
+ ::Sass::Engine.should_receive(:new).with(:style => :compressed, :syntax => :scss, :foo => "bar").and_return(compressor)
16
+ compressor.should_receive(:render).with("hello").and_return("world")
17
+ Crush::Sass::Engine.new(:foo => "bar").compress("hello")
18
+ end
19
+
20
+ it "is registered with Tilt" do
21
+ compressor = mock(:compressor)
22
+ ::Sass::Engine.should_receive(:new).with(:style => :compressed, :syntax => :scss).and_return(compressor)
23
+ compressor.should_receive(:render).with("hello").and_return("world")
24
+ Tilt.register Crush::Sass::Engine, "css"
25
+ Tilt.new("application.css").compress("hello").should == "world"
26
+ end
27
+ end
@@ -20,6 +20,7 @@ describe Crush do
20
20
  Tilt.mappings.delete "css"
21
21
  Crush.register_css
22
22
  Tilt.mappings["css"].should == [
23
+ Crush::Sass::Engine,
23
24
  Crush::YUI::CssCompressor,
24
25
  Crush::Rainpress,
25
26
  Crush::CSSMin
@@ -40,6 +41,7 @@ describe Crush do
40
41
  Crush::JSMin
41
42
  ]
42
43
  Tilt.mappings["css"].should == [
44
+ Crush::Sass::Engine,
43
45
  Crush::YUI::CssCompressor,
44
46
  Crush::Rainpress,
45
47
  Crush::CSSMin
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: crush
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.3.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pete Browne
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-27 00:00:00 Z
13
+ date: 2011-08-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: tilt
@@ -122,6 +122,17 @@ dependencies:
122
122
  version: "0"
123
123
  type: :development
124
124
  version_requirements: *id010
125
+ - !ruby/object:Gem::Dependency
126
+ name: sass
127
+ prerelease: false
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ type: :development
135
+ version_requirements: *id011
125
136
  description: Crush is a set of Tilt templates for the various JavaScript and CSS compression libraries in Ruby.
126
137
  email: me@petebrowne.com
127
138
  executables: []
@@ -148,6 +159,7 @@ files:
148
159
  - lib/crush/jsmin.rb
149
160
  - lib/crush/packr.rb
150
161
  - lib/crush/rainpress.rb
162
+ - lib/crush/sass.rb
151
163
  - lib/crush/uglifier.rb
152
164
  - lib/crush/version.rb
153
165
  - lib/crush/yui.rb
@@ -157,6 +169,7 @@ files:
157
169
  - spec/crush/jsmin_spec.rb
158
170
  - spec/crush/packr_spec.rb
159
171
  - spec/crush/rainpress_spec.rb
172
+ - spec/crush/sass_spec.rb
160
173
  - spec/crush/uglifier_spec.rb
161
174
  - spec/crush/yui_spec.rb
162
175
  - spec/crush_spec.rb
@@ -195,6 +208,7 @@ test_files:
195
208
  - spec/crush/jsmin_spec.rb
196
209
  - spec/crush/packr_spec.rb
197
210
  - spec/crush/rainpress_spec.rb
211
+ - spec/crush/sass_spec.rb
198
212
  - spec/crush/uglifier_spec.rb
199
213
  - spec/crush/yui_spec.rb
200
214
  - spec/crush_spec.rb