sprockets-helpers 0.5.0 → 0.6.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/README.md +4 -4
- data/lib/sprockets/helpers.rb +84 -12
- data/lib/sprockets/helpers/version.rb +1 -1
- data/spec/sprockets-helpers_spec.rb +24 -0
- metadata +95 -87
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
sprockets-helpers
|
2
2
|
=================
|
3
3
|
|
4
|
-
**Asset path helpers for Sprockets 2.
|
4
|
+
**Asset path helpers for Sprockets 2.x applications**
|
5
5
|
|
6
|
-
Sprockets::Helpers adds the asset_path helpers, familiar to Rails developers, to Sprockets 2.
|
6
|
+
Sprockets::Helpers adds the asset_path helpers, familiar to Rails developers, to Sprockets 2.x assets and applications.
|
7
7
|
|
8
8
|
### Features
|
9
9
|
|
10
|
-
* Includes
|
10
|
+
* Includes helpers for image, javascript, stylesheet, font, video, & audio assets.
|
11
11
|
* Automatically appends extension if necessary.
|
12
12
|
* Optionally outputs digest paths.
|
13
|
-
* Falls back to file paths in the public directory.
|
13
|
+
* Falls back to file paths in the public directory & adds cache busting timestamp.
|
14
14
|
|
15
15
|
|
16
16
|
Installation
|
data/lib/sprockets/helpers.rb
CHANGED
@@ -107,6 +107,78 @@ module Sprockets
|
|
107
107
|
end
|
108
108
|
alias_method :path_to_asset, :asset_path
|
109
109
|
|
110
|
+
# Computes the path to a audio asset either in the Sprockets environment
|
111
|
+
# or the public directory. External URIs are untouched.
|
112
|
+
#
|
113
|
+
# ==== Examples
|
114
|
+
#
|
115
|
+
# With files within Sprockets:
|
116
|
+
#
|
117
|
+
# audio_path 'audio.mp3' # => '/assets/audio.mp3'
|
118
|
+
# audio_path 'subfolder/audio.mp3' # => '/assets/subfolder/audio.mp3'
|
119
|
+
# audio_path '/subfolder/audio.mp3' # => '/assets/subfolder/audio.mp3'
|
120
|
+
#
|
121
|
+
# With files outside of Sprockets:
|
122
|
+
#
|
123
|
+
# audio_path 'audio' # => '/audios/audio'
|
124
|
+
# audio_path 'audio.mp3' # => '/audios/audio.mp3'
|
125
|
+
# audio_path 'subfolder/audio.mp3' # => '/audios/subfolder/audio.mp3'
|
126
|
+
# audio_path '/subfolder/audio.mp3 # => '/subfolder/audio.mp3'
|
127
|
+
# audio_path 'http://www.example.com/img/audio.mp3' # => 'http://www.example.com/img/audio.mp3'
|
128
|
+
#
|
129
|
+
def audio_path(source, options = {})
|
130
|
+
asset_path source, { :dir => 'audios' }.merge(options)
|
131
|
+
end
|
132
|
+
alias_method :path_to_audio, :audio_path
|
133
|
+
|
134
|
+
# Computes the path to a font asset either in the Sprockets environment
|
135
|
+
# or the public directory. External URIs are untouched.
|
136
|
+
#
|
137
|
+
# ==== Examples
|
138
|
+
#
|
139
|
+
# With files within Sprockets:
|
140
|
+
#
|
141
|
+
# font_path 'font.ttf' # => '/assets/font.ttf'
|
142
|
+
# font_path 'subfolder/font.ttf' # => '/assets/subfolder/font.ttf'
|
143
|
+
# font_path '/subfolder/font.ttf' # => '/assets/subfolder/font.ttf'
|
144
|
+
#
|
145
|
+
# With files outside of Sprockets:
|
146
|
+
#
|
147
|
+
# font_path 'font' # => '/fonts/font'
|
148
|
+
# font_path 'font.ttf' # => '/fonts/font.ttf'
|
149
|
+
# font_path 'subfolder/font.ttf' # => '/fonts/subfolder/font.ttf'
|
150
|
+
# font_path '/subfolder/font.ttf # => '/subfolder/font.ttf'
|
151
|
+
# font_path 'http://www.example.com/img/font.ttf' # => 'http://www.example.com/img/font.ttf'
|
152
|
+
#
|
153
|
+
def font_path(source, options = {})
|
154
|
+
asset_path source, { :dir => 'fonts' }.merge(options)
|
155
|
+
end
|
156
|
+
alias_method :path_to_font, :font_path
|
157
|
+
|
158
|
+
# Computes the path to an image asset either in the Sprockets environment
|
159
|
+
# or the public directory. External URIs are untouched.
|
160
|
+
#
|
161
|
+
# ==== Examples
|
162
|
+
#
|
163
|
+
# With files within Sprockets:
|
164
|
+
#
|
165
|
+
# image_path 'edit.png' # => '/assets/edit.png'
|
166
|
+
# image_path 'icons/edit.png' # => '/assets/icons/edit.png'
|
167
|
+
# image_path '/icons/edit.png' # => '/assets/icons/edit.png'
|
168
|
+
#
|
169
|
+
# With files outside of Sprockets:
|
170
|
+
#
|
171
|
+
# image_path 'edit' # => '/images/edit'
|
172
|
+
# image_path 'edit.png' # => '/images/edit.png'
|
173
|
+
# image_path 'icons/edit.png' # => '/images/icons/edit.png'
|
174
|
+
# image_path '/icons/edit.png' # => '/icons/edit.png'
|
175
|
+
# image_path 'http://www.example.com/img/edit.png' # => 'http://www.example.com/img/edit.png'
|
176
|
+
#
|
177
|
+
def image_path(source, options = {})
|
178
|
+
asset_path source, { :dir => 'images' }.merge(options)
|
179
|
+
end
|
180
|
+
alias_method :path_to_image, :image_path
|
181
|
+
|
110
182
|
# Computes the path to a javascript asset either in the Sprockets
|
111
183
|
# environment or the public directory. If the +source+ filename has no extension,
|
112
184
|
# <tt>.js</tt> will be appended. External URIs are untouched.
|
@@ -157,29 +229,29 @@ module Sprockets
|
|
157
229
|
end
|
158
230
|
alias_method :path_to_stylesheet, :stylesheet_path
|
159
231
|
|
160
|
-
# Computes the path to
|
232
|
+
# Computes the path to a video asset either in the Sprockets environment
|
161
233
|
# or the public directory. External URIs are untouched.
|
162
234
|
#
|
163
235
|
# ==== Examples
|
164
236
|
#
|
165
237
|
# With files within Sprockets:
|
166
238
|
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
239
|
+
# video_path 'video.mp4' # => '/assets/video.mp4'
|
240
|
+
# video_path 'subfolder/video.mp4' # => '/assets/subfolder/video.mp4'
|
241
|
+
# video_path '/subfolder/video.mp4' # => '/assets/subfolder/video.mp4'
|
170
242
|
#
|
171
243
|
# With files outside of Sprockets:
|
172
244
|
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
245
|
+
# video_path 'video' # => '/videos/video'
|
246
|
+
# video_path 'video.mp4' # => '/videos/video.mp4'
|
247
|
+
# video_path 'subfolder/video.mp4' # => '/videos/subfolder/video.mp4'
|
248
|
+
# video_path '/subfolder/video.mp4 # => '/subfolder/video.mp4'
|
249
|
+
# video_path 'http://www.example.com/img/video.mp4' # => 'http://www.example.com/img/video.mp4'
|
178
250
|
#
|
179
|
-
def
|
180
|
-
asset_path source, { :dir => '
|
251
|
+
def video_path(source, options = {})
|
252
|
+
asset_path source, { :dir => 'videos' }.merge(options)
|
181
253
|
end
|
182
|
-
alias_method :
|
254
|
+
alias_method :path_to_video, :video_path
|
183
255
|
|
184
256
|
protected
|
185
257
|
|
@@ -298,4 +298,28 @@ describe Sprockets::Helpers do
|
|
298
298
|
end
|
299
299
|
end
|
300
300
|
end
|
301
|
+
|
302
|
+
describe '#font_path' do
|
303
|
+
context 'with regular files' do
|
304
|
+
it 'prepends the fonts dir' do
|
305
|
+
context.font_path('font.ttf').should == '/fonts/font.ttf'
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe '#video_path' do
|
311
|
+
context 'with regular files' do
|
312
|
+
it 'prepends the videos dir' do
|
313
|
+
context.video_path('video.mp4').should == '/videos/video.mp4'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe '#audio_path' do
|
319
|
+
context 'with regular files' do
|
320
|
+
it 'prepends the audios dir' do
|
321
|
+
context.audio_path('audio.mp3').should == '/audios/audio.mp3'
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
301
325
|
end
|
metadata
CHANGED
@@ -1,103 +1,107 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-helpers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Pete Browne
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
date: 2012-06-24 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
23
|
none: false
|
18
|
-
requirements:
|
24
|
+
requirements:
|
19
25
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
22
|
-
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 0
|
31
|
+
version: "2.0"
|
32
|
+
version_requirements: *id001
|
33
|
+
name: sprockets
|
23
34
|
prerelease: false
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
38
|
none: false
|
26
|
-
requirements:
|
39
|
+
requirements:
|
27
40
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 4
|
46
|
+
version: "0.4"
|
47
|
+
version_requirements: *id002
|
31
48
|
name: appraisal
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0.4'
|
38
|
-
type: :development
|
39
49
|
prerelease: false
|
40
|
-
|
50
|
+
type: :development
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
53
|
none: false
|
42
|
-
requirements:
|
54
|
+
requirements:
|
43
55
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 15
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 6
|
61
|
+
version: "2.6"
|
62
|
+
version_requirements: *id003
|
47
63
|
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.6'
|
54
|
-
type: :development
|
55
64
|
prerelease: false
|
56
|
-
|
65
|
+
type: :development
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
57
68
|
none: false
|
58
|
-
requirements:
|
69
|
+
requirements:
|
59
70
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 11
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 2
|
76
|
+
version: "1.2"
|
77
|
+
version_requirements: *id004
|
63
78
|
name: test-construct
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.2'
|
70
|
-
type: :development
|
71
79
|
prerelease: false
|
72
|
-
|
80
|
+
type: :development
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
83
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
version_requirements: *id005
|
79
92
|
name: rake
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
93
|
prerelease: false
|
88
|
-
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
+
type: :development
|
94
95
|
description: Asset path helpers for Sprockets 2.x applications
|
95
|
-
email:
|
96
|
+
email:
|
96
97
|
- me@petebrowne.com
|
97
98
|
executables: []
|
99
|
+
|
98
100
|
extensions: []
|
101
|
+
|
99
102
|
extra_rdoc_files: []
|
100
|
-
|
103
|
+
|
104
|
+
files:
|
101
105
|
- .gitignore
|
102
106
|
- Appraisals
|
103
107
|
- Gemfile
|
@@ -119,36 +123,40 @@ files:
|
|
119
123
|
- spec/spec_helper.rb
|
120
124
|
- spec/sprockets-helpers_spec.rb
|
121
125
|
- sprockets-helpers.gemspec
|
126
|
+
has_rdoc: true
|
122
127
|
homepage: https://github.com/petebrowne/sprockets-helpers
|
123
128
|
licenses: []
|
129
|
+
|
124
130
|
post_install_message:
|
125
131
|
rdoc_options: []
|
126
|
-
|
132
|
+
|
133
|
+
require_paths:
|
127
134
|
- lib
|
128
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
136
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
134
|
-
segments:
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 3
|
141
|
+
segments:
|
135
142
|
- 0
|
136
|
-
|
137
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
version: "0"
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
145
|
none: false
|
139
|
-
requirements:
|
140
|
-
- -
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
|
143
|
-
segments:
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
144
151
|
- 0
|
145
|
-
|
152
|
+
version: "0"
|
146
153
|
requirements: []
|
154
|
+
|
147
155
|
rubyforge_project: sprockets-helpers
|
148
|
-
rubygems_version: 1.
|
156
|
+
rubygems_version: 1.6.2
|
149
157
|
signing_key:
|
150
158
|
specification_version: 3
|
151
159
|
summary: Asset path helpers for Sprockets 2.x applications
|
152
|
-
test_files:
|
160
|
+
test_files:
|
153
161
|
- spec/spec_helper.rb
|
154
162
|
- spec/sprockets-helpers_spec.rb
|