image_size 2.0.0 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82a7fbf13124c2d0472d5da0f7d210ef83519dcde8927ec9db13954cf3f3d44c
4
- data.tar.gz: 5b77e47649b9632ec16b882397d367343d61750884ab9642170150ec43f9895c
3
+ metadata.gz: c0fa25bd1e135ab32ca6314351395d6244da802b7ab2e2453e4693a144ec59d8
4
+ data.tar.gz: 3132376fd6fb5e06230a72682c9129d7d5429513552a07ec1bd2086333eb4866
5
5
  SHA512:
6
- metadata.gz: f1e666a5911f31b8b3d44cf94ab3223621561026f6701e43e8db39e3d36761641a6f8122cdcd9bff18740a50679ebec593de7b73dd5ea36309d4688f7926f29e
7
- data.tar.gz: 6322a3aa7488e76f2cd26ef0eb83492269165ba4948a2f888bf935d48ccba86d20f0fb306252ed0dc1af5e5adce11442edb70586331b40070fec866d46ae36e1
6
+ metadata.gz: eab18d5faae61455ed10c9a7a63eab394b0de1c6c808db0c5337ee8b87904f725ae6b55b1019c3da743171421a7401bc64b36bacc228be3b87e0d7de46338a25
7
+ data.tar.gz: d3009f25b1a73e0b9ae22c20e078e428869cc3cb79c7f7691b1886360a7aa5d75d0aa537643b65037d11d00dddba24104e68255489967ed4c6e030f0c78d6b60
@@ -54,6 +54,9 @@ Style/IfUnlessModifier:
54
54
  Style/ParallelAssignment:
55
55
  Enabled: false
56
56
 
57
+ Style/SafeNavigation:
58
+ Enabled: false
59
+
57
60
  Style/TrailingCommaInArrayLiteral:
58
61
  EnforcedStyleForMultiline: comma
59
62
 
@@ -1,24 +1,24 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  before_install:
4
- - gem update bundler
4
+ - gem install bundler || gem install bundler --version '< 2'
5
5
  rvm:
6
6
  - '1.8.7-p371'
7
7
  - '1.9.3-p551'
8
8
  - '2.0.0-p648'
9
9
  - '2.1.10'
10
10
  - '2.2.10'
11
- - '2.3.7'
12
- - '2.4.4'
13
- - '2.5.1'
14
- - 'jruby-9.0.5.0'
11
+ - '2.3.8'
12
+ - '2.4.6'
13
+ - '2.5.5'
14
+ - '2.6.3'
15
15
  - 'jruby-9.1.9.0'
16
16
  script: bundle exec rspec
17
17
  matrix:
18
18
  include:
19
19
  - env: RUBOCOP=✓
20
- rvm: '2.4.4'
20
+ rvm: '2.6.3'
21
21
  script: bundle exec rubocop
22
22
  - env: CHECK_RUBIES=✓
23
- rvm: '2.4.4'
23
+ rvm: '2.6.3'
24
24
  script: bundle exec travis_check_rubies
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## unreleased
4
4
 
5
+ ## v2.0.1 (2019-05-17)
6
+
7
+ * Adapt to frozen string literals [@toy](https://github.com/toy)
8
+
5
9
  ## v2.0.0 (2018-05-01)
6
10
 
7
11
  * Allow any class responding to `read` and `eof?` to be passed to `ImageSize` [@toy](https://github.com/toy)
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'image_size'
5
- s.version = '2.0.0'
5
+ s.version = '2.0.1'
6
6
  s.summary = %q{Measure image size using pure Ruby}
7
7
  s.description = %q{Measure following file dimensions: apng, bmp, cur, gif, jpeg, ico, mng, pbm, pcx, pgm, png, ppm, psd, swf, tiff, xbm, xpm, webp}
8
8
  s.homepage = "http://github.com/toy/#{s.name}"
@@ -11,13 +11,20 @@ Gem::Specification.new do |s|
11
11
 
12
12
  s.rubyforge_project = s.name
13
13
 
14
+ s.metadata = {
15
+ 'bug_tracker_uri' => "https://github.com/toy/#{s.name}/issues",
16
+ 'changelog_uri' => "https://github.com/toy/#{s.name}/blob/master/CHANGELOG.markdown",
17
+ 'documentation_uri' => "https://www.rubydoc.info/gems/#{s.name}/#{s.version}",
18
+ 'source_code_uri' => "https://github.com/toy/#{s.name}",
19
+ }
20
+
14
21
  s.files = `git ls-files`.split("\n")
15
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
24
  s.require_paths = %w[lib]
18
25
 
19
26
  s.add_development_dependency 'rspec', '~> 3.0'
20
- if RUBY_VERSION >= '2.1'
21
- s.add_development_dependency 'rubocop', '~> 0.55'
27
+ if RUBY_VERSION >= '2.2'
28
+ s.add_development_dependency 'rubocop', '~> 0.59'
22
29
  end
23
30
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: BINARY
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'stringio'
4
5
 
@@ -24,7 +25,7 @@ class ImageSize
24
25
  else
25
26
  raise ArgumentError, "expected data as String or an object responding to read and eof?, got #{data_or_io.class}"
26
27
  end
27
- @data = ''
28
+ @data = String.new # not frozen
28
29
  end
29
30
 
30
31
  CHUNK = 1024
@@ -32,6 +33,7 @@ class ImageSize
32
33
  while !@io.eof? && @data.length < offset + length
33
34
  data = @io.read(CHUNK)
34
35
  break unless data
36
+
35
37
  data.force_encoding(@data.encoding) if data.respond_to?(:encoding)
36
38
  @data << data
37
39
  end
@@ -59,6 +61,7 @@ class ImageSize
59
61
  ir = ImageReader.new(data)
60
62
  @format = detect_format(ir)
61
63
  return unless @format
64
+
62
65
  @width, @height = send("size_of_#{@format}", ir)
63
66
  end
64
67
 
@@ -80,7 +83,7 @@ class ImageSize
80
83
 
81
84
  private
82
85
 
83
- SVG_R = /<svg\b([^>]*)>/
86
+ SVG_R = /<svg\b([^>]*)>/.freeze
84
87
  def detect_format(ir)
85
88
  head = ir[0, 1024]
86
89
  case
@@ -127,6 +130,7 @@ private
127
130
  unless ir[12, 4] == 'MHDR'
128
131
  raise FormatError, 'MHDR not in place for MNG'
129
132
  end
133
+
130
134
  ir[16, 8].unpack('NN')
131
135
  end
132
136
 
@@ -134,6 +138,7 @@ private
134
138
  unless ir[12, 4] == 'IHDR'
135
139
  raise FormatError, 'IHDR not in place for PNG'
136
140
  end
141
+
137
142
  ir[16, 8].unpack('NN')
138
143
  end
139
144
  alias_method :size_of_apng, :size_of_png
@@ -158,6 +163,7 @@ private
158
163
  if JPEG_CODE_CHECK.include?(code)
159
164
  return ir[offset + 1, 4].unpack('nn').reverse
160
165
  end
166
+
161
167
  offset += length - 2
162
168
  end
163
169
  end
@@ -199,6 +205,7 @@ private
199
205
  if data.length != length
200
206
  raise FormatError, 'XPM size not found'
201
207
  end
208
+
202
209
  length += 1024
203
210
  end
204
211
  [$1.to_i, $2.to_i]
@@ -222,10 +229,12 @@ private
222
229
  until width && height
223
230
  ifd = ir[offset, 12]
224
231
  raise FormatError, 'Reached end of directory entries in TIFF' if ifd.nil? || offset > num_dirent
232
+
225
233
  tag, type = ifd.unpack(endian2b * 2)
226
234
  offset += 12
227
235
 
228
236
  next if packspec[type].nil?
237
+
229
238
  value = ifd[8, 4].unpack(packspec[type])[0]
230
239
  case tag
231
240
  when 0x0100
@@ -259,6 +268,7 @@ private
259
268
  dpi = self.class.dpi
260
269
  [attributes['width'], attributes['height']].map do |length|
261
270
  next unless length
271
+
262
272
  pixels = case length.downcase.strip[/(?:em|ex|px|in|cm|mm|pt|pc|%)\z/]
263
273
  when 'em', 'ex', '%' then nil
264
274
  when 'in' then length.to_f * dpi
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
  require 'image_size'
3
5
  require 'tempfile'
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: 2.0.0
4
+ version: 2.0.1
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: 2018-05-01 00:00:00.000000000 Z
12
+ date: 2019-05-17 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: '0.55'
34
+ version: '0.59'
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: '0.55'
41
+ version: '0.59'
42
42
  description: 'Measure following file dimensions: apng, bmp, cur, gif, jpeg, ico, mng,
43
43
  pbm, pcx, pgm, png, ppm, psd, swf, tiff, xbm, xpm, webp'
44
44
  email:
@@ -82,7 +82,11 @@ files:
82
82
  homepage: http://github.com/toy/image_size
83
83
  licenses:
84
84
  - Ruby
85
- metadata: {}
85
+ metadata:
86
+ bug_tracker_uri: https://github.com/toy/image_size/issues
87
+ changelog_uri: https://github.com/toy/image_size/blob/master/CHANGELOG.markdown
88
+ documentation_uri: https://www.rubydoc.info/gems/image_size/2.0.1
89
+ source_code_uri: https://github.com/toy/image_size
86
90
  post_install_message:
87
91
  rdoc_options: []
88
92
  require_paths:
@@ -98,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
102
  - !ruby/object:Gem::Version
99
103
  version: '0'
100
104
  requirements: []
101
- rubyforge_project: image_size
102
- rubygems_version: 2.7.6
105
+ rubygems_version: 3.0.3
103
106
  signing_key:
104
107
  specification_version: 4
105
108
  summary: Measure image size using pure Ruby