sprockets-sass 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,8 @@ require "sprockets/engines"
5
5
 
6
6
  module Sprockets
7
7
  module Sass
8
- autoload :Importer, "sprockets/sass/importer"
8
+ autoload :CacheStore, "sprockets/sass/cache_store"
9
+ autoload :Importer, "sprockets/sass/importer"
9
10
 
10
11
  class << self
11
12
  # Global configuration for `Sass::Engine` instances.
@@ -0,0 +1,27 @@
1
+ require "sass"
2
+
3
+ module Sprockets
4
+ module Sass
5
+ class CacheStore < ::Sass::CacheStores::Base
6
+ attr_reader :environment
7
+
8
+ def initialize(environment)
9
+ @environment = environment
10
+ end
11
+
12
+ def _store(key, version, sha, contents)
13
+ environment.send :cache_set, "sass/#{key}", { :version => version, :sha => sha, :contents => contents }
14
+ end
15
+
16
+ def _retrieve(key, version, sha)
17
+ if obj = environment.send(:cache_get, "sass/#{key}")
18
+ return unless obj[:version] == version
19
+ return unless obj[:sha] == sha
20
+ obj[:obj]
21
+ else
22
+ nil
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -8,9 +8,9 @@ module Sprockets
8
8
  # A reference to the current Sprockets context
9
9
  attr_reader :context
10
10
 
11
- # Templates are initialized once the
11
+ # Templates are initialized once the functions are added.
12
12
  def self.engine_initialized?
13
- super && defined?(@@sass_functions_added)
13
+ super && (!Sass.add_sass_functions || defined?(Functions))
14
14
  end
15
15
 
16
16
  # Add the Sass functions if they haven't already been added.
@@ -19,9 +19,6 @@ module Sprockets
19
19
 
20
20
  if Sass.add_sass_functions
21
21
  require "sprockets/sass/functions"
22
- @@sass_functions_added = true
23
- else
24
- @@sass_functions_added = false
25
22
  end
26
23
  end
27
24
 
@@ -46,6 +43,17 @@ module Sprockets
46
43
 
47
44
  protected
48
45
 
46
+ # Returns a Sprockets-aware cache store for Sass::Engine.
47
+ def cache_store
48
+ return nil if context.environment.cache.nil?
49
+
50
+ if defined?(Sprockets::SassCacheStore)
51
+ Sprockets::SassCacheStore.new context.environment
52
+ else
53
+ CacheStore.new context.environment
54
+ end
55
+ end
56
+
49
57
  # A reference to the custom Sass importer, `Sprockets::Sass::Importer`.
50
58
  def importer
51
59
  Importer.new context
@@ -54,10 +62,11 @@ module Sprockets
54
62
  # Assemble the options for the `Sass::Engine`
55
63
  def sass_options
56
64
  merge_sass_options(default_sass_options, options).merge(
57
- :filename => eval_file,
58
- :line => line,
59
- :syntax => syntax,
60
- :importer => importer
65
+ :filename => eval_file,
66
+ :line => line,
67
+ :syntax => syntax,
68
+ :cache_store => cache_store,
69
+ :importer => importer
61
70
  )
62
71
  end
63
72
 
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Sass
3
- VERSION = "0.6.1"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -181,6 +181,17 @@ describe Sprockets::Sass do
181
181
  asset.should_not be_fresh(@env)
182
182
  end
183
183
 
184
+ it "uses the environment's cache" do
185
+ cache = {}
186
+ @env.cache = cache
187
+
188
+ @assets.file "main.css.scss", %($color: blue;\nbody { color: $color; })
189
+
190
+ @env['main.css'].to_s
191
+ sass_cache = cache.keys.detect { |key| key =~ /main\.css\.scss/ }
192
+ sass_cache.should_not be_nil
193
+ end
194
+
184
195
  it "adds the #asset_path helper" do
185
196
  @assets.file "asset_path.css.scss", %(body { background: url(asset-path("image.jpg")); })
186
197
  @assets.file "asset_url.css.scss", %(body { background: asset-url("image.jpg"); })
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-sass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
5
+ version: 0.7.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Pete Browne
@@ -15,141 +10,106 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2012-02-23 00:00:00 Z
13
+ date: 2012-03-03 00:00:00 Z
19
14
  dependencies:
20
15
  - !ruby/object:Gem::Dependency
21
- type: :runtime
16
+ name: sprockets
22
17
  requirement: &id001 !ruby/object:Gem::Requirement
23
18
  none: false
24
19
  requirements:
25
20
  - - ~>
26
21
  - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 2
30
- - 0
31
22
  version: "2.0"
23
+ type: :runtime
32
24
  prerelease: false
33
- name: sprockets
34
25
  version_requirements: *id001
35
26
  - !ruby/object:Gem::Dependency
36
- type: :runtime
27
+ name: tilt
37
28
  requirement: &id002 !ruby/object:Gem::Requirement
38
29
  none: false
39
30
  requirements:
40
31
  - - ~>
41
32
  - !ruby/object:Gem::Version
42
- hash: 13
43
- segments:
44
- - 1
45
- - 1
46
33
  version: "1.1"
34
+ type: :runtime
47
35
  prerelease: false
48
- name: tilt
49
36
  version_requirements: *id002
50
37
  - !ruby/object:Gem::Dependency
51
- type: :development
38
+ name: appraisal
52
39
  requirement: &id003 !ruby/object:Gem::Requirement
53
40
  none: false
54
41
  requirements:
55
42
  - - ~>
56
43
  - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- - 4
61
44
  version: "0.4"
45
+ type: :development
62
46
  prerelease: false
63
- name: appraisal
64
47
  version_requirements: *id003
65
48
  - !ruby/object:Gem::Dependency
66
- type: :development
49
+ name: rspec
67
50
  requirement: &id004 !ruby/object:Gem::Requirement
68
51
  none: false
69
52
  requirements:
70
53
  - - ~>
71
54
  - !ruby/object:Gem::Version
72
- hash: 15
73
- segments:
74
- - 2
75
- - 6
76
55
  version: "2.6"
56
+ type: :development
77
57
  prerelease: false
78
- name: rspec
79
58
  version_requirements: *id004
80
59
  - !ruby/object:Gem::Dependency
81
- type: :development
60
+ name: test-construct
82
61
  requirement: &id005 !ruby/object:Gem::Requirement
83
62
  none: false
84
63
  requirements:
85
64
  - - ~>
86
65
  - !ruby/object:Gem::Version
87
- hash: 11
88
- segments:
89
- - 1
90
- - 2
91
66
  version: "1.2"
67
+ type: :development
92
68
  prerelease: false
93
- name: test-construct
94
69
  version_requirements: *id005
95
70
  - !ruby/object:Gem::Dependency
96
- type: :development
71
+ name: sprockets-helpers
97
72
  requirement: &id006 !ruby/object:Gem::Requirement
98
73
  none: false
99
74
  requirements:
100
75
  - - ~>
101
76
  - !ruby/object:Gem::Version
102
- hash: 13
103
- segments:
104
- - 0
105
- - 3
106
77
  version: "0.3"
78
+ type: :development
107
79
  prerelease: false
108
- name: sprockets-helpers
109
80
  version_requirements: *id006
110
81
  - !ruby/object:Gem::Dependency
111
- type: :development
82
+ name: sass
112
83
  requirement: &id007 !ruby/object:Gem::Requirement
113
84
  none: false
114
85
  requirements:
115
86
  - - ~>
116
87
  - !ruby/object:Gem::Version
117
- hash: 5
118
- segments:
119
- - 3
120
- - 1
121
88
  version: "3.1"
89
+ type: :development
122
90
  prerelease: false
123
- name: sass
124
91
  version_requirements: *id007
125
92
  - !ruby/object:Gem::Dependency
126
- type: :development
93
+ name: compass
127
94
  requirement: &id008 !ruby/object:Gem::Requirement
128
95
  none: false
129
96
  requirements:
130
97
  - - ~>
131
98
  - !ruby/object:Gem::Version
132
- hash: 29
133
- segments:
134
- - 0
135
- - 11
136
99
  version: "0.11"
100
+ type: :development
137
101
  prerelease: false
138
- name: compass
139
102
  version_requirements: *id008
140
103
  - !ruby/object:Gem::Dependency
141
- type: :development
104
+ name: rake
142
105
  requirement: &id009 !ruby/object:Gem::Requirement
143
106
  none: false
144
107
  requirements:
145
108
  - - ">="
146
109
  - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
110
  version: "0"
111
+ type: :development
151
112
  prerelease: false
152
- name: rake
153
113
  version_requirements: *id009
154
114
  description: When using Sprockets 2.0 with Sass you will eventually run into a pretty big issue. `//= require` directives will not allow Sass mixins, variables, etc. to be shared between files. So you'll try to use `@import`, and that'll also blow up in your face. `sprockets-sass` fixes all of this by creating a Sass::Importer that is Sprockets aware.
155
115
  email:
@@ -175,6 +135,7 @@ files:
175
135
  - gemfiles/sprockets-2.3.gemfile
176
136
  - lib/sprockets-sass.rb
177
137
  - lib/sprockets/sass.rb
138
+ - lib/sprockets/sass/cache_store.rb
178
139
  - lib/sprockets/sass/functions.rb
179
140
  - lib/sprockets/sass/importer.rb
180
141
  - lib/sprockets/sass/sass_template.rb
@@ -198,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
159
  requirements:
199
160
  - - ">="
200
161
  - !ruby/object:Gem::Version
201
- hash: 3
162
+ hash: -4611660647593714781
202
163
  segments:
203
164
  - 0
204
165
  version: "0"
@@ -207,14 +168,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
168
  requirements:
208
169
  - - ">="
209
170
  - !ruby/object:Gem::Version
210
- hash: 3
171
+ hash: -4611660647593714781
211
172
  segments:
212
173
  - 0
213
174
  version: "0"
214
175
  requirements: []
215
176
 
216
177
  rubyforge_project: sprockets-sass
217
- rubygems_version: 1.8.11
178
+ rubygems_version: 1.8.8
218
179
  signing_key:
219
180
  specification_version: 3
220
181
  summary: Better Sass integration with Sprockets 2.0