random_images 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/random_images.rb +7 -11
- data/random_images.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/random_images.rb
CHANGED
@@ -5,17 +5,17 @@ require 'cgi'
|
|
5
5
|
module RandomImages
|
6
6
|
|
7
7
|
module Images
|
8
|
-
|
8
|
+
|
9
9
|
def self.get(number = 100, keyword = "me", content = "face")
|
10
10
|
max = [number / 10, 1].max
|
11
11
|
nokogiri = (1..max).map{ Nokogiri::HTML(open_page(keyword, content)) }
|
12
12
|
nokogiri.map do |n|
|
13
|
-
n.search("a
|
13
|
+
n.search(".images_table a").map{ |x| x.attr('href').split(/=|&/)[1] }
|
14
14
|
end.flatten[0, number].map(&:unescape)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
private
|
18
|
-
|
18
|
+
|
19
19
|
def self.get_url(keyword = 'me', content = 'face')
|
20
20
|
"http://www.google.com/images?q=#{keyword}&hl=en&safe=active&biw=1280&bih=653&gbv=1&as_st=y&tbs=isch:1" +
|
21
21
|
if content == "any"
|
@@ -24,11 +24,11 @@ module RandomImages
|
|
24
24
|
",itp:face&ei=cq5dTe7UFomLswajlbDXCg&start=#{(1..850).random}&sa=N"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def self.open_page(keyword, content)
|
29
29
|
open(get_url(keyword, content)).read
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
33
|
|
34
34
|
module Image
|
@@ -36,7 +36,7 @@ module RandomImages
|
|
36
36
|
def self.get(keyword = "me", content = "face")
|
37
37
|
Images.get(1, keyword, content).random
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
end
|
41
41
|
|
42
42
|
end
|
@@ -54,10 +54,6 @@ class Range
|
|
54
54
|
end
|
55
55
|
|
56
56
|
class String
|
57
|
-
def to_url
|
58
|
-
"http://" + self
|
59
|
-
end
|
60
|
-
|
61
57
|
def unescape
|
62
58
|
CGI.unescape(self)
|
63
59
|
end
|
data/random_images.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{random_images}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jordi Noguera"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-04-17}
|
13
13
|
s.description = %q{Pull urls of random images from google searches to generate sample data.}
|
14
14
|
s.email = %q{jordinoguera83@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordi Noguera
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-17 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|