color_cat 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ddc683e80f9392b6c6973e897d9ca2a6b0d95db
4
- data.tar.gz: 724be683b844938c4375965f77dc3df700aac71c
3
+ metadata.gz: 3a7dab54fe1ad551c0adf7bd00cdee307abb93d9
4
+ data.tar.gz: 0f17ba4c6d897fc5a4b52b767701c7e3cef48f9c
5
5
  SHA512:
6
- metadata.gz: 991596ed154770e82de6abb45b2cf752673be45ad61946ba2d1c031e4e5b1487828f581b76e8ba6b202fa9111dd82ab353ff4ddcdf6aab91ef576b607557222d
7
- data.tar.gz: 32b7bea6f640cba1e394a5e6fc557478889792e32aa5e4882aacbdd6ed4bd4a9e833d2c4a12e1632fd9600f11465e1eeb2330f24aa269ce716c58a28a3eaa36a
6
+ metadata.gz: f069ef0a0ed025683e23f2f98895db05e772e7348ef83ad5a41fa7bcfc7bae7b8d6c0c4c42d4e302383585e4b7a3a8ce9df87013044c04a9186c68d5ec919bfb
7
+ data.tar.gz: 66534b7b33b94f0384683a8c89ea36ed05cdc9ba5e1db900ae03b9a43ae0ee1fc762857087fdfbe5c42a1e6ef117a7784c58af35137c3a9ce9e852c5574fcd71
@@ -1,4 +1,5 @@
1
1
  require 'RMagick'
2
+ require "open-uri"
2
3
 
3
4
  module ColorCat
4
5
  class Process
@@ -13,9 +14,12 @@ module ColorCat
13
14
  end
14
15
 
15
16
  def call
16
- process_image
17
- normal = sort_by_decreasing_frequency(quantized)
18
- get_pix(normal)
17
+ begin
18
+ process_image
19
+ normal = sort_by_decreasing_frequency(quantized)
20
+ get_pix(normal)
21
+ rescue OpenURI::HTTPError
22
+ end
19
23
  end
20
24
 
21
25
  def self.call(url, opts={})
@@ -74,7 +78,7 @@ module ColorCat
74
78
  private
75
79
 
76
80
  def process_image
77
- @original = Magick::Image.read(url).first
81
+ @original = Magick::Image.read(save_to_tempfile(url).path).first
78
82
  @quantized = original.quantize(NUMBER_OF_COLORS, Magick::RGBColorspace)
79
83
  end
80
84
 
@@ -113,5 +117,13 @@ module ColorCat
113
117
  self
114
118
  end
115
119
 
120
+ def save_to_tempfile(url_or_path)
121
+ tempfile = Tempfile.new("testfile.jpg")
122
+ tempfile.binmode
123
+ tempfile << open(url_or_path).read
124
+ tempfile.rewind
125
+ tempfile
126
+ end
127
+
116
128
  end
117
129
  end
@@ -1,3 +1,3 @@
1
1
  module ColorCat
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_cat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Piccolo