bart_waiting_list 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97c3260e87eae7cd17841ec69b826c4390ca80ac
4
- data.tar.gz: d989dffb180d3f9bd59e32a9642cb375c626a687
3
+ metadata.gz: 3e3219c9b288fee8f22075ac7ef9775318ff9954
4
+ data.tar.gz: e07ca09c2138e46bf401630334677abc9ee5c60c
5
5
  SHA512:
6
- metadata.gz: 69fce343ec7d8a216325585598d368e6dd2c2e61dff3517721a06d180456aec06f0279a5ff0a090693b35890d026bb690b9a1c3596b635afe0bba1af11a3cec4
7
- data.tar.gz: ae80174864f1c8c0fa93950ffa92a7fcd2168d4b2d0359fec84436508f799711342e0c7ec134ada17cb2f4e48e28ec36419aea056ab3255b3b0e0325e73d07fe
6
+ metadata.gz: f9da5a289e33e7d551e3c62d9c5ea0f31470025bf2f6a4c195d5e7db6b23d3f8b9e20e0d7d35c95582bc7d55500653451a116c155f8968feca4aa6748ed6311c
7
+ data.tar.gz: 1ef7c7b1035d9a3fb822a91efab9189d7c7e804319a54a4813412e8c2a3c8705c39c08960f00eebe582eccf6b842e11c81c5f8f2b4eecc13c5ec22c8d73575d7
@@ -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.2'
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}
@@ -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(email, password)
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
- /currently at <span class="bold">position (\d+)<\/span> on the waiting list for <span class="bold">Monthly Reserved<\/span> at <span class="bold">#{station_name}<\/span>/.match @page
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(WAITING_LIST_URL).body
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 contain the source for the waiting list page' do
12
- expect(subject.page).to be_an_instance_of String
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bart_waiting_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Keefe