image_size 3.0.1 → 3.0.2
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.
- checksums.yaml +4 -4
- data/.github/workflows/check.yml +3 -9
- data/.github/workflows/rubocop.yml +16 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +2 -2
- data/image_size.gemspec +3 -3
- data/lib/image_size/uri_reader.rb +2 -0
- data/lib/image_size.rb +1 -0
- data/spec/image_size_spec.rb +21 -7
- data/spec/images/empty +0 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e594fe6ec7b9018dd68867a5feaf557c6c22e7ed667876089fcbe35d6f3104c
|
4
|
+
data.tar.gz: a221e99d54a933452712df549e2b8b05ceb85c407b27f482042d35c97dbb95c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc4b3ec562040c3316edfc7412110eec1eef87028100f156e155a65bb38bccba7199b1094daa5ddc62317229a0fbe7241af0ba2089adf6ee03ab7eb4d85c634
|
7
|
+
data.tar.gz: db58b0bee4cf294cf44ac5b4afe01c8cd0420b0155e220e378755081ca1a655adb1ac30695966f150b094c648befbd8fb96f31d9a835afbefe1bffbc7ce717b4
|
data/.github/workflows/check.yml
CHANGED
@@ -19,8 +19,10 @@ jobs:
|
|
19
19
|
- '2.6'
|
20
20
|
- '2.7'
|
21
21
|
- '3.0'
|
22
|
+
- '3.1'
|
22
23
|
- jruby-9.1
|
23
24
|
- jruby-9.2
|
25
|
+
- jruby-9.3
|
24
26
|
fail-fast: false
|
25
27
|
steps:
|
26
28
|
- uses: actions/checkout@v2
|
@@ -50,6 +52,7 @@ jobs:
|
|
50
52
|
- '2.6'
|
51
53
|
- '2.7'
|
52
54
|
- '3.0'
|
55
|
+
- '3.1'
|
53
56
|
fail-fast: false
|
54
57
|
steps:
|
55
58
|
- uses: actions/checkout@v2
|
@@ -58,12 +61,3 @@ jobs:
|
|
58
61
|
ruby-version: "${{ matrix.ruby }}"
|
59
62
|
bundler-cache: true
|
60
63
|
- run: bundle exec rspec --format documentation
|
61
|
-
rubocop:
|
62
|
-
runs-on: ubuntu-latest
|
63
|
-
steps:
|
64
|
-
- uses: actions/checkout@v2
|
65
|
-
- uses: ruby/setup-ruby@v1
|
66
|
-
with:
|
67
|
-
ruby-version: '3.0'
|
68
|
-
bundler-cache: true
|
69
|
-
- run: bundle exec rubocop
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: rubocop
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
pull_request:
|
5
|
+
schedule:
|
6
|
+
- cron: 45 4 * * 3
|
7
|
+
jobs:
|
8
|
+
rubocop:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- uses: ruby/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: '3.1'
|
15
|
+
bundler-cache: true
|
16
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
CHANGED
@@ -53,6 +53,9 @@ Style/EmptyCaseCondition:
|
|
53
53
|
Style/Encoding:
|
54
54
|
Enabled: false
|
55
55
|
|
56
|
+
Style/FileRead:
|
57
|
+
Enabled: false
|
58
|
+
|
56
59
|
Style/HashEachMethods:
|
57
60
|
Enabled: true
|
58
61
|
|
@@ -77,6 +80,9 @@ Style/ParallelAssignment:
|
|
77
80
|
Style/SafeNavigation:
|
78
81
|
Enabled: false
|
79
82
|
|
83
|
+
Style/SlicingWithRange:
|
84
|
+
Enabled: false
|
85
|
+
|
80
86
|
Style/TrailingCommaInArrayLiteral:
|
81
87
|
EnforcedStyleForMultiline: comma
|
82
88
|
|
data/.rubocop_todo.yml
CHANGED
@@ -9,17 +9,17 @@
|
|
9
9
|
# Offense count: 8
|
10
10
|
# Configuration parameters: IgnoredMethods.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
|
12
|
+
Enabled: false
|
13
13
|
|
14
14
|
# Offense count: 5
|
15
15
|
# Configuration parameters: IgnoredMethods.
|
16
16
|
Metrics/CyclomaticComplexity:
|
17
|
-
|
17
|
+
Enabled: false
|
18
18
|
|
19
19
|
# Offense count: 2
|
20
20
|
# Configuration parameters: IgnoredMethods.
|
21
21
|
Metrics/PerceivedComplexity:
|
22
|
-
|
22
|
+
Enabled: false
|
23
23
|
|
24
24
|
# Offense count: 8
|
25
25
|
# Cop supports --auto-correct.
|
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v3.0.2 (2022-05-19)
|
6
|
+
|
7
|
+
* Fix handling empty files [#20](https://github.com/toy/image_size/issues/20) [@toy](https://github.com/toy)
|
8
|
+
|
5
9
|
## v3.0.1 (2021-10-21)
|
6
10
|
|
7
11
|
* Fix reading file chunks starting after EOF and reading chunks non-consecutively [toy/image_optim_rails#12](https://github.com/toy/image_optim_rails/issues/12) [@toy](https://github.com/toy)
|
data/README.markdown
CHANGED
@@ -17,7 +17,7 @@ gem install image_size
|
|
17
17
|
Add to your `Gemfile`:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
gem 'image_size', '~>
|
20
|
+
gem 'image_size', '~> 3.0'
|
21
21
|
```
|
22
22
|
|
23
23
|
## Usage
|
@@ -94,4 +94,4 @@ end
|
|
94
94
|
This code is free to use under the terms of the [Ruby's licence](LICENSE.txt).
|
95
95
|
|
96
96
|
Original author: Keisuke Minami <keisuke@rccn.com>.\
|
97
|
-
Further development 2010-
|
97
|
+
Further development 2010-2022 Ivan Kuchin https://github.com/toy/image_size
|
data/image_size.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'image_size'
|
5
|
-
s.version = '3.0.
|
5
|
+
s.version = '3.0.2'
|
6
6
|
s.summary = %q{Measure image size using pure Ruby}
|
7
7
|
s.description = %q{Measure following file dimensions: apng, bmp, cur, gif, ico, j2c, jp2, jpeg, jpx, mng, pam, pbm, pcx, pgm, png, ppm, psd, svg, swf, tiff, webp, xbm, xpm}
|
8
8
|
s.homepage = "https://github.com/toy/#{s.name}"
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.require_paths = %w[lib]
|
23
23
|
|
24
24
|
s.add_development_dependency 'rspec', '~> 3.0'
|
25
|
-
if RUBY_VERSION >= '2.
|
26
|
-
s.add_development_dependency 'rubocop', '~> 1.
|
25
|
+
if RUBY_VERSION >= '2.5'
|
26
|
+
s.add_development_dependency 'rubocop', '~> 1.22'
|
27
27
|
s.add_development_dependency 'rubocop-rspec', '~> 2.0'
|
28
28
|
end
|
29
29
|
end
|
data/lib/image_size.rb
CHANGED
@@ -76,6 +76,7 @@ private
|
|
76
76
|
def detect_format(ir)
|
77
77
|
head = ir[0, 1024]
|
78
78
|
case
|
79
|
+
when head.nil? || head.empty? then nil
|
79
80
|
when head[0, 6] =~ /GIF8[79]a/ then :gif
|
80
81
|
when head[0, 8] == "\211PNG\r\n\032\n" then detect_png_type(ir)
|
81
82
|
when head[0, 8] == "\212MNG\r\n\032\n" then :mng
|
data/spec/image_size_spec.rb
CHANGED
@@ -27,11 +27,8 @@ describe ImageSize do
|
|
27
27
|
@server_thread.join
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
(Dir['spec/images/*/*.*'] + [__FILE__[%r{spec/.+?\z}]]).each do |path|
|
33
|
-
filesize = File.size(path)
|
34
|
-
warn "#{path} is too big #{filesize} (max #{max_filesize})" if filesize > max_filesize
|
30
|
+
Dir['spec/**/*'].each do |path|
|
31
|
+
next unless File.file?(path)
|
35
32
|
|
36
33
|
describe "for #{path}" do
|
37
34
|
let(:name){ File.basename(path) }
|
@@ -49,6 +46,15 @@ describe ImageSize do
|
|
49
46
|
}
|
50
47
|
end
|
51
48
|
let(:file_data){ File.open(path, 'rb', &:read) }
|
49
|
+
let(:file_size){ file_data.length }
|
50
|
+
|
51
|
+
before do
|
52
|
+
max_file_size = 16_384
|
53
|
+
|
54
|
+
if file_size > max_file_size
|
55
|
+
raise "reduce resulting gem size, #{path} is too big (#{file_size} > #{max_file_size})"
|
56
|
+
end
|
57
|
+
end
|
52
58
|
|
53
59
|
context 'given as data' do
|
54
60
|
it 'gets format and dimensions' do
|
@@ -65,7 +71,11 @@ describe ImageSize do
|
|
65
71
|
image_size = ImageSize.new(io)
|
66
72
|
expect(image_size).to have_attributes(attributes)
|
67
73
|
expect(io).not_to be_closed
|
68
|
-
|
74
|
+
if file_size.zero?
|
75
|
+
expect(io.pos).to be_zero
|
76
|
+
else
|
77
|
+
expect(io.pos).to_not be_zero
|
78
|
+
end
|
69
79
|
io.rewind
|
70
80
|
expect(io.read).to eq(file_data)
|
71
81
|
end
|
@@ -102,7 +112,11 @@ describe ImageSize do
|
|
102
112
|
image_size = ImageSize.new(io)
|
103
113
|
expect(image_size).to have_attributes(attributes)
|
104
114
|
expect(io).not_to be_closed
|
105
|
-
|
115
|
+
if file_size.zero?
|
116
|
+
expect(io.pos).to be_zero
|
117
|
+
else
|
118
|
+
expect(io.pos).to_not be_zero
|
119
|
+
end
|
106
120
|
io.rewind
|
107
121
|
expect(io.read).to eq(file_data)
|
108
122
|
end
|
data/spec/images/empty
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_size
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keisuke Minami
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.22'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
41
|
+
version: '1.22'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rubocop-rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".github/workflows/check.yml"
|
64
|
+
- ".github/workflows/rubocop.yml"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rubocop.yml"
|
66
67
|
- ".rubocop_todo.yml"
|
@@ -85,6 +86,7 @@ files:
|
|
85
86
|
- spec/images/bmp/v3-bottom2top.42x50.bmp
|
86
87
|
- spec/images/bmp/v3-top2bottom.42x50.bmp
|
87
88
|
- spec/images/cur/32x256.cur
|
89
|
+
- spec/images/empty
|
88
90
|
- spec/images/gif/668x481.gif
|
89
91
|
- spec/images/ico/32x256.ico
|
90
92
|
- spec/images/jp2/163x402.jp2
|
@@ -124,7 +126,7 @@ licenses:
|
|
124
126
|
metadata:
|
125
127
|
bug_tracker_uri: https://github.com/toy/image_size/issues
|
126
128
|
changelog_uri: https://github.com/toy/image_size/blob/master/CHANGELOG.markdown
|
127
|
-
documentation_uri: https://www.rubydoc.info/gems/image_size/3.0.
|
129
|
+
documentation_uri: https://www.rubydoc.info/gems/image_size/3.0.2
|
128
130
|
source_code_uri: https://github.com/toy/image_size
|
129
131
|
post_install_message:
|
130
132
|
rdoc_options: []
|
@@ -141,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
143
|
- !ruby/object:Gem::Version
|
142
144
|
version: '0'
|
143
145
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
146
|
+
rubygems_version: 3.3.11
|
145
147
|
signing_key:
|
146
148
|
specification_version: 4
|
147
149
|
summary: Measure image size using pure Ruby
|
@@ -154,6 +156,7 @@ test_files:
|
|
154
156
|
- spec/images/bmp/v3-bottom2top.42x50.bmp
|
155
157
|
- spec/images/bmp/v3-top2bottom.42x50.bmp
|
156
158
|
- spec/images/cur/32x256.cur
|
159
|
+
- spec/images/empty
|
157
160
|
- spec/images/gif/668x481.gif
|
158
161
|
- spec/images/ico/32x256.ico
|
159
162
|
- spec/images/jp2/163x402.jp2
|