product_spy 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/product_spy/version.rb +1 -1
- data/lib/product_spy.rb +3 -2
- data/spec/host_spec.rb +9 -0
- data/spec/product_spy_spec.rb +17 -0
- metadata +6 -2
data/lib/product_spy/version.rb
CHANGED
data/lib/product_spy.rb
CHANGED
@@ -91,8 +91,9 @@ module ProductSpy
|
|
91
91
|
#
|
92
92
|
def self.parse(url)
|
93
93
|
uri = Addressable::URI.parse(url)
|
94
|
-
host = Configuration.instance.hosts[uri.host.downcase.to_sym] unless uri.host.nil?
|
94
|
+
host = Configuration.instance.hosts[uri.host.downcase.to_sym] unless uri.nil? or uri.host.nil?
|
95
95
|
return nil if host.nil?
|
96
|
-
|
96
|
+
return nil if (pk = host.make_pk(url)).nil?
|
97
|
+
[host.host_name.downcase, pk]
|
97
98
|
end
|
98
99
|
end
|
data/spec/host_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe ProductSpy do
|
3
|
+
describe '#parse' do
|
4
|
+
it "returns nil if no configured host matches the url" do
|
5
|
+
ProductSpy.parse('http://no.host/whatever').should be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns nil if no parser matches the url" do
|
9
|
+
ProductSpy.parse('http://amazon.de/whatever').should be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns nil if no url is given" do
|
13
|
+
ProductSpy.parse('').should be_nil
|
14
|
+
ProductSpy.parse(nil).should be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: product_spy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2013-04-
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -54,8 +54,10 @@ files:
|
|
54
54
|
- spec/baby-walz.de_spec.rb
|
55
55
|
- spec/ebay_spec.rb
|
56
56
|
- spec/hornbach.de_spec.rb
|
57
|
+
- spec/host_spec.rb
|
57
58
|
- spec/lecreuset.de_spec.rb
|
58
59
|
- spec/porzellanhandel24.de_spec.rb
|
60
|
+
- spec/product_spy_spec.rb
|
59
61
|
- spec/spec_helper.rb
|
60
62
|
homepage: https://github.com/spieker/product_spy
|
61
63
|
licenses: []
|
@@ -89,7 +91,9 @@ test_files:
|
|
89
91
|
- spec/baby-walz.de_spec.rb
|
90
92
|
- spec/ebay_spec.rb
|
91
93
|
- spec/hornbach.de_spec.rb
|
94
|
+
- spec/host_spec.rb
|
92
95
|
- spec/lecreuset.de_spec.rb
|
93
96
|
- spec/porzellanhandel24.de_spec.rb
|
97
|
+
- spec/product_spy_spec.rb
|
94
98
|
- spec/spec_helper.rb
|
95
99
|
has_rdoc:
|