ratis 3.1.0 → 3.1.1
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.
- data/.gitignore +6 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +89 -0
- data/Rakefile +8 -0
- data/lib/ratis/next_bus.rb +1 -1
- data/lib/ratis/next_bus2.rb +1 -1
- data/lib/ratis/schedule_nearby.rb +1 -1
- data/lib/ratis/version.rb +1 -1
- data/ratis.gemspec +33 -0
- data/spec/ratis/area_spec.rb +41 -0
- data/spec/ratis/closest_stop_spec.rb +99 -0
- data/spec/ratis/config_spec.rb +44 -0
- data/spec/ratis/core_ext_spec.rb +54 -0
- data/spec/ratis/itinerary_spec.rb +722 -0
- data/spec/ratis/landmark_category_spec.rb +46 -0
- data/spec/ratis/landmark_spec.rb +63 -0
- data/spec/ratis/location_spec.rb +207 -0
- data/spec/ratis/next_bus2_spec.rb +148 -0
- data/spec/ratis/next_bus_spec.rb +230 -0
- data/spec/ratis/pattern_spec.rb +122 -0
- data/spec/ratis/point_2_point_spec.rb +223 -0
- data/spec/ratis/request_spec.rb +132 -0
- data/spec/ratis/route_pattern_spec.rb +123 -0
- data/spec/ratis/route_spec.rb +75 -0
- data/spec/ratis/route_stops_spec.rb +82 -0
- data/spec/ratis/schedule_nearby_spec.rb +153 -0
- data/spec/ratis/timetable_spec.rb +115 -0
- data/spec/ratis/walk_spec.rb +72 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/ratis_helpers.rb +96 -0
- data/spec/support/vcr_cassettes/Point2Point.yml +200 -0
- metadata +64 -34
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.8.7-p371@ratis --create
|
data/CHANGELOG
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
3.1
|
2
|
+
- The NextBus class was really using the Nextbus2 api call all along. This was pretty confusing, so 2 seperate classes now exist; one for NextBus and NextBus2. This means any code using NextBus prior to 3.1 will break since it was really calling the Nextbus2 api and we've updated it so the class of matching name is calling the matching api method.
|
3
|
+
- Dev dependencies of chronic and rspec-instafail were also added to aid testing
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ratis (3.1.0)
|
5
|
+
savon (< 2.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (3.2.6)
|
11
|
+
i18n (~> 0.6)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
addressable (2.2.8)
|
14
|
+
akami (1.2.0)
|
15
|
+
gyoku (>= 0.4.0)
|
16
|
+
nokogiri (>= 1.4.0)
|
17
|
+
builder (3.2.0)
|
18
|
+
chronic (0.9.1)
|
19
|
+
columnize (0.3.6)
|
20
|
+
crack (0.3.1)
|
21
|
+
diff-lcs (1.2.3)
|
22
|
+
gyoku (0.4.6)
|
23
|
+
builder (>= 2.1.2)
|
24
|
+
hashdiff (0.0.5)
|
25
|
+
httpi (1.1.1)
|
26
|
+
rack
|
27
|
+
i18n (0.6.0)
|
28
|
+
linecache (0.46)
|
29
|
+
rbx-require-relative (> 0.0.4)
|
30
|
+
multi_json (1.3.6)
|
31
|
+
nokogiri (1.5.9)
|
32
|
+
nori (1.1.5)
|
33
|
+
rack (1.5.2)
|
34
|
+
rake (10.0.4)
|
35
|
+
rbx-require-relative (0.0.9)
|
36
|
+
redcarpet (2.1.1)
|
37
|
+
rspec (2.13.0)
|
38
|
+
rspec-core (~> 2.13.0)
|
39
|
+
rspec-expectations (~> 2.13.0)
|
40
|
+
rspec-mocks (~> 2.13.0)
|
41
|
+
rspec-core (2.13.1)
|
42
|
+
rspec-expectations (2.13.0)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-instafail (0.2.4)
|
45
|
+
rspec-mocks (2.13.1)
|
46
|
+
ruby-debug (0.10.4)
|
47
|
+
columnize (>= 0.1)
|
48
|
+
ruby-debug-base (~> 0.10.4.0)
|
49
|
+
ruby-debug-base (0.10.4)
|
50
|
+
linecache (>= 0.3)
|
51
|
+
savon (1.2.0)
|
52
|
+
akami (~> 1.2.0)
|
53
|
+
builder (>= 2.1.2)
|
54
|
+
gyoku (~> 0.4.5)
|
55
|
+
httpi (~> 1.1.0)
|
56
|
+
nokogiri (>= 1.4.0)
|
57
|
+
nori (~> 1.1.0)
|
58
|
+
wasabi (~> 2.5.0)
|
59
|
+
simplecov (0.6.4)
|
60
|
+
multi_json (~> 1.0)
|
61
|
+
simplecov-html (~> 0.5.3)
|
62
|
+
simplecov-html (0.5.3)
|
63
|
+
vcr (2.4.0)
|
64
|
+
wasabi (2.5.1)
|
65
|
+
httpi (~> 1.0)
|
66
|
+
nokogiri (>= 1.4.0)
|
67
|
+
webmock (1.8.7)
|
68
|
+
addressable (>= 2.2.7)
|
69
|
+
crack (>= 0.1.7)
|
70
|
+
yard (0.8.2.1)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
activesupport
|
77
|
+
bundler (>= 1.0.0)
|
78
|
+
chronic
|
79
|
+
hashdiff
|
80
|
+
rake
|
81
|
+
ratis!
|
82
|
+
redcarpet
|
83
|
+
rspec (~> 2.13.0)
|
84
|
+
rspec-instafail
|
85
|
+
ruby-debug
|
86
|
+
simplecov
|
87
|
+
vcr
|
88
|
+
webmock
|
89
|
+
yard
|
data/Rakefile
ADDED
data/lib/ratis/next_bus.rb
CHANGED
@@ -16,7 +16,7 @@ module Ratis
|
|
16
16
|
|
17
17
|
def self.where(conditions)
|
18
18
|
stop_id = conditions.delete(:stop_id)
|
19
|
-
app_id = conditions.delete(:app_id) || 'ratis-
|
19
|
+
app_id = conditions.delete(:app_id) || 'ratis-gem'
|
20
20
|
type = conditions.delete(:type) || 'N' # N for Next Bus
|
21
21
|
|
22
22
|
if datetime = conditions.delete(:datetime)
|
data/lib/ratis/next_bus2.rb
CHANGED
@@ -36,7 +36,7 @@ module Ratis
|
|
36
36
|
|
37
37
|
def self.where(conditions)
|
38
38
|
stop_id = conditions.delete :stop_id
|
39
|
-
app_id = conditions.delete(:app_id) || '
|
39
|
+
app_id = conditions.delete(:app_id) || 'ratis-gem'
|
40
40
|
|
41
41
|
raise ArgumentError.new('You must provide a stop ID') unless stop_id
|
42
42
|
Ratis.all_conditions_used? conditions
|
@@ -13,7 +13,7 @@ module Ratis
|
|
13
13
|
walk_distance = conditions.delete(:walk_distance)
|
14
14
|
landmark_id = conditions.delete(:landmark_id)
|
15
15
|
stop_id = conditions.delete(:stop_id) || ''
|
16
|
-
app_id = conditions.delete(:app_id) || '
|
16
|
+
app_id = conditions.delete(:app_id) || 'ratis-gem'
|
17
17
|
|
18
18
|
raise ArgumentError.new('You must provide latitude') unless latitude
|
19
19
|
raise ArgumentError.new('You must provide longitude') unless longitude
|
data/lib/ratis/version.rb
CHANGED
data/ratis.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'ratis/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'ratis'
|
7
|
+
s.version = Ratis.version
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = 'A Ruby wrapper around the ATIS SOAP Interface'
|
10
|
+
s.authors = ['Burst Software']
|
11
|
+
s.email = 'irish@burstdev.com'
|
12
|
+
s.files = `git ls-files`.split($/)
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
s.rdoc_options = ['--charset=UTF-8 --main=README.md']
|
15
|
+
s.extra_rdoc_files = ['README.md']
|
16
|
+
|
17
|
+
s.add_dependency 'savon', '<2.0'
|
18
|
+
|
19
|
+
s.add_development_dependency 'activesupport'
|
20
|
+
s.add_development_dependency 'bundler', '>= 1.0.0'
|
21
|
+
s.add_development_dependency 'chronic'
|
22
|
+
s.add_development_dependency 'hashdiff'
|
23
|
+
s.add_development_dependency 'rake'
|
24
|
+
s.add_development_dependency 'redcarpet'
|
25
|
+
s.add_development_dependency 'rspec', '~> 2.13.0'
|
26
|
+
s.add_development_dependency 'rspec-instafail'
|
27
|
+
s.add_development_dependency 'ruby-debug'
|
28
|
+
s.add_development_dependency 'simplecov'
|
29
|
+
s.add_development_dependency 'vcr'
|
30
|
+
s.add_development_dependency 'webmock'
|
31
|
+
s.add_development_dependency 'yard'
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::Area do
|
4
|
+
before do
|
5
|
+
Ratis.reset
|
6
|
+
Ratis.configure do |config|
|
7
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
8
|
+
config.namespace = 'PX_WEB'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#all' do
|
13
|
+
it 'only makes one request' do
|
14
|
+
# false just to stop further processing of response
|
15
|
+
Ratis::Request.should_receive(:get).once.and_call_original
|
16
|
+
Ratis::Area.all
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'requests the correct SOAP action with correct args' do
|
20
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
21
|
+
action.should eq('Getareas')
|
22
|
+
end.and_return(double('response', :success? => false))
|
23
|
+
|
24
|
+
Ratis::Area.all
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return all areas' do
|
28
|
+
areas = Ratis::Area.all
|
29
|
+
areas.should have(29).items
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse the area fields" do
|
33
|
+
areas = Ratis::Area.all
|
34
|
+
area = areas.last
|
35
|
+
|
36
|
+
expect(area.area).to eq('YG')
|
37
|
+
expect(area.description).to eq('Youngtown')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ratis::ClosestStop do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Ratis.reset
|
7
|
+
Ratis.configure do |config|
|
8
|
+
config.endpoint = 'http://soap.valleymetro.org/cgi-bin-soap-web-252/soap.cgi'
|
9
|
+
config.namespace = 'PX_WEB'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#where' do
|
14
|
+
before do
|
15
|
+
@today = Time.now.strftime("%m/%d/%Y")
|
16
|
+
@conditions = {:latitude => '33.4556',
|
17
|
+
:longitude => '-112.071807',
|
18
|
+
:location_text => 'some location text',
|
19
|
+
:num_stops => '15'}
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'only makes one request' do
|
23
|
+
# false just to stop further processing of response
|
24
|
+
Ratis::Request.should_receive(:get).once.and_call_original
|
25
|
+
Ratis::ClosestStop.where(@conditions.dup)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'requests the correct SOAP action' do
|
29
|
+
Ratis::Request.should_receive(:get) do |action, options|
|
30
|
+
action.should eq('Closeststop')
|
31
|
+
options["Locationlat"].should eq(@conditions[:latitude])
|
32
|
+
options["Locationlong"].should eq(@conditions[:longitude])
|
33
|
+
options["Locationtext"].should eq(@conditions[:location_text])
|
34
|
+
options["Numstops"].should eq(@conditions[:num_stops])
|
35
|
+
|
36
|
+
end.and_return(double('response', :success? => false))
|
37
|
+
|
38
|
+
Ratis::ClosestStop.where(@conditions.dup)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a collection of Ratis::Stop(s)" do
|
42
|
+
stops = Ratis::ClosestStop.where(@conditions.dup)
|
43
|
+
stops.each do |obj|
|
44
|
+
expect(obj).to be_a(Ratis::Stop)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns multiple locations' do
|
49
|
+
stops = Ratis::ClosestStop.where(@conditions.dup)
|
50
|
+
stops.should have(15).items
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'ignores a <Stop> without a blank <Description>' do
|
54
|
+
pending('Update specs to use new namespaced stop classes')
|
55
|
+
pending 'not sure if this is the correct behaviour'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'parses out the stop fields correctly' do
|
59
|
+
stops = Ratis::ClosestStop.where(@conditions.dup)
|
60
|
+
stop = stops.first
|
61
|
+
|
62
|
+
expect(stop.latitude).to eq('33.454494')
|
63
|
+
expect(stop.longitude).to eq('-112.070508')
|
64
|
+
expect(stop.area).to be_nil
|
65
|
+
expect(stop.walk_dir).to eq('SE')
|
66
|
+
expect(stop.stop_position).to eq('Y')
|
67
|
+
expect(stop.description).to eq('FILLMORE ST & 3RD ST')
|
68
|
+
expect(stop.walk_dist).to eq('0.15')
|
69
|
+
expect(stop.side).to eq('Far')
|
70
|
+
expect(stop.stop_id).to eq('10606')
|
71
|
+
expect(stop.heading).to eq('WB')
|
72
|
+
expect(stop.atis_stop_id).to eq('5648')
|
73
|
+
expect(stop.route_dirs).to eql({:routedir=>"7-S"})
|
74
|
+
expect(stop.route_dir).to eq('7-S')
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should raise error for missing arg latitude" do
|
78
|
+
conditions = @conditions.dup
|
79
|
+
conditions.delete(:latitude)
|
80
|
+
|
81
|
+
expect do
|
82
|
+
Ratis::ClosestStop.where(conditions)
|
83
|
+
end.to raise_error(ArgumentError, 'You must provide a latitude')
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should raise error for missing arg longitude" do
|
87
|
+
conditions = @conditions.dup
|
88
|
+
conditions.delete(:longitude)
|
89
|
+
|
90
|
+
expect do
|
91
|
+
Ratis::ClosestStop.where(conditions)
|
92
|
+
end.to raise_error(ArgumentError, 'You must provide a longitude')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Config do
|
4
|
+
|
5
|
+
context 'with an endpoint and namespace set' do
|
6
|
+
|
7
|
+
describe '#valid?' do
|
8
|
+
|
9
|
+
it 'is valid' do
|
10
|
+
Ratis.config.valid?.should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'without an endpoint or namespace set' do
|
18
|
+
|
19
|
+
before do
|
20
|
+
# Override Ratis.configure made in spec_helper.rb
|
21
|
+
# Ratis.config = Ratis::Config.new
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#valid?' do
|
25
|
+
|
26
|
+
it 'is not valid' do
|
27
|
+
pending('Need way in specs to set new config after one is set.')
|
28
|
+
Ratis.config.valid?.should be_false
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
after do
|
34
|
+
# Reset Ratis.configure made in spec_helper.rb
|
35
|
+
Ratis.configure do |config|
|
36
|
+
config.endpoint = 'http://example.com/soap.cgi'
|
37
|
+
config.namespace = 'TEST_NS'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
|
5
|
+
describe 'which is one level deep' do
|
6
|
+
|
7
|
+
describe '#to_array' do
|
8
|
+
|
9
|
+
it 'returns [] if key is not present in Hash' do
|
10
|
+
{}.to_array(:a).should eql []
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns [] if key is nil ' do
|
14
|
+
{ :a => nil }.to_array(:a).should eql []
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns [value] if value is not an Array' do
|
18
|
+
{ :a => 1 }.to_array(:a).should eql [1]
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'returns Array if value is an Array' do
|
22
|
+
{ :a => [1,2,3] }.to_array(:a).should eql [1,2,3]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'which is two levels deep' do
|
30
|
+
|
31
|
+
describe '#to_array' do
|
32
|
+
|
33
|
+
it 'returns [] if key is not present in Hash' do
|
34
|
+
{ :a => {} }.to_array(:a, :b).should eql []
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns [] if key is nil ' do
|
38
|
+
{ :a => { :b => nil } }.to_array(:a, :b).should eql []
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns [value] if value is not an Array' do
|
42
|
+
{ :a => { :b => 1 } }.to_array(:a, :b).should eql [1]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns Array if value is an Array' do
|
46
|
+
{ :a => { :b => [1,2,3] } }.to_array(:a, :b).should eql [1,2,3]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|