picture_tag 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/Gemfile +4 -1
- data/README.md +15 -4
- data/lib/picture_tag.rb +4 -4
- data/lib/picture_tag/railtie.rb +1 -1
- data/lib/picture_tag/version.rb +1 -1
- data/lib/picture_tag/view_helpers.rb +6 -8
- data/picture_tag.gemspec +15 -15
- data/test/picture_tag/view_helpers_test.rb +3 -4
- data/test/test_helper.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4696873e437ef6264ca7b71dbc69e4ae404a73bb
|
4
|
+
data.tar.gz: 3be7abdbb509e1d577438c3e7cdbbc723d06189d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f08f6720763c18d504994b2c67af50f50a915f94a0e389b48a56ec2a95ac812bc37abe93eb66446b6c8135c69765b1e84626060d28ed95a7e71e783624e4414d
|
7
|
+
data.tar.gz: e90348674340f5525a9f15b8beeee89da2e2f5c72c8473022ac4d72b2a04b27ecf7d892a56af2deb5d18ab3118d08ebdf8689b42a4658e844f18c8690ae3c4a1
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,21 +6,32 @@ Rails helper for `<picture>` tag integrated with [Picturefill](http://scottjehl.
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Add this
|
9
|
+
Add this to your application's Gemfile:
|
10
10
|
|
11
|
+
```ruby
|
11
12
|
gem 'picture_tag'
|
13
|
+
source 'https://rails-assets.org' do
|
14
|
+
gem 'rails-assets-picturefill'
|
15
|
+
end
|
16
|
+
```
|
12
17
|
|
13
18
|
And then execute:
|
14
19
|
|
15
|
-
|
20
|
+
```sh
|
21
|
+
$ bundle
|
22
|
+
```
|
16
23
|
|
17
24
|
Or install it yourself as:
|
18
25
|
|
19
|
-
|
26
|
+
```sh
|
27
|
+
$ gem install picture_tag
|
28
|
+
```
|
20
29
|
|
21
30
|
To make it work you need to add this to your `application.js`:
|
22
31
|
|
23
|
-
|
32
|
+
```JS
|
33
|
+
//= require picture_tag
|
34
|
+
```
|
24
35
|
|
25
36
|
## Usage
|
26
37
|
|
data/lib/picture_tag.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'picture_tag/railtie' if defined?(Rails)
|
2
|
+
require 'picture_tag/engine'
|
3
|
+
require 'picture_tag/version'
|
4
4
|
|
5
|
-
require
|
5
|
+
require 'rails-assets-picturefill'
|
data/lib/picture_tag/railtie.rb
CHANGED
data/lib/picture_tag/version.rb
CHANGED
@@ -2,29 +2,27 @@ require 'action_view'
|
|
2
2
|
|
3
3
|
module PictureTag
|
4
4
|
module ViewHelpers
|
5
|
-
|
6
|
-
def self.included klass
|
5
|
+
def self.included(klass)
|
7
6
|
klass.class_eval do
|
8
7
|
include ActionView::Context
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
12
|
-
def picture_tag
|
11
|
+
def picture_tag(srcset, options = {}, &block)
|
13
12
|
picture_options = options.except(:image)
|
14
13
|
image_options = options.fetch(:image, {})
|
15
14
|
image_options[:srcset] = srcset
|
16
15
|
|
17
16
|
content_tag :picture, picture_options do
|
18
17
|
"<!--[if IE 9]><video style='display: none;'><![endif]-->".html_safe +
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
capture(&block).html_safe +
|
19
|
+
'<!--[if IE 9]></video><![endif]-->'.html_safe +
|
20
|
+
tag('img', image_options)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
def source_tag
|
24
|
+
def source_tag(options = {})
|
26
25
|
tag :source, options
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
30
28
|
end
|
data/picture_tag.gemspec
CHANGED
@@ -4,26 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'picture_tag/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'picture_tag'
|
8
8
|
spec.version = PictureTag::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Tomas Celizna']
|
10
|
+
spec.email = ['tomas.celizna@gmail.com']
|
11
|
+
spec.summary = 'Rails helper for <picture> tag integrated with Picturefill.'
|
12
|
+
spec.description = 'Rails helper for <picture> tag integrated with Picturefill.'
|
13
|
+
spec.homepage = 'https://github.com/tomasc/picture_tag'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'rails', '>= 3.0'
|
22
|
+
spec.add_dependency 'rails-assets-picturefill'
|
23
23
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'coveralls'
|
26
|
+
spec.add_development_dependency 'minitest'
|
27
|
+
spec.add_development_dependency 'minitest-spec'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
29
|
end
|
@@ -11,7 +11,7 @@ module PictureTag
|
|
11
11
|
|
12
12
|
describe '#source_tag' do
|
13
13
|
it 'returns source tag' do
|
14
|
-
source_tag.must_match Regexp.new(
|
14
|
+
source_tag.must_match Regexp.new('<source.*?/>')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -24,10 +24,10 @@ module PictureTag
|
|
24
24
|
let(:image_options) { { alt: alt, src: src } }
|
25
25
|
let(:content) { 'content' }
|
26
26
|
let(:ie9_start) { "<!--[if IE 9]><video style='display: none;'><![endif]-->" }
|
27
|
-
let(:ie9_end) {
|
27
|
+
let(:ie9_end) { '<!--[if IE 9]></video><![endif]-->' }
|
28
28
|
|
29
29
|
it 'returns picture tag' do
|
30
|
-
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new(
|
30
|
+
picture_tag(srcset, image: image_options) { content }.must_match Regexp.new('\\A<picture>.*?</picture>\\z')
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'wraps content in the picture tag' do
|
@@ -58,6 +58,5 @@ module PictureTag
|
|
58
58
|
(index_of_ie9_end_tag > index_of_content).must_equal true
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
61
|
end
|
63
62
|
end
|
data/test/test_helper.rb
CHANGED
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|