sms_my_bus 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sms_my_bus.gemspec
4
+ gemspec
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
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ module SmsMyBus
2
+ class Locations
3
+ def self.get_stops route_id
4
+ response = Curl::Easy.http_get("http://www.smsmybus.com/api/v1/getstops?key=#{SmsMyBus.key}&routeID=#{route_id}")
5
+ JSON.parse(response.body_str)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module SmsMyBus
2
+ class Routes
3
+ def self.get_routes
4
+ response = Curl::Easy.http_get("http://www.smsmybus.com/api/v1/getroutes?key=#{SmsMyBus.key}")
5
+ JSON.parse(response.body_str)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module SmsMyBus
2
+ class Schedules
3
+ def self.get_arrivals stop_id
4
+ response = Curl::Easy.http_get("http://www.smsmybus.com/api/v1/getarrivals?key=#{SmsMyBus.key}&stopID=#{stop_id}")
5
+ JSON.parse(response.body_str)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module SmsMyBus
2
+ VERSION = "0.0.1"
3
+ end
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
@@ -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
@@ -0,0 +1,7 @@
1
+ require 'sms_my_bus'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+ end
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