aislefinder 0.0.01
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE.txt +21 -0
- data/README.markdown +70 -0
- data/Rakefile +2 -0
- data/aislefinder.gemspec +36 -0
- data/bin/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/aislefinder.rb +165 -0
- data/lib/aislefinder/version.rb +3 -0
- data/lib/array_of_product.rb +18 -0
- data/lib/array_of_store.rb +16 -0
- data/lib/array_of_store_city.rb +18 -0
- data/lib/array_of_store_state.rb +18 -0
- data/lib/array_of_string.rb +18 -0
- data/lib/product_set.rb +21 -0
- data/lib/store_city_set.rb +15 -0
- data/lib/store_set.rb +31 -0
- data/lib/store_state_set.rb +11 -0
- data/lib/string_set.rb +10 -0
- data/spec/.DS_Store +0 -0
- data/spec/client_spec.rb +58 -0
- data/spec/spec_helper.rb +14 -0
- metadata +217 -0
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2011 Wavell Watson, https://github.com/wavell/AisleFinder
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Aisle finder
|
2
|
+
===============================
|
3
|
+
|
4
|
+
**Installation**
|
5
|
+
|
6
|
+
```
|
7
|
+
gem install aislefinder
|
8
|
+
```
|
9
|
+
|
10
|
+
*Usage*
|
11
|
+
|
12
|
+
Set the get an api key from www.supermarketapi.com.
|
13
|
+
Set the base uri and apikey
|
14
|
+
|
15
|
+
```
|
16
|
+
require 'aislefinder'
|
17
|
+
AisleFinder.base_uri = 'http://www.SupermarketAPI.com/api.asmx'
|
18
|
+
AisleFinder.apikey = 'YOURAPIKEYHERE'
|
19
|
+
```
|
20
|
+
|
21
|
+
*Find by product name*
|
22
|
+
|
23
|
+
```
|
24
|
+
products = AisleFinder.find_by_product_name("Parsley")
|
25
|
+
products.first.item_name # should match /Mccormick Parsley Flake Gourmet/
|
26
|
+
```
|
27
|
+
|
28
|
+
*Find product by Id*
|
29
|
+
|
30
|
+
```
|
31
|
+
products = AisleFinder.find_by_product_id("32372")
|
32
|
+
products.first.item_name #should match /Mccormick Parsley Flake Gourmet/
|
33
|
+
```
|
34
|
+
|
35
|
+
*Find products by full name*
|
36
|
+
```
|
37
|
+
AisleFinder.find_product_names_by_full_name("Apple").first.product_name #should match /Apples/
|
38
|
+
```
|
39
|
+
|
40
|
+
*Find stores by name*
|
41
|
+
```
|
42
|
+
AisleFinder.find_stores_by_name("Safeway").first.store_name #should match /Safeway/
|
43
|
+
```
|
44
|
+
|
45
|
+
*Find products by store id*
|
46
|
+
```
|
47
|
+
AisleFinder.find_products_by_store_id("b97153fc14", "Apple").first.item_name #should match /Apples/
|
48
|
+
```
|
49
|
+
|
50
|
+
*Find stores by city and state*
|
51
|
+
```
|
52
|
+
AisleFinder.find_stores_by_city_and_state("San Francisco", "CA").first.store_name #should match /Safeway/
|
53
|
+
```
|
54
|
+
|
55
|
+
*Find stores by zip*
|
56
|
+
```
|
57
|
+
AisleFinder.find_stores_by_zip("95130").first.store_name #should match /Luckys/
|
58
|
+
```
|
59
|
+
|
60
|
+
*Find all of the U.S. states*
|
61
|
+
```
|
62
|
+
AisleFinder.find_all_us_states.first.state #should match /AL/
|
63
|
+
```
|
64
|
+
|
65
|
+
*Find cities by state*
|
66
|
+
```
|
67
|
+
AisleFinder.find_cities_by_state("CA").first.city #should match /Anderson/
|
68
|
+
```
|
69
|
+
|
70
|
+
|
data/Rakefile
ADDED
data/aislefinder.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "aislefinder/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.add_dependency "diff-lcs", "1.1.3"
|
8
|
+
s.add_dependency "mime-types", "1.17.2"
|
9
|
+
s.add_dependency "nokogiri", "1.5.0"
|
10
|
+
s.add_dependency "rspec", "2.8.0"
|
11
|
+
s.add_dependency "rspec-core", "~> 2.8.0"
|
12
|
+
s.add_dependency "rspec-expectations", "~> 2.8.0"
|
13
|
+
s.add_dependency "rspec-mocks", "~> 2.8.0"
|
14
|
+
s.add_dependency "rspec-core", "2.8.0"
|
15
|
+
s.add_dependency "rspec-expectations", "2.8.0"
|
16
|
+
s.add_dependency "diff-lcs", "~> 1.1.2"
|
17
|
+
s.add_dependency "rspec-mocks", "2.8.0"
|
18
|
+
s.add_dependency "typhoeus", "0.3.3"
|
19
|
+
s.add_dependency "mime-types"
|
20
|
+
|
21
|
+
s.name = "aislefinder"
|
22
|
+
s.version = AisleFinder::VERSION
|
23
|
+
s.platform = Gem::Platform::RUBY
|
24
|
+
s.authors = ["Wavell Watson"]
|
25
|
+
s.email = ["wavel.watson@gmail.com"]
|
26
|
+
s.homepage = "https://github.com/wavell/aislefinder"
|
27
|
+
s.summary = %q{Installs client for the aislefinder api.}
|
28
|
+
s.description = %q{Allows you to find the aisle for groceries per your local super market.}
|
29
|
+
s.license = "MIT"
|
30
|
+
s.rubyforge_project = "aislefinder"
|
31
|
+
|
32
|
+
s.files = `git ls-files`.split("\n")
|
33
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
34
|
+
s.executables = `git ls-files -- bin/aislefinder`.split("\n").map{ |f| File.basename(f) }
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
end
|
data/bin/.DS_Store
ADDED
Binary file
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/aislefinder.rb
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'typhoeus'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'array_of_product'
|
6
|
+
require 'array_of_store_state'
|
7
|
+
require 'array_of_store_city'
|
8
|
+
require 'array_of_string'
|
9
|
+
require 'array_of_store'
|
10
|
+
require 'cgi'
|
11
|
+
|
12
|
+
module AisleFinder
|
13
|
+
|
14
|
+
class << self;
|
15
|
+
attr_accessor :base_uri
|
16
|
+
attr_accessor :apikey
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.find_by_product_name(name)
|
20
|
+
# http://www.SupermarketAPI.com/api.asmx/SearchByProductName?APIKEY=APIKEY&ItemName=Parsley
|
21
|
+
response = Typhoeus::Request.get( "#{base_uri}/SearchByProductName?APIKEY=#{apikey}&ItemName=#{name}")
|
22
|
+
if response.code == 200
|
23
|
+
doc = Nokogiri::XML(response.body)
|
24
|
+
array_of_products = ArrayOfProduct.parse(doc)
|
25
|
+
|
26
|
+
# should be a 404 (not found) :(
|
27
|
+
if array_of_products.product_sets && array_of_products.product_sets.first.item_name != 'NOITEM'
|
28
|
+
array_of_products.product_sets
|
29
|
+
else
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
elsif response.code == 404
|
33
|
+
nil
|
34
|
+
else
|
35
|
+
raise response.body
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.find_by_product_id(id)
|
40
|
+
# hhttp://www.supermarketapi.com/api.asmx/SearchByItemID?APIKEY=APIKEY&ItemId=32372
|
41
|
+
response = Typhoeus::Request.get( "#{base_uri}/SearchByItemID?APIKEY=#{apikey}&ItemId=#{id}")
|
42
|
+
if response.code == 200
|
43
|
+
doc = Nokogiri::XML(response.body)
|
44
|
+
array_of_products = ArrayOfProduct.parse(doc)
|
45
|
+
|
46
|
+
# should be a 404 (not found) :(
|
47
|
+
if array_of_products.product_sets && array_of_products.product_sets.first.item_name != 'NOITEM'
|
48
|
+
array_of_products.product_sets
|
49
|
+
else
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
elsif response.code == 404
|
53
|
+
nil
|
54
|
+
else
|
55
|
+
raise response.body
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.find_all_us_states
|
60
|
+
# http://www.SupermarketAPI.com/api.asmx/AllUSStates
|
61
|
+
response = Typhoeus::Request.get( "#{base_uri}/AllUSStates")
|
62
|
+
if response.code == 200
|
63
|
+
doc = Nokogiri::XML(response.body)
|
64
|
+
array_of_store_states = ArrayOfStoreState.parse(doc)
|
65
|
+
array_of_store_states.store_state_sets
|
66
|
+
elsif response.code == 404
|
67
|
+
nil
|
68
|
+
else
|
69
|
+
raise response.body
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.find_cities_by_state(state)
|
74
|
+
#http://www.supermarketapi.com/api.asmx/CitiesByState?APIKEY=APIKEY&SelectedState=CA
|
75
|
+
response = Typhoeus::Request.get( "#{base_uri}/CitiesByState?APIKEY=#{apikey}&SelectedState=#{state}")
|
76
|
+
if response.code == 200
|
77
|
+
doc = Nokogiri::XML(response.body)
|
78
|
+
array_of_store_city = ArrayOfStoreCity.parse(doc)
|
79
|
+
array_of_store_city.store_city_sets
|
80
|
+
elsif response.code == 404
|
81
|
+
nil
|
82
|
+
else
|
83
|
+
raise response.body
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.find_product_names_by_full_name(full_name)
|
89
|
+
#http://www.supermarketapi.com/api.asmx/GetGroceries?APIKEY=APIKEY&SearchText=Apple
|
90
|
+
response = Typhoeus::Request.get( "#{base_uri}/GetGroceries?APIKEY=#{apikey}&SearchText=#{full_name}")
|
91
|
+
if response.code == 200
|
92
|
+
doc = Nokogiri::XML(response.body)
|
93
|
+
array_of_string = ArrayOfString.parse(doc)
|
94
|
+
array_of_string.string_sets
|
95
|
+
elsif response.code == 404
|
96
|
+
nil
|
97
|
+
else
|
98
|
+
raise response.body
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.find_stores_by_name(store)
|
103
|
+
#http://www.supermarketapi.com/api.asmx/ReturnStoresByName?APIKEY=APIKEY&StoreName=Safeway
|
104
|
+
response = Typhoeus::Request.get( "#{base_uri}/ReturnStoresByName?APIKEY=#{apikey}&StoreName=#{store}")
|
105
|
+
if response.code == 200
|
106
|
+
doc = Nokogiri::XML(response.body)
|
107
|
+
array_of_store = ArrayOfStore.parse(doc)
|
108
|
+
array_of_store.store_sets
|
109
|
+
elsif response.code == 404
|
110
|
+
nil
|
111
|
+
else
|
112
|
+
raise response.body
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.find_products_by_store_id(store_id, name)
|
117
|
+
# http://www.supermarketapi.com/api.asmx/SearchForItem?APIKEY=APIKEY&StoreId=b97153fc14&ItemName=Apple
|
118
|
+
response = Typhoeus::Request.get( "#{base_uri}/SearchForItem?APIKEY=#{apikey}&StoreId=#{store_id}&ItemName=#{name}")
|
119
|
+
if response.code == 200
|
120
|
+
doc = Nokogiri::XML(response.body)
|
121
|
+
array_of_products = ArrayOfProduct.parse(doc)
|
122
|
+
# should be a 404 (not found) :(
|
123
|
+
if array_of_products.product_sets && array_of_products.product_sets.first.item_name != 'NOITEM'
|
124
|
+
array_of_products.product_sets
|
125
|
+
else
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
elsif response.code == 404
|
129
|
+
nil
|
130
|
+
else
|
131
|
+
raise response.body
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.find_stores_by_city_and_state(city,state)
|
136
|
+
#http://http://www.SupermarketAPI.com/api.asmx/StoresByCityState?APIKEY=APIKEY&SelectedCity=San Francisco&SelectedState=CA
|
137
|
+
city=CGI::escape(city)
|
138
|
+
response = Typhoeus::Request.get( "#{base_uri}/StoresByCityState?APIKEY=#{apikey}&SelectedCity=#{city}&SelectedState=#{state}")
|
139
|
+
if response.code == 200
|
140
|
+
doc = Nokogiri::XML(response.body)
|
141
|
+
array_of_store = ArrayOfStore.parse(doc)
|
142
|
+
array_of_store.store_sets
|
143
|
+
elsif response.code == 404
|
144
|
+
nil
|
145
|
+
else
|
146
|
+
raise response.body
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.find_stores_by_zip(zip)
|
151
|
+
#http://www.SupermarketAPI.com/api.asmx/StoresByZip?APIKEY=APIKEY&ZipCode=95130
|
152
|
+
response = Typhoeus::Request.get( "#{base_uri}/StoresByZip?APIKEY=#{apikey}&ZipCode=#{zip}")
|
153
|
+
if response.code == 200
|
154
|
+
doc = Nokogiri::XML(response.body)
|
155
|
+
array_of_store = ArrayOfStore.parse(doc)
|
156
|
+
array_of_store.store_sets
|
157
|
+
elsif response.code == 404
|
158
|
+
nil
|
159
|
+
else
|
160
|
+
raise response.body
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'product_set'
|
2
|
+
|
3
|
+
class ArrayOfProduct
|
4
|
+
attr_reader :product_sets
|
5
|
+
def initialize(product_sets)
|
6
|
+
@product_sets = product_sets
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(xml)
|
10
|
+
# debugger
|
11
|
+
# doc = Nokogiri::XML(xml)
|
12
|
+
sets = xml.css("ArrayOfProduct > Product").map do |product|
|
13
|
+
ProductSet.from_xml(product)
|
14
|
+
end
|
15
|
+
new(sets)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'store_set'
|
2
|
+
|
3
|
+
class ArrayOfStore
|
4
|
+
attr_reader :store_sets
|
5
|
+
def initialize(store_sets)
|
6
|
+
@store_sets = store_sets
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(xml)
|
10
|
+
sets = xml.css("ArrayOfStore > Store").map do |store|
|
11
|
+
StoreSet.from_xml(store)
|
12
|
+
end
|
13
|
+
new(sets)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'store_city_set'
|
2
|
+
|
3
|
+
class ArrayOfStoreCity
|
4
|
+
attr_reader :store_city_sets
|
5
|
+
def initialize(store_city_sets)
|
6
|
+
@store_city_sets = store_city_sets
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(xml)
|
10
|
+
# debugger
|
11
|
+
# doc = Nokogiri::XML(xml)
|
12
|
+
sets = xml.css("ArrayOfStoreCity > StoreCity").map do |storecity|
|
13
|
+
StoreCitySet.from_xml(storecity)
|
14
|
+
end
|
15
|
+
new(sets)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'store_state_set'
|
2
|
+
|
3
|
+
class ArrayOfStoreState
|
4
|
+
attr_reader :store_state_sets
|
5
|
+
def initialize(store_state_sets)
|
6
|
+
@store_state_sets = store_state_sets
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(xml)
|
10
|
+
# debugger
|
11
|
+
# doc = Nokogiri::XML(xml)
|
12
|
+
sets = xml.css("ArrayOfStoreState > StoreState").map do |storestate|
|
13
|
+
StoreStateSet.from_xml(storestate)
|
14
|
+
end
|
15
|
+
new(sets)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'string_set'
|
2
|
+
|
3
|
+
class ArrayOfString
|
4
|
+
attr_reader :string_sets
|
5
|
+
def initialize(string_sets)
|
6
|
+
@string_sets = string_sets
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.parse(xml)
|
10
|
+
# debugger
|
11
|
+
# doc = Nokogiri::XML(xml)
|
12
|
+
sets = xml.css("ArrayOfString > string").map do |product_name|
|
13
|
+
StringSet.from_xml(product_name)
|
14
|
+
end
|
15
|
+
new(sets)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/product_set.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class ProductSet
|
2
|
+
attr_reader :item_name, :item_description, :item_category, :item_id, :item_image, :aisle_number
|
3
|
+
def initialize(attributes)
|
4
|
+
@item_name = attributes[:item_name]
|
5
|
+
@item_description = attributes[:item_description]
|
6
|
+
@item_category = attributes[:item_category]
|
7
|
+
@item_id = attributes[:item_id]
|
8
|
+
@item_image = attributes[:item_image]
|
9
|
+
@aisle_number = attributes[:aisle_number]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.from_xml(xml)
|
13
|
+
new( :item_name => xml.css("Itemname").text,
|
14
|
+
:item_description => xml.css("ItemDescription").text,
|
15
|
+
:item_category => xml.css("ItemCategory").text,
|
16
|
+
:item_id => xml.css("ItemID").text,
|
17
|
+
:item_image => xml.css("ItemImage").text,
|
18
|
+
:aisle_number => xml.css("AisleNumber").text)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class StoreCitySet
|
2
|
+
attr_reader :state
|
3
|
+
attr_reader :city
|
4
|
+
|
5
|
+
def initialize(attributes)
|
6
|
+
@city = attributes[:city]
|
7
|
+
@state = attributes[:state]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.from_xml(xml)
|
11
|
+
new( :city => xml.css("City").text,
|
12
|
+
:state => xml.css("State").text)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
data/lib/store_set.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class StoreSet
|
2
|
+
|
3
|
+
attr_reader :store_name
|
4
|
+
attr_reader :address
|
5
|
+
attr_reader :city
|
6
|
+
attr_reader :state
|
7
|
+
attr_reader :zip
|
8
|
+
attr_reader :phone
|
9
|
+
attr_reader :storeid
|
10
|
+
|
11
|
+
def initialize(attributes)
|
12
|
+
@store_name = attributes[:store_name]
|
13
|
+
@address = attributes[:address]
|
14
|
+
@city = attributes[:city]
|
15
|
+
@state = attributes[:state]
|
16
|
+
@zip = attributes[:zip]
|
17
|
+
@phone = attributes[:phone]
|
18
|
+
@storeid = attributes[:storeid]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.from_xml(xml)
|
22
|
+
new( :store_name => xml.css("Storename").text,
|
23
|
+
:address => xml.css("Address").text,
|
24
|
+
:city => xml.css("City").text,
|
25
|
+
:state => xml.css("State").text,
|
26
|
+
:zip => xml.css("Zip").text,
|
27
|
+
:phone => xml.css("Phone").text,
|
28
|
+
:storeid => xml.css("StoreId").text)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/lib/string_set.rb
ADDED
data/spec/.DS_Store
ADDED
Binary file
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'aislefinder'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "client" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
AisleFinder.base_uri = 'http://www.SupermarketAPI.com/api.asmx'
|
8
|
+
AisleFinder.apikey = 'YOURAPIKEYHERE'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should get a product by name" do
|
12
|
+
products = AisleFinder.find_by_product_name("Parsley")
|
13
|
+
products.first.item_name.should match /Mccormick Parsley Flake Gourmet/
|
14
|
+
# test other item
|
15
|
+
end
|
16
|
+
|
17
|
+
it "gettting a product by name should return nil for a product not found" do
|
18
|
+
AisleFinder.find_by_product_name("ParsleyFromMars").should be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should get a product by it's Id" do
|
22
|
+
products = AisleFinder.find_by_product_id("32372")
|
23
|
+
products.first.item_name.should match /Mccormick Parsley Flake Gourmet/
|
24
|
+
end
|
25
|
+
|
26
|
+
it "gettting a product by Id should return nil for a product not found" do
|
27
|
+
AisleFinder.find_by_product_id("12345").should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return all U.S. States" do
|
31
|
+
AisleFinder.find_all_us_states.first.state.should match /AL/
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return cities by state" do
|
35
|
+
AisleFinder.find_cities_by_state("CA").first.city.should match /Anderson/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return product names by their full name" do
|
39
|
+
AisleFinder.find_product_names_by_full_name("Apple").first.product_name.should match /Apples/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return stores by name" do
|
43
|
+
AisleFinder.find_stores_by_name("Safeway").first.store_name.should match /Safeway/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return products by store id" do
|
47
|
+
AisleFinder.find_products_by_store_id("b97153fc14", "Apple").first.item_name.should match /Apples/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return stores by city and state" do
|
51
|
+
AisleFinder.find_stores_by_city_and_state("San Francisco", "CA").first.store_name.should match /Safeway/
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return stores by zip" do
|
55
|
+
AisleFinder.find_stores_by_zip("95130").first.store_name.should match /Luckys/
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.mock_with :rspec
|
5
|
+
# Use color in STDOUT
|
6
|
+
config.color_enabled = true
|
7
|
+
|
8
|
+
# Use color not only in STDOUT but also in pagers and files
|
9
|
+
config.tty = true
|
10
|
+
|
11
|
+
# Use the specified formatter
|
12
|
+
config.formatter = :documentation # :progress, :html, :textmate
|
13
|
+
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aislefinder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.01
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Wavell Watson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-13 00:00:00.000000000 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: diff-lcs
|
17
|
+
requirement: &2153230860 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - =
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.3
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2153230860
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: mime-types
|
28
|
+
requirement: &2153230160 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - =
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.17.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2153230160
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: nokogiri
|
39
|
+
requirement: &2153229540 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - =
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.5.0
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2153229540
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
requirement: &2153220460 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - =
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.8.0
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2153220460
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec-core
|
61
|
+
requirement: &2153219800 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ~>
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.8.0
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2153219800
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec-expectations
|
72
|
+
requirement: &2153219160 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.8.0
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *2153219160
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec-mocks
|
83
|
+
requirement: &2153218540 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.8.0
|
89
|
+
type: :runtime
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *2153218540
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: rspec-core
|
94
|
+
requirement: &2153217900 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - =
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 2.8.0
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *2153217900
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rspec-expectations
|
105
|
+
requirement: &2153217280 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - =
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.8.0
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: *2153217280
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: diff-lcs
|
116
|
+
requirement: &2153216660 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ~>
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 1.1.2
|
122
|
+
type: :runtime
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: *2153216660
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-mocks
|
127
|
+
requirement: &2153216040 !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - =
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.8.0
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: *2153216040
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: typhoeus
|
138
|
+
requirement: &2153215540 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - =
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 0.3.3
|
144
|
+
type: :runtime
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: *2153215540
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: mime-types
|
149
|
+
requirement: &2153215020 !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
type: :runtime
|
156
|
+
prerelease: false
|
157
|
+
version_requirements: *2153215020
|
158
|
+
description: Allows you to find the aisle for groceries per your local super market.
|
159
|
+
email:
|
160
|
+
- wavel.watson@gmail.com
|
161
|
+
executables: []
|
162
|
+
extensions: []
|
163
|
+
extra_rdoc_files: []
|
164
|
+
files:
|
165
|
+
- .DS_Store
|
166
|
+
- .gitignore
|
167
|
+
- Gemfile
|
168
|
+
- MIT-LICENSE.txt
|
169
|
+
- README.markdown
|
170
|
+
- Rakefile
|
171
|
+
- aislefinder.gemspec
|
172
|
+
- bin/.DS_Store
|
173
|
+
- lib/.DS_Store
|
174
|
+
- lib/aislefinder.rb
|
175
|
+
- lib/aislefinder/version.rb
|
176
|
+
- lib/array_of_product.rb
|
177
|
+
- lib/array_of_store.rb
|
178
|
+
- lib/array_of_store_city.rb
|
179
|
+
- lib/array_of_store_state.rb
|
180
|
+
- lib/array_of_string.rb
|
181
|
+
- lib/product_set.rb
|
182
|
+
- lib/store_city_set.rb
|
183
|
+
- lib/store_set.rb
|
184
|
+
- lib/store_state_set.rb
|
185
|
+
- lib/string_set.rb
|
186
|
+
- spec/.DS_Store
|
187
|
+
- spec/client_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
has_rdoc: true
|
190
|
+
homepage: https://github.com/wavell/aislefinder
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
post_install_message:
|
194
|
+
rdoc_options: []
|
195
|
+
require_paths:
|
196
|
+
- lib
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
+
none: false
|
199
|
+
requirements:
|
200
|
+
- - ! '>='
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
requirements: []
|
210
|
+
rubyforge_project: aislefinder
|
211
|
+
rubygems_version: 1.6.2
|
212
|
+
signing_key:
|
213
|
+
specification_version: 3
|
214
|
+
summary: Installs client for the aislefinder api.
|
215
|
+
test_files:
|
216
|
+
- spec/client_spec.rb
|
217
|
+
- spec/spec_helper.rb
|