ruby_wmata 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8538252db13839452c68f8487a9eda07b5cf180
4
+ data.tar.gz: 9e36edcfaeace30c03eb1d564144b52cb6366a5a
5
+ SHA512:
6
+ metadata.gz: 1b25a41364469133612589c5fc1d5a5946e2ad504309303e2d5c12da04b6a5dc9d848dfe825ecf6788d5d80cb0fa0d900ca638f7ed72825b64fff0c3cd753ef1
7
+ data.tar.gz: 8dfd16f2b9de84630ed1306473755e2424f645ce748ee25c97538eef3e7c7615795fd7bfb7c2958e33a98e561438a89994483bfb4b4291250e8a3821e77bded8
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby_wmata.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 bennacer860
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.
@@ -0,0 +1,59 @@
1
+ # RubyWmata
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruby_wmata'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ruby_wmata
20
+
21
+ ## Usage
22
+
23
+ You will need to get your own api_key from [here](http://developer.wmata.com)
24
+ Setup you api key first
25
+
26
+ ```ruby
27
+ WMATA.api_key = "xxxxxxx"
28
+ ```
29
+ And then you can make you api calls like this
30
+
31
+ ```ruby
32
+ WMATA.next_trains("A01")
33
+ ```
34
+
35
+ In this case we have used the station name code as argument, you can determine the code for each station by making a simple code on a specific line
36
+
37
+ ```ruby
38
+ WMATA.train_station("RD")
39
+ ```
40
+
41
+ In this case 'RD' is the code name for the 'red line', you can find all those line code name by making a simple call
42
+
43
+ ```ruby
44
+ WMATA.lines
45
+ ```
46
+
47
+ Another cool feature you can make is to find the path between two stations
48
+
49
+ ```ruby
50
+ WMATA.train_path("A01","A15")
51
+ ```
52
+
53
+ ## Contributing
54
+
55
+ 1. Fork it ( https://github.com/[my-github-username]/ruby_wmata/fork )
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
57
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
58
+ 4. Push to the branch (`git push origin my-new-feature`)
59
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,35 @@
1
+ require 'httparty'
2
+ module WMATA
3
+
4
+ class Client
5
+ include HTTParty
6
+ base_uri "https://api.wmata.com"
7
+ def initialize(api_key)
8
+ @options = {query: {api_key: api_key} }
9
+ end
10
+
11
+ def next_trains(stations='A06')
12
+ response = self.class.get("/StationPrediction.svc/json/GetPrediction/#{stations}", @options)
13
+ JSON.parse(response.body)["Trains"]
14
+ end
15
+
16
+ def train_stations(line='RD', formated=true)
17
+ @options[:query][:LineCode]=line
18
+ response = self.class.get("/Rail.svc/json/jStations", @options)
19
+ JSON.parse(response.body)["Stations"]
20
+ end
21
+
22
+ def train_path(from,to)
23
+ @options[:query][:FromStationCode] = from
24
+ @options[:query][:ToStationCode] = to
25
+ response = self.class.get("/Rail.svc/json/jPath", @options)
26
+ JSON.parse(response.body)["Path"]
27
+ end
28
+
29
+ def train_incidents
30
+ response = self.class.get("/Incidents.svc/json/Incidents", @options)
31
+ JSON.parse(response.body)["Incidents"]
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,33 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'client'
3
+
4
+ module WMATA
5
+ def self.client
6
+ @client ||= Client.new(api)
7
+ end
8
+
9
+ def self.api
10
+ @api || raise("please set the api key")
11
+ end
12
+
13
+ def self.api=(api_key)
14
+ @client = Client.new(api_key)
15
+ @api = api_key
16
+ end
17
+
18
+ def self.next_trains(station = "A06")
19
+ client.next_trains(station)
20
+ end
21
+
22
+ def self.train_stations(line = 'RD')
23
+ client.train_stations(line)
24
+ end
25
+
26
+ def self.train_path(from,to)
27
+ client.train_path(from,to)
28
+ end
29
+
30
+ def self.train_incidents
31
+ client.train_incidents
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module RubyWmata
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruby_wmata/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruby_wmata"
8
+ spec.version = RubyWmata::VERSION
9
+ spec.authors = ["Rafik Bennacer"]
10
+ spec.email = ["bennacer860@gmail.com"]
11
+ spec.summary = "It is a simple WMATA api ruby wrapper"
12
+ spec.description = "With this gem you will be able to retrieve realtime information about stations, trains and incidents."
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "httparty", "~> 0.13.3"
24
+ spec.add_development_dependency "webmock", "~> 1.20.4"
25
+ spec.add_development_dependency "rspec", "~> 3.1.0"
26
+ end
@@ -0,0 +1,78 @@
1
+ {
2
+ "Trains":[
3
+ {
4
+ "Car":"6",
5
+ "Destination":"SilvrSpg",
6
+ "DestinationCode":"B08",
7
+ "DestinationName":"Silver Spring",
8
+ "Group":"1",
9
+ "Line":"RD",
10
+ "LocationCode":"A01",
11
+ "LocationName":"Metro Center",
12
+ "Min":"3"
13
+
14
+ },
15
+ {
16
+ "Car":"6",
17
+ "Destination":"Grsvnor",
18
+ "DestinationCode":"A11",
19
+ "DestinationName":"Grosvenor-Strathmore",
20
+ "Group":"2",
21
+ "Line":"RD",
22
+ "LocationCode":"A01",
23
+ "LocationName":"Metro Center",
24
+ "Min":"4"
25
+
26
+ },
27
+ {
28
+ "Car":"6",
29
+ "Destination":"Shady Gr",
30
+ "DestinationCode":"A15",
31
+ "DestinationName":"Shady Grove",
32
+ "Group":"2",
33
+ "Line":"RD",
34
+ "LocationCode":"A01",
35
+ "LocationName":"Metro Center",
36
+ "Min":"6"
37
+
38
+ },
39
+ {
40
+ "Car":"8",
41
+ "Destination":"Glenmont",
42
+ "DestinationCode":"B11",
43
+ "DestinationName":"Glenmont",
44
+ "Group":"1",
45
+ "Line":"RD",
46
+ "LocationCode":"A01",
47
+ "LocationName":"Metro Center",
48
+ "Min":"8"
49
+
50
+ },
51
+ {
52
+ "Car":"6",
53
+ "Destination":"SilvrSpg",
54
+ "DestinationCode":"B08",
55
+ "DestinationName":"Silver Spring",
56
+ "Group":"1",
57
+ "Line":"RD",
58
+ "LocationCode":"A01",
59
+ "LocationName":"Metro Center",
60
+ "Min":"9"
61
+
62
+ },
63
+ {
64
+ "Car":"6",
65
+ "Destination":"Grsvnor",
66
+ "DestinationCode":"A11",
67
+ "DestinationName":"Grosvenor-Strathmore",
68
+ "Group":"2",
69
+ "Line":"RD",
70
+ "LocationCode":"A01",
71
+ "LocationName":"Metro Center",
72
+ "Min":"9"
73
+
74
+ }
75
+
76
+ ]
77
+
78
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "Incidents": [
3
+ {
4
+ "DateUpdated": "2010-07-29T14:21:28",
5
+ "DelaySeverity": null,
6
+ "Description": "Red Line: Expect residual delays to Glenmont due to an earlier signal problem outside Forest Glen.",
7
+ "EmergencyText": null,
8
+ "EndLocationFullName": null,
9
+ "IncidentID": "3754F8B2-A0A6-494E-A4B5-82C9E72DFA74",
10
+ "IncidentType": "Delay",
11
+ "LinesAffected": "RD;",
12
+ "PassengerDelay": 0,
13
+ "StartLocationFullName": null
14
+
15
+ }
16
+
17
+ ]
18
+
19
+ }
@@ -0,0 +1,230 @@
1
+ {
2
+ "Path": [
3
+ {
4
+ "DistanceToPrev": 0,
5
+ "LineCode": "SV",
6
+ "SeqNum": 1,
7
+ "StationCode": "N06",
8
+ "StationName": "Wiehle-Reston East"
9
+
10
+ },
11
+ {
12
+ "DistanceToPrev": 30867,
13
+ "LineCode": "SV",
14
+ "SeqNum": 2,
15
+ "StationCode": "N04",
16
+ "StationName": "Spring Hill"
17
+
18
+ },
19
+ {
20
+ "DistanceToPrev": 3634,
21
+ "LineCode": "SV",
22
+ "SeqNum": 3,
23
+ "StationCode": "N03",
24
+ "StationName": "Greensboro"
25
+
26
+ },
27
+ {
28
+ "DistanceToPrev": 3902,
29
+ "LineCode": "SV",
30
+ "SeqNum": 4,
31
+ "StationCode": "N02",
32
+ "StationName": "Tysons Corner"
33
+
34
+ },
35
+ {
36
+ "DistanceToPrev": 3440,
37
+ "LineCode": "SV",
38
+ "SeqNum": 5,
39
+ "StationCode": "N01",
40
+ "StationName": "McLean"
41
+
42
+ },
43
+ {
44
+ "DistanceToPrev": 24745,
45
+ "LineCode": "SV",
46
+ "SeqNum": 6,
47
+ "StationCode": "K05",
48
+ "StationName": "E Falls Church"
49
+
50
+ },
51
+ {
52
+ "DistanceToPrev": 13156,
53
+ "LineCode": "SV",
54
+ "SeqNum": 7,
55
+ "StationCode": "K04",
56
+ "StationName": "Ballston"
57
+
58
+ },
59
+ {
60
+ "DistanceToPrev": 2980,
61
+ "LineCode": "SV",
62
+ "SeqNum": 8,
63
+ "StationCode": "K03",
64
+ "StationName": "Virginia Square"
65
+
66
+ },
67
+ {
68
+ "DistanceToPrev": 2473,
69
+ "LineCode": "SV",
70
+ "SeqNum": 9,
71
+ "StationCode": "K02",
72
+ "StationName": "Clarendon"
73
+
74
+ },
75
+ {
76
+ "DistanceToPrev": 2687,
77
+ "LineCode": "SV",
78
+ "SeqNum": 10,
79
+ "StationCode": "K01",
80
+ "StationName": "Court House"
81
+
82
+ },
83
+ {
84
+ "DistanceToPrev": 4936,
85
+ "LineCode": "SV",
86
+ "SeqNum": 11,
87
+ "StationCode": "C05",
88
+ "StationName": "Rosslyn"
89
+
90
+ },
91
+ {
92
+ "DistanceToPrev": 6993,
93
+ "LineCode": "SV",
94
+ "SeqNum": 12,
95
+ "StationCode": "C04",
96
+ "StationName": "Foggy Bottom"
97
+
98
+ },
99
+ {
100
+ "DistanceToPrev": 2783,
101
+ "LineCode": "SV",
102
+ "SeqNum": 13,
103
+ "StationCode": "C03",
104
+ "StationName": "Farragut West"
105
+
106
+ },
107
+ {
108
+ "DistanceToPrev": 2001,
109
+ "LineCode": "SV",
110
+ "SeqNum": 14,
111
+ "StationCode": "C02",
112
+ "StationName": "McPherson Square"
113
+
114
+ },
115
+ {
116
+ "DistanceToPrev": 2359,
117
+ "LineCode": "SV",
118
+ "SeqNum": 15,
119
+ "StationCode": "C01",
120
+ "StationName": "Metro Center"
121
+
122
+ },
123
+ {
124
+ "DistanceToPrev": 1561,
125
+ "LineCode": "SV",
126
+ "SeqNum": 16,
127
+ "StationCode": "D01",
128
+ "StationName": "Federal Triangle"
129
+
130
+ },
131
+ {
132
+ "DistanceToPrev": 2016,
133
+ "LineCode": "SV",
134
+ "SeqNum": 17,
135
+ "StationCode": "D02",
136
+ "StationName": "Smithsonian"
137
+
138
+ },
139
+ {
140
+ "DistanceToPrev": 2643,
141
+ "LineCode": "SV",
142
+ "SeqNum": 18,
143
+ "StationCode": "D03",
144
+ "StationName": "L'Enfant Plaza"
145
+
146
+ },
147
+ {
148
+ "DistanceToPrev": 1757,
149
+ "LineCode": "SV",
150
+ "SeqNum": 19,
151
+ "StationCode": "D04",
152
+ "StationName": "Federal Center SW"
153
+
154
+ },
155
+ {
156
+ "DistanceToPrev": 3052,
157
+ "LineCode": "SV",
158
+ "SeqNum": 20,
159
+ "StationCode": "D05",
160
+ "StationName": "Capitol South"
161
+
162
+ },
163
+ {
164
+ "DistanceToPrev": 2703,
165
+ "LineCode": "SV",
166
+ "SeqNum": 21,
167
+ "StationCode": "D06",
168
+ "StationName": "Eastern Market"
169
+
170
+ },
171
+ {
172
+ "DistanceToPrev": 3289,
173
+ "LineCode": "SV",
174
+ "SeqNum": 22,
175
+ "StationCode": "D07",
176
+ "StationName": "Potomac Avenue"
177
+
178
+ },
179
+ {
180
+ "DistanceToPrev": 3750,
181
+ "LineCode": "SV",
182
+ "SeqNum": 23,
183
+ "StationCode": "D08",
184
+ "StationName": "Stadium Armory"
185
+
186
+ },
187
+ {
188
+ "DistanceToPrev": 12162,
189
+ "LineCode": "SV",
190
+ "SeqNum": 24,
191
+ "StationCode": "G01",
192
+ "StationName": "Benning Road"
193
+
194
+ },
195
+ {
196
+ "DistanceToPrev": 7779,
197
+ "LineCode": "SV",
198
+ "SeqNum": 25,
199
+ "StationCode": "G02",
200
+ "StationName": "Capitol Heights"
201
+
202
+ },
203
+ {
204
+ "DistanceToPrev": 5215,
205
+ "LineCode": "SV",
206
+ "SeqNum": 26,
207
+ "StationCode": "G03",
208
+ "StationName": "Addison Road"
209
+
210
+ },
211
+ {
212
+ "DistanceToPrev": 7960,
213
+ "LineCode": "SV",
214
+ "SeqNum": 27,
215
+ "StationCode": "G04",
216
+ "StationName": "Morgan Blvd"
217
+
218
+ },
219
+ {
220
+ "DistanceToPrev": 7256,
221
+ "LineCode": "SV",
222
+ "SeqNum": 28,
223
+ "StationCode": "G05",
224
+ "StationName": "Largo Town Center"
225
+
226
+ }
227
+
228
+ ]
229
+
230
+ }
@@ -0,0 +1,490 @@
1
+ {
2
+ "Stations": [
3
+ {
4
+ "Address": {
5
+ "City": "Rockville",
6
+ "State": "MD",
7
+ "Street": "15903 Somerville Drive",
8
+ "Zip": "20855"
9
+ },
10
+ "Code": "A15",
11
+ "Lat": 39.1199273249,
12
+ "LineCode1": "RD",
13
+ "LineCode2": null,
14
+ "LineCode3": null,
15
+ "LineCode4": null,
16
+ "Lon": -77.1646273343,
17
+ "Name": "Shady Grove",
18
+ "StationTogether1": "",
19
+ "StationTogether2": ""
20
+ },
21
+ {
22
+ "Address": {
23
+ "City": "Rockville",
24
+ "State": "MD",
25
+ "Street": "251 Hungerford Drive",
26
+ "Zip": "20850"
27
+ },
28
+ "Code": "A14",
29
+ "Lat": 39.0843216075,
30
+ "LineCode1": "RD",
31
+ "LineCode2": null,
32
+ "LineCode3": null,
33
+ "LineCode4": null,
34
+ "Lon": -77.1461253392,
35
+ "Name": "Rockville",
36
+ "StationTogether1": "",
37
+ "StationTogether2": ""
38
+ },
39
+ {
40
+ "Address": {
41
+ "City": "Rockville",
42
+ "State": "MD",
43
+ "Street": "1600 Chapman Avenue",
44
+ "Zip": "20852"
45
+ },
46
+ "Code": "A13",
47
+ "Lat": 39.0624676517,
48
+ "LineCode1": "RD",
49
+ "LineCode2": null,
50
+ "LineCode3": null,
51
+ "LineCode4": null,
52
+ "Lon": -77.1208179517,
53
+ "Name": "Twinbrook",
54
+ "StationTogether1": "",
55
+ "StationTogether2": ""
56
+ },
57
+ {
58
+ "Address": {
59
+ "City": "Rockville",
60
+ "State": "MD",
61
+ "Street": "5500 Marinelli Road",
62
+ "Zip": "20852"
63
+ },
64
+ "Code": "A12",
65
+ "Lat": 39.0481513573,
66
+ "LineCode1": "RD",
67
+ "LineCode2": null,
68
+ "LineCode3": null,
69
+ "LineCode4": null,
70
+ "Lon": -77.112829859,
71
+ "Name": "White Flint",
72
+ "StationTogether1": "",
73
+ "StationTogether2": ""
74
+ },
75
+ {
76
+ "Address": {
77
+ "City": "Bethesda",
78
+ "State": "MD",
79
+ "Street": "10300 Rockville Pike",
80
+ "Zip": "20852"
81
+ },
82
+ "Code": "A11",
83
+ "Lat": 39.02926895,
84
+ "LineCode1": "RD",
85
+ "LineCode2": null,
86
+ "LineCode3": null,
87
+ "LineCode4": null,
88
+ "Lon": -77.10384972,
89
+ "Name": "Grosvenor",
90
+ "StationTogether1": "",
91
+ "StationTogether2": ""
92
+ },
93
+ {
94
+ "Address": {
95
+ "City": "Bethesda",
96
+ "State": "MD",
97
+ "Street": "8810 Rockville Pike",
98
+ "Zip": "20814"
99
+ },
100
+ "Code": "A10",
101
+ "Lat": 39.0000564843,
102
+ "LineCode1": "RD",
103
+ "LineCode2": null,
104
+ "LineCode3": null,
105
+ "LineCode4": null,
106
+ "Lon": -77.0969522905,
107
+ "Name": "Medical Center",
108
+ "StationTogether1": "",
109
+ "StationTogether2": ""
110
+ },
111
+ {
112
+ "Address": {
113
+ "City": "Bethesda",
114
+ "State": "MD",
115
+ "Street": "7450 Wisconsin Avenue",
116
+ "Zip": "20814"
117
+ },
118
+ "Code": "A09",
119
+ "Lat": 38.9843936603,
120
+ "LineCode1": "RD",
121
+ "LineCode2": null,
122
+ "LineCode3": null,
123
+ "LineCode4": null,
124
+ "Lon": -77.0941291922,
125
+ "Name": "Bethesda",
126
+ "StationTogether1": "",
127
+ "StationTogether2": ""
128
+ },
129
+ {
130
+ "Address": {
131
+ "City": "Washington",
132
+ "State": "DC",
133
+ "Street": "5337 Wisconsin Avenue NW",
134
+ "Zip": "20015"
135
+ },
136
+ "Code": "A08",
137
+ "Lat": 38.9594838736,
138
+ "LineCode1": "RD",
139
+ "LineCode2": null,
140
+ "LineCode3": null,
141
+ "LineCode4": null,
142
+ "Lon": -77.084995805,
143
+ "Name": "Friendship Heights",
144
+ "StationTogether1": "",
145
+ "StationTogether2": ""
146
+ },
147
+ {
148
+ "Address": {
149
+ "City": "Washington",
150
+ "State": "DC",
151
+ "Street": "4501 Wisconsin Avenue NW",
152
+ "Zip": "20016"
153
+ },
154
+ "Code": "A07",
155
+ "Lat": 38.9488514351,
156
+ "LineCode1": "RD",
157
+ "LineCode2": null,
158
+ "LineCode3": null,
159
+ "LineCode4": null,
160
+ "Lon": -77.0795873255,
161
+ "Name": "Tenleytown",
162
+ "StationTogether1": "",
163
+ "StationTogether2": ""
164
+ },
165
+ {
166
+ "Address": {
167
+ "City": "Washington",
168
+ "State": "DC",
169
+ "Street": "4200 Connecticut Avenue NW",
170
+ "Zip": "20008"
171
+ },
172
+ "Code": "A06",
173
+ "Lat": 38.9432652883,
174
+ "LineCode1": "RD",
175
+ "LineCode2": null,
176
+ "LineCode3": null,
177
+ "LineCode4": null,
178
+ "Lon": -77.0629861805,
179
+ "Name": "Van Ness UDC",
180
+ "StationTogether1": "",
181
+ "StationTogether2": ""
182
+ },
183
+ {
184
+ "Address": {
185
+ "City": "Washington",
186
+ "State": "DC",
187
+ "Street": "3599 Connecticut Avenue NW",
188
+ "Zip": "20008"
189
+ },
190
+ "Code": "A05",
191
+ "Lat": 38.9347628908,
192
+ "LineCode1": "RD",
193
+ "LineCode2": null,
194
+ "LineCode3": null,
195
+ "LineCode4": null,
196
+ "Lon": -77.0580425191,
197
+ "Name": "Cleveland Park",
198
+ "StationTogether1": "",
199
+ "StationTogether2": ""
200
+ },
201
+ {
202
+ "Address": {
203
+ "City": "Washington",
204
+ "State": "DC",
205
+ "Street": "2700 Connecticut Ave., NW",
206
+ "Zip": "20008"
207
+ },
208
+ "Code": "A04",
209
+ "Lat": 38.9250851371,
210
+ "LineCode1": "RD",
211
+ "LineCode2": null,
212
+ "LineCode3": null,
213
+ "LineCode4": null,
214
+ "Lon": -77.0524180207,
215
+ "Name": "Woodley Park Zoo",
216
+ "StationTogether1": "",
217
+ "StationTogether2": ""
218
+ },
219
+ {
220
+ "Address": {
221
+ "City": "Washington",
222
+ "State": "DC",
223
+ "Street": "1525 20th St. NW",
224
+ "Zip": "20036"
225
+ },
226
+ "Code": "A03",
227
+ "Lat": 38.9095980575,
228
+ "LineCode1": "RD",
229
+ "LineCode2": null,
230
+ "LineCode3": null,
231
+ "LineCode4": null,
232
+ "Lon": -77.0434143597,
233
+ "Name": "Dupont Circle",
234
+ "StationTogether1": "",
235
+ "StationTogether2": ""
236
+ },
237
+ {
238
+ "Address": {
239
+ "City": "Washington",
240
+ "State": "DC",
241
+ "Street": "1001 Connecticut Avenue NW",
242
+ "Zip": "20036"
243
+ },
244
+ "Code": "A02",
245
+ "Lat": 38.9032019462,
246
+ "LineCode1": "RD",
247
+ "LineCode2": null,
248
+ "LineCode3": null,
249
+ "LineCode4": null,
250
+ "Lon": -77.0397008272,
251
+ "Name": "Farragut North",
252
+ "StationTogether1": "",
253
+ "StationTogether2": ""
254
+ },
255
+ {
256
+ "Address": {
257
+ "City": "Washington",
258
+ "State": "DC",
259
+ "Street": "607 13th St. NW",
260
+ "Zip": "20005"
261
+ },
262
+ "Code": "A01",
263
+ "Lat": 38.8983144732,
264
+ "LineCode1": "RD",
265
+ "LineCode2": null,
266
+ "LineCode3": null,
267
+ "LineCode4": null,
268
+ "Lon": -77.0280779971,
269
+ "Name": "Metro Center",
270
+ "StationTogether1": "C01",
271
+ "StationTogether2": ""
272
+ },
273
+ {
274
+ "Address": {
275
+ "City": "Washington",
276
+ "State": "DC",
277
+ "Street": "630 H St. NW",
278
+ "Zip": "20001"
279
+ },
280
+ "Code": "B01",
281
+ "Lat": 38.8983168097,
282
+ "LineCode1": "RD",
283
+ "LineCode2": null,
284
+ "LineCode3": null,
285
+ "LineCode4": null,
286
+ "Lon": -77.0219153904,
287
+ "Name": "Gallery Place",
288
+ "StationTogether1": "F01",
289
+ "StationTogether2": ""
290
+ },
291
+ {
292
+ "Address": {
293
+ "City": "Washington",
294
+ "State": "DC",
295
+ "Street": "450 F Street NW",
296
+ "Zip": "20001"
297
+ },
298
+ "Code": "B02",
299
+ "Lat": 38.8960903176,
300
+ "LineCode1": "RD",
301
+ "LineCode2": null,
302
+ "LineCode3": null,
303
+ "LineCode4": null,
304
+ "Lon": -77.0166389566,
305
+ "Name": "Judiciary Square",
306
+ "StationTogether1": "",
307
+ "StationTogether2": ""
308
+ },
309
+ {
310
+ "Address": {
311
+ "City": "Washington",
312
+ "State": "DC",
313
+ "Street": "701 First St. NE",
314
+ "Zip": "20002"
315
+ },
316
+ "Code": "B03",
317
+ "Lat": 38.8977660392,
318
+ "LineCode1": "RD",
319
+ "LineCode2": null,
320
+ "LineCode3": null,
321
+ "LineCode4": null,
322
+ "Lon": -77.0074142921,
323
+ "Name": "Union Station",
324
+ "StationTogether1": "",
325
+ "StationTogether2": ""
326
+ },
327
+ {
328
+ "Address": {
329
+ "City": "Washington",
330
+ "State": "DC",
331
+ "Street": "200 Florida Ave N.E.",
332
+ "Zip": "20002"
333
+ },
334
+ "Code": "B35",
335
+ "Lat": 38.9070162121,
336
+ "LineCode1": "RD",
337
+ "LineCode2": null,
338
+ "LineCode3": null,
339
+ "LineCode4": null,
340
+ "Lon": -77.0030204472,
341
+ "Name": "New York Avenue",
342
+ "StationTogether1": "",
343
+ "StationTogether2": ""
344
+ },
345
+ {
346
+ "Address": {
347
+ "City": "Washington",
348
+ "State": "DC",
349
+ "Street": "919 Rhode Island Avenue NE",
350
+ "Zip": "20018"
351
+ },
352
+ "Code": "B04",
353
+ "Lat": 38.9210596891,
354
+ "LineCode1": "RD",
355
+ "LineCode2": null,
356
+ "LineCode3": null,
357
+ "LineCode4": null,
358
+ "Lon": -76.9959369166,
359
+ "Name": "Rhode Island Avenue",
360
+ "StationTogether1": "",
361
+ "StationTogether2": ""
362
+ },
363
+ {
364
+ "Address": {
365
+ "City": "Washington",
366
+ "State": "DC",
367
+ "Street": "801 Michigan Avenue NE",
368
+ "Zip": "20017"
369
+ },
370
+ "Code": "B05",
371
+ "Lat": 38.9332109913,
372
+ "LineCode1": "RD",
373
+ "LineCode2": null,
374
+ "LineCode3": null,
375
+ "LineCode4": null,
376
+ "Lon": -76.9945342851,
377
+ "Name": "Brookland",
378
+ "StationTogether1": "",
379
+ "StationTogether2": ""
380
+ },
381
+ {
382
+ "Address": {
383
+ "City": "Washington",
384
+ "State": "DC",
385
+ "Street": "550 Galloway Street NE",
386
+ "Zip": "20011"
387
+ },
388
+ "Code": "B06",
389
+ "Lat": 38.9518467675,
390
+ "LineCode1": "RD",
391
+ "LineCode2": null,
392
+ "LineCode3": null,
393
+ "LineCode4": null,
394
+ "Lon": -77.0022030768,
395
+ "Name": "Fort Totten",
396
+ "StationTogether1": "E06",
397
+ "StationTogether2": ""
398
+ },
399
+ {
400
+ "Address": {
401
+ "City": "Washington",
402
+ "State": "DC",
403
+ "Street": "327 Cedar Street NW",
404
+ "Zip": "20012"
405
+ },
406
+ "Code": "B07",
407
+ "Lat": 38.976078531,
408
+ "LineCode1": "RD",
409
+ "LineCode2": null,
410
+ "LineCode3": null,
411
+ "LineCode4": null,
412
+ "Lon": -77.0181766987,
413
+ "Name": "Takoma",
414
+ "StationTogether1": "",
415
+ "StationTogether2": ""
416
+ },
417
+ {
418
+ "Address": {
419
+ "City": "Silver Spring",
420
+ "State": "MD",
421
+ "Street": "8400 Colesville Road",
422
+ "Zip": "20910"
423
+ },
424
+ "Code": "B08",
425
+ "Lat": 38.9939493747,
426
+ "LineCode1": "RD",
427
+ "LineCode2": null,
428
+ "LineCode3": null,
429
+ "LineCode4": null,
430
+ "Lon": -77.0310178268,
431
+ "Name": "Silver Spring",
432
+ "StationTogether1": "",
433
+ "StationTogether2": ""
434
+ },
435
+ {
436
+ "Address": {
437
+ "City": "Forest Glen",
438
+ "State": "MD",
439
+ "Street": "9730 Georgia Avenue",
440
+ "Zip": "20910"
441
+ },
442
+ "Code": "B09",
443
+ "Lat": 39.0149542752,
444
+ "LineCode1": "RD",
445
+ "LineCode2": null,
446
+ "LineCode3": null,
447
+ "LineCode4": null,
448
+ "Lon": -77.0429165548,
449
+ "Name": "Forest Glen",
450
+ "StationTogether1": "",
451
+ "StationTogether2": ""
452
+ },
453
+ {
454
+ "Address": {
455
+ "City": "Silver Spring",
456
+ "State": "MD",
457
+ "Street": "11171 Georgia Avenue",
458
+ "Zip": "20902"
459
+ },
460
+ "Code": "B10",
461
+ "Lat": 39.0375271436,
462
+ "LineCode1": "RD",
463
+ "LineCode2": null,
464
+ "LineCode3": null,
465
+ "LineCode4": null,
466
+ "Lon": -77.0501070535,
467
+ "Name": "Wheaton",
468
+ "StationTogether1": "",
469
+ "StationTogether2": ""
470
+ },
471
+ {
472
+ "Address": {
473
+ "City": "Silver Spring",
474
+ "State": "MD",
475
+ "Street": "12501 Georgia Avenue",
476
+ "Zip": "20906"
477
+ },
478
+ "Code": "B11",
479
+ "Lat": 39.0617837655,
480
+ "LineCode1": "RD",
481
+ "LineCode2": null,
482
+ "LineCode3": null,
483
+ "LineCode4": null,
484
+ "Lon": -77.0535573593,
485
+ "Name": "Glenmont",
486
+ "StationTogether1": "",
487
+ "StationTogether2": ""
488
+ }
489
+ ]
490
+ }
@@ -0,0 +1,23 @@
1
+ $:.unshift 'lib'
2
+ require 'ruby_wmata'
3
+ require 'webmock/rspec'
4
+ WebMock.disable_net_connect!(allow_localhost: true)
5
+
6
+
7
+ RSpec.configure do |config|
8
+
9
+ config.before(:each) do
10
+ stub_request(:get, %r|https://api.wmata.com/StationPrediction.svc/json/GetPrediction/|).
11
+ to_return(status: 200, body: File.open("./spec/fixtures/next_trains.json"){|f| f.read}, headers: {})
12
+
13
+ stub_request(:get, %r|https://api.wmata.com/Rail.svc/json/jStations|).
14
+ to_return(status: 200, body: File.open("./spec/fixtures/train_stations.json"){|f| f.read}, headers: {})
15
+
16
+ stub_request(:get, %r|https://api.wmata.com/Rail.svc/json/jPath|).
17
+ to_return(status: 200, body: File.open("./spec/fixtures/train_path.json"){|f| f.read}, headers: {})
18
+
19
+ stub_request(:get, %r|https://api.wmata.com/Incidents.svc/json/Incidents|).
20
+ to_return(status: 200, body: File.open("./spec/fixtures/train_incidents.json"){|f| f.read}, headers: {})
21
+
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ #require 'pry'
3
+ describe WMATA do
4
+ before(:all) { WMATA.api = 'xxxxx' }
5
+
6
+ it 'should predict next trains' do
7
+ expect(WMATA).to respond_to :next_trains
8
+ expect(WMATA.next_trains).not_to be_empty
9
+ ["Car","Min","DestinationName"].each{ |field|
10
+ expect(WMATA.next_trains.first[field]).not_to be_nil
11
+ }
12
+ end
13
+
14
+ it 'should give a list of all train stations ' do
15
+ expect(WMATA).to respond_to :train_stations
16
+ expect(WMATA.train_stations).not_to be_empty
17
+ ["Code","Name","LineCode1","Address"].each {|field|
18
+ expect(WMATA.train_stations.first[field]).not_to be_nil
19
+ }
20
+ end
21
+
22
+ it 'should give path from station to another ' do
23
+ expect(WMATA).to respond_to :train_path
24
+ expect(WMATA.train_path("A02","A01")).not_to be_empty
25
+ path = WMATA.train_path("A02","A01")
26
+ #binding.pry
27
+ ["LineCode","SeqNum","StationCode","StationName"].each{|field|
28
+ #puts "#{field} "#=> #{path.first[field]}"
29
+ expect(path.first[field]).not_to be_nil
30
+ }
31
+ end
32
+
33
+
34
+ it 'should give rails incidents' do
35
+ expect(WMATA).to respond_to :train_incidents
36
+ expect(WMATA.train_incidents).not_to be_empty
37
+ end
38
+ =begin
39
+ def rail_incidents(self):
40
+ return self._get('Incidents', 'Incidents')
41
+ =end
42
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_wmata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Rafik Bennacer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.13.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.20.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.20.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.0
83
+ description: With this gem you will be able to retrieve realtime information about
84
+ stations, trains and incidents.
85
+ email:
86
+ - bennacer860@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/client.rb
97
+ - lib/ruby_wmata.rb
98
+ - lib/ruby_wmata/version.rb
99
+ - ruby_wmata.gemspec
100
+ - spec/fixtures/next_trains.json
101
+ - spec/fixtures/train_incidents.json
102
+ - spec/fixtures/train_path.json
103
+ - spec/fixtures/train_stations.json
104
+ - spec/spec_helper.rb
105
+ - spec/train_spec.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.3
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: It is a simple WMATA api ruby wrapper
130
+ test_files:
131
+ - spec/fixtures/next_trains.json
132
+ - spec/fixtures/train_incidents.json
133
+ - spec/fixtures/train_path.json
134
+ - spec/fixtures/train_stations.json
135
+ - spec/spec_helper.rb
136
+ - spec/train_spec.rb