image_size 1.1.3 → 1.1.4

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
- Y2ZmMGNhMjllMTRhOGVkMDc3MjA4OTM2NGFkZjQxN2MyN2QwNTUzNQ==
4
+ NjNlM2Y5M2U0NTk4M2NjNGQ2MWM2OWZjYjVmMWJkODcxZTVhYjI4Mg==
5
5
  data.tar.gz: !binary |-
6
- NGIwMDQ0ZGY0ZjY5MmIxNmExYjJkNzU2OTZjMjJiNWI2MjEyOWZhOQ==
6
+ YjY0NTc4ZDRjNjkwNWFlZmM5NDk1NmIwYWFjYjI1YzkyOGU2N2Q5Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjQ1NDBhMzk0YjAzM2QwMzgyOWU3NTA2OGI5ZjNmZGQwZTllYzExN2E4MGFj
10
- YmE5ZGM0ZDhkZmQ1MDA0Nzk2NjBlZDhhNTZlYWUzYWNlNzFkMWYxYTgzMjc5
11
- ZDE1Njc1NmZmNWRmYmNlNzVkZjdiZmEyZDg3OTgxNTI0MTExNzE=
9
+ Y2MzNzhhOWNhOTY5ZjM2NDk0MDE5MTUzNzkwNWYyZjVkYjEwNGQ1MThkMGYw
10
+ OWY3MWRlMGY1ODgyMTk5MzRiNDExZDIyOWVkZjQzNjkxNGMyNGVlNzI3MGY0
11
+ ODhjMzA1OTljNWQyYmYxM2JlODVjY2ZmNGM3YmY1NjM5ZjNhYzE=
12
12
  data.tar.gz: !binary |-
13
- NGM0ZTM1ZjRkYzlkMjcyMmM0MTU4NjkxZTA3MGMzM2E4ZmUzN2I5ODExYWE5
14
- NTUwYWM4NzhlNmE4ZDNkMWEwMTYxNjIzOGFiMmM5NGJlNzM1NTNmYzYzNzE3
15
- MzA3YjFmZmVlM2I1YWFhYzdhYWU4ZDI1MWZiMzQ1MWRhY2UzZDk=
13
+ YTY1NTEwZmZmYWQ2Njk5ZWUyZWU2OWEyODlmZDAwYWJhN2UzMWZmMTkyOTk2
14
+ M2Y5YTE4N2YwZmIzNjQ5NzZlMzBmZGFjNTE0MmQwNTdlYzgyN2ZjODllZDdj
15
+ NmQxYzYzZjBkYjAyOGI1MTAzMGVhM2UxMDk2YTYxMzRiMWFlZDQ=
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /.yardoc/
7
7
  /coverage/
8
8
 
9
+ Gemfile.lock
9
10
  Makefile
10
11
  *.o
11
12
  *.bundle
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - jruby-18mode
8
+ - jruby-19mode
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ - ree
12
+ script: "bundle exec rspec"
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.markdown CHANGED
@@ -3,6 +3,8 @@
3
3
  measure image size using pure Ruby
4
4
  formats: `bmp`, `gif`, `jpeg`, `pbm`, `pcx`, `pgm`, `png`, `ppm`, `psd`, `swf`, `tiff`, `xbm`, `xpm`
5
5
 
6
+ [![Build Status](https://travis-ci.org/toy/image_size.png?branch=master)](https://travis-ci.org/toy/image_size)
7
+
6
8
  ## Download
7
9
 
8
10
  The latest version of image\_size can be found at http://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 = '1.1.3'
5
+ s.version = '1.1.4'
6
6
  s.summary = %q{Measure image size using pure Ruby}
7
7
  s.description = %q{Measure following file dimensions: bmp, gif, jpeg, pbm, pcx, pgm, png, ppm, psd, swf, tiff, xbm, xpm}
8
8
  s.homepage = "http://github.com/toy/#{s.name}"
data/lib/image_size.rb CHANGED
@@ -25,8 +25,9 @@ class ImageSize
25
25
  @data = ''
26
26
  end
27
27
 
28
- def rewind
28
+ def close
29
29
  @io.rewind
30
+ @io.close if IO === @io
30
31
  end
31
32
 
32
33
  CHUNK = 1024
@@ -55,7 +56,7 @@ class ImageSize
55
56
  if @format = detect_format(ir)
56
57
  @width, @height = self.send("size_of_#{@format}", ir)
57
58
  end
58
- ir.rewind
59
+ ir.close
59
60
  end
60
61
 
61
62
  # Image format
@@ -19,35 +19,42 @@ describe ImageSize do
19
19
  ['image_size_spec.rb', nil, nil, nil],
20
20
  ].each do |name, format, width, height|
21
21
  path = File.join(File.dirname(__FILE__), name)
22
+ file_data = File.open(path, 'rb', &:read)
22
23
 
23
24
  it "should get format and dimensions for #{name} given IO" do
24
25
  File.open(path, 'rb') do |fh|
25
26
  is = ImageSize.new(fh)
26
27
  [is.format, is.width, is.height].should == [format, width, height]
28
+ fh.should_not be_closed
29
+ fh.rewind
30
+ fh.read.should == file_data
27
31
  end
28
32
  end
29
33
 
30
34
  it "should get format and dimensions for #{name} given StringIO" do
31
- File.open(path, 'rb') do |fh|
32
- is = ImageSize.new(StringIO.new(fh.read))
33
- [is.format, is.width, is.height].should == [format, width, height]
34
- end
35
+ io = StringIO.new(file_data)
36
+ is = ImageSize.new(io)
37
+ [is.format, is.width, is.height].should == [format, width, height]
38
+ io.should_not be_closed
39
+ io.rewind
40
+ io.read.should == file_data
35
41
  end
36
42
 
37
43
  it "should get format and dimensions for #{name} given file data" do
38
- File.open(path, 'rb') do |fh|
39
- is = ImageSize.new(fh.read)
40
- [is.format, is.width, is.height].should == [format, width, height]
41
- end
44
+ is = ImageSize.new(file_data)
45
+ [is.format, is.width, is.height].should == [format, width, height]
42
46
  end
43
47
 
44
48
  it "should get format and dimensions for #{name} given Tempfile" do
45
- file_data = File.open(path, 'rb') { |fh| fh.read }
46
49
  Tempfile.open(name) do |tf|
50
+ tf.binmode
47
51
  tf.write(file_data)
48
52
  tf.rewind
49
53
  is = ImageSize.new(tf)
50
54
  [is.format, is.width, is.height].should == [format, width, height]
55
+ tf.should_not be_closed
56
+ tf.rewind
57
+ tf.read.should == file_data
51
58
  end
52
59
  end
53
60
 
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: 1.1.3
4
+ version: 1.1.4
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: 2013-07-24 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -33,6 +33,8 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - .gitignore
36
+ - .travis.yml
37
+ - Gemfile
36
38
  - README.markdown
37
39
  - image_size.gemspec
38
40
  - lib/image_size.rb