sms_my_bus 0.0.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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/lib/sms_my_bus/locations.rb +8 -0
- data/lib/sms_my_bus/routes.rb +8 -0
- data/lib/sms_my_bus/schedules.rb +8 -0
- data/lib/sms_my_bus/version.rb +3 -0
- data/lib/sms_my_bus.rb +22 -0
- data/sms_my_bus.gemspec +21 -0
- data/spec/sms_my_bus_spec.rb +58 -0
- data/spec/spec_helper.rb +7 -0
- metadata +95 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Matt Gauger
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# SmsMyBus
|
2
|
+
|
3
|
+
Integrate SMSMyBus into your Ruby apps quickly and easily.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sms_my_bus'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sms_my_bus
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
You will need set your SMSMyBus API key:
|
22
|
+
|
23
|
+
SmsMyBus.key = 'API KEY HERE'
|
24
|
+
|
25
|
+
If you don't want to check your API key into your git repo, we recommend keeping the API key in an ENV variable or in something like [Idkfa](https://github.com/bendyworks/idkfa).
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/sms_my_bus.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'sms_my_bus/version'
|
2
|
+
|
3
|
+
require 'sms_my_bus/locations'
|
4
|
+
require 'sms_my_bus/schedules'
|
5
|
+
require 'sms_my_bus/routes'
|
6
|
+
|
7
|
+
require 'curb'
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
|
11
|
+
module SmsMyBus
|
12
|
+
|
13
|
+
def self.key= key
|
14
|
+
@key = key
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.key
|
18
|
+
raise 'No key set; please see README.md' unless @key
|
19
|
+
@key
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/sms_my_bus.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sms_my_bus/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Matt Gauger", "Jaymes Waters"]
|
6
|
+
gem.email = ["matt.gauger@gmail.com", "jaymes@bendyworks.com"]
|
7
|
+
gem.description = %q{A gem to talk to the awesome SMSMyBus API in Madison, WI.}
|
8
|
+
gem.summary = %q{SMSMyBus API integration}
|
9
|
+
gem.homepage = "http://github.com/bendyworks/sms_my_bus"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "sms_my_bus"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = SmsMyBus::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'curb'
|
19
|
+
gem.add_development_dependency 'rspec'
|
20
|
+
gem.add_development_dependency 'pry'
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SmsMyBus' do
|
4
|
+
describe 'key' do
|
5
|
+
let(:key) { 'foobazzlew' }
|
6
|
+
it 'should be set' do
|
7
|
+
SmsMyBus.key = key
|
8
|
+
SmsMyBus.key.should == key
|
9
|
+
end
|
10
|
+
it 'should raise if key is not set' do
|
11
|
+
SmsMyBus.key.should raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe SmsMyBus::Schedules do
|
16
|
+
before do
|
17
|
+
SmsMyBus.key = ENV['SMSMYBUS_KEY']
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'get_arrivals' do
|
21
|
+
let(:invalid_stop_id) { 0 }
|
22
|
+
let(:valid_stop_id) { 1101 }
|
23
|
+
|
24
|
+
it 'invalid stop ID' do
|
25
|
+
SmsMyBus::Schedules.get_arrivals(invalid_stop_id)['status'].should == '-1'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'valid stop ID' do
|
29
|
+
SmsMyBus::Schedules.get_arrivals(valid_stop_id)['status'].should == '0'
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
describe SmsMyBus::Routes do
|
35
|
+
describe 'get_routes' do
|
36
|
+
it 'returns all the routes in the Metro system' do
|
37
|
+
SmsMyBus::Routes.get_routes['status'].should == 0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe SmsMyBus::Locations do
|
43
|
+
describe 'get_stops' do
|
44
|
+
let(:route_id) { 3 }
|
45
|
+
let(:invalid_route_id) { 404 }
|
46
|
+
it 'returns all stops for specified route' do
|
47
|
+
SmsMyBus::Locations.get_stops(route_id)['status'].should == '0'
|
48
|
+
end
|
49
|
+
it 'invalid route' do
|
50
|
+
# Behavior is not specified in API docs; always returns 0 status, even
|
51
|
+
# for invalid route IDs
|
52
|
+
SmsMyBus::Locations.get_stops(invalid_route_id)['status'].should == '0'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'Notifications'
|
58
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sms_my_bus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matt Gauger
|
9
|
+
- Jaymes Waters
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-02-10 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: curb
|
17
|
+
requirement: &2160929340 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2160929340
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
requirement: &2160928920 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2160928920
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: pry
|
39
|
+
requirement: &2152952280 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2152952280
|
48
|
+
description: A gem to talk to the awesome SMSMyBus API in Madison, WI.
|
49
|
+
email:
|
50
|
+
- matt.gauger@gmail.com
|
51
|
+
- jaymes@bendyworks.com
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- lib/sms_my_bus.rb
|
62
|
+
- lib/sms_my_bus/locations.rb
|
63
|
+
- lib/sms_my_bus/routes.rb
|
64
|
+
- lib/sms_my_bus/schedules.rb
|
65
|
+
- lib/sms_my_bus/version.rb
|
66
|
+
- sms_my_bus.gemspec
|
67
|
+
- spec/sms_my_bus_spec.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
homepage: http://github.com/bendyworks/sms_my_bus
|
70
|
+
licenses: []
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.8.15
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: SMSMyBus API integration
|
93
|
+
test_files:
|
94
|
+
- spec/sms_my_bus_spec.rb
|
95
|
+
- spec/spec_helper.rb
|