image_suckr 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ Description
2
+ -----------
3
+ ImageSuckr is a ruby gem that allows you to get random images from Google for seeding purposes.
4
+ In a future it will support other sources.
5
+
6
+ Installation
7
+ ------------
8
+ 1. Add `gem 'image_suckr'` to your Gemfile
9
+ 2. Run `bundle install`
10
+
11
+ Basic use
12
+ ---------
13
+ suckr = ImageSuckr::GoogleSuckr.new
14
+
15
+ To get a fully random image url:
16
+
17
+ suckr.getImageUrl
18
+
19
+ To get a random image url based on a query:
20
+
21
+ suckr.getImageUrl({"q" => "car"})
22
+
23
+ To get the image content instead of the url:
24
+
25
+ suckr.getImage
data/image_suckr.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Mauricio Miranda"]
10
10
  s.email = ["mmiranda@xoomcode.com"]
11
- s.homepage = ""
11
+ s.homepage = "https://github.com/maurimiranda/ImageSuckr"
12
12
  s.summary = %q{Get images randomly from the web}
13
13
  s.description = %q{Ruby class to get images randomly from some websites for seeding pourposes.}
14
14
 
@@ -1,3 +1,3 @@
1
1
  module ImageSuckr
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/image_suckr.rb CHANGED
@@ -1,3 +1,7 @@
1
+ require 'net/http' unless defined?(Net::HTTP)
2
+ require 'json' unless defined?(JSON)
3
+ require File.dirname(__FILE__) + '/support' unless "".respond_to? :to_query and [].respond_to? :to_query
4
+
1
5
  module ImageSuckr
2
6
  class GoogleSuckr
3
7
 
data/lib/support.rb ADDED
@@ -0,0 +1,14 @@
1
+ class String
2
+ def to_query(key)
3
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
4
+ "#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(to_s)}"
5
+ end
6
+ end
7
+
8
+ class Hash
9
+ def to_query(namespace = nil)
10
+ collect do |key, value|
11
+ value.to_query(namespace ? "#{namespace}[#{key}]" : key)
12
+ end.sort * '&'
13
+ end
14
+ 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.1
4
+ version: 0.0.2
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-05 00:00:00.000000000 -03:00
12
+ date: 2011-05-06 00:00:00.000000000 -03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Ruby class to get images randomly from some websites for seeding pourposes.
@@ -21,12 +21,14 @@ extra_rdoc_files: []
21
21
  files:
22
22
  - .gitignore
23
23
  - Gemfile
24
+ - README.md
24
25
  - Rakefile
25
26
  - image_suckr.gemspec
26
27
  - lib/image_suckr.rb
27
28
  - lib/image_suckr/version.rb
29
+ - lib/support.rb
28
30
  has_rdoc: true
29
- homepage: ''
31
+ homepage: https://github.com/maurimiranda/ImageSuckr
30
32
  licenses: []
31
33
  post_install_message:
32
34
  rdoc_options: []