dimensions-rails 1.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.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dimensions-rails.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Elia Schito
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,34 @@
1
+ # Dimensions::Rails
2
+
3
+ Use [dimensions](http://github.com/sstephenson/dimensions) by [@sstephenson](http://github.com/sstephenson) to add automatic images size and improve browser rendering.
4
+
5
+ ### How this improves browser rendering?
6
+
7
+ See: https://developers.google.com/speed/docs/best-practices/rendering#SpecifyImageDimensions
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'dimensions-rails'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install dimensions-rails
23
+
24
+ ## Usage
25
+
26
+ Just use the `image_tag` rails helper as usual, the `:size` options will be magically added by `dimensions-rails` elves!
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/dimensions-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Elia Schito']
6
+ gem.email = ['elia@schito.me']
7
+ gem.description = %q{Use dimensions by @sstephenson to add automatic images size and improve browser rendering}
8
+ gem.summary = %q{Improve browser rendering adding the size to <img> tags}
9
+ gem.homepage = 'http://elia.github.com/dimensions-rails'
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = 'dimensions-rails'
15
+ gem.require_paths = ['lib']
16
+ gem.version = Dimensions::Rails::VERSION
17
+
18
+ gem.add_runtime_dependency 'dimensions'
19
+ gem.add_runtime_dependency 'railties', '~> 3.0'
20
+ gem.add_runtime_dependency 'actionpack', '~> 3.0'
21
+ gem.add_runtime_dependency 'activesupport', '~> 3.0'
22
+ end
@@ -0,0 +1,38 @@
1
+ require 'dimensions-rails/version'
2
+ require 'active_support/ordered_options'
3
+ require 'rails/railtie'
4
+ require 'dimensions'
5
+
6
+ module Dimensions
7
+ module Rails
8
+
9
+ module Helper
10
+
11
+ # Use dimensions by @sstephenson to add automatic images size and improve browser rendering.
12
+ #
13
+ # How this improves browser rendering?
14
+ # https://developers.google.com/speed/docs/best-practices/rendering#SpecifyImageDimensions
15
+ #
16
+ def image_tag source, options = {}
17
+ unless options[:size]
18
+ fs_path = asset_paths.asset_for(source, nil)
19
+ options[:width], options[:height] = ::Dimensions.dimensions(fs_path)
20
+ end
21
+ super
22
+ end
23
+
24
+ end
25
+
26
+ class Railtie < ::Rails::Railtie
27
+ config.dimensions = ActiveSupport::OrderedOptions.new
28
+ config.dimensions.add_size_by_default = true
29
+
30
+
31
+ initializer 'dimensions.initialize' do
32
+ ActiveSupport.on_load(:action_view) do
33
+ include ::Dimensions::Rails::Helper
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Dimensions
2
+ module Rails
3
+ VERSION = '1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dimensions-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Elia Schito
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: dimensions
16
+ requirement: &70143501764400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70143501764400
25
+ - !ruby/object:Gem::Dependency
26
+ name: railties
27
+ requirement: &70143501763760 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70143501763760
36
+ - !ruby/object:Gem::Dependency
37
+ name: actionpack
38
+ requirement: &70143501762960 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70143501762960
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: &70143501790060 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70143501790060
58
+ description: Use dimensions by @sstephenson to add automatic images size and improve
59
+ browser rendering
60
+ email:
61
+ - elia@schito.me
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - .gitignore
67
+ - Gemfile
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - dimensions-rails.gemspec
72
+ - lib/dimensions-rails.rb
73
+ - lib/dimensions-rails/version.rb
74
+ homepage: http://elia.github.com/dimensions-rails
75
+ licenses: []
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.17
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Improve browser rendering adding the size to <img> tags
98
+ test_files: []