watson 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +0 -0
- data/Manifest +19 -0
- data/README.rdoc +0 -0
- data/Rakefile +8 -0
- data/lib/client/account.rb +7 -0
- data/lib/client/tools.rb +10 -0
- data/lib/client/transact.rb +16 -0
- data/lib/dom/buy_session.rb +19 -0
- data/lib/dom/buyer.rb +8 -0
- data/lib/dom/coord.rb +8 -0
- data/lib/dom/device.rb +10 -0
- data/lib/dom/sell_session.rb +42 -0
- data/lib/dom/seller.rb +3 -0
- data/lib/parkingauction.rb +19 -0
- data/spec/client_account_spec.rb +7 -0
- data/spec/client_transact_spec.rb +23 -0
- data/watson.gemspec +42 -0
- metadata +159 -0
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rspec (2.0.1)
|
6
|
+
rspec-core (~> 2.0.1)
|
7
|
+
rspec-expectations (~> 2.0.1)
|
8
|
+
rspec-mocks (~> 2.0.1)
|
9
|
+
rspec-core (2.0.1)
|
10
|
+
rspec-expectations (2.0.1)
|
11
|
+
diff-lcs (>= 1.1.2)
|
12
|
+
rspec-mocks (2.0.1)
|
13
|
+
rspec-core (~> 2.0.1)
|
14
|
+
rspec-expectations (~> 2.0.1)
|
15
|
+
yajl-ruby (0.7.8)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
rspec
|
22
|
+
yajl-ruby
|
data/LICENSE
ADDED
File without changes
|
data/Manifest
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
Gemfile
|
3
|
+
Gemfile.lock
|
4
|
+
LICENSE
|
5
|
+
README.rdoc
|
6
|
+
Rakefile
|
7
|
+
lib/client/account.rb
|
8
|
+
lib/client/tools.rb
|
9
|
+
lib/client/transact.rb
|
10
|
+
lib/dom/buy_session.rb
|
11
|
+
lib/dom/buyer.rb
|
12
|
+
lib/dom/coord.rb
|
13
|
+
lib/dom/device.rb
|
14
|
+
lib/dom/sell_session.rb
|
15
|
+
lib/dom/seller.rb
|
16
|
+
lib/parkingauction.rb
|
17
|
+
spec/client_account_spec.rb
|
18
|
+
spec/client_transact_spec.rb
|
19
|
+
Manifest
|
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
class PA::Client::Account
|
2
|
+
def self.create_device(description)
|
3
|
+
description = PA::Client::Tools.uri_escape(description)
|
4
|
+
result = PA::Client::Tools.get_json("http://api.parkingauction.com/device/create?description=" + description)
|
5
|
+
PA::DOM::Device.adapt_json(result);
|
6
|
+
end
|
7
|
+
end
|
data/lib/client/tools.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class PA::Client::Transact
|
2
|
+
def self.start_buy_session(device, lat, lng)
|
3
|
+
result = PA::Client::Tools.get_json("http://api.parkingauction.com/transact/buy?device=#{device}&lat=#{lat}&lng=#{lng}")
|
4
|
+
PA::DOM::BuySession.adapt_json(result)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.start_sell_session(device, lat, lng)
|
8
|
+
result = PA::Client::Tools.get_json("http://api.parkingauction.com/transact/sell?device=#{device}&lat=#{lat}&lng=#{lng}")
|
9
|
+
PA::DOM::SellSession.adapt_json(result)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find_sellers_nearby(shard, buyer)
|
13
|
+
results = PA::Client::Tools.get_json("http://api.parkingauction.com/sellers/nearby?shard=#{shard}&buyer=#{buyer}")
|
14
|
+
PA::DOM::SellSession.adapt_json_array(results)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class PA::DOM::BuySession
|
2
|
+
attr_accessor :shard, :buyer
|
3
|
+
|
4
|
+
def initialize(shard = nil, buyer = nil)
|
5
|
+
@shard = shard
|
6
|
+
@buyer = buyer
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.adapt_json(value)
|
10
|
+
buyer_session = PA::DOM::BuySession.new
|
11
|
+
buyer_session.shard = value["Shard"]
|
12
|
+
|
13
|
+
buyer = PA::DOM::Buyer.new
|
14
|
+
buyer.id = value["Buyer"]["ID"]
|
15
|
+
buyer_session.buyer = buyer
|
16
|
+
|
17
|
+
buyer_session
|
18
|
+
end
|
19
|
+
end
|
data/lib/dom/buyer.rb
ADDED
data/lib/dom/coord.rb
ADDED
data/lib/dom/device.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
class PA::DOM::SellSession
|
2
|
+
attr_accessor :shard, :seller
|
3
|
+
|
4
|
+
def initialize(shard = nil, seller = nil)
|
5
|
+
@shard = shard
|
6
|
+
@seller = seller
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.adapt_json(value)
|
10
|
+
sell_session = PA::DOM::SellSession.new
|
11
|
+
sell_session.shard = value["Shard"]
|
12
|
+
|
13
|
+
seller = PA::DOM::Seller.new
|
14
|
+
seller.id = value["Seller"]["ID"]
|
15
|
+
sell_session.seller = seller
|
16
|
+
|
17
|
+
sell_session
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.adapt_json_array(value)
|
21
|
+
sell_sessions = []
|
22
|
+
value.each do |s|
|
23
|
+
sell_session = PA::DOM::SellSession.new
|
24
|
+
sell_session.shard = s["Shard"]
|
25
|
+
|
26
|
+
seller = PA::DOM::Seller.new
|
27
|
+
seller.id = s["Seller"]["ID"]
|
28
|
+
seller.ask = s["Seller"]["Ask"]
|
29
|
+
seller.distance = s["Seller"]["Distance"]
|
30
|
+
|
31
|
+
coord = PA::DOM::Coord.new
|
32
|
+
coord.lat = s["Seller"]["Location"]["Lat"]
|
33
|
+
coord.lng = s["Seller"]["Location"]["Lng"]
|
34
|
+
seller.location = coord
|
35
|
+
|
36
|
+
sell_session.seller = seller
|
37
|
+
|
38
|
+
sell_sessions << seller
|
39
|
+
end
|
40
|
+
sell_sessions
|
41
|
+
end
|
42
|
+
end
|
data/lib/dom/seller.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'uri'
|
4
|
+
require 'net/http'
|
5
|
+
require 'yajl'
|
6
|
+
|
7
|
+
module PA; module DOM; end; module Client; end; end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__))
|
10
|
+
|
11
|
+
require 'dom/coord'
|
12
|
+
require 'dom/device'
|
13
|
+
require 'dom/seller'
|
14
|
+
require 'dom/buyer'
|
15
|
+
require 'dom/sell_session'
|
16
|
+
require 'dom/buy_session'
|
17
|
+
require 'client/tools'
|
18
|
+
require 'client/account'
|
19
|
+
require 'client/transact'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'lib/parkingauction'
|
2
|
+
|
3
|
+
describe PA::Client::Transact do
|
4
|
+
|
5
|
+
describe "sessions" do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@device = 1263
|
9
|
+
end
|
10
|
+
it "start buy session should not fail" do
|
11
|
+
PA::Client::Transact.start_buy_session(@device, 0, 0)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "start sell session should not fail" do
|
15
|
+
PA::Client::Transact.start_sell_session(@device, 0, 0)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "get sellers nearby should return results" do
|
20
|
+
sellers = PA::Client::Transact.find_sellers_nearby(1,10)
|
21
|
+
sellers.length.should > 0
|
22
|
+
end
|
23
|
+
end
|
data/watson.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{watson}
|
5
|
+
s.version = "0.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["John H. Watson, M.D."]
|
9
|
+
s.date = %q{2010-11-11}
|
10
|
+
s.description = %q{Watson SDK}
|
11
|
+
s.email = %q{}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "lib/client/account.rb", "lib/client/tools.rb", "lib/client/transact.rb", "lib/dom/buy_session.rb", "lib/dom/buyer.rb", "lib/dom/coord.rb", "lib/dom/device.rb", "lib/dom/sell_session.rb", "lib/dom/seller.rb", "lib/parkingauction.rb"]
|
13
|
+
s.files = ["CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "lib/client/account.rb", "lib/client/tools.rb", "lib/client/transact.rb", "lib/dom/buy_session.rb", "lib/dom/buyer.rb", "lib/dom/coord.rb", "lib/dom/device.rb", "lib/dom/sell_session.rb", "lib/dom/seller.rb", "lib/parkingauction.rb", "spec/client_account_spec.rb", "spec/client_transact_spec.rb", "Manifest", "watson.gemspec"]
|
14
|
+
s.homepage = %q{}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Watson", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{watson}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Watson SDK}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
|
27
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
28
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
29
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
32
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
33
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
34
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<yajl-ruby>, [">= 0"])
|
38
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
39
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
40
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watson
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John H. Watson, M.D.
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-11 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: yajl-ruby
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
description: Watson SDK
|
78
|
+
email: ""
|
79
|
+
executables: []
|
80
|
+
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files:
|
84
|
+
- CHANGELOG
|
85
|
+
- LICENSE
|
86
|
+
- README.rdoc
|
87
|
+
- lib/client/account.rb
|
88
|
+
- lib/client/tools.rb
|
89
|
+
- lib/client/transact.rb
|
90
|
+
- lib/dom/buy_session.rb
|
91
|
+
- lib/dom/buyer.rb
|
92
|
+
- lib/dom/coord.rb
|
93
|
+
- lib/dom/device.rb
|
94
|
+
- lib/dom/sell_session.rb
|
95
|
+
- lib/dom/seller.rb
|
96
|
+
- lib/parkingauction.rb
|
97
|
+
files:
|
98
|
+
- CHANGELOG
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
101
|
+
- LICENSE
|
102
|
+
- README.rdoc
|
103
|
+
- Rakefile
|
104
|
+
- lib/client/account.rb
|
105
|
+
- lib/client/tools.rb
|
106
|
+
- lib/client/transact.rb
|
107
|
+
- lib/dom/buy_session.rb
|
108
|
+
- lib/dom/buyer.rb
|
109
|
+
- lib/dom/coord.rb
|
110
|
+
- lib/dom/device.rb
|
111
|
+
- lib/dom/sell_session.rb
|
112
|
+
- lib/dom/seller.rb
|
113
|
+
- lib/parkingauction.rb
|
114
|
+
- spec/client_account_spec.rb
|
115
|
+
- spec/client_transact_spec.rb
|
116
|
+
- Manifest
|
117
|
+
- watson.gemspec
|
118
|
+
has_rdoc: true
|
119
|
+
homepage: ""
|
120
|
+
licenses: []
|
121
|
+
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options:
|
124
|
+
- --line-numbers
|
125
|
+
- --inline-source
|
126
|
+
- --title
|
127
|
+
- Watson
|
128
|
+
- --main
|
129
|
+
- README.rdoc
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
version: "0"
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 11
|
147
|
+
segments:
|
148
|
+
- 1
|
149
|
+
- 2
|
150
|
+
version: "1.2"
|
151
|
+
requirements: []
|
152
|
+
|
153
|
+
rubyforge_project: watson
|
154
|
+
rubygems_version: 1.3.7
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: Watson SDK
|
158
|
+
test_files: []
|
159
|
+
|