sprockets 2.4.6 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprockets might be problematic. Click here for more details.

data/README.md CHANGED
@@ -361,6 +361,12 @@ submit a pull request.
361
361
 
362
362
  ## Version History ##
363
363
 
364
+ **2.5.0** (September 4, 2012)
365
+
366
+ * Fixed Ruby 2.0 RegExp warning
367
+ * Provide stubbed implementation of context *_path helpers
368
+ * Add SassCompressor
369
+
364
370
  **2.4.5** (July 10, 2012)
365
371
 
366
372
  * Tweaked some logger levels
data/lib/sprockets.rb CHANGED
@@ -20,6 +20,8 @@ module Sprockets
20
20
  autoload :JstProcessor, "sprockets/jst_processor"
21
21
  autoload :Processor, "sprockets/processor"
22
22
  autoload :SassCacheStore, "sprockets/sass_cache_store"
23
+ autoload :SassCompressor, "sprockets/sass_compressor"
24
+ autoload :SassFunctions, "sprockets/sass_functions"
23
25
  autoload :SassImporter, "sprockets/sass_importer"
24
26
  autoload :SassTemplate, "sprockets/sass_template"
25
27
  autoload :ScssTemplate, "sprockets/scss_template"
@@ -221,6 +221,56 @@ module Sprockets
221
221
  "data:#{asset.content_type};base64,#{Rack::Utils.escape(base64)}"
222
222
  end
223
223
 
224
+ # Expands logical path to full url to asset.
225
+ #
226
+ # NOTE: This helper is currently not implemented and should be
227
+ # customized by the application. Though, in the future, some
228
+ # basics implemention may be provided with different methods that
229
+ # are required to be overridden.
230
+ def asset_path(path, options = {})
231
+ message = <<-EOS
232
+ Custom asset_path helper is not implemented
233
+
234
+ Extend your environment context with a custom method.
235
+
236
+ environment.context_class.class_eval do
237
+ def asset_path(path, options = {})
238
+ end
239
+ end
240
+ EOS
241
+ raise NotImplementedError, message
242
+ end
243
+
244
+ # Expand logical image asset path.
245
+ def image_path(path)
246
+ asset_path(path, :type => :image)
247
+ end
248
+
249
+ # Expand logical video asset path.
250
+ def video_path(path)
251
+ asset_path(path, :type => :video)
252
+ end
253
+
254
+ # Expand logical audio asset path.
255
+ def audio_path(path)
256
+ asset_path(path, :type => :audio)
257
+ end
258
+
259
+ # Expand logical font asset path.
260
+ def font_path(path)
261
+ asset_path(path, :type => :font)
262
+ end
263
+
264
+ # Expand logical javascript asset path.
265
+ def javascript_path(path)
266
+ asset_path(path, :type => :javascript)
267
+ end
268
+
269
+ # Expand logical stylesheet asset path.
270
+ def stylesheet_path(path)
271
+ asset_path(path, :type => :stylesheet)
272
+ end
273
+
224
274
  private
225
275
  # Annotates exception backtrace with the original template that
226
276
  # the exception was raised in.
@@ -65,7 +65,7 @@ module Sprockets
65
65
  # //= require "foo"
66
66
  #
67
67
  DIRECTIVE_PATTERN = /
68
- ^ [\W]* = \s* (\w+.*?) (\*\/)? $
68
+ ^ \W* = \s* (\w+.*?) (\*\/)? $
69
69
  /x
70
70
 
71
71
  attr_reader :pathname
@@ -7,6 +7,7 @@ module Sprockets
7
7
  class EncodingError < Error; end
8
8
  class FileNotFound < Error; end
9
9
  class FileOutsidePaths < Error; end
10
+ class NotImplementedError < Error; end
10
11
  class UnserializeError < Error; end
11
12
 
12
13
  module EngineError
@@ -0,0 +1,18 @@
1
+ require 'sass'
2
+
3
+ module Sprockets
4
+ class SassCompressor
5
+ def self.compress(css)
6
+ new.compress(css)
7
+ end
8
+
9
+ def compress(css)
10
+ Sass::Engine.new(css, {
11
+ :syntax => :scss,
12
+ :cache => false,
13
+ :read_cache => false,
14
+ :style => :compressed
15
+ }).render
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,70 @@
1
+ require 'sass'
2
+
3
+ module Sprockets
4
+ module SassFunctions
5
+ def asset_path(path)
6
+ Sass::Script::String.new(sprockets_context.asset_path(path.value), :string)
7
+ end
8
+
9
+ def asset_url(path)
10
+ Sass::Script::String.new("url(" + sprockets_context.asset_path(path.value) + ")")
11
+ end
12
+
13
+ def image_path(path)
14
+ Sass::Script::String.new(sprockets_context.image_path(path.value), :string)
15
+ end
16
+
17
+ def image_url(path)
18
+ Sass::Script::String.new("url(" + sprockets_context.image_path(path.value) + ")")
19
+ end
20
+
21
+ def video_path(path)
22
+ Sass::Script::String.new(sprockets_context.video_path(path.value), :string)
23
+ end
24
+
25
+ def video_url(path)
26
+ Sass::Script::String.new("url(" + sprockets_context.video_path(path.value) + ")")
27
+ end
28
+
29
+ def audio_path(path)
30
+ Sass::Script::String.new(sprockets_context.audio_path(path.value), :string)
31
+ end
32
+
33
+ def audio_url(path)
34
+ Sass::Script::String.new("url(" + sprockets_context.audio_path(path.value) + ")")
35
+ end
36
+
37
+ def font_path(path)
38
+ Sass::Script::String.new(sprockets_context.font_path(path.value), :string)
39
+ end
40
+
41
+ def font_url(path)
42
+ Sass::Script::String.new("url(" + sprockets_context.font_path(path.value) + ")")
43
+ end
44
+
45
+ def javascript_path(path)
46
+ Sass::Script::String.new(sprockets_context.javascript_path(path.value), :string)
47
+ end
48
+
49
+ def javascript_url(path)
50
+ Sass::Script::String.new("url(" + sprockets_context.javascript_path(path.value) + ")")
51
+ end
52
+
53
+ def stylesheet_path(path)
54
+ Sass::Script::String.new(sprockets_context.stylesheet_path(path.value), :string)
55
+ end
56
+
57
+ def stylesheet_url(path)
58
+ Sass::Script::String.new("url(" + sprockets_context.stylesheet_path(path.value) + ")")
59
+ end
60
+
61
+ protected
62
+ def sprockets_context
63
+ options[:sprockets][:context]
64
+ end
65
+
66
+ def sprockets_environment
67
+ options[:sprockets][:environment]
68
+ end
69
+ end
70
+ end
@@ -10,11 +10,20 @@ module Sprockets
10
10
  self.default_mime_type = 'text/css'
11
11
 
12
12
  def self.engine_initialized?
13
- defined? ::Sass::Engine
13
+ defined?(::Sass::Engine) && defined?(::Sass::Script::Functions) &&
14
+ Sass::Script::Functions < Sprockets::SassFunctions
14
15
  end
15
16
 
16
17
  def initialize_engine
17
- require_template_library 'sass'
18
+ # Double check constant to avoid tilt warning
19
+ unless defined? ::Sass
20
+ require_template_library 'sass'
21
+ end
22
+
23
+ # Install custom functions. It'd be great if this didn't need to
24
+ # be installed globally, but could be passed into Engine as an
25
+ # option.
26
+ Sass::Script::Functions.send :include, Sprockets::SassFunctions
18
27
  end
19
28
 
20
29
  def prepare
@@ -33,16 +33,16 @@ module Sprockets
33
33
  # Extract the path from everything after the leading slash
34
34
  path = unescape(env['PATH_INFO'].to_s.sub(/^\//, ''))
35
35
 
36
- # Strip fingerprint
37
- if fingerprint = path_fingerprint(path)
38
- path = path.sub("-#{fingerprint}", '')
39
- end
40
-
41
36
  # URLs containing a `".."` are rejected for security reasons.
42
37
  if forbidden_request?(path)
43
38
  return forbidden_response
44
39
  end
45
40
 
41
+ # Strip fingerprint
42
+ if fingerprint = path_fingerprint(path)
43
+ path = path.sub("-#{fingerprint}", '')
44
+ end
45
+
46
46
  # Look up the asset.
47
47
  asset = find_asset(path, :bundle => !body_only?(env))
48
48
 
@@ -90,7 +90,7 @@ module Sprockets
90
90
  #
91
91
  # http://example.org/assets/../../../etc/passwd
92
92
  #
93
- path.include?("..") || Pathname.new(path).absolute?
93
+ path.include?("..")
94
94
  end
95
95
 
96
96
  # Returns a 403 Forbidden response tuple
@@ -222,7 +222,7 @@ module Sprockets
222
222
  # # => "0aa2105d29558f3eb790d411d7d8fb66"
223
223
  #
224
224
  def path_fingerprint(path)
225
- path[/-([0-9a-f]{7,40})\.[^.]+\z/, 1]
225
+ path[/-([0-9a-f]{7,40})\.[^.]+$/, 1]
226
226
  end
227
227
 
228
228
  # URI.unescape is deprecated on 1.9. We need to use URI::Parser
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "2.4.6"
2
+ VERSION = "2.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.6
4
+ version: 2.5.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Sam Stephenson
@@ -9,194 +10,220 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-10-28 00:00:00.000000000 Z
13
+ date: 2012-09-04 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: hike
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - "~>"
20
+ - - ~>
19
21
  - !ruby/object:Gem::Version
20
22
  version: '1.2'
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
- - - "~>"
28
+ - - ~>
26
29
  - !ruby/object:Gem::Version
27
30
  version: '1.2'
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: multi_json
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
- - - "~>"
36
+ - - ~>
33
37
  - !ruby/object:Gem::Version
34
38
  version: '1.0'
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
- - - "~>"
44
+ - - ~>
40
45
  - !ruby/object:Gem::Version
41
46
  version: '1.0'
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: rack
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
- - - "~>"
52
+ - - ~>
47
53
  - !ruby/object:Gem::Version
48
54
  version: '1.0'
49
55
  type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
- - - "~>"
60
+ - - ~>
54
61
  - !ruby/object:Gem::Version
55
62
  version: '1.0'
56
63
  - !ruby/object:Gem::Dependency
57
64
  name: tilt
58
65
  requirement: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
- - - "~>"
68
+ - - ~>
61
69
  - !ruby/object:Gem::Version
62
70
  version: '1.1'
63
- - - "!="
71
+ - - ! '!='
64
72
  - !ruby/object:Gem::Version
65
73
  version: 1.3.0
66
74
  type: :runtime
67
75
  prerelease: false
68
76
  version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
69
78
  requirements:
70
- - - "~>"
79
+ - - ~>
71
80
  - !ruby/object:Gem::Version
72
81
  version: '1.1'
73
- - - "!="
82
+ - - ! '!='
74
83
  - !ruby/object:Gem::Version
75
84
  version: 1.3.0
76
85
  - !ruby/object:Gem::Dependency
77
86
  name: coffee-script
78
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
79
89
  requirements:
80
- - - "~>"
90
+ - - ~>
81
91
  - !ruby/object:Gem::Version
82
92
  version: '2.0'
83
93
  type: :development
84
94
  prerelease: false
85
95
  version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
86
97
  requirements:
87
- - - "~>"
98
+ - - ~>
88
99
  - !ruby/object:Gem::Version
89
100
  version: '2.0'
90
101
  - !ruby/object:Gem::Dependency
91
102
  name: coffee-script-source
92
103
  requirement: !ruby/object:Gem::Requirement
104
+ none: false
93
105
  requirements:
94
- - - "~>"
106
+ - - ~>
95
107
  - !ruby/object:Gem::Version
96
108
  version: 1.2.0
97
109
  type: :development
98
110
  prerelease: false
99
111
  version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
100
113
  requirements:
101
- - - "~>"
114
+ - - ~>
102
115
  - !ruby/object:Gem::Version
103
116
  version: 1.2.0
104
117
  - !ruby/object:Gem::Dependency
105
118
  name: eco
106
119
  requirement: !ruby/object:Gem::Requirement
120
+ none: false
107
121
  requirements:
108
- - - "~>"
122
+ - - ~>
109
123
  - !ruby/object:Gem::Version
110
124
  version: '1.0'
111
125
  type: :development
112
126
  prerelease: false
113
127
  version_requirements: !ruby/object:Gem::Requirement
128
+ none: false
114
129
  requirements:
115
- - - "~>"
130
+ - - ~>
116
131
  - !ruby/object:Gem::Version
117
132
  version: '1.0'
118
133
  - !ruby/object:Gem::Dependency
119
134
  name: ejs
120
135
  requirement: !ruby/object:Gem::Requirement
136
+ none: false
121
137
  requirements:
122
- - - "~>"
138
+ - - ~>
123
139
  - !ruby/object:Gem::Version
124
140
  version: '1.0'
125
141
  type: :development
126
142
  prerelease: false
127
143
  version_requirements: !ruby/object:Gem::Requirement
144
+ none: false
128
145
  requirements:
129
- - - "~>"
146
+ - - ~>
130
147
  - !ruby/object:Gem::Version
131
148
  version: '1.0'
132
149
  - !ruby/object:Gem::Dependency
133
150
  name: execjs
134
151
  requirement: !ruby/object:Gem::Requirement
152
+ none: false
135
153
  requirements:
136
- - - "~>"
154
+ - - ~>
137
155
  - !ruby/object:Gem::Version
138
156
  version: '1.0'
139
157
  type: :development
140
158
  prerelease: false
141
159
  version_requirements: !ruby/object:Gem::Requirement
160
+ none: false
142
161
  requirements:
143
- - - "~>"
162
+ - - ~>
144
163
  - !ruby/object:Gem::Version
145
164
  version: '1.0'
146
165
  - !ruby/object:Gem::Dependency
147
166
  name: json
148
167
  requirement: !ruby/object:Gem::Requirement
168
+ none: false
149
169
  requirements:
150
- - - ">="
170
+ - - ! '>='
151
171
  - !ruby/object:Gem::Version
152
172
  version: '0'
153
173
  type: :development
154
174
  prerelease: false
155
175
  version_requirements: !ruby/object:Gem::Requirement
176
+ none: false
156
177
  requirements:
157
- - - ">="
178
+ - - ! '>='
158
179
  - !ruby/object:Gem::Version
159
180
  version: '0'
160
181
  - !ruby/object:Gem::Dependency
161
182
  name: rack-test
162
183
  requirement: !ruby/object:Gem::Requirement
184
+ none: false
163
185
  requirements:
164
- - - ">="
186
+ - - ! '>='
165
187
  - !ruby/object:Gem::Version
166
188
  version: '0'
167
189
  type: :development
168
190
  prerelease: false
169
191
  version_requirements: !ruby/object:Gem::Requirement
192
+ none: false
170
193
  requirements:
171
- - - ">="
194
+ - - ! '>='
172
195
  - !ruby/object:Gem::Version
173
196
  version: '0'
174
197
  - !ruby/object:Gem::Dependency
175
198
  name: rake
176
199
  requirement: !ruby/object:Gem::Requirement
200
+ none: false
177
201
  requirements:
178
- - - ">="
202
+ - - ! '>='
179
203
  - !ruby/object:Gem::Version
180
204
  version: '0'
181
205
  type: :development
182
206
  prerelease: false
183
207
  version_requirements: !ruby/object:Gem::Requirement
208
+ none: false
184
209
  requirements:
185
- - - ">="
210
+ - - ! '>='
186
211
  - !ruby/object:Gem::Version
187
212
  version: '0'
188
213
  - !ruby/object:Gem::Dependency
189
214
  name: sass
190
215
  requirement: !ruby/object:Gem::Requirement
216
+ none: false
191
217
  requirements:
192
- - - "~>"
218
+ - - ~>
193
219
  - !ruby/object:Gem::Version
194
220
  version: '3.1'
195
221
  type: :development
196
222
  prerelease: false
197
223
  version_requirements: !ruby/object:Gem::Requirement
224
+ none: false
198
225
  requirements:
199
- - - "~>"
226
+ - - ~>
200
227
  - !ruby/object:Gem::Version
201
228
  version: '3.1'
202
229
  description: Sprockets is a Rack-based asset packaging system that concatenates and
@@ -209,11 +236,9 @@ executables:
209
236
  extensions: []
210
237
  extra_rdoc_files: []
211
238
  files:
212
- - LICENSE
213
239
  - README.md
214
- - bin/sprockets
240
+ - LICENSE
215
241
  - lib/rake/sprocketstask.rb
216
- - lib/sprockets.rb
217
242
  - lib/sprockets/asset.rb
218
243
  - lib/sprockets/asset_attributes.rb
219
244
  - lib/sprockets/base.rb
@@ -238,6 +263,8 @@ files:
238
263
  - lib/sprockets/processor.rb
239
264
  - lib/sprockets/safety_colons.rb
240
265
  - lib/sprockets/sass_cache_store.rb
266
+ - lib/sprockets/sass_compressor.rb
267
+ - lib/sprockets/sass_functions.rb
241
268
  - lib/sprockets/sass_importer.rb
242
269
  - lib/sprockets/sass_template.rb
243
270
  - lib/sprockets/scss_template.rb
@@ -245,27 +272,30 @@ files:
245
272
  - lib/sprockets/static_asset.rb
246
273
  - lib/sprockets/utils.rb
247
274
  - lib/sprockets/version.rb
275
+ - lib/sprockets.rb
276
+ - bin/sprockets
248
277
  homepage: http://getsprockets.org/
249
278
  licenses: []
250
- metadata: {}
251
279
  post_install_message:
252
280
  rdoc_options: []
253
281
  require_paths:
254
282
  - lib
255
283
  required_ruby_version: !ruby/object:Gem::Requirement
284
+ none: false
256
285
  requirements:
257
- - - ">="
286
+ - - ! '>='
258
287
  - !ruby/object:Gem::Version
259
288
  version: '0'
260
289
  required_rubygems_version: !ruby/object:Gem::Requirement
290
+ none: false
261
291
  requirements:
262
- - - ">="
292
+ - - ! '>='
263
293
  - !ruby/object:Gem::Version
264
294
  version: '0'
265
295
  requirements: []
266
296
  rubyforge_project: sprockets
267
- rubygems_version: 2.2.2
297
+ rubygems_version: 1.8.24
268
298
  signing_key:
269
- specification_version: 4
299
+ specification_version: 3
270
300
  summary: Rack-based asset packaging system
271
301
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1471328329eb1e6f3a8e218553de19ded2731956
4
- data.tar.gz: 8bd2fc9eb30ab785ef04ed901a86ee3e9b416775
5
- SHA512:
6
- metadata.gz: ade13ae863b06566bf143574ade26233e005dbf078ed400b6e7b5e0a3b370017b22f464c0e08da0416244c47e3044b1fb7e9705467620cf38e113424d432da1a
7
- data.tar.gz: b50b7d1451f79a7d7446ac2ae428b36b6d006d1901e2ab86c0a489b642a30f217eed3a53dbc6f2414413fcad76b9bd427f22131bc853c68119d4a063608adaba