carrierwave-imageoptimizer 0.0.1
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 +18 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +6 -0
- data/carrierwave-imageoptimizer.gemspec +25 -0
- data/lib/carrierwave-imageoptimizer.rb +12 -0
- data/lib/carrierwave-imageoptimizer/version.rb +5 -0
- data/spec/carrierwave-imageoptimizer/version_spec.rb +7 -0
- data/spec/carrierwave_imageoptimizer_spec.rb +20 -0
- data/spec/spec_helper.rb +4 -0
- metadata +130 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Julian Tescher
|
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,64 @@
|
|
1
|
+
# CarrierWave ImageOptimizer
|
2
|
+
|
3
|
+
This gem allows you to simply optimize CarrierWave images via jpegoptim or optipng using the image_optimizer gem.
|
4
|
+
|
5
|
+
Tested against ruby 1.8.7, 1.9.2, 1.9.3, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-18mode, rbx-19mode, and
|
6
|
+
ree
|
7
|
+
|
8
|
+
[]
|
9
|
+
(http://travis-ci.org/jtescher/carrierwave-imageoptimizer)
|
10
|
+
[](https://gemnasium.com/jtescher/carrierwave-imageoptimizer)
|
11
|
+
[](https://codeclimate.com/github/jtescher/carrierwave-imageoptimizer)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'carrierwave-imageoptimizer'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install carrierwave-imageoptimizer
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
To add image optimization to your CarrierWave uploader, first include the module:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class MyUploader < CarrierWave::Uploader::Base
|
33
|
+
include CarrierWave::ImageOptimizer
|
34
|
+
...
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Then apply to all versions via:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
class MyUploader < CarrierWave::Uploader::Base
|
42
|
+
...
|
43
|
+
process :optimize
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
Or to a single image version via:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class MyUploader < CarrierWave::Uploader::Base
|
51
|
+
...
|
52
|
+
version :thumbnail do
|
53
|
+
process :optimize
|
54
|
+
end
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
1. Fork it
|
61
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'carrierwave-imageoptimizer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "carrierwave-imageoptimizer"
|
8
|
+
gem.version = CarrierWave::ImageOptimizer::VERSION
|
9
|
+
gem.authors = ["Julian Tescher"]
|
10
|
+
gem.email = ["jatescher@gmail.com"]
|
11
|
+
gem.description = %q{A simple image optimizer for CarrierWave}
|
12
|
+
gem.summary = %q{Simply optimize CarrierWave images via jpegoptim or optipng}
|
13
|
+
gem.homepage = "https://github.com/jtescher/carrierwave-imageoptimizer"
|
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
|
+
|
20
|
+
gem.add_dependency "carrierwave", ["~> 0.8"]
|
21
|
+
gem.add_dependency "image_optimizer", ["~> 0.0.2"]
|
22
|
+
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CarrierWave::ImageOptimizer do
|
4
|
+
describe '#optimize' do
|
5
|
+
before do
|
6
|
+
@uploader = Class.new do
|
7
|
+
include CarrierWave::ImageOptimizer
|
8
|
+
def manipulate!; yield end
|
9
|
+
def current_path; '/tmp/path/to/image.jpg' end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'delegates to a new instance of ImageOptimizer with the current path to the file' do
|
14
|
+
image_optimizer = stub(::ImageOptimizer)
|
15
|
+
::ImageOptimizer.should_receive(:new).with('/tmp/path/to/image.jpg').and_return(image_optimizer)
|
16
|
+
image_optimizer.should_receive(:optimize)
|
17
|
+
@uploader.new.optimize
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carrierwave-imageoptimizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Julian Tescher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: carrierwave
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.8'
|
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: '0.8'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: image_optimizer
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
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: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '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: '0'
|
78
|
+
description: A simple image optimizer for CarrierWave
|
79
|
+
email:
|
80
|
+
- jatescher@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- .travis.yml
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- carrierwave-imageoptimizer.gemspec
|
92
|
+
- lib/carrierwave-imageoptimizer.rb
|
93
|
+
- lib/carrierwave-imageoptimizer/version.rb
|
94
|
+
- spec/carrierwave-imageoptimizer/version_spec.rb
|
95
|
+
- spec/carrierwave_imageoptimizer_spec.rb
|
96
|
+
- spec/spec_helper.rb
|
97
|
+
homepage: https://github.com/jtescher/carrierwave-imageoptimizer
|
98
|
+
licenses: []
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: 913982671649387595
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
hash: 913982671649387595
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.24
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Simply optimize CarrierWave images via jpegoptim or optipng
|
127
|
+
test_files:
|
128
|
+
- spec/carrierwave-imageoptimizer/version_spec.rb
|
129
|
+
- spec/carrierwave_imageoptimizer_spec.rb
|
130
|
+
- spec/spec_helper.rb
|