random_images 0.0.1 → 0.0.2
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 +6 -1
- data/random_images.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/random_images.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'cgi'
|
3
4
|
|
4
5
|
module RandomImages
|
5
6
|
|
@@ -10,7 +11,7 @@ module RandomImages
|
|
10
11
|
nokogiri = (1..max).map{ Nokogiri::HTML(open_page(keyword, content)) }
|
11
12
|
nokogiri.map do |n|
|
12
13
|
n.search("a img").map{ |x| x["src"].split(":http://")[1] }.compact.map(&:to_url)
|
13
|
-
end.flatten[0, number]
|
14
|
+
end.flatten[0, number].amp(&:unescape)
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
@@ -56,4 +57,8 @@ class String
|
|
56
57
|
def to_url
|
57
58
|
"http://" + self
|
58
59
|
end
|
60
|
+
|
61
|
+
def unescape
|
62
|
+
CGI.unescape(self)
|
63
|
+
end
|
59
64
|
end
|
data/random_images.gemspec
CHANGED
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordi Noguera
|