image_suckr 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -27,23 +27,23 @@ _All [Google Image Search API arguments](http://code.google.com/apis/imagesearch
27
27
 
28
28
  **To get the image content instead of the URL:**
29
29
 
30
- suckr.get_image
30
+ suckr.get_image_content
31
31
 
32
32
  Other useful examples
33
33
  ---
34
34
 
35
- **To get a RMagick image:**
35
+ **To get a [RMagick](http://rmagick.rubyforge.org/) image:**
36
36
 
37
- _You need to install [RMagick](http://rmagick.rubyforge.org/) to use this._
37
+ image = Magick::Image.from_blob(suckr.get_image_content).first
38
38
 
39
- image = Magick::Image.from_blob(suckr.get_image).first
39
+ **To get a [MiniMagick](https://github.com/probablycorey/mini_magick) image:**
40
40
 
41
- **To get a MiniMagick image:**
42
-
43
- _You need to install [MiniMagick](https://github.com/probablycorey/mini_magick) to use this._
44
-
45
- image = MiniMagick::Image.read(suckr.get_image)
41
+ image = MiniMagick::Image.read(suckr.get_image_content)
46
42
 
47
43
  or
48
44
 
49
- image = MiniMagick::Image.open(suckr.get_image_url)
45
+ image = MiniMagick::Image.open(suckr.get_image_url)
46
+
47
+ **To use with [Paperclip](https://github.com/thoughtbot/paperclip):**
48
+
49
+ car.picture = suckr.get_image_file({"q" => "car"})
@@ -1,3 +1,3 @@
1
1
  module ImageSuckr
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/image_suckr.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'net/http' unless defined?(Net::HTTP)
2
2
  require 'json' unless defined?(JSON)
3
+ require 'open-uri' unless defined?(OpenURI)
3
4
  require File.dirname(__FILE__) + '/support' unless "".respond_to? :to_query and [].respond_to? :to_query
4
5
 
5
6
  module ImageSuckr
@@ -25,8 +26,12 @@ module ImageSuckr
25
26
  imageUrl = result["responseData"]["results"][rand(params["rsz"].to_i)]["url"]
26
27
  end
27
28
 
28
- def get_image(params = {})
29
- image = Net::HTTP.get_response(URI.parse(getImageUrl(params))).body
29
+ def get_image_content(params = {})
30
+ content = Net::HTTP.get_response(URI.parse(get_image_url(params))).body
31
+ end
32
+
33
+ def get_image_file(params = {})
34
+ file = open(URI.parse(get_image_url(params)))
30
35
  end
31
36
 
32
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_suckr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-06 00:00:00.000000000 -03:00
12
+ date: 2011-05-09 00:00:00.000000000 -03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: ImageSuckr is a ruby gem that allows you to get random images from Google