picture_tag 0.0.3 → 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd99d2f195ba70b1a41043775fa1b88e41faa088
4
- data.tar.gz: a1cd3e9931823d22a91482129e93ef4a2e6f2ea7
3
+ metadata.gz: c93bb3c99284e44ba64a169011a6b11ba5e7f85d
4
+ data.tar.gz: 2182c3ac69c6c4bf852c0297c9918efbef680b6a
5
5
  SHA512:
6
- metadata.gz: 7f091ff8e9399b0e5ae7166f429819c8a830a4e3f35b728918a720705bbb35d145225770b1fb56efd5dbfc6835abaccbc0b824639cd4ffff8bfb449c038840bb
7
- data.tar.gz: 391fe317013ca6805842453887fcbf0973681d832bae5b5bca2d8bd5ab57a121ba4d7375329aa802696674971c8559dbf9fc89b47b8f770a94cddc023c334176
6
+ metadata.gz: 0f3c17cbbcc097f341a1db287e7acbc29a1ccc107e917640b05175d82f2af69194d55963796c12aa72c444bff46350b505b59c5cf9119691edeb1ba9bd46b79b
7
+ data.tar.gz: f7ee8ddb7cbe653e51541f9263a8537dde134162374bc1eed9d94b1f7d23cf8c68c7f73f2adf888aa159ca16487828443d0eecd00acaca07c244cb45d798bc32
data/README.md CHANGED
@@ -25,7 +25,7 @@ To make it work you need to add this to your `application.js`:
25
25
  ## Usage
26
26
 
27
27
  ```Slim
28
- = picture_tag '/images/fallback.jpg', alt: 'Your smart alt attribute' do
28
+ = picture_tag '/images/fallback.jpg', image: { alt: 'Your smart alt attribute' } do
29
29
  = source_tag srcset: '/images/extralarge.jpg', media: '(min-width: 1000px)', sizes: '100vw'
30
30
  = source_tag srcset: '/images/large.jpg', media: '(min-width: 800px)', sizes: '100vw'
31
31
  = source_tag srcset: '/images/medium.jpg', sizes: '100vw'
@@ -6,4 +6,4 @@ module PictureTag
6
6
  ActionView::Base.send :include, ViewHelpers
7
7
  end
8
8
  end
9
- end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module PictureTag
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -10,11 +10,14 @@ module PictureTag
10
10
  end
11
11
 
12
12
  def picture_tag src, options={}, &block
13
- content_tag :picture do
13
+ image_options = options.fetch(:image, {})
14
+ picture_options = options.except(:image)
15
+
16
+ content_tag :picture, picture_options do
14
17
  "<!--[if IE 9]><video style='display: none;'><![endif]-->".html_safe +
15
18
  capture(&block) +
16
19
  "<!--[if IE 9]></video><![endif]-->".html_safe +
17
- image_tag(src, options)
20
+ image_tag(src, image_options)
18
21
  end
19
22
  end
20
23
 
@@ -23,4 +26,4 @@ module PictureTag
23
26
  end
24
27
 
25
28
  end
26
- end
29
+ end
data/picture_tag.gemspec CHANGED
@@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.6"
25
25
  spec.add_development_dependency "coveralls"
26
26
  spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "minitest-spec"
27
28
  spec.add_development_dependency "rake"
28
29
  end
@@ -19,29 +19,30 @@ module PictureTag
19
19
 
20
20
  describe '#picture_tag' do
21
21
  let(:src) { 'src' }
22
- let(:alt) { 'alt' }
22
+ let(:alt) { 'alt text' }
23
+ let(:image_options) { { alt: alt } }
23
24
  let(:content) { 'content' }
24
25
  let(:ie9_start) { "<!--[if IE 9]><video style='display: none;'><![endif]-->" }
25
26
  let(:ie9_end) { "<!--[if IE 9]></video><![endif]-->" }
26
27
 
27
28
  it 'returns picture tag' do
28
- picture_tag(src, alt: alt) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
29
+ picture_tag(src, image: image_options) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
29
30
  end
30
31
 
31
32
  it 'wraps content in the picture tag' do
32
- picture_tag(src, alt: alt) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
33
+ picture_tag(src, image: image_options) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
33
34
  end
34
35
 
35
36
  it 'adds image tag after the content' do
36
- picture_tag(src, alt: alt) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
37
+ picture_tag(src, image: image_options) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
37
38
  end
38
39
 
39
40
  it 'passes src to the image tag' do
40
41
  picture_tag(src) { content }.must_match Regexp.new("<img.*?src=\".*?#{src}.*?\".*?/>")
41
42
  end
42
43
 
43
- it 'passes options to the image tag' do
44
- picture_tag(src, alt: alt) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
44
+ it 'passes image options to the image tag' do
45
+ picture_tag(src, image: image_options) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
45
46
  end
46
47
 
47
48
  it 'wraps content with the IE9 fix' do
@@ -54,4 +55,4 @@ module PictureTag
54
55
  end
55
56
 
56
57
  end
57
- end
58
+ end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rails'
1
2
  require 'action_view'
2
3
  require 'action_view/helpers'
3
4
  require 'bundler/setup'
@@ -10,4 +11,4 @@ require 'rubygems'
10
11
  if ENV["CI"]
11
12
  require "coveralls"
12
13
  Coveralls.wear!
13
- end
14
+ end
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: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-spec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
152
  version: '0'
139
153
  requirements: []
140
154
  rubyforge_project:
141
- rubygems_version: 2.2.2
155
+ rubygems_version: 2.4.8
142
156
  signing_key:
143
157
  specification_version: 4
144
158
  summary: Rails helper for <picture> tag integrated with Picturefill.