sprockets-helpers 0.6.1 → 0.7.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/Appraisals CHANGED
@@ -17,3 +17,11 @@ end
17
17
  appraise 'sprockets-2.4' do
18
18
  gem 'sprockets', '~> 2.4.0'
19
19
  end
20
+
21
+ appraise 'sprockets-2.5' do
22
+ gem 'sprockets', '~> 2.5.0'
23
+ end
24
+
25
+ appraise 'sprockets-2.6' do
26
+ gem 'sprockets', '~> 2.6.0'
27
+ end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sprockets", "~> 2.5.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "sprockets", "~> 2.6.0"
6
+
7
+ gemspec :path=>"../"
@@ -11,24 +11,24 @@ module Sprockets
11
11
  class << self
12
12
  # Link to assets from a dedicated server.
13
13
  attr_accessor :asset_host
14
-
14
+
15
15
  # When true, the asset paths will return digest paths.
16
16
  attr_accessor :digest
17
-
17
+
18
18
  # Set the Sprockets environment to search for assets.
19
19
  # This defaults to the context's #environment method.
20
20
  attr_accessor :environment
21
-
21
+
22
22
  # The manifest file used for lookup
23
23
  attr_accessor :manifest
24
-
24
+
25
25
  # The base URL the Sprocket environment is mapped to.
26
26
  # This defaults to '/assets'.
27
27
  def prefix
28
28
  @prefix ||= '/assets'
29
29
  end
30
30
  attr_writer :prefix
31
-
31
+
32
32
  # Customize the protocol when using asset hosts.
33
33
  # If the value is :relative, A relative protocol ('//')
34
34
  # will be used.
@@ -36,7 +36,7 @@ module Sprockets
36
36
  @protocol ||= 'http://'
37
37
  end
38
38
  attr_writer :protocol
39
-
39
+
40
40
  # The path to the public directory, where the assets
41
41
  # not managed by Sprockets will be located.
42
42
  # Defaults to './public'
@@ -44,13 +44,15 @@ module Sprockets
44
44
  @public_path ||= './public'
45
45
  end
46
46
  attr_writer :public_path
47
-
47
+
48
48
  # Convience method for configuring Sprockets::Helpers.
49
49
  def configure
50
50
  yield self
51
51
  end
52
52
  end
53
-
53
+ end
54
+
55
+ class Context
54
56
  # Returns the path to an asset either in the Sprockets environment
55
57
  # or the public directory. External URIs are untouched.
56
58
  #
@@ -79,35 +81,43 @@ module Sprockets
79
81
  # asset_path '/dir/xmlhr.js', :dir => 'javascripts' # => '/dir/xmlhr.js'
80
82
  # asset_path 'http://www.example.com/js/xmlhr' # => 'http://www.example.com/js/xmlhr'
81
83
  # asset_path 'http://www.example.com/js/xmlhr.js' # => 'http://www.example.com/js/xmlhr.js'
82
- #
84
+ #
83
85
  def asset_path(source, options = {})
84
86
  uri = URI.parse(source)
85
-
87
+
86
88
  # Return fast if the URI is absolute
87
89
  return source if uri.absolute?
88
-
90
+
91
+ # When debugging return paths without digests, asset_hosts, etc.
92
+ if options[:debug]
93
+ options[:manifest] = false
94
+ options[:digest] = false
95
+ options[:asset_host] = false
96
+ end
97
+
89
98
  # Append extension if necessary
90
99
  source_ext = File.extname(source)
91
100
  if options[:ext] && source_ext != ".#{options[:ext]}"
92
101
  uri.path << ".#{options[:ext]}"
93
102
  end
94
-
103
+
95
104
  # If a manifest is present, try to grab the path from the manifest first
96
- if Helpers.manifest && Helpers.manifest.assets[uri.path]
97
- return ManifestPath.new(uri, Helpers.manifest.assets[uri.path], options).to_s
105
+ # Don't try looking in manifest in the first place if we're not looking for digest version
106
+ if options[:manifest] != false && Helpers.manifest && Helpers.manifest.assets[uri.path]
107
+ return Helpers::ManifestPath.new(uri, Helpers.manifest.assets[uri.path], options).to_s
98
108
  end
99
-
109
+
100
110
  # If the source points to an asset in the Sprockets
101
111
  # environment use AssetPath to generate the full path.
102
112
  assets_environment.resolve(uri.path) do |path|
103
- return AssetPath.new(uri, assets_environment[path], options).to_s
113
+ return Helpers::AssetPath.new(uri, assets_environment[path], options).to_s
104
114
  end
105
-
115
+
106
116
  # Use FilePath for normal files on the file system
107
- FilePath.new(uri, options).to_s
117
+ return Helpers::FilePath.new(uri, options).to_s
108
118
  end
109
119
  alias_method :path_to_asset, :asset_path
110
-
120
+
111
121
  # Computes the path to a audio asset either in the Sprockets environment
112
122
  # or the public directory. External URIs are untouched.
113
123
  #
@@ -131,7 +141,7 @@ module Sprockets
131
141
  asset_path source, { :dir => 'audios' }.merge(options)
132
142
  end
133
143
  alias_method :path_to_audio, :audio_path
134
-
144
+
135
145
  # Computes the path to a font asset either in the Sprockets environment
136
146
  # or the public directory. External URIs are untouched.
137
147
  #
@@ -155,7 +165,7 @@ module Sprockets
155
165
  asset_path source, { :dir => 'fonts' }.merge(options)
156
166
  end
157
167
  alias_method :path_to_font, :font_path
158
-
168
+
159
169
  # Computes the path to an image asset either in the Sprockets environment
160
170
  # or the public directory. External URIs are untouched.
161
171
  #
@@ -179,7 +189,7 @@ module Sprockets
179
189
  asset_path source, { :dir => 'images' }.merge(options)
180
190
  end
181
191
  alias_method :path_to_image, :image_path
182
-
192
+
183
193
  # Computes the path to a javascript asset either in the Sprockets
184
194
  # environment or the public directory. If the +source+ filename has no extension,
185
195
  # <tt>.js</tt> will be appended. External URIs are untouched.
@@ -204,7 +214,7 @@ module Sprockets
204
214
  asset_path source, { :dir => 'javascripts', :ext => 'js' }.merge(options)
205
215
  end
206
216
  alias_method :path_to_javascript, :javascript_path
207
-
217
+
208
218
  # Computes the path to a stylesheet asset either in the Sprockets
209
219
  # environment or the public directory. If the +source+ filename has no extension,
210
220
  # <tt>.css</tt> will be appended. External URIs are untouched.
@@ -229,7 +239,7 @@ module Sprockets
229
239
  asset_path source, { :dir => 'stylesheets', :ext => 'css' }.merge(options)
230
240
  end
231
241
  alias_method :path_to_stylesheet, :stylesheet_path
232
-
242
+
233
243
  # Computes the path to a video asset either in the Sprockets environment
234
244
  # or the public directory. External URIs are untouched.
235
245
  #
@@ -253,9 +263,9 @@ module Sprockets
253
263
  asset_path source, { :dir => 'videos' }.merge(options)
254
264
  end
255
265
  alias_method :path_to_video, :video_path
256
-
266
+
257
267
  protected
258
-
268
+
259
269
  # Returns the Sprockets environment #asset_path uses to search for
260
270
  # assets. This can be overridden for more control, if necessary.
261
271
  # Defaults to Sprockets::Helpers.environment or the envrionment
@@ -264,8 +274,4 @@ module Sprockets
264
274
  Helpers.environment || environment
265
275
  end
266
276
  end
267
-
268
- class Context
269
- include Helpers
270
- end
271
277
  end
@@ -3,40 +3,40 @@ require 'zlib'
3
3
 
4
4
  module Sprockets
5
5
  module Helpers
6
- #
6
+ #
7
7
  class BasePath
8
8
  # The parsed URI from which to generate the full path to the asset.
9
9
  attr_reader :uri
10
-
10
+
11
11
  # The various options used when generating the path.
12
12
  attr_reader :options
13
-
13
+
14
14
  #
15
15
  def initialize(uri, options = {})
16
16
  @uri = uri
17
17
  @options = options
18
18
  end
19
-
19
+
20
20
  # Returns the full path to the asset, complete with
21
21
  # timestamp.
22
22
  def to_s
23
23
  rewrite_path
24
24
  rewrite_query
25
25
  rewrite_host
26
-
26
+
27
27
  uri.to_s
28
28
  end
29
-
29
+
30
30
  protected
31
-
31
+
32
32
  # Hook for rewriting the base path.
33
33
  def rewrite_path # :nodoc:
34
34
  end
35
-
35
+
36
36
  # Hook for rewriting the query string.
37
37
  def rewrite_query # :nodoc:
38
38
  end
39
-
39
+
40
40
  # Hook for rewriting the host.
41
41
  def rewrite_host # :nodoc:
42
42
  if host = compute_asset_host
@@ -44,36 +44,40 @@ module Sprockets
44
44
  uri.scheme = compute_scheme
45
45
  end
46
46
  end
47
-
47
+
48
48
  # Pick an asset host for this source. Returns +nil+ if no host is set,
49
49
  # the host if no wildcard is set, the host interpolated with the
50
50
  # numbers 0-3 if it contains <tt>%d</tt> (the number is the source hash mod 4),
51
51
  # or the value returned from invoking call on an object responding to call
52
52
  # (proc or otherwise).
53
53
  def compute_asset_host # :nodoc:
54
+ return nil if options[:asset_host] == false
55
+
54
56
  if host = options[:asset_host] || Helpers.asset_host
55
57
  if host.respond_to?(:call)
56
58
  host.call(uri.to_s)
57
59
  elsif host =~ /%d/
58
60
  host % (Zlib.crc32(uri.to_s) % 4)
61
+ elsif host.empty?
62
+ nil
59
63
  else
60
64
  host
61
65
  end
62
66
  end
63
67
  end
64
-
68
+
65
69
  # Pick a scheme for the protocol if we are using
66
70
  # an asset host.
67
71
  def compute_scheme # :nodoc:
68
72
  protocol = options[:protocol] || Helpers.protocol
69
-
73
+
70
74
  if protocol.nil? || protocol == :relative
71
75
  nil
72
76
  else
73
77
  protocol.to_s.sub %r{://\z}, ''
74
78
  end
75
79
  end
76
-
80
+
77
81
  # Prepends the given path. If the path is absolute
78
82
  # An attempt to merge the URIs is made.
79
83
  #
@@ -81,16 +85,16 @@ module Sprockets
81
85
  def prepend_path(value) # :nodoc:
82
86
  prefix_uri = URI.parse(value)
83
87
  uri.path = File.join prefix_uri.path, uri.path
84
-
88
+
85
89
  if prefix_uri.absolute?
86
90
  @uri = prefix_uri.merge(uri)
87
91
  end
88
92
  end
89
-
93
+
90
94
  # Append the given query string to the URI
91
95
  # instead of clobbering it.
92
96
  def append_query(value) # :nodoc:
93
- if uri.query.nil? || uri.query.empty?
97
+ if uri.query.nil? || uri.query.empty?
94
98
  uri.query = value
95
99
  else
96
100
  uri.query << ('&' + value)
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Helpers
3
- VERSION = '0.6.1'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
9
9
 
10
10
  RSpec.configure do |config|
11
11
  config.include Construct::Helpers
12
-
12
+
13
13
  # Returns a Sprockets environment. Automatically
14
14
  # appends the 'assets' path if available.
15
15
  def env
@@ -17,7 +17,7 @@ RSpec.configure do |config|
17
17
  env.append_path 'assets' if File.directory?('assets')
18
18
  end
19
19
  end
20
-
20
+
21
21
  # Returns a fresh context, that can be used to test helpers.
22
22
  def context(logical_path = 'application.js', pathname = nil)
23
23
  pathname ||= Pathname.new(File.join('assets', logical_path)).expand_path
@@ -5,7 +5,7 @@ describe Sprockets::Helpers do
5
5
  it 'sets global configuration' do
6
6
  within_construct do |c|
7
7
  c.file 'assets/main.css'
8
-
8
+
9
9
  context.asset_path('main.css').should == '/assets/main.css'
10
10
  Sprockets::Helpers.configure do |config|
11
11
  config.digest = true
@@ -17,12 +17,12 @@ describe Sprockets::Helpers do
17
17
  end
18
18
  end
19
19
  end
20
-
20
+
21
21
  describe '.digest' do
22
22
  it 'globally configures digest paths' do
23
23
  within_construct do |c|
24
24
  c.file 'assets/main.js'
25
-
25
+
26
26
  context.asset_path('main', :ext => 'js').should == '/assets/main.js'
27
27
  Sprockets::Helpers.digest = true
28
28
  context.asset_path('main', :ext => 'js').should =~ %r(/assets/main-[0-9a-f]+.js)
@@ -30,12 +30,12 @@ describe Sprockets::Helpers do
30
30
  end
31
31
  end
32
32
  end
33
-
33
+
34
34
  describe '.environment' do
35
35
  it 'sets a custom assets environment' do
36
36
  within_construct do |c|
37
37
  c.file 'themes/main.css'
38
-
38
+
39
39
  custom_env = Sprockets::Environment.new
40
40
  custom_env.append_path 'themes'
41
41
  Sprockets::Helpers.environment = custom_env
@@ -44,27 +44,27 @@ describe Sprockets::Helpers do
44
44
  end
45
45
  end
46
46
  end
47
-
47
+
48
48
  describe '.asset_host' do
49
49
  context 'that is a string' do
50
50
  it 'prepends the asset_host' do
51
51
  within_construct do |c|
52
52
  c.file 'assets/main.js'
53
53
  c.file 'public/logo.jpg'
54
-
54
+
55
55
  Sprockets::Helpers.asset_host = 'assets.example.com'
56
56
  context.asset_path('main.js').should == 'http://assets.example.com/assets/main.js'
57
57
  context.asset_path('logo.jpg').should =~ %r(http://assets.example.com/logo.jpg\?\d+)
58
58
  Sprockets::Helpers.asset_host = nil
59
59
  end
60
60
  end
61
-
61
+
62
62
  context 'with a wildcard' do
63
63
  it 'cycles asset_host between 0-3' do
64
64
  within_construct do |c|
65
65
  c.file 'assets/main.css'
66
66
  c.file 'public/logo.jpg'
67
-
67
+
68
68
  Sprockets::Helpers.asset_host = 'assets%d.example.com'
69
69
  context.asset_path('main.css').should =~ %r(http://assets[0-3].example.com/assets/main.css)
70
70
  context.asset_path('logo.jpg').should =~ %r(http://assets[0-3].example.com/logo.jpg\?\d+)
@@ -73,13 +73,13 @@ describe Sprockets::Helpers do
73
73
  end
74
74
  end
75
75
  end
76
-
76
+
77
77
  context 'that is a proc' do
78
78
  it 'prepends the returned asset_host' do
79
79
  within_construct do |c|
80
80
  c.file 'assets/main.js'
81
81
  c.file 'public/logo.jpg'
82
-
82
+
83
83
  Sprockets::Helpers.asset_host = Proc.new { |source| File.basename(source, File.extname(source)) + '.assets.example.com' }
84
84
  context.asset_path('main.js').should == 'http://main.assets.example.com/assets/main.js'
85
85
  context.asset_path('logo.jpg').should =~ %r(http://logo.assets.example.com/logo.jpg\?\d+)
@@ -88,12 +88,12 @@ describe Sprockets::Helpers do
88
88
  end
89
89
  end
90
90
  end
91
-
91
+
92
92
  describe '.prefix' do
93
93
  it 'sets a custom assets prefix' do
94
94
  within_construct do |c|
95
95
  c.file 'assets/logo.jpg'
96
-
96
+
97
97
  context.asset_path('logo.jpg').should == '/assets/logo.jpg'
98
98
  Sprockets::Helpers.prefix = '/images'
99
99
  context.asset_path('logo.jpg').should == '/images/logo.jpg'
@@ -101,13 +101,13 @@ describe Sprockets::Helpers do
101
101
  end
102
102
  end
103
103
  end
104
-
104
+
105
105
  describe '.protocol' do
106
106
  it 'sets the protocol to use with asset_hosts' do
107
107
  within_construct do |c|
108
108
  c.file 'assets/main.js'
109
109
  c.file 'public/logo.jpg'
110
-
110
+
111
111
  Sprockets::Helpers.asset_host = 'assets.example.com'
112
112
  Sprockets::Helpers.protocol = 'https'
113
113
  context.asset_path('main.js').should == 'https://assets.example.com/assets/main.js'
@@ -116,13 +116,13 @@ describe Sprockets::Helpers do
116
116
  Sprockets::Helpers.protocol = nil
117
117
  end
118
118
  end
119
-
119
+
120
120
  context 'that is :relative' do
121
121
  it 'sets a relative protocol' do
122
122
  within_construct do |c|
123
123
  c.file 'assets/main.js'
124
124
  c.file 'public/logo.jpg'
125
-
125
+
126
126
  Sprockets::Helpers.asset_host = 'assets.example.com'
127
127
  Sprockets::Helpers.protocol = :relative
128
128
  context.asset_path('main.js').should == '//assets.example.com/assets/main.js'
@@ -133,12 +133,12 @@ describe Sprockets::Helpers do
133
133
  end
134
134
  end
135
135
  end
136
-
136
+
137
137
  describe '.public_path' do
138
138
  it 'sets a custom location for the public path' do
139
139
  within_construct do |c|
140
140
  c.file 'output/main.js'
141
-
141
+
142
142
  context.asset_path('main.js').should == '/main.js'
143
143
  Sprockets::Helpers.public_path = './output'
144
144
  context.asset_path('main.js').should =~ %r(/main.js\?\d+)
@@ -158,32 +158,32 @@ describe Sprockets::Helpers do
158
158
  '//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'
159
159
  end
160
160
  end
161
-
161
+
162
162
  context 'with regular files' do
163
163
  it 'returns absolute paths' do
164
164
  context.asset_path('/path/to/file.js').should == '/path/to/file.js'
165
165
  context.asset_path('/path/to/file.jpg').should == '/path/to/file.jpg'
166
166
  context.asset_path('/path/to/file.eot?#iefix').should == '/path/to/file.eot?#iefix'
167
167
  end
168
-
168
+
169
169
  it 'appends the extension for javascripts and stylesheets' do
170
170
  context.asset_path('/path/to/file', :ext => 'js').should == '/path/to/file.js'
171
171
  context.asset_path('/path/to/file', :ext => 'css').should == '/path/to/file.css'
172
172
  end
173
-
173
+
174
174
  it 'prepends a base dir' do
175
175
  context.asset_path('main', :dir => 'stylesheets', :ext => 'css').should == '/stylesheets/main.css'
176
176
  context.asset_path('main', :dir => 'javascripts', :ext => 'js').should == '/javascripts/main.js'
177
177
  context.asset_path('logo.jpg', :dir => 'images').should == '/images/logo.jpg'
178
178
  end
179
-
179
+
180
180
  it 'appends a timestamp if the file exists in the output path' do
181
181
  within_construct do |c|
182
182
  c.file 'public/main.js'
183
183
  c.file 'public/favicon.ico'
184
184
  c.file 'public/font.eot'
185
185
  c.file 'public/font.svg'
186
-
186
+
187
187
  context.asset_path('main', :ext => 'js').should =~ %r(/main.js\?\d+)
188
188
  context.asset_path('/favicon.ico').should =~ %r(/favicon.ico\?\d+)
189
189
  context.asset_path('font.eot?#iefix').should =~ %r(/font.eot\?\d+#iefix)
@@ -191,110 +191,155 @@ describe Sprockets::Helpers do
191
191
  end
192
192
  end
193
193
  end
194
-
194
+
195
195
  context 'with assets' do
196
196
  it 'returns URLs to the assets' do
197
197
  within_construct do |c|
198
198
  c.file 'assets/logo.jpg'
199
199
  c.file 'assets/main.js'
200
200
  c.file 'assets/main.css'
201
-
201
+
202
202
  context.asset_path('main', :ext => 'css').should == '/assets/main.css'
203
203
  context.asset_path('main', :ext => 'js').should == '/assets/main.js'
204
204
  context.asset_path('logo.jpg').should == '/assets/logo.jpg'
205
205
  end
206
206
  end
207
-
207
+
208
208
  it 'prepends the assets prefix' do
209
209
  within_construct do |c|
210
210
  c.file 'assets/logo.jpg'
211
-
211
+
212
212
  context.asset_path('logo.jpg').should == '/assets/logo.jpg'
213
213
  context.asset_path('logo.jpg', :prefix => '/images').should == '/images/logo.jpg'
214
214
  end
215
215
  end
216
-
216
+
217
217
  it 'uses the digest path if configured' do
218
218
  within_construct do |c|
219
219
  c.file 'assets/main.js'
220
220
  c.file 'assets/font.eot'
221
221
  c.file 'assets/font.svg'
222
-
222
+
223
223
  context.asset_path('main', :ext => 'js').should == '/assets/main.js'
224
224
  context.asset_path('main', :ext => 'js', :digest => true).should =~ %r(/assets/main-[0-9a-f]+.js)
225
225
  context.asset_path('font.eot?#iefix', :digest => true).should =~ %r(/assets/font-[0-9a-f]+.eot\?#iefix)
226
226
  context.asset_path('font.svg#FontName', :digest => true).should =~ %r(/assets/font-[0-9a-f]+.svg#FontName)
227
227
  end
228
228
  end
229
-
229
+
230
230
  it 'returns a body parameter' do
231
231
  within_construct do |c|
232
232
  c.file 'assets/main.js'
233
233
  c.file 'assets/font.eot'
234
234
  c.file 'assets/font.svg'
235
-
235
+
236
236
  context.asset_path('main', :ext => 'js', :body => true).should == '/assets/main.js?body=1'
237
237
  context.asset_path('font.eot?#iefix', :body => true).should == '/assets/font.eot?body=1#iefix'
238
238
  context.asset_path('font.svg#FontName', :body => true).should == '/assets/font.svg?body=1#FontName'
239
239
  end
240
240
  end
241
241
  end
242
-
242
+
243
+ context 'when debuging' do
244
+ it 'does not use the digest path' do
245
+ within_construct do |c|
246
+ c.file 'assets/main.js'
247
+
248
+ Sprockets::Helpers.digest = true
249
+ context.asset_path('main.js', :debug => true).should == '/assets/main.js'
250
+ Sprockets::Helpers.digest = nil
251
+ end
252
+ end
253
+
254
+ it 'does not prepend the asset host' do
255
+ within_construct do |c|
256
+ c.file 'assets/main.js'
257
+
258
+ Sprockets::Helpers.asset_host = 'assets.example.com'
259
+ context.asset_path('main.js', :debug => true).should == '/assets/main.js'
260
+ Sprockets::Helpers.asset_host = nil
261
+ end
262
+ end
263
+ end
264
+
243
265
  if defined?(::Sprockets::Manifest)
244
266
  context 'with a manifest' do
245
267
  it 'reads path from a manifest file' do
246
268
  within_construct do |c|
247
269
  asset_file = c.file 'assets/application.js'
248
270
  manifest_file = c.join 'manifest.json'
249
-
271
+
250
272
  manifest = Sprockets::Manifest.new(env, manifest_file)
251
273
  manifest.compile 'application.js'
252
-
274
+
253
275
  Sprockets::Helpers.configure do |config|
254
276
  config.digest = true
255
277
  config.prefix = '/assets'
256
278
  config.manifest = Sprockets::Manifest.new(env, manifest_file)
257
279
  end
258
-
280
+
259
281
  asset_file.delete
260
282
  context.asset_path('application.js').should =~ %r(/assets/application-[0-9a-f]+.js)
261
-
283
+
262
284
  Sprockets::Helpers.digest = nil
263
285
  Sprockets::Helpers.prefix = nil
264
286
  end
265
287
  end
288
+
289
+ context 'when debuging' do
290
+ it 'does not read the path from the manifest file' do
291
+ within_construct do |c|
292
+ asset_file = c.file 'assets/application.js'
293
+ manifest_file = c.join 'manifest.json'
294
+
295
+ manifest = Sprockets::Manifest.new(env, manifest_file)
296
+ manifest.compile 'application.js'
297
+
298
+ Sprockets::Helpers.configure do |config|
299
+ config.digest = true
300
+ config.prefix = '/assets'
301
+ config.manifest = Sprockets::Manifest.new(env, manifest_file)
302
+ end
303
+
304
+ context.asset_path('application.js', :debug => true).should == '/assets/application.js'
305
+
306
+ Sprockets::Helpers.digest = nil
307
+ Sprockets::Helpers.prefix = nil
308
+ end
309
+ end
310
+ end
266
311
  end
267
312
  end
268
313
  end
269
-
314
+
270
315
  describe '#javascript_path' do
271
316
  context 'with regular files' do
272
317
  it 'appends the js extension' do
273
318
  context.javascript_path('/path/to/file').should == '/path/to/file.js'
274
319
  context.javascript_path('/path/to/file.min').should == '/path/to/file.min.js'
275
320
  end
276
-
321
+
277
322
  it 'prepends the javascripts dir' do
278
323
  context.javascript_path('main').should == '/javascripts/main.js'
279
324
  context.javascript_path('main.min').should == '/javascripts/main.min.js'
280
325
  end
281
326
  end
282
327
  end
283
-
328
+
284
329
  describe '#stylesheet_path' do
285
330
  context 'with regular files' do
286
331
  it 'appends the css extension' do
287
332
  context.stylesheet_path('/path/to/file').should == '/path/to/file.css'
288
333
  context.stylesheet_path('/path/to/file.min').should == '/path/to/file.min.css'
289
334
  end
290
-
335
+
291
336
  it 'prepends the stylesheets dir' do
292
337
  context.stylesheet_path('main').should == '/stylesheets/main.css'
293
338
  context.stylesheet_path('main.min').should == '/stylesheets/main.min.css'
294
339
  end
295
340
  end
296
341
  end
297
-
342
+
298
343
  describe '#image_path' do
299
344
  context 'with regular files' do
300
345
  it 'prepends the images dir' do
@@ -302,7 +347,7 @@ describe Sprockets::Helpers do
302
347
  end
303
348
  end
304
349
  end
305
-
350
+
306
351
  describe '#font_path' do
307
352
  context 'with regular files' do
308
353
  it 'prepends the fonts dir' do
@@ -310,7 +355,7 @@ describe Sprockets::Helpers do
310
355
  end
311
356
  end
312
357
  end
313
-
358
+
314
359
  describe '#video_path' do
315
360
  context 'with regular files' do
316
361
  it 'prepends the videos dir' do
@@ -318,7 +363,7 @@ describe Sprockets::Helpers do
318
363
  end
319
364
  end
320
365
  end
321
-
366
+
322
367
  describe '#audio_path' do
323
368
  context 'with regular files' do
324
369
  it 'prepends the audios dir' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-11 00:00:00.000000000 Z
12
+ date: 2012-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -109,6 +109,8 @@ files:
109
109
  - gemfiles/sprockets-2.2.gemfile
110
110
  - gemfiles/sprockets-2.3.gemfile
111
111
  - gemfiles/sprockets-2.4.gemfile
112
+ - gemfiles/sprockets-2.5.gemfile
113
+ - gemfiles/sprockets-2.6.gemfile
112
114
  - lib/sprockets-helpers.rb
113
115
  - lib/sprockets/helpers.rb
114
116
  - lib/sprockets/helpers/asset_path.rb
@@ -133,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
135
  version: '0'
134
136
  segments:
135
137
  - 0
136
- hash: -275350641
138
+ hash: 193858515
137
139
  required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  none: false
139
141
  requirements:
@@ -142,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
144
  version: '0'
143
145
  segments:
144
146
  - 0
145
- hash: -275350641
147
+ hash: 193858515
146
148
  requirements: []
147
149
  rubyforge_project: sprockets-helpers
148
150
  rubygems_version: 1.8.23