bart_waiting_list 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bart_waiting_list.gemspec +1 -1
- data/lib/bart_waiting_list.rb +5 -9
- data/spec/bart_waiting_list_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3219c9b288fee8f22075ac7ef9775318ff9954
|
4
|
+
data.tar.gz: e07ca09c2138e46bf401630334677abc9ee5c60c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9da5a289e33e7d551e3c62d9c5ea0f31470025bf2f6a4c195d5e7db6b23d3f8b9e20e0d7d35c95582bc7d55500653451a116c155f8968feca4aa6748ed6311c
|
7
|
+
data.tar.gz: 1ef7c7b1035d9a3fb822a91efab9189d7c7e804319a54a4813412e8c2a3c8705c39c08960f00eebe582eccf6b842e11c81c5f8f2b4eecc13c5ec22c8d73575d7
|
data/bart_waiting_list.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'bart_waiting_list'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.3'
|
8
8
|
spec.authors = ["Brian O'Keefe"]
|
9
9
|
spec.email = ['brian@bokstuff.com']
|
10
10
|
spec.summary = %q{Get data from the BART select-a-spot waiting list page}
|
data/lib/bart_waiting_list.rb
CHANGED
@@ -9,19 +9,15 @@ class BartWaitingList
|
|
9
9
|
attr_reader :page
|
10
10
|
|
11
11
|
def initialize(email, password)
|
12
|
-
@page = get_waiting_list_page
|
12
|
+
@page = get_waiting_list_page email, password
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_waiting_list_position(station)
|
16
16
|
station_name = get_station_name station
|
17
|
+
regexp = %r{position (?<position>\d+)[a-zA-Z<>/"= ]+at <span class="bold">#{station_name}<\/span>}
|
18
|
+
match = @page.body.match regexp
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
if $1.nil?
|
21
|
-
$1
|
22
|
-
else
|
23
|
-
$1.to_i
|
24
|
-
end
|
20
|
+
Integer match[:position] rescue nil
|
25
21
|
end
|
26
22
|
|
27
23
|
private
|
@@ -48,7 +44,7 @@ class BartWaitingList
|
|
48
44
|
form.submit
|
49
45
|
|
50
46
|
# now that we're logged in, return the waiting list page
|
51
|
-
agent.get
|
47
|
+
agent.get WAITING_LIST_URL
|
52
48
|
end
|
53
49
|
|
54
50
|
def get_station_name(station)
|
@@ -8,8 +8,8 @@ describe BartWaitingList do
|
|
8
8
|
expect(subject).to be_an_instance_of BartWaitingList
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'should
|
12
|
-
expect(subject.page).to be_an_instance_of
|
11
|
+
it 'should store the waiting list page' do
|
12
|
+
expect(subject.page).to be_an_instance_of Mechanize::Page
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|