picture_tag 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/picture_tag/version.rb +1 -1
- data/lib/picture_tag/view_helpers.rb +2 -2
- data/test/picture_tag/view_helpers_test.rb +16 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07303344956dfbc17835db1ed6b262af3f3f8c85
|
4
|
+
data.tar.gz: 928988902d49cd4e034f2c9085111396cdbc6741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c2421d15f25135c59dcfa2a89c6403aef6f7248529acbb0a0c824e5e5923550df89fc48fb04d8096a4c5d3da7f3bf7f5b25a9fe6d25041983decbee44b1c44d
|
7
|
+
data.tar.gz: 855abf42b82ce6d8584ec41a8bb97661402d3d4406563f3c9a4fcab641fe33cd480e31ff39a3862f97303402426ff600e279e2b5bf747b1ed351881f731f0de0
|
data/.gitignore
CHANGED
data/lib/picture_tag/version.rb
CHANGED
@@ -9,10 +9,10 @@ module PictureTag
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def picture_tag
|
12
|
+
def picture_tag srcset, options={}, &block
|
13
13
|
picture_options = options.except(:image)
|
14
14
|
image_options = options.fetch(:image, {})
|
15
|
-
image_options[:srcset] =
|
15
|
+
image_options[:srcset] = srcset
|
16
16
|
|
17
17
|
content_tag :picture, picture_options do
|
18
18
|
"<!--[if IE 9]><video style='display: none;'><![endif]-->".html_safe +
|
@@ -18,36 +18,41 @@ module PictureTag
|
|
18
18
|
# ---------------------------------------------------------------------
|
19
19
|
|
20
20
|
describe '#picture_tag' do
|
21
|
-
let(:
|
21
|
+
let(:srcset) { 'srcset' }
|
22
22
|
let(:alt) { 'alt text' }
|
23
|
-
let(:
|
23
|
+
let(:src) { 'foo bar src' }
|
24
|
+
let(:image_options) { { alt: alt, src: src } }
|
24
25
|
let(:content) { 'content' }
|
25
26
|
let(:ie9_start) { "<!--[if IE 9]><video style='display: none;'><![endif]-->" }
|
26
27
|
let(:ie9_end) { "<!--[if IE 9]></video><![endif]-->" }
|
27
28
|
|
28
29
|
it 'returns picture tag' do
|
29
|
-
picture_tag(
|
30
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'wraps content in the picture tag' do
|
33
|
-
picture_tag(
|
34
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'adds image tag after the content' do
|
37
|
-
picture_tag(
|
38
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
|
38
39
|
end
|
39
40
|
|
40
|
-
it 'passes
|
41
|
-
picture_tag(
|
41
|
+
it 'passes srcset to the image tag srcset' do
|
42
|
+
picture_tag(srcset) { content }.must_match Regexp.new("<img.*?srcset=\".*?#{srcset}.*?\".*?/>")
|
42
43
|
end
|
43
44
|
|
44
|
-
it 'passes
|
45
|
-
picture_tag(
|
45
|
+
it 'passes alt to the image tag' do
|
46
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'passes src to the image tag' do
|
50
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new("<img.*?src=\"#{src}\".*?/>")
|
46
51
|
end
|
47
52
|
|
48
53
|
it 'wraps content with the IE9 fix' do
|
49
|
-
index_of_content = picture_tag(
|
50
|
-
index_of_ie9_start_tag = picture_tag(
|
54
|
+
index_of_content = picture_tag(srcset) { content }.index(content)
|
55
|
+
index_of_ie9_start_tag = picture_tag(srcset) { content }.index(ie9_start)
|
51
56
|
index_of_ie9_end_tag = picture_tag(src) { content }.index(ie9_end)
|
52
57
|
(index_of_ie9_start_tag < index_of_content).must_equal true
|
53
58
|
(index_of_ie9_end_tag > index_of_content).must_equal true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picture_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|