pronto-image_optim 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9e46f39603ff8cc5ee6cc16431a86849c7cf40a8eea50df4c1df55693f37be03
4
+ data.tar.gz: bcdc43fcd3ad79581dfd861e08a6e2c484cc7c81a793c3697e2b00ac0708204d
5
+ SHA512:
6
+ metadata.gz: 7b7939a2f66b3305232dca85fc1032bfa85b2e2e7bf45bf7fa4918cb1186939469f5a889b50e58c451562bed703423882279dd335d7d45010bcaf7fcaef5ae81
7
+ data.tar.gz: a4afa693c3e0dc70ffcadce900f5e96a1eedd6bd17fb0697cf549a2db942c31d1778495980056143bac64001ac9bfe4b233ed631530f72226fe4f5b7e53e9465
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in pronto-image_optim.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,83 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pronto-image_optim (0.1.0)
5
+ image_optim
6
+ image_optim_pack
7
+ pronto (~> 0.9.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
14
+ diff-lcs (1.3)
15
+ exifr (1.3.3)
16
+ faraday (0.13.1)
17
+ multipart-post (>= 1.2, < 3)
18
+ fspath (3.1.0)
19
+ gitlab (4.2.0)
20
+ httparty
21
+ terminal-table
22
+ httparty (0.15.6)
23
+ multi_xml (>= 0.5.2)
24
+ image_optim (0.26.1)
25
+ exifr (~> 1.2, >= 1.2.2)
26
+ fspath (~> 3.0)
27
+ image_size (~> 1.5)
28
+ in_threads (~> 1.3)
29
+ progress (~> 3.0, >= 3.0.1)
30
+ image_optim_pack (0.5.0.20171208)
31
+ fspath (>= 2.1, < 4)
32
+ image_optim (~> 0.19)
33
+ image_size (1.5.0)
34
+ in_threads (1.5.0)
35
+ multi_xml (0.6.0)
36
+ multipart-post (2.0.0)
37
+ octokit (4.8.0)
38
+ sawyer (~> 0.8.0, >= 0.5.3)
39
+ progress (3.4.0)
40
+ pronto (0.9.5)
41
+ gitlab (~> 4.0, >= 4.0.0)
42
+ httparty (>= 0.13.7)
43
+ octokit (~> 4.7, >= 4.7.0)
44
+ rainbow (~> 2.1)
45
+ rugged (~> 0.24, >= 0.23.0)
46
+ thor (~> 0.19.0)
47
+ public_suffix (3.0.1)
48
+ rainbow (2.2.2)
49
+ rake
50
+ rake (10.5.0)
51
+ rspec (3.7.0)
52
+ rspec-core (~> 3.7.0)
53
+ rspec-expectations (~> 3.7.0)
54
+ rspec-mocks (~> 3.7.0)
55
+ rspec-core (3.7.0)
56
+ rspec-support (~> 3.7.0)
57
+ rspec-expectations (3.7.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.7.0)
60
+ rspec-mocks (3.7.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.7.0)
63
+ rspec-support (3.7.0)
64
+ rugged (0.26.0)
65
+ sawyer (0.8.1)
66
+ addressable (>= 2.3.5, < 2.6)
67
+ faraday (~> 0.8, < 1.0)
68
+ terminal-table (1.8.0)
69
+ unicode-display_width (~> 1.1, >= 1.1.1)
70
+ thor (0.19.4)
71
+ unicode-display_width (1.3.0)
72
+
73
+ PLATFORMS
74
+ ruby
75
+
76
+ DEPENDENCIES
77
+ bundler (~> 1.16)
78
+ pronto-image_optim!
79
+ rake (~> 10.0)
80
+ rspec (~> 3.4)
81
+
82
+ BUNDLED WITH
83
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Christoph Lupprich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Pronto::ImageOptim
2
+
3
+ [![Build Status](https://travis-ci.org/clupprich/pronto-image_optim.svg?branch=master)](https://travis-ci.org/clupprich/pronto-image_optim)
4
+
5
+ [Pronto](https://github.com/prontolabs/pronto) runner for [ImageOptim](https://github.com/toy/image_optim) to optimize images.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pronto-image_optim'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pronto-image_optim
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/clupprich/pronto-image_optim.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pronto/image_optim'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,48 @@
1
+ require 'pronto'
2
+ require 'image_optim'
3
+
4
+ module Pronto
5
+ class ImageOptim < Runner
6
+ def initialize(*args)
7
+ super
8
+
9
+ @image_optim = ::ImageOptim.new
10
+ end
11
+
12
+ # Entry point to our Pronto runner
13
+ def run
14
+ return [] unless @patches
15
+
16
+ @patches.select(&method(:valid_patch?))
17
+ .map(&method(:inspect))
18
+ .flatten
19
+ .compact
20
+ end
21
+
22
+ private
23
+
24
+ def valid_patch?(patch)
25
+ path = patch.new_file_full_path
26
+ image_file?(path)
27
+ end
28
+
29
+ def inspect(patch)
30
+ path = patch.new_file_full_path
31
+ size = File.size(path)
32
+
33
+ optimized_path = @image_optim.optimize_image(path)
34
+ return unless optimized_path
35
+
36
+ optimized_size = File.size(optimized_path)
37
+ return unless optimized_size < size
38
+
39
+ percent = 100 - (100.0 / size * optimized_size)
40
+
41
+ Message.new(path, nil, :info, "File size can be reduced by #{percent.round(2)}%", nil, self.class)
42
+ end
43
+
44
+ def image_file?(path)
45
+ %w[.png .jpg .jpeg].include?(File.extname(path))
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ class ImageOptimVersion
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'pronto/image_optim/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pronto-image_optim'
7
+ spec.version = Pronto::ImageOptimVersion::VERSION
8
+ spec.authors = ['Christoph Lupprich']
9
+ spec.email = ['christoph@luppri.ch']
10
+
11
+ spec.summary = %q{Pronto runner for ImageOptim}
12
+ spec.homepage = 'https://github.com/clupprich/pronto-image_optim'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency('pronto', '~> 0.9.0')
21
+ spec.add_runtime_dependency('image_optim')
22
+ spec.add_runtime_dependency('image_optim_pack')
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.4'
27
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-image_optim
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christoph Lupprich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: image_optim
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: image_optim_pack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.16'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.16'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.4'
97
+ description:
98
+ email:
99
+ - christoph@luppri.ch
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/pronto/image_optim.rb
114
+ - lib/pronto/image_optim/version.rb
115
+ - pronto-image_optim.gemspec
116
+ homepage: https://github.com/clupprich/pronto-image_optim
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.7.6
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Pronto runner for ImageOptim
140
+ test_files: []