ratis 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ coverage
2
+ *DS_Store
3
+ .yardoc
4
+ _yardoc
5
+ doc/
6
+ /gem_reference/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require rspec/instafail
3
+ --format RSpec::Instafail
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
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
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
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new('spec')
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ desc 'Run tests'
8
+ task :default => :spec
@@ -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-specs'
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)
@@ -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) || 'na'
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) || 'na'
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
@@ -5,7 +5,7 @@ module Ratis
5
5
  def version
6
6
  @version ||= begin
7
7
 
8
- string = '3.1.0'
8
+ string = '3.1.1'
9
9
 
10
10
  def string.parts
11
11
  split('.').map { |p| p.to_i }
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
+