image_tag_silent_alt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @rubygems
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rails', '> 3.2.0'
5
+ end
6
+
7
+ # Specify your gem's dependencies in image_tag_silent_alt.gemspec
8
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Philip Hallstrom
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # ImageTagSilentAlt
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/image_tag_silent_alt.png)](http://badge.fury.io/rb/image_tag_silent_alt)
4
+
5
+ In a call to `image_tag` Rails will set the `alt` attribute to the filename by default.
6
+ This gem sets an empty `alt` attribute unless it's already been set.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'image_tag_silent_alt'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install image_tag_silent_alt
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib'
6
+ test.libs << 'test'
7
+ test.pattern = 'test/**/test_*.rb'
8
+ test.verbose = true
9
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'image_tag_silent_alt/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "image_tag_silent_alt"
8
+ gem.version = ImageTagSilentAlt::VERSION
9
+ gem.authors = ["Philip Hallstrom"]
10
+ gem.email = ["philip@pjkh.com"]
11
+ gem.description = %q{Set an image's alt attribute to a blank string by default.}
12
+ gem.summary = %q{Set an image's alt attribute to a blank string by default.}
13
+ gem.homepage = "https://github.com/phallstrom/image_tag_silent_alt"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,3 @@
1
+ module ImageTagSilentAlt
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ require "image_tag_silent_alt/version"
2
+ require "action_view"
3
+
4
+ module ImageTagSilentAlt
5
+ module ActionViewExtensions
6
+
7
+ def image_tag(source, options = {})
8
+ options.symbolize_keys!
9
+ options[:alt] ||= ''
10
+ super
11
+ end
12
+
13
+ end
14
+ end
15
+
16
+ ActionView::Base.send :include, ImageTagSilentAlt::ActionViewExtensions
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+
3
+ ['actionpack/lib', 'actionpack/lib/action_view'].each do |p|
4
+ path = File.dirname(__FILE__) + "/../../../rails/#{p}"
5
+ next unless File.directory?(path)
6
+ $:.unshift(path)
7
+ end
8
+
9
+ require 'action_controller'
10
+ require 'action_controller/assertions'
11
+ require 'action_view'
12
+
13
+ require File.dirname(__FILE__) + "/../lib/image_tag_silent_alt.rb"
14
+
15
+ require 'test/unit'
16
+
17
+ class ImageTagSilentAltTest < Test::Unit::TestCase
18
+ include ActionView::Helpers::TagHelper
19
+ include ActionView::Helpers::UrlHelper
20
+ include ActionView::Helpers::AssetTagHelper
21
+
22
+ def setup
23
+ @controller = Class.new do
24
+
25
+ attr_accessor :request
26
+
27
+ def url_for(options, *parameters_for_method_reference)
28
+ "http://www.example.com"
29
+ end
30
+
31
+ end.new
32
+
33
+ @request = Class.new do
34
+ def relative_url_root
35
+ ""
36
+ end
37
+
38
+ def protocol
39
+ 'http://'
40
+ end
41
+ end.new
42
+
43
+ @controller.request = @request
44
+
45
+ ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
46
+ end
47
+
48
+ def teardown
49
+ Object.send(:remove_const, :RAILS_ROOT) if defined?(RAILS_ROOT)
50
+ ENV["RAILS_ASSET_ID"] = nil
51
+ end
52
+
53
+ ImageLinkToTag = {
54
+ %(image_tag("xml.png")) => %(<img alt="" src="/images/xml.png" />),
55
+ %(image_tag("rss.png", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.png" />),
56
+ %(image_tag("rss.png", :alt => "")) => %(<img alt="" src="/images/rss.png" />),
57
+ %(image_tag("gold.png", :size => "45x70")) => %(<img alt="" height="70" src="/images/gold.png" width="45" />),
58
+ %(image_tag("symbolize.png", "size" => "45x70")) => %(<img alt="" height="70" src="/images/symbolize.png" width="45" />),
59
+ %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="" src="http://www.rubyonrails.com/images/rails.png" />)
60
+ }
61
+
62
+ def test_image_tag
63
+ ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
64
+ end
65
+
66
+ end
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require 'action_controller'
5
+ require 'action_view'
6
+ require 'action_view/template'
7
+ require 'action_view/test_case'
8
+
9
+ require 'image_tag_silent_alt'
10
+
11
+ class TestStylesheetsForAll < ActionView::TestCase
12
+ tests ActionView::Helpers::AssetTagHelper
13
+ tests ImageTagSilentAlt::ActionViewExtensions
14
+
15
+ ImageLinkToTag = {
16
+ %(image_tag("xml.png")) => %(<img alt="" src="/images/xml.png" />),
17
+ %(image_tag("rss.png", :alt => "rss syndication")) => %(<img alt="rss syndication" src="/images/rss.png" />),
18
+ %(image_tag("rss.png", :alt => "")) => %(<img alt="" src="/images/rss.png" />),
19
+ %(image_tag("gold.png", :size => "45x70")) => %(<img alt="" height="70" src="/images/gold.png" width="45" />),
20
+ %(image_tag("symbolize.png", "size" => "45x70")) => %(<img alt="" height="70" src="/images/symbolize.png" width="45" />),
21
+ %(image_tag("http://www.rubyonrails.com/images/rails.png")) => %(<img alt="" src="http://www.rubyonrails.com/images/rails.png" />)
22
+ }
23
+
24
+ def test_stylesheet_link_tag
25
+ ENV["RAILS_ASSET_ID"] = ""
26
+ ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
27
+ end
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: image_tag_silent_alt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Philip Hallstrom
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Set an image's alt attribute to a blank string by default.
15
+ email:
16
+ - philip@pjkh.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rvmrc
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - image_tag_silent_alt.gemspec
28
+ - lib/image_tag_silent_alt.rb
29
+ - lib/image_tag_silent_alt/version.rb
30
+ - test/image_tag_default_alt_test.rb
31
+ - test/test_image_tag_silent_alt.rb
32
+ homepage: https://github.com/phallstrom/image_tag_silent_alt
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ segments:
45
+ - 0
46
+ hash: 3455838494270949707
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ segments:
54
+ - 0
55
+ hash: 3455838494270949707
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.24
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Set an image's alt attribute to a blank string by default.
62
+ test_files:
63
+ - test/image_tag_default_alt_test.rb
64
+ - test/test_image_tag_silent_alt.rb