product_spy 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module ProductSpy
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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
- [host.host_name.downcase, host.make_pk(url)]
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,9 @@
1
+ require 'spec_helper'
2
+ describe ProductSpy::Host do
3
+ describe '#make_pk' do
4
+ it "returns nil if no parser matches" do
5
+ host = ProductSpy::Configuration.instance.hosts[:'amazon.de']
6
+ host.make_pk('http://amazon.de/whatever').should be_nil
7
+ end
8
+ end
9
+ end
@@ -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.3
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-20 00:00:00.000000000 Z
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: