lakes 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lakes/helper.rb +2 -1
- data/lib/lakes/texas/share_lunker.rb +45 -8
- data/lib/lakes.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30258a90e0c078f8458d0e9b5a4d684feacffee4
|
4
|
+
data.tar.gz: cadf28eca8c3a73171d478ffaa78f4ca5a10b2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eadff3e5c00966942b00fa265f2414d4079bdf0b71b3032ac535cd707380b739a94311e98c479805fbf5810c314f957eef410ef428851f05172c01240096222
|
7
|
+
data.tar.gz: 848ec09caf3c99270c8daa156d35795f2b2931600a6a9261d21c7535062a165e8b5f3ab92fdc475f1b9344416ddc13c56fec18b36130c5de90d221b739f1679b
|
data/lib/lakes/helper.rb
CHANGED
@@ -5,6 +5,16 @@ module Lakes
|
|
5
5
|
include Lakes::Helper
|
6
6
|
URL = 'https://tpwd.texas.gov/spdest/visitorcenters/tffc/sharelunker/archives/lunkersearch_adv.phtml'
|
7
7
|
|
8
|
+
WEEKDAYS = {
|
9
|
+
'mon' => 'Monday',
|
10
|
+
'tue' => 'Tuesday',
|
11
|
+
'wed' => 'Wednesday',
|
12
|
+
'thu' => 'Thursday',
|
13
|
+
'fri' => 'Friday',
|
14
|
+
'sat' => 'Saturday',
|
15
|
+
'sun' => 'Sunday'
|
16
|
+
}
|
17
|
+
|
8
18
|
def initialize
|
9
19
|
@lunker_data = []
|
10
20
|
end
|
@@ -17,31 +27,58 @@ module Lakes
|
|
17
27
|
results = []
|
18
28
|
html_doc.search('div#contentwide table tr').each_with_index do |row, index|
|
19
29
|
next if index == 0
|
20
|
-
data = row.search('th, td')
|
30
|
+
data = row.search('th, td')
|
31
|
+
|
32
|
+
girth = cleanup_raw_text(data[6].text)
|
33
|
+
girth = girth.nil? ? nil : girth.to_f
|
34
|
+
|
35
|
+
length = cleanup_raw_text(data[5].text)
|
36
|
+
length = length.nil? ? nil : length.to_f
|
37
|
+
|
38
|
+
status = cleanup_raw_text(data[15].text)
|
39
|
+
died = status.try(:downcase)
|
40
|
+
died = if !died.nil?
|
41
|
+
died.match('died').try(:length) == 1
|
42
|
+
end
|
21
43
|
|
22
44
|
results << {
|
23
45
|
id: data[0].text.to_i,
|
24
|
-
details_uri: data[0].search('a')[0][:href],
|
46
|
+
details_uri: convert_relative_href("../" + data[0].search('a')[0][:href], URL),
|
25
47
|
date_caught: Date.strptime(cleanup_raw_text(data[1].text), '%m/%d/%Y'),
|
26
48
|
angler: cleanup_raw_text(data[2].text),
|
27
49
|
angler_location: cleanup_raw_text(data[3].text),
|
28
50
|
weight: cleanup_raw_text(data[4].text).to_f,
|
29
|
-
length:
|
30
|
-
girth:
|
51
|
+
length: length,
|
52
|
+
girth: girth,
|
31
53
|
type: cleanup_raw_text(data[7].text),
|
32
54
|
lake: cleanup_raw_text(data[8].text),
|
33
55
|
record: cleanup_raw_text(data[9].text),
|
34
56
|
caught_on: cleanup_raw_text(data[10].text),
|
35
|
-
day_of_week: cleanup_raw_text(data[11].text),
|
57
|
+
day_of_week: WEEKDAYS[cleanup_raw_text(data[11].text).try(:downcase)],
|
36
58
|
moon_phase: cleanup_raw_text(data[12].text),
|
37
|
-
spawned: cleanup_raw_text(data[13].text),
|
38
|
-
returned_to_lake: cleanup_raw_text(data[14].text),
|
39
|
-
status: cleanup_raw_text(data[15].text)
|
59
|
+
spawned: convert_YN_boolean(cleanup_raw_text(data[13].text)),
|
60
|
+
returned_to_lake: convert_YN_boolean(cleanup_raw_text(data[14].text)),
|
61
|
+
status: cleanup_raw_text(data[15].text),
|
62
|
+
died: died
|
40
63
|
}
|
41
64
|
end
|
42
65
|
@lunker_data = results
|
43
66
|
return @lunker_data
|
44
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def convert_YN_boolean(value)
|
71
|
+
v = value.try(:downcase)
|
72
|
+
v = if v == 'Y'
|
73
|
+
true
|
74
|
+
elsif v == 'N'
|
75
|
+
false
|
76
|
+
else
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
v
|
80
|
+
end
|
81
|
+
|
45
82
|
end
|
46
83
|
end
|
47
84
|
end
|
data/lib/lakes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lakes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Sherman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|