padrino-assets 0.2.1 → 0.2.2
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/lib/padrino-assets/helpers.rb +18 -12
- data/lib/padrino-assets/version.rb +1 -1
- data/test/test_helpers.rb +146 -7
- metadata +12 -12
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
##
|
|
42
42
|
# Returns an HTML script tag for the specified sources
|
|
43
43
|
#
|
|
44
|
-
# @overload include_javascript(sources, options
|
|
44
|
+
# @overload include_javascript(sources, options)
|
|
45
45
|
# @param [Array<String, Symbol>] sources
|
|
46
46
|
# Sources
|
|
47
47
|
# @param [Hash] options
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
# Script tag for +sources+ with specified +options+.
|
|
52
52
|
#
|
|
53
53
|
# @example
|
|
54
|
-
#
|
|
54
|
+
# include_javascripts :application, :jquery
|
|
55
55
|
# # => <script type="text/javascript" src="/assets/application.js"></script>
|
|
56
56
|
# # => <script type="text/javascript" src="/assets/jquery.js"></script>
|
|
57
57
|
#
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
# @api public
|
|
63
63
|
def include_javascript(*sources)
|
|
64
64
|
options = sources.extract_options!.symbolize_keys
|
|
65
|
-
options.reverse_merge!(type: 'text/javascript'
|
|
65
|
+
options.reverse_merge!(type: 'text/javascript')
|
|
66
66
|
sources.collect do |source|
|
|
67
|
-
|
|
67
|
+
content_tag(:script, nil, options.reverse_merge(src: asset_path(source, :js)))
|
|
68
68
|
end.join("\n")
|
|
69
69
|
end
|
|
70
70
|
alias_method :include_javascripts, :include_javascript
|
|
@@ -96,26 +96,26 @@
|
|
|
96
96
|
#
|
|
97
97
|
# @example
|
|
98
98
|
# image 'example.png'
|
|
99
|
-
# # => <img src="/assets/example.png" alt="Example"
|
|
99
|
+
# # => <img src="/assets/example.png" alt="Example">
|
|
100
100
|
#
|
|
101
101
|
# image 'example.png', size: '40x40'
|
|
102
|
-
# # => <img src="/assets/example.png" width="40" height="40" alt="Example"
|
|
102
|
+
# # => <img src="/assets/example.png" width="40" height="40" alt="Example">
|
|
103
103
|
#
|
|
104
104
|
# image 'example.png', width: 40
|
|
105
|
-
# # => <img src="/assets/example.png" width="40" alt="Example"
|
|
105
|
+
# # => <img src="/assets/example.png" width="40" alt="Example">
|
|
106
106
|
#
|
|
107
107
|
# image 'example.png', height: 40
|
|
108
|
-
# # => <img src="/assets/example.png" height="40" alt="Example"
|
|
108
|
+
# # => <img src="/assets/example.png" height="40" alt="Example">
|
|
109
109
|
#
|
|
110
110
|
# image 'example.png', alt: 'My Little Pony'
|
|
111
|
-
# # => <img src="/assets/example.png" alt="My Little Pony"
|
|
111
|
+
# # => <img src="/assets/example.png" alt="My Little Pony">
|
|
112
112
|
#
|
|
113
113
|
# image 'http://www.example.com/example.png'
|
|
114
|
-
# # => <img src="http://www.example.com/example.png"
|
|
114
|
+
# # => <img src="http://www.example.com/example.png">
|
|
115
115
|
#
|
|
116
116
|
# images 'example.png', 'example.jpg'
|
|
117
|
-
# # => <img src="/assets/example.png" alt="Example"
|
|
118
|
-
# # => <img src="/assets/example.jpg" alt="Example"
|
|
117
|
+
# # => <img src="/assets/example.png" alt="Example">
|
|
118
|
+
# # => <img src="/assets/example.jpg" alt="Example">
|
|
119
119
|
#
|
|
120
120
|
# @since 0.1.0
|
|
121
121
|
# @api public
|
|
@@ -199,6 +199,11 @@
|
|
|
199
199
|
# @api public
|
|
200
200
|
def video(*sources)
|
|
201
201
|
options = sources.extract_options!.symbolize_keys
|
|
202
|
+
sources = sources.first if sources.size == 1
|
|
203
|
+
|
|
204
|
+
if options[:poster]
|
|
205
|
+
options[:poster] = asset_path(options[:poster])
|
|
206
|
+
end
|
|
202
207
|
|
|
203
208
|
if size = options.delete(:size)
|
|
204
209
|
options[:width], options[:height] = size.split('x') if size =~ /^[0-9]+x[0-9]+$/
|
|
@@ -262,6 +267,7 @@
|
|
|
262
267
|
# @api public
|
|
263
268
|
def audio(*sources)
|
|
264
269
|
options = sources.extract_options!.symbolize_keys
|
|
270
|
+
sources = sources.first if sources.size == 1
|
|
265
271
|
|
|
266
272
|
if sources.is_a?(Array)
|
|
267
273
|
content_tag(:audio, options) do
|
data/test/test_helpers.rb
CHANGED
|
@@ -52,7 +52,7 @@ describe 'Helpers' do
|
|
|
52
52
|
asset.must_equal '/test/application.css'
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
it 'should not interfere with a
|
|
55
|
+
it 'should not interfere with a reference URI' do
|
|
56
56
|
asset = asset_path('/application.css')
|
|
57
57
|
asset.must_equal '/application.css'
|
|
58
58
|
|
|
@@ -158,17 +158,17 @@ describe 'Helpers' do
|
|
|
158
158
|
image.must_have_tag :img, width: '40', height: '40'
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
it 'should allow you to set the width and height with size' do
|
|
161
|
+
it 'should allow you to set the :width and :height with size' do
|
|
162
162
|
image = image 'application.jpg', size: '40x40'
|
|
163
163
|
image.must_have_tag :img, width: '40', height: '40'
|
|
164
164
|
end
|
|
165
165
|
|
|
166
|
-
it 'should allow you to set the width' do
|
|
166
|
+
it 'should allow you to set the :width' do
|
|
167
167
|
image = image 'application.jpg', width: '40'
|
|
168
168
|
image.must_have_tag :img, width: '40'
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
it 'should allow you to set the height' do
|
|
171
|
+
it 'should allow you to set the :height' do
|
|
172
172
|
image = image 'application.jpg', height: '40'
|
|
173
173
|
image.must_have_tag :img, height: '40'
|
|
174
174
|
end
|
|
@@ -180,15 +180,15 @@ describe 'Helpers' do
|
|
|
180
180
|
|
|
181
181
|
it 'should automatically set an alternate text when none present' do
|
|
182
182
|
image = image 'application.jpg'
|
|
183
|
-
image.must_have_tag :img, alt: '
|
|
183
|
+
image.must_have_tag :img, alt: 'Application'
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
-
it 'should allow you to set the class' do
|
|
186
|
+
it 'should allow you to set the :class' do
|
|
187
187
|
image = image 'application.jpg', class: 'image'
|
|
188
188
|
image.must_have_tag :img, class: 'image'
|
|
189
189
|
end
|
|
190
190
|
|
|
191
|
-
it 'should allow you to set the
|
|
191
|
+
it 'should allow you to set the :id' do
|
|
192
192
|
image = image 'application.jpg', id: 'logo'
|
|
193
193
|
image.must_have_tag :img, id: 'logo'
|
|
194
194
|
end
|
|
@@ -197,4 +197,143 @@ describe 'Helpers' do
|
|
|
197
197
|
respond_to?(:image_tag).must_equal true
|
|
198
198
|
end
|
|
199
199
|
end
|
|
200
|
+
|
|
201
|
+
describe 'video' do
|
|
202
|
+
it 'should accept multiple sources' do
|
|
203
|
+
videos = videos 'test.webm', 'test.mov'
|
|
204
|
+
videos.must_have_tag :source, src: '/assets/test.webm'
|
|
205
|
+
videos.must_have_tag :source, src: '/assets/test.mov'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it 'should accept multiple sources with attributes' do
|
|
209
|
+
videos = videos 'test.webm', 'test.mov', width: '40', height: '40'
|
|
210
|
+
videos.must_have_tag :video, width: '40', height: '40'
|
|
211
|
+
videos.must_have_tag :source, src: '/assets/test.webm'
|
|
212
|
+
videos.must_have_tag :source, src: '/assets/test.mov'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it 'should accept a single source' do
|
|
216
|
+
video = video 'test.webm'
|
|
217
|
+
video.must_have_tag :video, src: '/assets/test.webm'
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
it 'should accept a single source with attributes' do
|
|
221
|
+
video = video 'test.webm', width: '40', height: '40'
|
|
222
|
+
video.must_have_tag :video, src: '/assets/test.webm', width: '40', height: '40'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'should allow you to set the :class' do
|
|
226
|
+
video = video 'test.webm', class: 'video'
|
|
227
|
+
video.must_have_tag :video, class: 'video'
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it 'should allow you to set the :id' do
|
|
231
|
+
video = video 'test.webm', id: 'video'
|
|
232
|
+
video.must_have_tag :video, id: 'video'
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
it 'should allow you to set the :width and :height with :size' do
|
|
236
|
+
video = video 'test.webm', size: '40x40'
|
|
237
|
+
video.must_have_tag :video, width: '40', height: '40'
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
it 'should allow you to set the :width' do
|
|
241
|
+
video = video 'test.webm', width: '40'
|
|
242
|
+
video.must_have_tag :video, width: '40'
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'should allow you to set the :height' do
|
|
246
|
+
video = video 'test.webm', height: '40'
|
|
247
|
+
video.must_have_tag :video, height: '40'
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it 'should allow :poster to use an absolute URI' do
|
|
251
|
+
video = video 'test.webm', poster: 'http://test.com/poster.jpg'
|
|
252
|
+
video.must_have_tag :video, poster: 'http://test.com/poster.jpg'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it 'should use asset_path when :poster is present' do
|
|
256
|
+
video = video 'test.webm', poster: 'poster.jpg'
|
|
257
|
+
video.must_have_tag :video, poster: '/assets/poster.jpg'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
it 'should allow you to set the :preload method' do
|
|
261
|
+
video = video 'test.webm', preload: 'auto'
|
|
262
|
+
video.must_have_tag :video, preload: 'auto'
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
it 'should allow you to set :muted to true' do
|
|
266
|
+
video = video 'test.webm', muted: true
|
|
267
|
+
video.must_have_tag :video, muted: 'muted'
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
it 'should allow you to set :autoplay to true' do
|
|
271
|
+
video = video 'test.webm', autoplay: true
|
|
272
|
+
video.must_have_tag :video, autoplay: 'autoplay'
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it 'should allow you to set :loop to true' do
|
|
276
|
+
video = video 'test.webm', loop: true
|
|
277
|
+
video.must_have_tag :video, loop: 'loop'
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
it 'should allow you to set :controls to true' do
|
|
281
|
+
video = video 'test.webm', controls: true
|
|
282
|
+
video.must_have_tag :video, controls: 'controls'
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
it 'should be aliased for compatibility' do
|
|
286
|
+
respond_to?(:video_tag).must_equal true
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
describe 'audio' do
|
|
291
|
+
it 'should accept multiple sources' do
|
|
292
|
+
audios = audios 'test.ogg', 'test.aac'
|
|
293
|
+
audios.must_have_tag :source, src: '/assets/test.ogg'
|
|
294
|
+
audios.must_have_tag :source, src: '/assets/test.aac'
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it 'should accept multiple sources with attributes' do
|
|
298
|
+
audios = audios 'test.ogg', 'test.aac', id: 'audio'
|
|
299
|
+
audios.must_have_tag :audio, id: 'audio'
|
|
300
|
+
audios.must_have_tag :source, src: '/assets/test.ogg'
|
|
301
|
+
audios.must_have_tag :source, src: '/assets/test.aac'
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it 'should accept a single source' do
|
|
305
|
+
audio = audio 'test.ogg'
|
|
306
|
+
audio.must_have_tag :audio, src: '/assets/test.ogg'
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it 'should accept a single source with attributes' do
|
|
310
|
+
audio = audio 'test.ogg', id: 'audio'
|
|
311
|
+
audio.must_have_tag :audio, src: '/assets/test.ogg', id: 'audio'
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
it 'should allow you to set the :class' do
|
|
315
|
+
audio = audio 'test.ogg', class: 'audio'
|
|
316
|
+
audio.must_have_tag :audio, class: 'audio'
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
it 'should allow you to set the :id' do
|
|
320
|
+
audio = audio 'test.ogg', id: 'audio'
|
|
321
|
+
audio.must_have_tag :audio, id: 'audio'
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
it 'should allow you to set :autoplay to true' do
|
|
325
|
+
audio = audio 'test.ogg', autoplay: true
|
|
326
|
+
audio.must_have_tag :audio, autoplay: 'autoplay'
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
it 'should allow you to set :loop to true' do
|
|
330
|
+
audio = audio 'test.ogg', loop: true
|
|
331
|
+
audio.must_have_tag :audio, loop: 'loop'
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it 'should allow you to set :controls to true' do
|
|
335
|
+
audio = audio 'test.ogg', controls: true
|
|
336
|
+
audio.must_have_tag :audio, controls: 'controls'
|
|
337
|
+
end
|
|
338
|
+
end
|
|
200
339
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: padrino-assets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-01-
|
|
12
|
+
date: 2012-01-23 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sprockets
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &6755340 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 2.3.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *6755340
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: padrino-core
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &6755090 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *6755090
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: padrino-helpers
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &6754830 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: '0'
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *6754830
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: minitest
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &6754570 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: '0'
|
|
55
55
|
type: :development
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *6754570
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: webrat
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &6754330 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,7 +65,7 @@ dependencies:
|
|
|
65
65
|
version: '0'
|
|
66
66
|
type: :development
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *6754330
|
|
69
69
|
description: A plugin for the Padrino web framework which uses Sprockets to manage
|
|
70
70
|
and compile assets
|
|
71
71
|
email:
|