sanfrecce 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683666ee9036ca405ed906fc5476fdce362f621d
4
- data.tar.gz: 91f5cff50bb3bbd35368b46eb90aa4526c90bab9
3
+ metadata.gz: 13aa4a37c5d18d8dbf8a84e155b107ada40e8020
4
+ data.tar.gz: d40d6eb616b3210972947670881d96f852ab76ac
5
5
  SHA512:
6
- metadata.gz: f5d2715f9d5064a0b07d81fe19ba30e0ebf69158aa8de3d1c6dcc0d8df120e1a68e4b8ac53f88ac4586ddee62f5dca79b2e13f1dd305ebd4f6f58680fed2477a
7
- data.tar.gz: b398c6a68ae63ec11ed87932a2e6f217f90def691ac2c0b8d609743fb3205c97d68ae28325e757c52046303cef41b02cc2ed7244d9828e725c0502699f1ea1fc
6
+ metadata.gz: e1d2baf3e9da9ea08f124145e00c2cc2fa86a40b0412c5993e9eb0c4b3e228dce5a2dbb8c0f5f540193ed70a53e7b586cdc4175f7d14eaff2598a6242128ef95
7
+ data.tar.gz: 1744c0d965c6959e243a47a9441498d03ac2150866035fc5421cf0607defde7edaa323fcbbdc90cf4fc3b9e7fdd10577e00b92ef59d842bd7d976f8e6f50f3dd
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/sanfrecce.svg)](http://badge.fury.io/rb/sanfrecce)
2
+
1
3
  # Sanfrecce
2
4
 
3
5
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sanfrecce`. To experiment with that code, run `bin/console` for an interactive prompt.
@@ -38,4 +40,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
38
40
  ## License
39
41
 
40
42
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -27,6 +27,17 @@ module Sanfrecce
27
27
  def number(no = 11)
28
28
  p Sanfrecce.players[no]
29
29
  end
30
+
31
+ desc 'games', 'all games'
32
+ def games
33
+ hoge = Sanfrecce.all_games
34
+ pp hoge
35
+ end
36
+
37
+ desc 'game', 'game result'
38
+ def game(no = 1)
39
+ pp Sanfrecce.first_stage['1st-' + no]
40
+ end
30
41
  end
31
42
  end
32
43
 
@@ -13,7 +13,27 @@ module Sanfrecce
13
13
  name = item.css('span.player_name > strong').text
14
14
  players[no] = name
15
15
  end
16
- return players
16
+ players
17
+ end
18
+
19
+ def first_stage
20
+ games = {}
21
+ fetch_games.css('div:nth-child(3) > table > tr').each do |item|
22
+ games['1st-' + item.css('td:nth-child(1)').text] = game_detail(item)
23
+ end
24
+ games.delete_if { |key, _value| key == '1st-' }
25
+ end
26
+
27
+ def second_stage
28
+ games = {}
29
+ fetch_games.css('div:nth-child(4) > table > tr').each do |item|
30
+ games['2nd-' + item.css('td:nth-child(1)').text] = game_detail(item)
31
+ end
32
+ games.delete_if { |key, _value| key == '2nd-' }
33
+ end
34
+
35
+ def all_games
36
+ first_stage.merge(second_stage)
17
37
  end
18
38
 
19
39
  private
@@ -23,6 +43,23 @@ module Sanfrecce
23
43
  url = 'http://www.sanfrecce.co.jp/player/'
24
44
  html = Nokogiri::HTML(open(url), nil, 'CP932')
25
45
  players_html = html.css('#contents > div.stadium_bg > div > div.content_area.clearfix.player')
26
- return players_html
46
+ players_html
47
+ end
48
+
49
+ def self.fetch_games
50
+ url = 'http://www.sanfrecce.co.jp/info/game_schedule/'
51
+ html = Nokogiri::HTML(open(url), nil, 'CP932')
52
+ games_html = html.css('#contents > div.stadium_bg > div > div.content_area.clearfix > div.content_area_left.float_l')
53
+ games_html
54
+ end
55
+
56
+ def self.game_detail(item)
57
+ {
58
+ 'Day': item.css('td:nth-child(2)').text,
59
+ 'Kickoff': item.css('td:nth-child(3)').text,
60
+ 'team': item.css('td:nth-child(4)').text,
61
+ 'result': item.css('td:nth-child(5)').text,
62
+ 'stadium': item.css('td:nth-child(6)').text
63
+ }
27
64
  end
28
65
  end
@@ -1,3 +1,3 @@
1
1
  module Sanfrecce
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: sanfrecce
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
  - gennei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-27 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor