one_bus_away 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ require 'one_bus_away'
2
+
3
+ RSpec.describe OneBusAway::Utilities do
4
+ describe '.convert_time' do
5
+ it { expect(OneBusAway::Utilities).to respond_to(:convert_time) }
6
+
7
+ # Format from OBA API is Time as integer * 1000
8
+ it 'returns the correct format' do
9
+ time = (Time.now + 240).to_i * 1000
10
+
11
+ expect(OneBusAway::Utilities.convert_time(time))
12
+ .to eq('4 minutes')
13
+ end
14
+ end
15
+
16
+ describe '#strip_time' do
17
+ it { expect(OneBusAway::Utilities.new).to respond_to(:strip_time) }
18
+ it 'removes the last for characters' do
19
+ time = '1445318245161'
20
+ obj = OneBusAway::Utilities.new
21
+
22
+ expect(obj.strip_time(time)).to eq('1445318245')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.pugetsound.onebusaway.org/api/where/current-time.json?key=6a1c72f7-6ec4-4522-bf33-3698b3ad86c2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ Etag:
24
+ - '1684664496'
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '226'
29
+ Date:
30
+ - Tue, 20 Oct 2015 05:17:25 GMT
31
+ body:
32
+ encoding: UTF-8
33
+ string: '{"code":200,"currentTime":1445318245161,"data":{"entry":{"readableTime":"2015-10-19T22:17:25-07:00","time":1445318245161},"references":{"agencies":[],"routes":[],"situations":[],"stops":[],"trips":[]}},"text":"OK","version":2}'
34
+ http_version:
35
+ recorded_at: Tue, 20 Oct 2015 05:17:25 GMT
36
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,9 @@
1
+ require 'one_bus_away/version'
2
+
3
+ RSpec.describe OneBusAway do
4
+ context '#Version' do
5
+ it 'has a version' do
6
+ expect(OneBusAway::VERSION).to be_kind_of(String)
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: one_bus_away
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Ellis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-17 00:00:00.000000000 Z
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,62 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-mocks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.22'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.22'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.9'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: contracts
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - ">="
101
+ - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: '0'
103
+ version: '0.12'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - ">="
108
+ - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: '0'
110
+ version: '0.12'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: guard-rspec
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -84,50 +126,134 @@ dependencies:
84
126
  name: terminal-notifier-guard
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - ">="
129
+ - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: '0'
131
+ version: '1.6'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
- - - ">="
136
+ - - "~>"
95
137
  - !ruby/object:Gem::Version
96
- version: '0'
138
+ version: '1.6'
139
+ - !ruby/object:Gem::Dependency
140
+ name: fuubar
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.10'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.10'
97
167
  - !ruby/object:Gem::Dependency
98
168
  name: commander
99
169
  requirement: !ruby/object:Gem::Requirement
100
170
  requirements:
101
- - - ">="
171
+ - - "~>"
102
172
  - !ruby/object:Gem::Version
103
- version: '0'
173
+ version: '4.3'
104
174
  type: :runtime
105
175
  prerelease: false
106
176
  version_requirements: !ruby/object:Gem::Requirement
107
177
  requirements:
108
- - - ">="
178
+ - - "~>"
109
179
  - !ruby/object:Gem::Version
110
- version: '0'
180
+ version: '4.3'
111
181
  - !ruby/object:Gem::Dependency
112
182
  name: rest-client
113
183
  requirement: !ruby/object:Gem::Requirement
114
184
  requirements:
115
- - - ">="
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.8'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.8'
195
+ - !ruby/object:Gem::Dependency
196
+ name: recursive-open-struct
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.6'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.6'
209
+ - !ruby/object:Gem::Dependency
210
+ name: activesupport
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
116
214
  - !ruby/object:Gem::Version
117
- version: '0'
215
+ version: '4.2'
118
216
  type: :runtime
119
217
  prerelease: false
120
218
  version_requirements: !ruby/object:Gem::Requirement
121
219
  requirements:
122
- - - ">="
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '4.2'
223
+ - !ruby/object:Gem::Dependency
224
+ name: actionview
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '4.2'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '4.2'
237
+ - !ruby/object:Gem::Dependency
238
+ name: geocoder
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '1.2'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
123
249
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description: This is a simple gem to query bus stops, delay times, and additional
126
- features. This does require that you apply for an API key from One Bus Away -- http://pugetsound.onebusaway.org/p/OneBusAwayApiService.action
250
+ version: '1.2'
251
+ description: This is a simple gem to query bus stops,delay times, and additional features.
252
+ Thisdoes require that you apply for an API keyfrom One Bus Away --http://pugetsound.onebusaway.org/p/OneBusAwayApiService.action
127
253
  email:
128
254
  - jack@mnmlst.cc
129
255
  executables:
130
- - one-bus-away
256
+ - one_bus_away
131
257
  extensions: []
132
258
  extra_rdoc_files: []
133
259
  files:
@@ -138,13 +264,18 @@ files:
138
264
  - LICENSE.txt
139
265
  - README.md
140
266
  - Rakefile
141
- - bin/one-bus-away
267
+ - bin/one_bus_away
142
268
  - lib/one_bus_away.rb
269
+ - lib/one_bus_away/client.rb
270
+ - lib/one_bus_away/utilities.rb
143
271
  - lib/one_bus_away/version.rb
144
- - lib/utilities.rb
145
272
  - one_bus_away.gemspec
273
+ - spec/client_spec.rb
146
274
  - spec/one_bus_away_spec.rb
147
275
  - spec/spec_helper.rb
276
+ - spec/utilities_spec.rb
277
+ - spec/vcr/one_bus_away/current-time.yml
278
+ - spec/version_spec.rb
148
279
  homepage: https://github.com/ellisandy/one-bus-away-cli
149
280
  licenses:
150
281
  - MIT
@@ -170,6 +301,10 @@ signing_key:
170
301
  specification_version: 4
171
302
  summary: Simple Gem to query One Bus Away API
172
303
  test_files:
304
+ - spec/client_spec.rb
173
305
  - spec/one_bus_away_spec.rb
174
306
  - spec/spec_helper.rb
307
+ - spec/utilities_spec.rb
308
+ - spec/vcr/one_bus_away/current-time.yml
309
+ - spec/version_spec.rb
175
310
  has_rdoc:
data/bin/one-bus-away DELETED
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'commander/import'
5
- #require 'one_bus_away'
6
- require_relative '../lib/one_bus_away'
7
-
8
- program :version, '0.0.1'
9
- program :description, 'Simple querying of One Bus Away'
10
-
11
- # puts $LOAD_PATH
12
- @one_bus_away = OneBusAway.new(File.read(ENV['HOME']+"/.one_bus_away"))
13
-
14
- command "current-time" do |c|
15
- c.syntax = 'one-bus-away current-time'
16
- c.summary = 'Get the current system time from One Bus Away'
17
- c.description = 'Makes the current_time API call against the One Bus Away API. Simple, Straightforward, Unneeded'
18
- c.example '','one-bus-away current-time'
19
- c.action do |args, options|
20
- puts @one_bus_away.current_time
21
- end
22
- end
23
-
24
- command "arrivals-and-departures-for-stop" do |c|
25
- c.syntax = 'one-bus-away arrivals-and-departures-for-stop [stop] [route] [arrival time from now]'
26
- c.summary = 'Next Arrival Time for a specific Stop'
27
- c.description = 'By default, you can get the next available arrival time.'
28
- c.example 'description', 'one-bus-away arrivals-and-departures-for-stop [stop] [route] [arrival time from now]'
29
- c.action do |args, options|
30
- arrivals = @one_bus_away.arrivals_and_departures_for_stop(args[0], args[1], args[2])
31
- unless arrivals.empty?
32
- arrivals.each do |arrival|
33
- puts "The #{args[1]} arrives in #{arrival}"
34
- end
35
- else
36
- puts "No buses in that time constrain"
37
- end
38
- end
39
- end
40
-
data/lib/utilities.rb DELETED
@@ -1,32 +0,0 @@
1
- require("date")
2
- class Utilities
3
- def self.convert_time(time)
4
- stripped_time = self.strip_time(time)
5
-
6
- converted_date = DateTime.strptime(stripped_time,"%s")
7
-
8
- new_time = converted_date.to_time#.strftime "%I:%M %P"
9
- distance_of_time_in_hours_and_minutes(new_time, Time.now)
10
- end
11
-
12
- def self.strip_time(time_to_strip)
13
- n = time_to_strip.size
14
- stripped_time = time_to_strip[0..n-4]
15
- return stripped_time
16
-
17
- end
18
-
19
- def self.distance_of_time_in_hours_and_minutes(from_time, to_time)
20
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
21
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
22
- dist = to_time - from_time
23
- minutes = (dist.abs / 60).round
24
- hours = minutes / 60
25
- minutes = minutes - (hours * 60)
26
-
27
- words = dist <= 0 ? '' : '-'
28
-
29
- words << "#{hours} #{hours > 1 ? 'hours' : 'hour' } and " if hours > 0
30
- words << "#{minutes} #{minutes == 1 ? 'minute' : 'minutes' }"
31
- end
32
- end