fastimage 2.2.1 → 2.2.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +1 -1
  3. data/lib/fastimage.rb +13 -11
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72e83c6f6d442c29071e060cca8a8b0a0a17024a7871cd19a64b83f77e0c0ced
4
- data.tar.gz: 56d0f5f86e11f1a8922cdf5bbe292fef2753f5637df402fd7532ef21d8393537
3
+ metadata.gz: 6e4c8a8fb1f0bf8db7dff5aef7fd640d56e0938bd0c0e8bd2f5f0a659009429d
4
+ data.tar.gz: f827ef53ce46af99612e2628f72ed5bfa2c82b4729ea3a5dccd76dc67079b6c3
5
5
  SHA512:
6
- metadata.gz: 002eb40a04b2ce79f8cdc34ee2fdc0d70fe35ff964d380096302682756a17e4b22f8275e335822f5229080aada2ca8d5d17603607cb0cf6479b61ac6d4dd64ef
7
- data.tar.gz: 17c8efefdc90fae00178d045bb0670e2914f9f19eabdb0be983c49ffb573b752672f02678e38b1395129d7f55ffc42905fa1cbeb9017445ffa295db6cc4fe119
6
+ metadata.gz: 599ffa78f1020ece118a5f1bc47533ad98085ac6f71ede9ad4b2b0c1d8748c81e4fb060f6a1b9f5001f7df2661d70d9a16972bd118863461d39d491d0e3b2988
7
+ data.tar.gz: d761639e39eae059e2f810c7d6a124515d3c6db1470236044db376b424e78effaf48c51f4197c3a565c1aae3d1f742e1899e221f566a828c4f1f209d4e91d588
@@ -132,7 +132,7 @@ h2. Tests
132
132
 
133
133
  You'll need to @gem install fakeweb@ and possibly also @gem install test-unit@ to be able to run the tests.
134
134
 
135
- bc.. $ ruby test.rb
135
+ bc.. $ ruby test/test.rb
136
136
  Run options:
137
137
 
138
138
  # Running tests:
@@ -251,10 +251,8 @@ class FastImage
251
251
  Errno::ENETUNREACH, ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT,
252
252
  OpenSSL::SSL::SSLError
253
253
  raise ImageFetchFailure if @options[:raise_on_failure]
254
- rescue NoMethodError # 1.8.7p248 can raise this due to a net/http bug
255
- raise ImageFetchFailure if @options[:raise_on_failure]
256
254
  rescue UnknownImageType
257
- raise UnknownImageType if @options[:raise_on_failure]
255
+ raise if @options[:raise_on_failure]
258
256
  rescue CannotParseImage
259
257
  if @options[:raise_on_failure]
260
258
  if @property == :size
@@ -434,8 +432,11 @@ class FastImage
434
432
  end
435
433
 
436
434
  def fetch_using_base64(uri)
437
- data = uri.split(',')[1]
438
- decoded = Base64.decode64(data)
435
+ decoded = begin
436
+ Base64.decode64(uri.split(',')[1])
437
+ rescue
438
+ raise CannotParseImage
439
+ end
439
440
  @content_length = decoded.size
440
441
  fetch_using_read StringIO.new(decoded)
441
442
  end
@@ -471,19 +472,20 @@ class FastImage
471
472
 
472
473
  # Peeking beyond the end of the input will raise
473
474
  def peek(n)
474
- while @strpos + n - 1 >= @str.size
475
+ while @strpos + n > @str.size
475
476
  unused_str = @str[@strpos..-1]
477
+
476
478
  new_string = @read_fiber.resume
479
+ new_string = @read_fiber.resume if new_string.is_a? Net::ReadAdapter
477
480
  raise CannotParseImage if !new_string
478
-
479
481
  # we are dealing with bytes here, so force the encoding
480
- new_string.force_encoding("ASCII-8BIT") if String.method_defined? :force_encoding
482
+ new_string.force_encoding("ASCII-8BIT") if new_string.respond_to? :force_encoding
481
483
 
482
484
  @str = unused_str + new_string
483
485
  @strpos = 0
484
486
  end
485
487
 
486
- @str[@strpos..(@strpos + n - 1)]
488
+ @str[@strpos, n]
487
489
  end
488
490
 
489
491
  def read(n)
@@ -501,7 +503,7 @@ class FastImage
501
503
  new_string = @read_fiber.resume
502
504
  raise CannotParseImage if !new_string
503
505
 
504
- new_string.force_encoding("ASCII-8BIT") if String.method_defined? :force_encoding
506
+ new_string.force_encoding("ASCII-8BIT") if new_string.respond_to? :force_encoding
505
507
 
506
508
  fetched += new_string.size
507
509
  @str = new_string
@@ -585,7 +587,7 @@ class FastImage
585
587
 
586
588
  # fields (1) + bg color (1) + pixel ratio (1)
587
589
  fields = @stream.read(3).unpack("CCC")[0]
588
- if fields & 0x80 # Global Color Table
590
+ if fields & 0x80 != 0 # Global Color Table
589
591
  # 2 * (depth + 1) colors, each occupying 3 bytes (RGB)
590
592
  @stream.skip(3 * 2 ** ((fields & 0x7) + 1))
591
593
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2021-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakeweb-fi
@@ -81,7 +81,7 @@ homepage: http://github.com/sdsykes/fastimage
81
81
  licenses:
82
82
  - MIT
83
83
  metadata: {}
84
- post_install_message:
84
+ post_install_message:
85
85
  rdoc_options:
86
86
  - "--charset=UTF-8"
87
87
  require_paths:
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.0.3
101
- signing_key:
100
+ rubygems_version: 3.2.3
101
+ signing_key:
102
102
  specification_version: 4
103
103
  summary: FastImage - Image info fast
104
104
  test_files: []