golfscrape 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/golfscrape/client.rb +17 -17
- data/lib/golfscrape/version.rb +1 -1
- metadata +2 -28
data/lib/golfscrape/client.rb
CHANGED
@@ -10,27 +10,27 @@ module Golfscrape
|
|
10
10
|
doc = Nokogiri::HTML(open(url))
|
11
11
|
doc.css('div#leaderboardtable table.sportsTable').first.css('tbody tr').each do |player|
|
12
12
|
begin
|
13
|
-
@position = player.css('td.position').children.last.content.gsub
|
14
|
-
@name = player.css('td.player').css('a').first.children.last.content
|
15
|
-
@first = player.css('td')[2].children.last.content.gsub
|
16
|
-
@second = player.css('td')[3].children.last.content.gsub
|
17
|
-
@third = player.css('td')[4].children.last.content.gsub
|
18
|
-
@fourth = player.css('td')[5].children.last.content.gsub
|
19
|
-
@today = player.css('td')[6].children.last.content.gsub
|
20
|
-
@thru = player.css('td')[7].children.last.content.gsub
|
21
|
-
@total = player.css('td.total').children.last.content.gsub
|
22
|
-
|
13
|
+
@position = player.css('td.position').children.last.try(:content).try(:gsub, "\n", "")
|
14
|
+
@name = player.css('td.player').css('a').first.children.last.try(:content)
|
15
|
+
@first = player.css('td')[2].children.last.try(:content).try(:gsub, "\n", "")
|
16
|
+
@second = player.css('td')[3].children.last.try(:content).try(:gsub, "\n", "")
|
17
|
+
@third = player.css('td')[4].children.last.try(:content).try(:gsub, "\n", "")
|
18
|
+
@fourth = player.css('td')[5].children.last.try(:content).try(:gsub, "\n", "")
|
19
|
+
@today = player.css('td')[6].children.last.try(:content).try(:gsub, "\n", "")
|
20
|
+
@thru = player.css('td')[7].children.last.try(:content).try(:gsub, "\n", "") unless player.css('td')[7].attributes["class"].value.match(/total/)
|
21
|
+
@total = player.css('td.total').children.last.try(:content).try(:gsub, "\n", "")
|
22
|
+
|
23
23
|
if player.css('td.earnings')
|
24
|
-
@strokes = player.css('td')[8].children.last.content.gsub
|
24
|
+
@strokes = player.css('td')[8].children.last.try(:content).try(:gsub, "\n", "")
|
25
25
|
else
|
26
|
-
@strokes = player.css('td')[9].children.last.content.gsub
|
26
|
+
@strokes = player.css('td')[9].children.last.try(:content).try(:gsub, "\n", "")
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
response << Hashie::Mash.new(:position => @position, :name => @name, :first_round => @first, :second_round => @second, :third_round => @third,
|
30
|
+
:fourth_round => @fourth, :today => @today, :thru => @thru, :total => @total, :strokes => @strokes)
|
31
|
+
|
29
32
|
rescue
|
30
|
-
end
|
31
|
-
|
32
|
-
response << Hashie::Mash.new(:position => @position, :name => @name, :first_round => @first, :second_round => @second, :third_round => @third,
|
33
|
-
:fourth_round => @fourth, :today => @today, :thru => @thru, :total => @total, :strokes => @strokes)
|
33
|
+
end
|
34
34
|
end
|
35
35
|
|
36
36
|
response
|
data/lib/golfscrape/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: golfscrape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 19
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 6
|
10
|
-
version: 0.0.6
|
5
|
+
version: 0.0.7
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Johnny Khai Nguyen
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2013-04-04 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: nokogiri
|
@@ -25,9 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
23
|
version: "0"
|
32
24
|
type: :runtime
|
33
25
|
version_requirements: *id001
|
@@ -39,9 +31,6 @@ dependencies:
|
|
39
31
|
requirements:
|
40
32
|
- - ">="
|
41
33
|
- !ruby/object:Gem::Version
|
42
|
-
hash: 3
|
43
|
-
segments:
|
44
|
-
- 0
|
45
34
|
version: "0"
|
46
35
|
type: :runtime
|
47
36
|
version_requirements: *id002
|
@@ -53,9 +42,6 @@ dependencies:
|
|
53
42
|
requirements:
|
54
43
|
- - ">="
|
55
44
|
- !ruby/object:Gem::Version
|
56
|
-
hash: 3
|
57
|
-
segments:
|
58
|
-
- 0
|
59
45
|
version: "0"
|
60
46
|
type: :development
|
61
47
|
version_requirements: *id003
|
@@ -67,9 +53,6 @@ dependencies:
|
|
67
53
|
requirements:
|
68
54
|
- - ">="
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
hash: 3
|
71
|
-
segments:
|
72
|
-
- 0
|
73
56
|
version: "0"
|
74
57
|
type: :development
|
75
58
|
version_requirements: *id004
|
@@ -81,9 +64,6 @@ dependencies:
|
|
81
64
|
requirements:
|
82
65
|
- - ">="
|
83
66
|
- !ruby/object:Gem::Version
|
84
|
-
hash: 3
|
85
|
-
segments:
|
86
|
-
- 0
|
87
67
|
version: "0"
|
88
68
|
type: :development
|
89
69
|
version_requirements: *id005
|
@@ -124,18 +104,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
104
|
requirements:
|
125
105
|
- - ">="
|
126
106
|
- !ruby/object:Gem::Version
|
127
|
-
hash: 3
|
128
|
-
segments:
|
129
|
-
- 0
|
130
107
|
version: "0"
|
131
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
109
|
none: false
|
133
110
|
requirements:
|
134
111
|
- - ">="
|
135
112
|
- !ruby/object:Gem::Version
|
136
|
-
hash: 3
|
137
|
-
segments:
|
138
|
-
- 0
|
139
113
|
version: "0"
|
140
114
|
requirements: []
|
141
115
|
|