image_suckr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/image_suckr.gemspec +21 -0
- data/lib/image_suckr.rb +29 -0
- data/lib/image_suckr/version.rb +3 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/image_suckr.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "image_suckr/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "image_suckr"
|
7
|
+
s.version = ImageSuckr::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Mauricio Miranda"]
|
10
|
+
s.email = ["mmiranda@xoomcode.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Get images randomly from the web}
|
13
|
+
s.description = %q{Ruby class to get images randomly from some websites for seeding pourposes.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "image_suckr"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/image_suckr.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module ImageSuckr
|
2
|
+
class GoogleSuckr
|
3
|
+
|
4
|
+
DEFAULT_PARAMS = {
|
5
|
+
"rsz" => "8",
|
6
|
+
#"as_filetype" => "png",
|
7
|
+
#"imgc" => "color",
|
8
|
+
#"imgcolor" => "black",
|
9
|
+
#"imgsz" => "medium",
|
10
|
+
#"imgtype" => "photo",
|
11
|
+
#"safe" => "active",
|
12
|
+
"v" => "1.0"
|
13
|
+
}
|
14
|
+
|
15
|
+
def getImageUrl(params = {})
|
16
|
+
params = DEFAULT_PARAMS.merge(params)
|
17
|
+
params["q"] = rand(1000).to_s if params["q"].nil?
|
18
|
+
url = "http://ajax.googleapis.com/ajax/services/search/images?" + params.to_query
|
19
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
20
|
+
result = JSON.parse(resp.body)
|
21
|
+
imageUrl = result["responseData"]["results"][rand(params["rsz"].to_i)]["url"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def getImage(params = {})
|
25
|
+
image = Net::HTTP.get_response(URI.parse(getImageUrl(params))).body
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: image_suckr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mauricio Miranda
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-05-05 00:00:00.000000000 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
description: Ruby class to get images randomly from some websites for seeding pourposes.
|
16
|
+
email:
|
17
|
+
- mmiranda@xoomcode.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- Rakefile
|
25
|
+
- image_suckr.gemspec
|
26
|
+
- lib/image_suckr.rb
|
27
|
+
- lib/image_suckr/version.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: image_suckr
|
49
|
+
rubygems_version: 1.5.2
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Get images randomly from the web
|
53
|
+
test_files: []
|