sanfrecce 0.1.2 → 0.1.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 +4 -4
- data/exe/sanfrecce +16 -2
- data/lib/sanfrecce/version.rb +1 -1
- data/lib/sanfrecce.rb +57 -8
- 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: 33a471416ba1c4585ffbd135fe4d3512c9d6a072
|
4
|
+
data.tar.gz: 08338e80e8a2c92f8094fb38c10da55bc32afd00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4b8c47c14d4d00cd9735de1d4fd69082a10613def566a6a55fd8e1d7a5ca83ac95af1356a7f5d77b5f176f498265dc0cc05e47a95c328aaa90d946b39236fb
|
7
|
+
data.tar.gz: 994a401249d147f346b84b9d9751f5db119b3b0da8eb7a69c015d4204c5c0436609e918ed2246b61cbc983f7d424031a01fbfc950801df108926e331b920dae1
|
data/exe/sanfrecce
CHANGED
@@ -30,8 +30,22 @@ module Sanfrecce
|
|
30
30
|
|
31
31
|
desc 'games', 'all games'
|
32
32
|
def games
|
33
|
-
|
34
|
-
|
33
|
+
pp Sanfrecce.all_games
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'first_ranking', '1stage ranking'
|
37
|
+
def first_ranking
|
38
|
+
pp Sanfrecce.first_ranking
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'second_ranking', '2stage ranking'
|
42
|
+
def second_ranking
|
43
|
+
pp Sanfrecce.second_ranking
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'ranking', 'ranking'
|
47
|
+
def ranking
|
48
|
+
pp Sanfrecce.ranking
|
35
49
|
end
|
36
50
|
|
37
51
|
desc 'game', 'game result'
|
data/lib/sanfrecce/version.rb
CHANGED
data/lib/sanfrecce.rb
CHANGED
@@ -10,7 +10,7 @@ module Sanfrecce
|
|
10
10
|
players = {}
|
11
11
|
html.css('a').each do |item|
|
12
12
|
no = item.css('span.uniform_number').text
|
13
|
-
name = item
|
13
|
+
name = html2text(item, 'span.player_name > strong')
|
14
14
|
players[no] = name
|
15
15
|
end
|
16
16
|
players
|
@@ -19,7 +19,7 @@ module Sanfrecce
|
|
19
19
|
def first_stage
|
20
20
|
games = {}
|
21
21
|
fetch_games.css('div:nth-child(3) > table > tr').each do |item|
|
22
|
-
games['1st-' + item
|
22
|
+
games['1st-' + html2text(item, 'td:nth-child(1)')] = game_detail(item)
|
23
23
|
end
|
24
24
|
games.delete_if { |key, _value| key == '1st-' }
|
25
25
|
end
|
@@ -27,7 +27,7 @@ module Sanfrecce
|
|
27
27
|
def second_stage
|
28
28
|
games = {}
|
29
29
|
fetch_games.css('div:nth-child(4) > table > tr').each do |item|
|
30
|
-
games['2nd-' + item
|
30
|
+
games['2nd-' + html2text(item, 'td:nth-child(1)')] = game_detail(item)
|
31
31
|
end
|
32
32
|
games.delete_if { |key, _value| key == '2nd-' }
|
33
33
|
end
|
@@ -36,6 +36,30 @@ module Sanfrecce
|
|
36
36
|
first_stage.merge(second_stage)
|
37
37
|
end
|
38
38
|
|
39
|
+
def ranking
|
40
|
+
rank = {}
|
41
|
+
fetch_ranking.css('div:nth-child(5) > table > tr').each do |item|
|
42
|
+
rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
|
43
|
+
end
|
44
|
+
rank
|
45
|
+
end
|
46
|
+
|
47
|
+
def first_ranking
|
48
|
+
rank = {}
|
49
|
+
fetch_ranking.css('div:nth-child(3) > table > tr').each do |item|
|
50
|
+
rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
|
51
|
+
end
|
52
|
+
rank
|
53
|
+
end
|
54
|
+
|
55
|
+
def second_ranking
|
56
|
+
rank = {}
|
57
|
+
fetch_ranking.css('div:nth-child(4) > table > tr').each do |item|
|
58
|
+
rank[html2text(item, 'td:nth-child(1)')] = rank_detail(item)
|
59
|
+
end
|
60
|
+
rank
|
61
|
+
end
|
62
|
+
|
39
63
|
private
|
40
64
|
|
41
65
|
def self.fetch_players
|
@@ -53,13 +77,38 @@ module Sanfrecce
|
|
53
77
|
games_html
|
54
78
|
end
|
55
79
|
|
80
|
+
def self.fetch_ranking
|
81
|
+
url = 'http://www.sanfrecce.co.jp/info/ranking/'
|
82
|
+
html = Nokogiri::HTML(open(url), nil, 'CP932')
|
83
|
+
games_html = html.css('#contents > div.stadium_bg > div > div.content_area.clearfix')
|
84
|
+
games_html
|
85
|
+
end
|
86
|
+
|
56
87
|
def self.game_detail(item)
|
57
88
|
{
|
58
|
-
'Day': item
|
59
|
-
'Kickoff': item
|
60
|
-
'team': item
|
61
|
-
'result': item
|
62
|
-
'stadium': item
|
89
|
+
'Day': html2text(item, 'td:nth-child(2)'),
|
90
|
+
'Kickoff': html2text(item, 'td:nth-child(3)'),
|
91
|
+
'team': html2text(item, 'td:nth-child(4)'),
|
92
|
+
'result': html2text(item, 'td:nth-child(5)'),
|
93
|
+
'stadium': html2text(item, 'td:nth-child(6)')
|
63
94
|
}
|
64
95
|
end
|
96
|
+
|
97
|
+
def self.rank_detail(item)
|
98
|
+
{
|
99
|
+
'team': html2text(item, 'td:nth-child(2)'),
|
100
|
+
'points': html2text(item, 'td:nth-child(3)'),
|
101
|
+
'played': html2text(item, 'td:nth-child(4)'),
|
102
|
+
'win': html2text(item, 'td:nth-child(5)'),
|
103
|
+
'draw': html2text(item, 'td:nth-child(6)'),
|
104
|
+
'lose': html2text(item, 'td:nth-child(7)'),
|
105
|
+
'goal': html2text(item, 'td:nth-child(8)'),
|
106
|
+
'lost': html2text(item, 'td:nth-child(9)'),
|
107
|
+
'diff': html2text(item, 'td:nth-child(10)')
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.html2text(item, tag)
|
112
|
+
item.css(tag).text
|
113
|
+
end
|
65
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanfrecce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gennei
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|