retina_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- ## Retina Rails [![Build Status](https://secure.travis-ci.org/jhnvz/retina_rails.png?branch=master)](http://travis-ci.org/jhnvz/retina_rails)
1
+ ## Retina Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/retina_rails.png)](http://badge.fury.io/rb/retina_rails) [![Build Status](https://secure.travis-ci.org/jhnvz/retina_rails.png?branch=master)](http://travis-ci.org/jhnvz/retina_rails) [![Coverage Status](https://coveralls.io/repos/jhnvz/retina_rails/badge.png?branch=master)](https://coveralls.io/r/jhnvz/retina_rails) [![Code Climate](https://codeclimate.com/github/jhnvz/retina_rails.png)](https://codeclimate.com/github/jhnvz/retina_rails) [![Dependency Status](https://gemnasium.com/jhnvz/retina_rails.png)](https://gemnasium.com/jhnvz/retina_rails)
2
4
 
3
5
  Makes your live easier optimizing an application for retina displays.
4
6
 
@@ -80,4 +82,4 @@ Note on Patches/Pull Requests
80
82
  Copyright
81
83
  ------------
82
84
 
83
- Copyright (c) 2012 Johan van Zonneveld. See LICENSE for details.
85
+ Copyright (c) 2012 Johan van Zonneveld. See LICENSE for details.
@@ -9,17 +9,18 @@ module RetinaRails
9
9
  ## Define retina version based on defined versions in the uploader class
10
10
  versions.each do |v|
11
11
 
12
- processor = nil
12
+ processors = v[1][:uploader].processors.dup
13
+ dimensions_processor = nil
13
14
 
14
15
  ## Check if there's a resize processor to get the dimensions
15
- v[1][:uploader].processors.each do |p|
16
- processor = p if p[0].to_s.scan(/resize_to_fill|resize_to_limit|resize_to_fit|resize_and_pad/).any?
16
+ processors.each do |p|
17
+ dimensions_processor = processors.delete(p) if p[0].to_s.scan(/resize_to_fill|resize_to_limit|resize_to_fit|resize_and_pad/).any?
17
18
  end
18
19
 
19
20
  ## Define a retina version if processor is present
20
- if processor
21
+ if dimensions_processor
21
22
 
22
- options = processor[1].dup
23
+ options = dimensions_processor[1].dup
23
24
 
24
25
  width = options[0] * 2
25
26
  height = options[1] * 2
@@ -30,7 +31,12 @@ module RetinaRails
30
31
  options.insert(0, width)
31
32
 
32
33
  version "#{v[0]}_retina" do
33
- process processor[0] => options
34
+ process dimensions_processor[0] => options
35
+
36
+ ## Set other processors
37
+ processors.each do |processor|
38
+ process processor[0] => processor[1]
39
+ end
34
40
  end
35
41
 
36
42
  end
@@ -1,3 +1,3 @@
1
1
  module RetinaRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -4,10 +4,10 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'retina_rails/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "retina_rails"
7
+ gem.name = 'retina_rails'
8
8
  gem.version = RetinaRails::VERSION
9
- gem.authors = ["Johan van Zonneveld"]
10
- gem.email = ["johan@vzonneveld.nl"]
9
+ gem.authors = ['Johan van Zonneveld']
10
+ gem.email = ['johan@vzonneveld.nl']
11
11
  gem.homepage = 'https://github.com/jhnvz/retina_rails.git'
12
12
  gem.summary = %q{Makes your live easier optimizing for retina displays}
13
13
  gem.description = %q{Retina Rails automatically generates retina versions of your uploaded images (CarrierWave or Paperclip). It detects if a visitor has a retina display and if so it displays the @2x version}
@@ -15,15 +15,16 @@ Gem::Specification.new do |gem|
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = ['lib']
19
19
 
20
- gem.add_development_dependency "bundler", ">= 1.0.0"
21
- gem.add_development_dependency "rake"
22
- gem.add_development_dependency "rspec", ">= 2.3"
23
- gem.add_development_dependency "rspec-rails", "~> 2.0"
20
+ gem.add_development_dependency 'bundler', '>= 1.0.0'
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'rspec', '>= 2.3'
23
+ gem.add_development_dependency 'rspec-rails', '~> 2.0'
24
24
  gem.add_development_dependency 'carrierwave'
25
25
  gem.add_development_dependency 'paperclip'
26
- gem.add_development_dependency "sqlite3"
26
+ gem.add_development_dependency 'sqlite3'
27
+ gem.add_development_dependency 'coveralls'
27
28
 
28
29
  gem.add_dependency 'rails', '>= 3.0'
29
30
  gem.add_dependency 'rmagick'
@@ -8,6 +8,21 @@ class AnonymousUploader < CarrierWave::Uploader::Base
8
8
  process :resize_to_fill => [30, 30]
9
9
  end
10
10
 
11
+ version :small_without_dimensions do
12
+ process :desaturate
13
+ end
14
+
15
+ version :small_multiple_processors do
16
+ process :resize_to_fill => [30, 30]
17
+ process :desaturate
18
+ end
19
+
20
+ def desaturate
21
+ manipulate! do |img|
22
+ img = img.quantize 256, Magick::GRAYColorspace
23
+ end
24
+ end
25
+
11
26
  version :small_without_processor
12
27
 
13
28
  include RetinaRails::CarrierWave
@@ -46,7 +61,7 @@ describe RetinaRails::CarrierWave do
46
61
  @uploader.remove!
47
62
  end
48
63
 
49
- context 'with processor' do
64
+ context 'with dimensions processor' do
50
65
 
51
66
  its(:versions) { should include :small_retina }
52
67
 
@@ -60,6 +75,28 @@ describe RetinaRails::CarrierWave do
60
75
 
61
76
  end
62
77
 
78
+ context 'without dimensions processor' do
79
+
80
+ its(:versions) { should_not include :small_without_dimensions_retina }
81
+
82
+ end
83
+
84
+ context 'with multiple processors' do
85
+
86
+ its(:versions) { should include :small_multiple_processors_retina }
87
+
88
+ it { subject.versions[:small_multiple_processors][:uploader].processors.should include([:desaturate, [], nil]) }
89
+
90
+ it { @uploader.small_multiple_processors.should have_dimensions(30, 30) }
91
+ it { @uploader.small_multiple_processors_retina.should have_dimensions(60, 60) }
92
+
93
+ it { File.basename(@uploader.small_multiple_processors.current_path, 'jpeg').should include 'small_'}
94
+
95
+ it { File.basename(@uploader.small_multiple_processors_retina.current_path, 'jpeg').should include '@2x'}
96
+ it { File.basename(@uploader.small_multiple_processors_retina.current_path, 'jpeg').should_not include 'retina_'}
97
+
98
+ end
99
+
63
100
  context 'without processor' do
64
101
 
65
102
  its(:versions) { should include :small_without_processor }
@@ -1,4 +1,10 @@
1
- require 'rubygems'
1
+ ## Test coverage
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ ## Rails
7
+
2
8
  require 'active_support'
3
9
  require 'active_record'
4
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retina_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: coveralls
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: rails
128
144
  requirement: !ruby/object:Gem::Requirement