image_scraper 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/image_scraper.gemspec +2 -2
- data/lib/image_scraper.rb +0 -1
- data/lib/image_scraper/client.rb +4 -2
- data/lib/image_scraper/util.rb +4 -0
- data/test/test_image_scraper.rb +13 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/image_scraper.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{image_scraper}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John McAliley"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-03}
|
13
13
|
s.description = %q{Simple utility to pull image urls from web page}
|
14
14
|
s.email = %q{john.mcaliley@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/image_scraper.rb
CHANGED
data/lib/image_scraper/client.rb
CHANGED
@@ -34,10 +34,12 @@ module ImageScraper
|
|
34
34
|
css = file.string rescue IO.read(file)
|
35
35
|
|
36
36
|
images += css.scan(/url\((.*?)\)/).collect do |image_url|
|
37
|
+
image_url = image_url[0]
|
37
38
|
if image_url.include?("data:image") and @include_css_data_images
|
38
|
-
image_url
|
39
|
+
image_url
|
39
40
|
else
|
40
|
-
|
41
|
+
image_url = ImageScraper::Util.strip_quotes(image_url)
|
42
|
+
@convert_to_absolute_url ? ImageScraper::Util.absolute_url(url,image_url) : image_url
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
data/lib/image_scraper/util.rb
CHANGED
data/test/test_image_scraper.rb
CHANGED
@@ -44,4 +44,17 @@ class TestImageScraper < Test::Unit::TestCase
|
|
44
44
|
scraper = ImageScraper::Client.new("http://local.couponshack.com")
|
45
45
|
assert scraper.stylesheet_images.include? ("http://local.couponshack.com/images/bg.png")
|
46
46
|
end
|
47
|
+
|
48
|
+
should "strip quotes from a url" do
|
49
|
+
assert_equal "/images/test.png", ImageScraper::Util.strip_quotes("'/images/test.png'")
|
50
|
+
assert_equal "http://www.somsite.com/images/test.png", ImageScraper::Util.strip_quotes("'http://www.somsite.com/images/test.png'")
|
51
|
+
assert_equal "/images/test.png", ImageScraper::Util.strip_quotes('"/images/test.png"')
|
52
|
+
end
|
53
|
+
|
54
|
+
should "return domain section from a url" do
|
55
|
+
assert_equal "http://ug.ly", ImageScraper::Util.domain("http://ug.ly/what/is/this.html")
|
56
|
+
assert_equal "http://ug.ly", ImageScraper::Util.domain("http://ug.ly/what/is/this/")
|
57
|
+
assert_equal "http://ug.ly", ImageScraper::Util.domain("http://ug.ly/what")
|
58
|
+
assert_equal "http://www.ug.ly", ImageScraper::Util.domain("http://www.ug.ly/what/is/this/")
|
59
|
+
end
|
47
60
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John McAliley
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-06-
|
17
|
+
date: 2011-06-03 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -175,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
175
175
|
requirements:
|
176
176
|
- - ">="
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
hash:
|
178
|
+
hash: -738762267344225369
|
179
179
|
segments:
|
180
180
|
- 0
|
181
181
|
version: "0"
|