image_tag_with_sane_alt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+ gem "actionpack", ">= 3"
3
+
4
+ # Add dependencies to develop your gem here.
5
+ # Include everything needed to run rake, tests, features, etc.
6
+ group :development do
7
+ gem "rspec", "~> 2.13"
8
+ gem "rdoc", "~> 3.12"
9
+ gem "bundler", "~> 1.0"
10
+ gem "jeweler", "~> 1.8"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionpack (3.2.13)
5
+ activemodel (= 3.2.13)
6
+ activesupport (= 3.2.13)
7
+ builder (~> 3.0.0)
8
+ erubis (~> 2.7.0)
9
+ journey (~> 1.0.4)
10
+ rack (~> 1.4.5)
11
+ rack-cache (~> 1.2)
12
+ rack-test (~> 0.6.1)
13
+ sprockets (~> 2.2.1)
14
+ activemodel (3.2.13)
15
+ activesupport (= 3.2.13)
16
+ builder (~> 3.0.0)
17
+ activesupport (3.2.13)
18
+ i18n (= 0.6.1)
19
+ multi_json (~> 1.0)
20
+ builder (3.0.4)
21
+ diff-lcs (1.2.4)
22
+ erubis (2.7.0)
23
+ git (1.2.5)
24
+ hike (1.2.2)
25
+ i18n (0.6.1)
26
+ jeweler (1.8.4)
27
+ bundler (~> 1.0)
28
+ git (>= 1.2.5)
29
+ rake
30
+ rdoc
31
+ journey (1.0.4)
32
+ json (1.8.0)
33
+ multi_json (1.7.4)
34
+ rack (1.4.5)
35
+ rack-cache (1.2)
36
+ rack (>= 0.4)
37
+ rack-test (0.6.2)
38
+ rack (>= 1.0)
39
+ rake (10.0.4)
40
+ rdoc (3.12.2)
41
+ json (~> 1.4)
42
+ rspec (2.13.0)
43
+ rspec-core (~> 2.13.0)
44
+ rspec-expectations (~> 2.13.0)
45
+ rspec-mocks (~> 2.13.0)
46
+ rspec-core (2.13.1)
47
+ rspec-expectations (2.13.0)
48
+ diff-lcs (>= 1.1.3, < 2.0)
49
+ rspec-mocks (2.13.1)
50
+ sprockets (2.2.2)
51
+ hike (~> 1.2)
52
+ multi_json (~> 1.0)
53
+ rack (~> 1.0)
54
+ tilt (~> 1.1, != 1.3.0)
55
+ tilt (1.4.1)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ actionpack (>= 3)
62
+ bundler (~> 1.0)
63
+ jeweler (~> 1.8)
64
+ rdoc (~> 3.12)
65
+ rspec (~> 2.13)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Todd Eichel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ [`image_tag_with_sane_alt`](http://github.com/tfe/image_tag_with_sane_alt/)
2
+ ========
3
+
4
+ Prevents default Rails behavior for `image_tag` alt text (uses the file name, which can be long and ugly). Instead, this outputs no alt text unless you specify some.
5
+
6
+ Works by monkey patching `ActionView::Helpers::AssetTagHelper`'s `image_tag` method and just setting `nil` as the alt text if nothing else is set. Setting `nil` is sufficient for preventing Rails from doing the ugly filename thing.
7
+
8
+
9
+ Installation
10
+ ------------
11
+
12
+ gem install image_tag_with_sane_alt
13
+
14
+
15
+ Usage
16
+ -----
17
+
18
+ Just works! Keep using `image_tag` like normal.
19
+
20
+
21
+ Todo
22
+ ----
23
+
24
+ * It would be cool to allow circumventing this behavior by respecting an option passed to `image_tag`. Maybe `:default_alt_behavior => true`?
25
+ * Specs would be nice.
26
+
27
+
28
+ Contact
29
+ -------
30
+
31
+ Problems, comments, and pull requests all welcome. [Find me on GitHub.](http://github.com/tfe/)
32
+
33
+
34
+ Copyright
35
+ ---------
36
+
37
+ Copyright © 2013 [Todd Eichel](http://toddeichel.com/). See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "image_tag_with_sane_alt"
18
+ gem.homepage = "http://github.com/tfe/image_tag_with_sane_alt"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Modifies default Rails behavior for image_tag alt text.}
21
+ gem.description = %Q{Prevents default Rails behavior for image_tag alt text (uses the file name, which can be long and ugly). Instead, this outputs no alt text unless you specify some.}
22
+ gem.email = "todd@toddeichel.com"
23
+ gem.authors = ["Todd Eichel"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "image_tag_with_sane_alt #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "image_tag_with_sane_alt"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Todd Eichel"]
12
+ s.date = "2013-05-29"
13
+ s.description = "Prevents default Rails behavior for image_tag alt text (uses the file name, which can be long and ugly). Instead, this outputs no alt text unless you specify some."
14
+ s.email = "todd@toddeichel.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.md",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "image_tag_with_sane_alt.gemspec",
29
+ "lib/image_tag_with_sane_alt.rb",
30
+ "lib/image_tag_with_sane_alt/image_tag_patch.rb",
31
+ "lib/image_tag_with_sane_alt/railtie.rb",
32
+ "spec/image_tag_with_sane_alt_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = "http://github.com/tfe/image_tag_with_sane_alt"
36
+ s.licenses = ["MIT"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = "1.8.23"
39
+ s.summary = "Modifies default Rails behavior for image_tag alt text."
40
+
41
+ if s.respond_to? :specification_version then
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<actionpack>, [">= 3"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.13"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
50
+ else
51
+ s.add_dependency(%q<actionpack>, [">= 3"])
52
+ s.add_dependency(%q<rspec>, ["~> 2.13"])
53
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.8"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<actionpack>, [">= 3"])
59
+ s.add_dependency(%q<rspec>, ["~> 2.13"])
60
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.8"])
63
+ end
64
+ end
65
+
@@ -0,0 +1,7 @@
1
+ module ActionView::Helpers::AssetTagHelper
2
+ def image_tag_with_sane_alt(source, options={})
3
+ options[:alt] ||= nil # set alt to nil unless already set
4
+ image_tag_without_sane_alt(source, options)
5
+ end
6
+ alias_method_chain :image_tag, :sane_alt
7
+ end
@@ -0,0 +1,9 @@
1
+ module ImageTagWithSaneAlt
2
+ class Railtie < Rails::Railtie
3
+ initializer 'image_tag_with_sane_alt.configure' do
4
+ ActiveSupport.on_load :action_view do
5
+ require 'image_tag_with_sane_alt/asset_tag_patch'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'image_tag_with_sane_alt/railtie' if defined?(Rails)
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "ImageTagWithSaneAlt" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'image_tag_with_sane_alt'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: image_tag_with_sane_alt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Todd Eichel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.13'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.13'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '1.8'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.8'
94
+ description: Prevents default Rails behavior for image_tag alt text (uses the file
95
+ name, which can be long and ugly). Instead, this outputs no alt text unless you
96
+ specify some.
97
+ email: todd@toddeichel.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files:
101
+ - LICENSE.txt
102
+ - README.md
103
+ files:
104
+ - .document
105
+ - .rspec
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - VERSION
112
+ - image_tag_with_sane_alt.gemspec
113
+ - lib/image_tag_with_sane_alt.rb
114
+ - lib/image_tag_with_sane_alt/image_tag_patch.rb
115
+ - lib/image_tag_with_sane_alt/railtie.rb
116
+ - spec/image_tag_with_sane_alt_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: http://github.com/tfe/image_tag_with_sane_alt
119
+ licenses:
120
+ - MIT
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ segments:
132
+ - 0
133
+ hash: 140390681818119989
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 1.8.23
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: Modifies default Rails behavior for image_tag alt text.
146
+ test_files: []