dimensions-rails 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.md +8 -9
- data/lib/dimensions-rails.rb +6 -2
- data/lib/dimensions-rails/version.rb +1 -1
- metadata +17 -16
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Dimensions::Rails
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/elia/dimensions-rails.png?branch=master)](http://travis-ci.org/elia/dimensions-rails)
|
4
|
+
|
3
5
|
```erb
|
4
6
|
<%= image_tag 'logo.png' %>
|
5
7
|
```
|
@@ -10,6 +12,7 @@
|
|
10
12
|
|
11
13
|
It uses [dimensions](http://github.com/sstephenson/dimensions) by [@sstephenson](http://github.com/sstephenson) to add automatic images size and improve browser rendering.
|
12
14
|
|
15
|
+
|
13
16
|
### How this improves browser rendering?
|
14
17
|
|
15
18
|
See: https://developers.google.com/speed/docs/best-practices/rendering#SpecifyImageDimensions
|
@@ -19,24 +22,20 @@ See: https://developers.google.com/speed/docs/best-practices/rendering#SpecifyIm
|
|
19
22
|
|
20
23
|
Add this line to your application's Gemfile:
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
$ bundle
|
27
|
-
|
28
|
-
Or install it yourself as:
|
25
|
+
```ruby
|
26
|
+
gem 'dimensions-rails'
|
27
|
+
```
|
29
28
|
|
30
|
-
$ gem install dimensions-rails
|
31
29
|
|
32
30
|
## Usage
|
33
31
|
|
34
32
|
Just use the `image_tag` rails helper as usual, the `:size` options will be magically added by `dimensions-rails` elves!
|
35
33
|
|
34
|
+
|
36
35
|
## Contributing
|
37
36
|
|
38
37
|
1. Fork it
|
39
38
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
39
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
41
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
4. Push to the branch (`git push -u origin my-new-feature`)
|
42
41
|
5. Create new Pull Request
|
data/lib/dimensions-rails.rb
CHANGED
@@ -16,7 +16,12 @@ module Dimensions
|
|
16
16
|
#
|
17
17
|
def image_tag source, options = {}
|
18
18
|
unless options[:size] or options[:width] or options[:height]
|
19
|
-
fs_path =
|
19
|
+
fs_path = begin
|
20
|
+
asset_paths.asset_for(source, nil)
|
21
|
+
rescue Sprockets::FileOutsidePaths
|
22
|
+
nil
|
23
|
+
end if respond_to? :asset_paths
|
24
|
+
|
20
25
|
fs_path = fs_path.present? ? fs_path.to_path : File.join(::Rails.public_path, source)
|
21
26
|
|
22
27
|
if fs_path.present? and File.exist? fs_path
|
@@ -32,7 +37,6 @@ module Dimensions
|
|
32
37
|
config.dimensions = ActiveSupport::OrderedOptions.new
|
33
38
|
config.dimensions.add_size_by_default = true
|
34
39
|
|
35
|
-
|
36
40
|
initializer 'dimensions.initialize' do
|
37
41
|
ActiveSupport.on_load(:action_view) do
|
38
42
|
include ::Dimensions::Rails::Helper
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dimensions-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dimensions
|
16
|
-
requirement: &
|
16
|
+
requirement: &70234360267640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70234360267640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: railties
|
27
|
-
requirement: &
|
27
|
+
requirement: &70234360266600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70234360266600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: actionpack
|
38
|
-
requirement: &
|
38
|
+
requirement: &70234359966780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70234359966780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
|
-
requirement: &
|
49
|
+
requirement: &70234359966180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70234359966180
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &70234359965460 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70234359965460
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec-rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &70234359964360 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '2.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70234359964360
|
80
80
|
description: Use dimensions by @sstephenson to add automatic images size and improve
|
81
81
|
browser rendering
|
82
82
|
email:
|
@@ -87,6 +87,7 @@ extra_rdoc_files: []
|
|
87
87
|
files:
|
88
88
|
- .gitignore
|
89
89
|
- .rspec
|
90
|
+
- .travis.yml
|
90
91
|
- Gemfile
|
91
92
|
- LICENSE
|
92
93
|
- README.md
|
@@ -145,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
146
|
version: '0'
|
146
147
|
segments:
|
147
148
|
- 0
|
148
|
-
hash:
|
149
|
+
hash: -515983816017865509
|
149
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
151
|
none: false
|
151
152
|
requirements:
|
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
155
|
version: '0'
|
155
156
|
segments:
|
156
157
|
- 0
|
157
|
-
hash:
|
158
|
+
hash: -515983816017865509
|
158
159
|
requirements: []
|
159
160
|
rubyforge_project:
|
160
161
|
rubygems_version: 1.8.17
|