nanoc-image-compressor 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/lib/nanoc/filters/image_compressor.rb +5 -1
- data/nanoc-image-compressor.gemspec +1 -1
- data/spec/{test.gif → fixtures/test.gif} +0 -0
- data/spec/{test.jpg → fixtures/test.jpg} +0 -0
- data/spec/{test.png → fixtures/test.png} +0 -0
- data/spec/image_compressor_spec.rb +35 -3
- metadata +108 -110
data/.travis.yml
CHANGED
@@ -6,7 +6,7 @@ module Nanoc
|
|
6
6
|
module Filters
|
7
7
|
class ImageCompressor < Nanoc::Filter
|
8
8
|
|
9
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.1'
|
10
10
|
|
11
11
|
identifier :image_compressor
|
12
12
|
type :binary
|
@@ -21,6 +21,10 @@ module Nanoc
|
|
21
21
|
result = io.optimize_image(filename)
|
22
22
|
path = result ? result.to_s : filename
|
23
23
|
FileUtils.cp path, output_filename
|
24
|
+
# ensure the output permissions match the input
|
25
|
+
in_mode = File.stat(filename).mode & 0777
|
26
|
+
out_mode = File.stat(output_filename).mode & 0777
|
27
|
+
File.chmod(in_mode, output_filename) if in_mode != out_mode
|
24
28
|
end
|
25
29
|
|
26
30
|
end
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
gem.name = "nanoc-image-compressor"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = '0.1.
|
15
|
+
gem.version = '0.1.1'
|
16
16
|
|
17
17
|
gem.add_dependency 'nanoc', '>= 3.3.1'
|
18
18
|
gem.add_dependency 'image_optim'
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,9 +5,9 @@ require 'nanoc/filters/image_compressor'
|
|
5
5
|
|
6
6
|
describe Nanoc::Filters::ImageCompressor do
|
7
7
|
|
8
|
-
let(:gif_path) { File.expand_path('../test.gif', __FILE__) }
|
9
|
-
let(:jpg_path) { File.expand_path('../test.jpg', __FILE__) }
|
10
|
-
let(:png_path) { File.expand_path('../test.png', __FILE__) }
|
8
|
+
let(:gif_path) { File.expand_path('../fixtures/test.gif', __FILE__) }
|
9
|
+
let(:jpg_path) { File.expand_path('../fixtures/test.jpg', __FILE__) }
|
10
|
+
let(:png_path) { File.expand_path('../fixtures/test.png', __FILE__) }
|
11
11
|
let(:run_options) { { :pngout => false } }
|
12
12
|
|
13
13
|
before do
|
@@ -22,6 +22,37 @@ describe Nanoc::Filters::ImageCompressor do
|
|
22
22
|
let(:extension) { path.sub(/^.+\.([a-z]+)$/, '\1') }
|
23
23
|
let(:output_size) { File.size subject.output_filename }
|
24
24
|
|
25
|
+
context 'image whose output permission changes' do
|
26
|
+
|
27
|
+
def image_with_mode(mode)
|
28
|
+
file = Tempfile.new(['test', '.jpg'])
|
29
|
+
file.close
|
30
|
+
FileUtils.cp jpg_path, file.path
|
31
|
+
File.chmod mode, file.path
|
32
|
+
file.path
|
33
|
+
end
|
34
|
+
|
35
|
+
def mode_of(path)
|
36
|
+
File.stat(path).mode & 0777
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should match the input file whose mode is private' do
|
40
|
+
subject.run image_with_mode(0600), run_options
|
41
|
+
mode_of(subject.output_filename).should == 0600
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should match the input file whose mode is public' do
|
45
|
+
subject.run image_with_mode(0644), run_options
|
46
|
+
mode_of(subject.output_filename).should == 0644
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should match the input file whose mode is world readable' do
|
50
|
+
subject.run image_with_mode(0666), run_options
|
51
|
+
mode_of(subject.output_filename).should == 0666
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
25
56
|
context 'jpg image' do
|
26
57
|
let(:path) { jpg_path }
|
27
58
|
it 'should compress' do
|
@@ -35,6 +66,7 @@ describe Nanoc::Filters::ImageCompressor do
|
|
35
66
|
file = Tempfile.new(['test', '.jpeg'])
|
36
67
|
file.close
|
37
68
|
FileUtils.cp jpg_path, file.path
|
69
|
+
File.chmod 0644, file.path
|
38
70
|
file.path
|
39
71
|
end
|
40
72
|
it 'should compress' do
|
metadata
CHANGED
@@ -1,118 +1,119 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-image-compressor
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- John Nishinaga
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: nanoc
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 9
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 3
|
32
|
-
- 1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 3.3.1
|
34
22
|
type: :runtime
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: image_optim
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.3.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: image_optim
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
40
33
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
48
38
|
type: :runtime
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rake
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
54
49
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
62
54
|
type: :development
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rspec
|
66
55
|
prerelease: false
|
67
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
57
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
76
70
|
type: :development
|
77
|
-
version_requirements: *id004
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: yard
|
80
71
|
prerelease: false
|
81
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
73
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: yard
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
90
86
|
type: :development
|
91
|
-
version_requirements: *id005
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
|
-
name: bluecloth
|
94
87
|
prerelease: false
|
95
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
89
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bluecloth
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
104
102
|
type: :development
|
105
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
106
110
|
description: Nanoc image compressor filter
|
107
|
-
email:
|
111
|
+
email:
|
108
112
|
- jingoro@casa-z.org
|
109
113
|
executables: []
|
110
|
-
|
111
114
|
extensions: []
|
112
|
-
|
113
115
|
extra_rdoc_files: []
|
114
|
-
|
115
|
-
files:
|
116
|
+
files:
|
116
117
|
- .gitignore
|
117
118
|
- .rspec
|
118
119
|
- .travis.yml
|
@@ -123,46 +124,43 @@ files:
|
|
123
124
|
- lib/nanoc-image-compressor.rb
|
124
125
|
- lib/nanoc/filters/image_compressor.rb
|
125
126
|
- nanoc-image-compressor.gemspec
|
127
|
+
- spec/fixtures/test.gif
|
128
|
+
- spec/fixtures/test.jpg
|
129
|
+
- spec/fixtures/test.png
|
126
130
|
- spec/image_compressor_spec.rb
|
127
|
-
- spec/test.gif
|
128
|
-
- spec/test.jpg
|
129
|
-
- spec/test.png
|
130
131
|
homepage: https://github.com/jingoro/nanoc-image-compressor
|
131
132
|
licenses: []
|
132
|
-
|
133
133
|
post_install_message:
|
134
134
|
rdoc_options: []
|
135
|
-
|
136
|
-
require_paths:
|
135
|
+
require_paths:
|
137
136
|
- lib
|
138
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
138
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
segments:
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
segments:
|
145
144
|
- 0
|
146
|
-
|
147
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
hash: -4129835042860490982
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
147
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
|
153
|
-
segments:
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
154
153
|
- 0
|
155
|
-
|
154
|
+
hash: -4129835042860490982
|
156
155
|
requirements: []
|
157
|
-
|
158
156
|
rubyforge_project:
|
159
|
-
rubygems_version: 1.8.
|
157
|
+
rubygems_version: 1.8.24
|
160
158
|
signing_key:
|
161
159
|
specification_version: 3
|
162
160
|
summary: A nanoc filter that compresses gif, jpg and png images losslessly
|
163
|
-
test_files:
|
161
|
+
test_files:
|
162
|
+
- spec/fixtures/test.gif
|
163
|
+
- spec/fixtures/test.jpg
|
164
|
+
- spec/fixtures/test.png
|
164
165
|
- spec/image_compressor_spec.rb
|
165
|
-
- spec/test.gif
|
166
|
-
- spec/test.jpg
|
167
|
-
- spec/test.png
|
168
166
|
has_rdoc:
|