nypl-site-scraper 0.1.1 → 0.1.2

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: 62542695832e4f92ebb34831948747906f23a939
4
- data.tar.gz: 80a55110450211b9c4e43fc36d984301ebbbf567
3
+ metadata.gz: ae38c0466638a3e6bea2d077b6b774962bd81d05
4
+ data.tar.gz: 5481b0384d607e5f64522526f721fd69c701ee12
5
5
  SHA512:
6
- metadata.gz: 78f405985ae1188622647f8c0559e7c0b5a088a030554c9e6599dcf053fc298cbf537a67790280cee7709702ef0266e8bb269d668eede2c6ec6afa0ce5c76cfc
7
- data.tar.gz: 1c1e3ac070c3514bd6991d28bf594f8b5650a4658d64318fd7235b048d5612e4a67d597a4870f8522c065c0387661b847a30f4de812a96cc1ad57a1b73c8b867
6
+ metadata.gz: 3beb836976fd317d1146c17d5d2c493b2455d00a7b77c454632e68cdac7e2454ad69dc642b984855cc281e3427b7579730e7cd43494c5312dc129fa1e1529ef2
7
+ data.tar.gz: 1acfeeb135cfc3d108916b538a7f365affe0f6457d8ffa6cde291ce992a7b2dc595653b569f31249af5600e9f27871f6661177a9e565aa648a3e4a78c08d3533
data/README.md CHANGED
@@ -37,10 +37,13 @@ client = NyplSiteScraper::Client.new(barcode: '11111111111111', pin: '2222')
37
37
  client.login! # This is the network call
38
38
 
39
39
  client.get_holds
40
- # {"holds"=>[{"title"=>"Persepolis. English", "statusString"=>"READY FOR PICKUP", "status"=>"ready", "pickupLocation"=>"Mid-Manhattan Library at 42nd St"}...
40
+ # {"holds"=>[{"title"=>"Persepolis. English", "statusString"=>"READY FOR PICKUP", "status"=>"ready", "pickupLocation"=>"Mid-Manhattan Library at 42nd St"}...
41
41
 
42
- client.get_fines
43
- #{:fines=>[{:title=>"Zog and the flying doctors / by Julia Donaldson & illustrated by Axel Scheffler.", :fineAmount=>"$0.20"}...
42
+ client.get_fines
43
+ #{:fines=>[{:title=>"Zog and the flying doctors / by Julia Donaldson & illustrated by Axel Scheffler.", :fineAmount=>"$0.20"}...
44
+
45
+ client.get_checkouts
46
+ # {:checkouts => [{:title "Foo", dueDate: "Some date"}]}
44
47
  ```
45
48
 
46
49
  ## Development
@@ -20,6 +20,21 @@ module NyplSiteScraper
20
20
  true
21
21
  end
22
22
 
23
+ def get_checkouts
24
+ @check_outs_page ||= @homepage.link_with(text: "My Checked Out Items").click
25
+ check_cout_rows = @check_outs_page.search('tr.patFuncEntry')
26
+
27
+ check_outs_response = []
28
+ check_cout_rows.each do |check_out_row|
29
+ check_outs_response << {
30
+ title: check_out_row.search('td.patFuncTitle').text.strip,
31
+ dueDate: check_out_row.search('td.patFuncStatus').text.strip
32
+ }
33
+ end
34
+
35
+ {checkouts: check_outs_response}
36
+ end
37
+
23
38
  def get_fines
24
39
  @fines_page ||= @agent.get("https://catalog.nypl.org/patroninfo~S1/thisurlsegment-doesnt-seem-to-matter-hahahah/overdues")
25
40
  fines_rows = @fines_page.search('tr.patFuncFinesEntryTitle')
@@ -54,31 +69,30 @@ module NyplSiteScraper
54
69
  {holds: response_holds}
55
70
  end
56
71
 
57
- private
72
+ private
58
73
 
59
- def map_status_string(status_string)
74
+ def map_status_string(status_string)
60
75
 
61
- if status_string == "READY FOR PICKUP"
62
- return "ready"
63
- elsif status_string == "IN TRANSIT"
64
- return "in transit"
65
- elsif status_string.include?('of')
66
- return "pending"
67
- else
68
- return status_string
69
- end
70
- end
76
+ if status_string == "READY FOR PICKUP"
77
+ return "ready"
78
+ elsif status_string == "IN TRANSIT"
79
+ return "in transit"
80
+ elsif status_string.include?('of')
81
+ return "pending"
82
+ else
83
+ return status_string
84
+ end
85
+ end
71
86
 
72
- # Helper because markup for pending vs ready is different
73
- def get_pickup_location(row)
74
- pickUpCell = row.css('td.patFuncPickup')
75
- if pickUpCell.search('div.patFuncPickupLabel').length > 0
76
- row.css('td.patFuncPickup option[selected=selected]').first.text.strip
77
- # pickUpCell.search('div.patFuncPickupLabel').text.strip
78
- else
79
- pickUpCell.text.strip
80
- end
81
- end
87
+ # Helper because markup for pending vs ready is different
88
+ def get_pickup_location(row)
89
+ pickUpCell = row.css('td.patFuncPickup')
90
+ if pickUpCell.search('div.patFuncPickupLabel').length > 0
91
+ row.css('td.patFuncPickup option[selected=selected]').first.text.strip
92
+ else
93
+ pickUpCell.text.strip
94
+ end
95
+ end
82
96
 
83
97
  end
84
98
 
@@ -1,3 +1,3 @@
1
1
  module NyplSiteScraper
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nypl-site-scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - nodanaonlyzuul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-09 00:00:00.000000000 Z
11
+ date: 2017-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize