picture_tag 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d48ecebb20b31b6c68c89a8773d492f779897026
4
+ data.tar.gz: fdf83388d8347f676543ce06d239af3ab39c1306
5
+ SHA512:
6
+ metadata.gz: 4811204c7ce8fa711252429ee0926623fb7c5dbc1795e2dc0ef8d4014d6ec57031e30368587db977b387bd88d8001d1dbc9b9193c1dce19fa024cc70816661aa
7
+ data.tar.gz: af3a4e0d62733cda4548288fa4ccf1bfce5c706c88f3ba9a0728adbc844619c809418e2be142a9472d2918f735f4f964e1ff6918e70dc717e9d3bef7da0da502
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache: bundler
3
+ script: 'bundle exec rake'
4
+ rvm:
5
+ - 1.9.3
6
+
7
+ notifications:
8
+ email:
9
+ recipients:
10
+ - tomas.celizna@gmail.com
11
+ on_failure: change
12
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ source 'https://rails-assets.org'
3
+
4
+ # Specify your gem's dependencies in simple_form_epic_editor.gemspec
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Tomas Celizna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # PictureTag
2
+
3
+ [![Coverage Status](https://img.shields.io/coveralls/tomasc/picture_tag.svg)](https://coveralls.io/r/tomasc/picture_tag)
4
+
5
+ Rails helper for `<picture>` tag integrated with [Picturefill](http://scottjehl.github.io/picturefill/).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'picture_tag'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install picture_tag
20
+
21
+ To make it work you need to add this to your `application.js`:
22
+
23
+ //= require picture_tag
24
+
25
+ ## Usage
26
+
27
+ ```Slim
28
+ = picture_tag '/images/fallback.jpg', alt: 'Your smart alt attribute' do
29
+ = source_tag srcset: '/images/extralarge.jpg', media: '(min-width: 1000px)', size: '100vw'
30
+ = source_tag srcset: '/images/large.jpg', media: '(min-width: 800px)', size: '100vw'
31
+ = source_tag srcset: '/images/medium.jpg', size: '100vw'
32
+ ```
33
+
34
+ produces
35
+
36
+ ```HTML
37
+ <picture>
38
+ <source srcset="/images/extralarge.jpg" media="(min-width: 1000px)" size="100vw">
39
+ <source srcset="/images/large.jpg" media="(min-width: 800px)" size="100vw" >
40
+ <source srcset="/images/medium.jpg" size="100vw">
41
+ <img alt="Your smart alt attribute" src="/images/fallback.jpg">
42
+ </picture>
43
+ ```
44
+
45
+ Note that the mandatory `img` tag is automatically generated based on the arguments passed to the `picture_tag`.
46
+
47
+ ## More information
48
+
49
+ * [Picturefill](http://scottjehl.github.io/picturefill/), the neat polyfill used by this gem
50
+ * [Specification](http://picture.responsiveimages.org/) provided by [Responsive Images Community Group](http://responsiveimages.org)
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( https://github.com/[my-github-username]/picture_tag/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/*/*_test.rb'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1 @@
1
+ document.createElement( "picture" )
@@ -0,0 +1,2 @@
1
+ //= require picture_tag/picture_tag
2
+ //= require picturefill
@@ -0,0 +1,8 @@
1
+ require 'rails/engine'
2
+
3
+ module PictureTag
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'picture_tag/view_helpers'
2
+
3
+ module PictureTag
4
+ class Railtie < Rails::Railtie
5
+ initializer "picture_tag.view_helpers" do
6
+ ActionView::Base.send :include, ViewHelpers
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module PictureTag
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ require 'action_view'
2
+
3
+ module PictureTag
4
+ module ViewHelpers
5
+
6
+ def self.included klass
7
+ klass.class_eval do
8
+ include ActionView::Context
9
+ end
10
+ end
11
+
12
+ def picture_tag src, options={}, &block
13
+ content_tag :picture do
14
+ capture(&block) +
15
+ image_tag(src, options)
16
+ end
17
+ end
18
+
19
+ def source_tag options={}
20
+ tag :source, options
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ require "picture_tag/railtie" if defined?(Rails)
2
+ require "picture_tag/engine"
3
+ require "picture_tag/version"
4
+
5
+ require "rails-assets-picturefill"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'picture_tag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "picture_tag"
8
+ spec.version = PictureTag::VERSION
9
+ spec.authors = ["Tomas Celizna"]
10
+ spec.email = ["tomas.celizna@gmail.com"]
11
+ spec.summary = %q{Rails helper for <picture> tag integrated with Picturefill.}
12
+ spec.description = %q{Rails helper for <picture> tag integrated with Picturefill.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails", ">= 4.1.0"
22
+ spec.add_dependency "rails-assets-picturefill", ">= 2.0.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "coveralls"
26
+ spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "rake"
28
+ end
@@ -0,0 +1,47 @@
1
+ require 'picture_tag/view_helpers'
2
+ require 'test_helper'
3
+
4
+ module PictureTag
5
+ describe ViewHelpers do
6
+ include ViewHelpers
7
+ include ActionView::Helpers
8
+ include ActionView::Helpers::TagHelper
9
+
10
+ # =====================================================================
11
+
12
+ describe '#source_tag' do
13
+ it 'returns source tag' do
14
+ source_tag.must_match Regexp.new("<source.*?\/>")
15
+ end
16
+ end
17
+
18
+ # ---------------------------------------------------------------------
19
+
20
+ describe '#picture_tag' do
21
+ let(:src) { 'src' }
22
+ let(:alt) { 'alt' }
23
+ let(:content) { 'content' }
24
+
25
+ it 'returns picture tag' do
26
+ picture_tag(src, alt: alt) { content }.must_match Regexp.new("\\A<picture>.*?</picture>\\z")
27
+ end
28
+
29
+ it 'wraps content in the picture tag' do
30
+ picture_tag(src, alt: alt) { content }.must_match Regexp.new("<picture>.*#{content}.*</picture>")
31
+ end
32
+
33
+ it 'adds image tag after the content' do
34
+ picture_tag(src, alt: alt) { content }.must_match Regexp.new("#{content}.*<img.*?/></picture>")
35
+ end
36
+
37
+ it 'passes src to the image tag' do
38
+ picture_tag(src) { content }.must_match Regexp.new("<img.*?src=\".*?#{src}.*?\".*?/>")
39
+ end
40
+
41
+ it 'passes options to the image tag' do
42
+ picture_tag(src, alt: alt) { content }.must_match Regexp.new("<img.*?alt=\"#{alt}\".*?/>")
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ require 'action_view'
2
+ require 'action_view/helpers'
3
+ require 'bundler/setup'
4
+ require 'minitest'
5
+ require 'minitest/autorun'
6
+ require 'minitest/spec'
7
+ require 'picture_tag'
8
+ require 'rubygems'
9
+ require 'coveralls'
10
+
11
+ Coveralls.wear!
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: picture_tag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Celizna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails-assets-picturefill
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
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'
97
+ description: Rails helper for <picture> tag integrated with Picturefill.
98
+ email:
99
+ - tomas.celizna@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .coveralls.yml
105
+ - .gitignore
106
+ - .travis.yml
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/assets/javascripts/picture_tag.js
112
+ - lib/assets/javascripts/picture_tag/picture_tag.js.coffee
113
+ - lib/picture_tag.rb
114
+ - lib/picture_tag/engine.rb
115
+ - lib/picture_tag/railtie.rb
116
+ - lib/picture_tag/version.rb
117
+ - lib/picture_tag/view_helpers.rb
118
+ - picture_tag.gemspec
119
+ - test/picture_tag/view_helpers_test.rb
120
+ - test/test_helper.rb
121
+ homepage: ''
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.1.10
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Rails helper for <picture> tag integrated with Picturefill.
145
+ test_files:
146
+ - test/picture_tag/view_helpers_test.rb
147
+ - test/test_helper.rb
148
+ has_rdoc: