image_optim 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzI5M2M3MWM1OWNiMDM5MGFiMmFkNDYwYzBiZjY5NWFiNDc0NTkyNQ==
4
+ MmIyYWJlYjg2ODQ0YmE1MzZmMTE2ODI5Njk0OGZlZmFlMjAwODAzNg==
5
5
  data.tar.gz: !binary |-
6
- YWI3NDcwN2U3ZmIzZGI4NjYxZmJkOTVhYmQ5OGMzNTYyNGFlODI3Ng==
6
+ NjI2NTE5ZmNiMjNkMWM0MTc3ZmJlY2FhNzJlODQ5MDg1ZWVmYzllYg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjVkYjUwYTEzMzQ2ZWZjNjg3ZWU1ZDJlMGRmY2FjOTc3NzU4YThlYTVmMmE2
10
- YWEwODAzMGVkN2QyZDc4MjUyZGQ4ZDAyMTgzMDA3ZjVjNDQ3ODc5NTBlMzI1
11
- MDU4ZDRlZTAzNjc2M2IwNWMxZGNjZjY0OWQ0MDQ2NGNhMThlYTE=
9
+ ZTQwMDk3ZDE3YTBiNzdmOTBiMzU5NzkxNDI4ZDI1ODJhOWY3Y2Q3NzdlZjcy
10
+ NmJiZDE0MDdkODhjZmZhNjlhYmNlMGYyYmJmMzliYzdiM2RiOGI5OTk3ZjBm
11
+ YWQyN2RlMTFiMjVmY2M2NDFhMjJiMWFhYzE5OTlmNDQ2Y2RiOTY=
12
12
  data.tar.gz: !binary |-
13
- YjlhYjk1NDIyM2FlMzE4NjZlM2QxOTJjYzk0ZjJlYTI1YTYwMGUxODA3Yzdj
14
- NzdjODY2NDBjZDIwODA2YTIzNThjZWJjMTg2ZGRlYjllYjg3NGIxNzU0Y2Fk
15
- NWYwNDYwODkwN2FjNmI2ODU5NWNlNjdmMjY5NjdkZjk3ZTY3NDM=
13
+ NDcwZWMyMzg3YWRkM2RmYmM5NTRmOTgyYTlhOGJiMTc2M2RmN2Q3MjMyM2Yx
14
+ NzA1ZmMwZTFlNjYyYWRhMDg4MDNhYWRlNjM5Y2M1ODQzZDk1ODViZThjYTg0
15
+ ZTVkMzFlY2UxNGY5MzlhNzJlNjVkZDVmODI4ZDI5MmE1NGVmYmM=
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2013 Ivan Kuchin
1
+ Copyright (c) 2012-2014 Ivan Kuchin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -116,6 +116,10 @@ Optimize image in place:
116
116
 
117
117
  image_optim.optimize_image!('b.jpg')
118
118
 
119
+ Optimize image data:
120
+
121
+ image_optim.optimize_image_data(data)
122
+
119
123
  Multiple images:
120
124
 
121
125
  image_optim.optimize_images(Dir['*.png']) do |unoptimized, optimized|
@@ -126,6 +130,8 @@ Multiple images:
126
130
 
127
131
  image_optim.optimize_images!(Dir['*.*'])
128
132
 
133
+ image_optim.optimize_images_data(datas)
134
+
129
135
  ### From rails
130
136
 
131
137
  `ImageOptim::Railtie` will automatically initialize processing of assets if `config.assets.compress` is true.
@@ -190,4 +196,4 @@ Worker can be disabled by passing false instead of options hash.
190
196
 
191
197
  ## Copyright
192
198
 
193
- Copyright (c) 2012-2013 Ivan Kuchin. See LICENSE.txt for details.
199
+ Copyright (c) 2012-2014 Ivan Kuchin. See LICENSE.txt for details.
data/image_optim.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'image_optim'
5
- s.version = '0.10.0'
5
+ s.version = '0.10.1'
6
6
  s.summary = %q{Optimize (lossless compress) images (jpeg, png, gif) using external utilities (advpng, gifsicle, jpegoptim, jpegtran, optipng, pngcrush, pngout)}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
data/lib/image_optim.rb CHANGED
@@ -99,7 +99,7 @@ class ImageOptim
99
99
  temp.close
100
100
 
101
101
  if result = optimize_image(temp.path)
102
- result.read
102
+ result.open('rb', &:read)
103
103
  end
104
104
  end
105
105
  end
@@ -79,12 +79,16 @@ class ImageOptim
79
79
  else
80
80
  warning "#{arg} is not an image or there is no optimizer for it"
81
81
  end
82
- elsif @recursive && File.directory?(arg)
83
- Find.find(arg) do |path|
84
- files << path if File.file?(path) && @image_optim.optimizable?(path)
82
+ elsif @recursive
83
+ if File.directory?(arg)
84
+ Find.find(arg) do |path|
85
+ files << path if File.file?(path) && @image_optim.optimizable?(path)
86
+ end
87
+ else
88
+ warning "#{arg} is not a file or a directory or does not exist"
85
89
  end
86
90
  else
87
- warning "#{arg} does not exist"
91
+ warning "#{arg} is not a file or does not exist"
88
92
  end
89
93
  end
90
94
  files
@@ -92,7 +92,7 @@ describe ImageOptim do
92
92
  it "should optimize #{original}" do
93
93
  image_optim = ImageOptim.new
94
94
  optimized_data = image_optim.optimize_image_data(original.read)
95
- optimized_data.should == image_optim.optimize_image(original.temp_copy).read
95
+ optimized_data.should == image_optim.optimize_image(original.temp_copy).open('rb', &:read)
96
96
 
97
97
  image_optim.optimize_image_data(optimized_data).should be_nil
98
98
  end
@@ -139,7 +139,7 @@ describe ImageOptim do
139
139
  it "should optimize datas" do
140
140
  optimized_images_datas = ImageOptim.optimize_images_data(TEST_IMAGES.map(&:read))
141
141
  TEST_IMAGES.zip(optimized_images_datas).each do |original, optimized_image_data|
142
- optimized_image_data.should == ImageOptim.optimize_image(original.temp_copy).read
142
+ optimized_image_data.should == ImageOptim.optimize_image(original.temp_copy).open('rb', &:read)
143
143
  end
144
144
  end
145
145
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_optim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-25 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fspath