footty 0.2.0 → 0.3.0
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/HISTORY.md +3 -3
- data/Manifest.txt +10 -10
- data/README.md +79 -43
- data/Rakefile +30 -30
- data/bin/footty +5 -5
- data/lib/footty/client.rb +103 -74
- data/lib/footty/version.rb +14 -4
- data/lib/footty.rb +118 -55
- data/test/helper.rb +0 -2
- data/test/test_client.rb +144 -32
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 930601b32688da7494d8ee0ee4ad531075b728f1
|
4
|
+
data.tar.gz: a39c443fe682fb6a429633b783a0377ca98844bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de355cd9ef713b79b2076e52778d38b59412a4a668bb7196d1eb6ff01ff729dcdf848a0fed00ea6cee0c003dd44a79492e349296f68892620154bf6062705d0
|
7
|
+
data.tar.gz: d75c615a075dda25f5bfde475d44b27b75e8402d48fc3481668ee9a466e95c7dbc73db0ede0804ff6db140f15c4ef757048b93f10548a3313c4d4210d3789b19
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
### 1.0.0 / 2018-06-09
|
2
|
-
|
3
|
-
* Everything is new (again). First release.
|
1
|
+
### 1.0.0 / 2018-06-09
|
2
|
+
|
3
|
+
* Everything is new (again). First release.
|
data/Manifest.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
HISTORY.md
|
2
|
-
Manifest.txt
|
3
|
-
README.md
|
4
|
-
Rakefile
|
5
|
-
bin/footty
|
6
|
-
lib/footty.rb
|
7
|
-
lib/footty/client.rb
|
8
|
-
lib/footty/version.rb
|
9
|
-
test/helper.rb
|
10
|
-
test/test_client.rb
|
1
|
+
HISTORY.md
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
bin/footty
|
6
|
+
lib/footty.rb
|
7
|
+
lib/footty/client.rb
|
8
|
+
lib/footty/version.rb
|
9
|
+
test/helper.rb
|
10
|
+
test/test_client.rb
|
data/README.md
CHANGED
@@ -1,43 +1,79 @@
|
|
1
|
-
# footty -
|
2
|
-
|
3
|
-
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
4
|
-
* bugs :: [github.com/sportdb/footty/issues](https://github.com/sportdb/footty/issues)
|
5
|
-
* gem :: [rubygems.org/gems/footty](https://rubygems.org/gems/footty)
|
6
|
-
* rdoc :: [rubydoc.info/gems/footty](http://rubydoc.info/gems/footty)
|
7
|
-
* forum :: [opensport](http://groups.google.com/group/opensport)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
# footty - football.db command line client for world cup (russia 2018) and more
|
2
|
+
|
3
|
+
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
4
|
+
* bugs :: [github.com/sportdb/footty/issues](https://github.com/sportdb/footty/issues)
|
5
|
+
* gem :: [rubygems.org/gems/footty](https://rubygems.org/gems/footty)
|
6
|
+
* rdoc :: [rubydoc.info/gems/footty](http://rubydoc.info/gems/footty)
|
7
|
+
* forum :: [opensport](http://groups.google.com/group/opensport)
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## Usage - Who's playing today?
|
14
|
+
|
15
|
+
The footty command line tool lets you query the online football.db HTTP JSON API services
|
16
|
+
for upcoming or past matches. For example:
|
17
|
+
|
18
|
+
$ footty # Defaults to today's world cup 2018 matches
|
19
|
+
|
20
|
+
prints on Jun/14 2018:
|
21
|
+
|
22
|
+
#1 Thu Jun/14 Russia (RUS) vs Saudi Arabia (KSA) Group A @ Luzhniki Stadium, Moscow
|
23
|
+
|
24
|
+
prints on Jun/15 2018:
|
25
|
+
|
26
|
+
#2 Fri Jun/15 Egypt (EGY) vs Uruguay (URU) Group A @ Ekaterinburg Arena, Ekaterinburg
|
27
|
+
#3 Fri Jun/15 Portugal (POR) vs Spain (ESP) Group B @ Fisht Stadium, Sochi
|
28
|
+
#4 Fri Jun/15 Morocco (MAR) vs Iran (IRN) Group B @ Saint Petersburg Stadium, Saint Petersburg
|
29
|
+
|
30
|
+
prints on Jun/16:
|
31
|
+
|
32
|
+
#5 Sat Jun/16 France (FRA) vs Australia (AUS) Group C @ Kazan Arena, Kazan
|
33
|
+
#6 Sat Jun/16 Peru (PER) vs Denmark (DEN) Group C @ Mordovia Arena, Saransk
|
34
|
+
#7 Sat Jun/16 Argentina (ARG) vs Iceland (ISL) Group D @ Spartak Stadium, Moscow
|
35
|
+
#8 Sat Jun/16 Croatia (CRO) vs Nigeria (NGA) Group D @ Kaliningrad Stadium, Kaliningrad
|
36
|
+
|
37
|
+
and so on.
|
38
|
+
Use `tomorrow` or `t` or `+1` to print tomorrow's matches e.g.:
|
39
|
+
|
40
|
+
$ footty tomorrow # -or-
|
41
|
+
$ footty t
|
42
|
+
|
43
|
+
Use `yesterday` or `y` or `-1` to print yesterday's matches e.g.:
|
44
|
+
|
45
|
+
$ footty yesterday # -or-
|
46
|
+
$ footty y
|
47
|
+
|
48
|
+
Use `upcoming` or `up` or `u` to print all upcoming matches e.g.:
|
49
|
+
|
50
|
+
$ footty upcoming # -or-
|
51
|
+
$ footty up
|
52
|
+
|
53
|
+
Use `past` or `p` to print all past matches e.g.:
|
54
|
+
|
55
|
+
$ footty past # -or-
|
56
|
+
$ footty p
|
57
|
+
|
58
|
+
|
59
|
+
That's it. Enjoy the beautiful game.
|
60
|
+
|
61
|
+
|
62
|
+
## Install
|
63
|
+
|
64
|
+
Just install the gem:
|
65
|
+
|
66
|
+
$ gem install footty
|
67
|
+
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
The `footty` scripts are dedicated to the public domain.
|
72
|
+
Use it as you please with no restrictions whatsoever.
|
73
|
+
|
74
|
+
|
75
|
+
## Questions? Comments?
|
76
|
+
|
77
|
+
Send them along to the
|
78
|
+
[Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
|
79
|
+
Thanks!
|
data/Rakefile
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
require 'hoe'
|
2
|
-
require './lib/footty/version.rb'
|
3
|
-
|
4
|
-
Hoe.spec 'footty' do
|
5
|
-
|
6
|
-
self.version = Footty::VERSION
|
7
|
-
|
8
|
-
self.summary = 'footty -
|
9
|
-
self.description = summary
|
10
|
-
|
11
|
-
self.urls = ['https://github.com/sportdb/footty']
|
12
|
-
|
13
|
-
self.author = 'Gerald Bauer'
|
14
|
-
self.email = 'opensport@googlegroups.com'
|
15
|
-
|
16
|
-
# switch extension to .markdown for gihub formatting
|
17
|
-
self.readme_file = 'README.md'
|
18
|
-
self.history_file = 'HISTORY.md'
|
19
|
-
|
20
|
-
self.extra_deps = [
|
21
|
-
['logutils' ],
|
22
|
-
['fetcher']
|
23
|
-
]
|
24
|
-
|
25
|
-
self.licenses = ['Public Domain']
|
26
|
-
|
27
|
-
self.spec_extras = {
|
28
|
-
:required_ruby_version => '>= 2.3'
|
29
|
-
}
|
30
|
-
end
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/footty/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'footty' do
|
5
|
+
|
6
|
+
self.version = Footty::VERSION
|
7
|
+
|
8
|
+
self.summary = 'footty - football.db command line client for world cup (russia 2018) and more - who is playing today?'
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = ['https://github.com/sportdb/footty']
|
12
|
+
|
13
|
+
self.author = 'Gerald Bauer'
|
14
|
+
self.email = 'opensport@googlegroups.com'
|
15
|
+
|
16
|
+
# switch extension to .markdown for gihub formatting
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'HISTORY.md'
|
19
|
+
|
20
|
+
self.extra_deps = [
|
21
|
+
['logutils' ],
|
22
|
+
['fetcher']
|
23
|
+
]
|
24
|
+
|
25
|
+
self.licenses = ['Public Domain']
|
26
|
+
|
27
|
+
self.spec_extras = {
|
28
|
+
:required_ruby_version => '>= 2.3'
|
29
|
+
}
|
30
|
+
end
|
data/bin/footty
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'footty'
|
4
|
-
|
5
|
-
Footty.main
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'footty'
|
4
|
+
|
5
|
+
Footty.main
|
data/lib/footty/client.rb
CHANGED
@@ -1,74 +1,103 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Footty
|
4
|
-
|
5
|
-
class Client
|
6
|
-
|
7
|
-
include LogUtils::Logging
|
8
|
-
|
9
|
-
API_BASE = '
|
10
|
-
|
11
|
-
def initialize( opts={} )
|
12
|
-
@opts = opts
|
13
|
-
@worker = Fetcher::Worker.new
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Footty
|
4
|
+
|
5
|
+
class Client
|
6
|
+
|
7
|
+
include LogUtils::Logging
|
8
|
+
|
9
|
+
API_BASE = 'https://raw.githubusercontent.com/openfootball/world-cup.json/master/2018'
|
10
|
+
|
11
|
+
def initialize( opts={} )
|
12
|
+
@opts = opts
|
13
|
+
@worker = Fetcher::Worker.new
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
### note:
|
19
|
+
## cache ALL methods - only do one web request for worldcup match schedule & results
|
20
|
+
def get_worldcup
|
21
|
+
@worldcup ||= get( 'worldcup.json' ) ## use "memoized" / cached result
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
## for testing lets you use /round/1 etc.
|
29
|
+
def get_round( num )
|
30
|
+
h = get_worldcup
|
31
|
+
matches = h[ 'rounds' ][ num-1 ] ## note: rounds hash starts with zero (not 1)
|
32
|
+
matches
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def get_todays_matches( date: Date.today ) get_matches_for( date ); end
|
37
|
+
def get_tomorrows_matches( date: Date.today ) get_matches_for( date+1 ); end
|
38
|
+
def get_yesterdays_matches( date: Date.today ) get_matches_for( date-1 ); end
|
39
|
+
|
40
|
+
def get_matches_for( date )
|
41
|
+
hash = get_worldcup
|
42
|
+
matches = select_matches( hash[ 'rounds' ] ) { |match| date == Date.parse( match['date'] ) }
|
43
|
+
matches
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def get_upcoming_matches( date: Date.today )
|
48
|
+
## note: includes todays matches for now
|
49
|
+
hash = get_worldcup
|
50
|
+
matches = select_matches( hash[ 'rounds' ] ) { |match| date <= Date.parse( match['date'] ) }
|
51
|
+
matches
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_past_matches( date: Date.today )
|
55
|
+
hash = get_worldcup
|
56
|
+
matches = select_matches( hash[ 'rounds' ] ) { |match| date > Date.parse( match['date'] ) }
|
57
|
+
## note reveserve matches (chronological order/last first)
|
58
|
+
matches.reverse
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def select_matches( rounds )
|
64
|
+
matches = []
|
65
|
+
rounds.each do |round|
|
66
|
+
round['matches'].each do |match|
|
67
|
+
if yield( match )
|
68
|
+
## hack: add (outer) round to match
|
69
|
+
match['round'] = round['name']
|
70
|
+
matches << match
|
71
|
+
else
|
72
|
+
## puts " skipping game play_date #{play_date}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
matches
|
77
|
+
end
|
78
|
+
|
79
|
+
def get( path )
|
80
|
+
## uri = URI.parse( "#{API_BASE}/#{path}" )
|
81
|
+
# fix: use is_a? URI in fetcher
|
82
|
+
uri_string = "#{API_BASE}/#{path}"
|
83
|
+
|
84
|
+
response = @worker.get_response( uri_string )
|
85
|
+
|
86
|
+
if response.code == '200'
|
87
|
+
##
|
88
|
+
## todo/check:
|
89
|
+
## do we need to force utf-8 encoding?
|
90
|
+
## check for teams w/ non-ascii names
|
91
|
+
hash = JSON.parse( response.body )
|
92
|
+
## pp hash
|
93
|
+
hash
|
94
|
+
else
|
95
|
+
logger.error "fetch HTTP - #{response.code} #{response.message}"
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end # class Client
|
101
|
+
|
102
|
+
|
103
|
+
end # module Footty
|
data/lib/footty/version.rb
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module Footty
|
5
|
+
VERSION = '0.3.0'
|
6
|
+
|
7
|
+
def self.banner
|
8
|
+
"footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.root
|
12
|
+
"#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
|
13
|
+
end
|
14
|
+
end
|
data/lib/footty.rb
CHANGED
@@ -1,55 +1,118 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
## stdlibs
|
5
|
-
|
6
|
-
require 'net/http'
|
7
|
-
require 'uri'
|
8
|
-
require 'json'
|
9
|
-
require 'pp'
|
10
|
-
|
11
|
-
|
12
|
-
## 3rd party gems/libs
|
13
|
-
## require 'props'
|
14
|
-
|
15
|
-
require 'logutils'
|
16
|
-
require 'fetcher'
|
17
|
-
|
18
|
-
# our own code
|
19
|
-
|
20
|
-
require 'footty/version' # let it always go first
|
21
|
-
require 'footty/client'
|
22
|
-
|
23
|
-
|
24
|
-
module Footty
|
25
|
-
|
26
|
-
def self.
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
## stdlibs
|
5
|
+
|
6
|
+
require 'net/http'
|
7
|
+
require 'uri'
|
8
|
+
require 'json'
|
9
|
+
require 'pp'
|
10
|
+
|
11
|
+
|
12
|
+
## 3rd party gems/libs
|
13
|
+
## require 'props'
|
14
|
+
|
15
|
+
require 'logutils'
|
16
|
+
require 'fetcher'
|
17
|
+
|
18
|
+
# our own code
|
19
|
+
|
20
|
+
require 'footty/version' # let it always go first
|
21
|
+
require 'footty/client'
|
22
|
+
|
23
|
+
|
24
|
+
module Footty
|
25
|
+
|
26
|
+
def self.client
|
27
|
+
@@client ||= Client.new ## use "singelton" / shared client
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
def self.main
|
33
|
+
puts banner # say hello
|
34
|
+
|
35
|
+
what = ARGV[0] || 'today'
|
36
|
+
what = what.downcase
|
37
|
+
|
38
|
+
## in the future make today "configurable" as param - why? why not?
|
39
|
+
today = Date.today
|
40
|
+
|
41
|
+
if ['yesterday', 'y', '-1'].include? what
|
42
|
+
matches = client.get_todays_matches( date: today )
|
43
|
+
if matches.empty?
|
44
|
+
puts "** No matches played yesterday.\n"
|
45
|
+
end
|
46
|
+
elsif ['tomorrow', 't', '+1', '1'].include? what
|
47
|
+
matches = client.get_tomorrows_matches( date: today )
|
48
|
+
if matches.empty?
|
49
|
+
puts "** No matches scheduled tomorrow.\n"
|
50
|
+
end
|
51
|
+
elsif ['past', 'p', 'prev'].include? what
|
52
|
+
matches = client.get_past_matches( date: today )
|
53
|
+
if matches.empty?
|
54
|
+
puts "** No matches played yet.\n"
|
55
|
+
end
|
56
|
+
elsif ['upcoming', 'up', 'u', 'next', 'n'].include? what
|
57
|
+
matches = client.get_upcoming_matches( date: today )
|
58
|
+
if matches.empty?
|
59
|
+
puts "** No more matches scheduled.\n"
|
60
|
+
end
|
61
|
+
else
|
62
|
+
matches = client.get_todays_matches( date: today )
|
63
|
+
|
64
|
+
## no matches today
|
65
|
+
if matches.empty?
|
66
|
+
puts "** No matches scheduled today.\n"
|
67
|
+
|
68
|
+
if Date.today > Date.new( 2018, 7, 11 ) ## world cup is over, look back
|
69
|
+
puts "Past matches:"
|
70
|
+
matches = client.get_past_matches( date: today )
|
71
|
+
else ## world cup is upcoming /in-progress,look forward
|
72
|
+
puts "Upcoming matches:"
|
73
|
+
matches = client.get_upcoming_matches( date: today )
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
print_matches( matches )
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
def self.print_matches( matches )
|
84
|
+
## print games
|
85
|
+
|
86
|
+
today = Date.today
|
87
|
+
|
88
|
+
matches.each do |match|
|
89
|
+
print " "
|
90
|
+
print "\##{match['num']} "
|
91
|
+
|
92
|
+
date = Date.parse( match['date'] )
|
93
|
+
print "#{date.strftime('%a %b/%d')} " ## e.g. Thu Jun/14
|
94
|
+
if date > today
|
95
|
+
diff = (date - today).to_i
|
96
|
+
print "(in #{diff}d) "
|
97
|
+
end
|
98
|
+
|
99
|
+
print "%18s" % "#{match['team1']['name']} (#{match['team1']['code']})"
|
100
|
+
print " vs "
|
101
|
+
print "%18s" % "#{match['team2']['name']} (#{match['team2']['code']})"
|
102
|
+
|
103
|
+
if match['group']
|
104
|
+
print " #{match['group']} " ## group phase/stage
|
105
|
+
else
|
106
|
+
print " #{match['round']} " ## knock out (k.o.) phase/stage
|
107
|
+
end
|
108
|
+
|
109
|
+
print " @ #{match['stadium']['name']}, #{match['city']}"
|
110
|
+
print "\n"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end # module Footty
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
Footty.main if __FILE__ == $0
|
data/test/helper.rb
CHANGED
data/test/test_client.rb
CHANGED
@@ -3,49 +3,161 @@
|
|
3
3
|
|
4
4
|
require 'helper'
|
5
5
|
|
6
|
-
class TestClient < MiniTest::Unit::TestCase
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
|
8
|
+
class TestClient < MiniTest::Test
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@client = Footty.client
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def test_getters
|
16
|
+
today = Date.new( 2018, 6, 16 )
|
17
|
+
|
18
|
+
todays = @client.get_todays_matches( date: today )
|
19
|
+
pp todays
|
20
|
+
assert_equal 4, todays.size
|
21
|
+
|
22
|
+
yesterdays = @client.get_yesterdays_matches( date: today )
|
23
|
+
pp yesterdays
|
24
|
+
assert_equal 3, yesterdays.size
|
25
|
+
|
26
|
+
tomorrows = @client.get_tomorrows_matches( date: today )
|
27
|
+
pp tomorrows
|
28
|
+
assert_equal 3, tomorrows.size
|
29
|
+
|
30
|
+
past = @client.get_past_matches( date: today )
|
31
|
+
pp past
|
32
|
+
|
33
|
+
upcoming = @client.get_upcoming_matches( date: today )
|
34
|
+
pp upcoming
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
def test_todays_matches_2018_6_14
|
40
|
+
today = Date.new( 2018, 6, 14 )
|
41
|
+
ary = @client.get_todays_matches( date: today )
|
42
|
+
## pp ary
|
43
|
+
=begin
|
44
|
+
[{"num"=>1,
|
45
|
+
"date"=>"2018-06-14",
|
46
|
+
"time"=>"18:00",
|
47
|
+
"team1"=>{"name"=>"Russia", "code"=>"RUS"},
|
48
|
+
"team2"=>{"name"=>"Saudi Arabia", "code"=>"KSA"},
|
49
|
+
"score1"=>nil,
|
50
|
+
"score2"=>nil,
|
51
|
+
"score1i"=>nil,
|
52
|
+
"score2i"=>nil,
|
53
|
+
"group"=>"Group A",
|
54
|
+
"stadium"=>{"key"=>"luzhniki", "name"=>"Luzhniki Stadium"},
|
55
|
+
"city"=>"Moscow",
|
56
|
+
"timezone"=>"UTC+3",
|
57
|
+
"round"=>"Matchday 1"}]
|
58
|
+
=end
|
59
|
+
|
60
|
+
assert_equal Array, ary.class ## for now just check return type (e.g. assume Array for parsed JSON data)
|
61
|
+
assert_equal 1, ary.size
|
62
|
+
assert_equal 'RUS', ary[0]['team1']['code']
|
63
|
+
assert_equal 'KSA', ary[0]['team2']['code']
|
64
|
+
assert_equal 'Matchday 1', ary[0]['round']
|
65
|
+
assert_nil ary[0]['score1']
|
66
|
+
assert_nil ary[0]['score2']
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_todays_matches_2018_6_10
|
70
|
+
today = Date.new( 2018, 6, 10 )
|
71
|
+
ary = @client.get_todays_matches( date: today )
|
72
|
+
## note: returns empty array if no matches scheduled/playing today
|
12
73
|
pp ary
|
13
74
|
|
14
75
|
assert_equal Array, ary.class ## for now just check return type (e.g. assume Array for parsed JSON data)
|
76
|
+
assert ary.empty?
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_world_2018_round_1
|
80
|
+
h = @client.get_round( 1 )
|
81
|
+
|
82
|
+
## pp h
|
83
|
+
=begin
|
84
|
+
{"name"=>"Matchday 1",
|
85
|
+
"matches"=>
|
86
|
+
[{"num"=>1,
|
87
|
+
"date"=>"2018-06-14",
|
88
|
+
"time"=>"18:00",
|
89
|
+
"team1"=>{"name"=>"Russia", "code"=>"RUS"},
|
90
|
+
"team2"=>{"name"=>"Saudi Arabia", "code"=>"KSA"},
|
91
|
+
"score1"=>nil,
|
92
|
+
"score2"=>nil,
|
93
|
+
"score1i"=>nil,
|
94
|
+
"score2i"=>nil,
|
95
|
+
"group"=>"Group A",
|
96
|
+
"stadium"=>{"key"=>"luzhniki", "name"=>"Luzhniki Stadium"},
|
97
|
+
"city"=>"Moscow",
|
98
|
+
"timezone"=>"UTC+3"}]}
|
99
|
+
=end
|
100
|
+
|
101
|
+
assert_equal 'RUS', h['matches'][0]['team1']['code']
|
102
|
+
assert_equal 'KSA', h['matches'][0]['team2']['code']
|
103
|
+
assert_nil h['matches'][0]['score1']
|
104
|
+
assert_nil h['matches'][0]['score2']
|
15
105
|
end
|
16
106
|
|
17
|
-
|
18
|
-
|
19
|
-
h = client.get_round(
|
107
|
+
|
108
|
+
def test_world_2018_round_2
|
109
|
+
h = @client.get_round( 2 )
|
20
110
|
|
21
111
|
## pp h
|
22
112
|
=begin
|
23
|
-
{"
|
24
|
-
"
|
25
|
-
{"
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"
|
30
|
-
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
113
|
+
{"name"=>"Matchday 2",
|
114
|
+
"matches"=>
|
115
|
+
[{"num"=>2,
|
116
|
+
"date"=>"2018-06-15",
|
117
|
+
"time"=>"17:00",
|
118
|
+
"team1"=>{"name"=>"Egypt", "code"=>"EGY"},
|
119
|
+
"team2"=>{"name"=>"Uruguay", "code"=>"URU"},
|
120
|
+
"score1"=>nil,
|
121
|
+
"score2"=>nil,
|
122
|
+
"score1i"=>nil,
|
123
|
+
"score2i"=>nil,
|
124
|
+
"group"=>"Group A",
|
125
|
+
"stadium"=>{"key"=>"ekaterinburg", "name"=>"Ekaterinburg Arena"},
|
126
|
+
"city"=>"Ekaterinburg",
|
127
|
+
"timezone"=>"UTC+5"},
|
128
|
+
{"num"=>3,
|
129
|
+
"date"=>"2018-06-15",
|
130
|
+
"time"=>"21:00",
|
131
|
+
"team1"=>{"name"=>"Portugal", "code"=>"POR"},
|
132
|
+
"team2"=>{"name"=>"Spain", "code"=>"ESP"},
|
133
|
+
"score1"=>nil,
|
134
|
+
"score2"=>nil,
|
135
|
+
"score1i"=>nil,
|
136
|
+
"score2i"=>nil,
|
137
|
+
"group"=>"Group B",
|
138
|
+
"stadium"=>{"key"=>"fisht", "name"=>"Fisht Stadium"},
|
139
|
+
"city"=>"Sochi",
|
140
|
+
"timezone"=>"UTC+3"},
|
141
|
+
{"num"=>4,
|
142
|
+
"date"=>"2018-06-15",
|
143
|
+
"time"=>"18:00",
|
144
|
+
"team1"=>{"name"=>"Morocco", "code"=>"MAR"},
|
145
|
+
"team2"=>{"name"=>"Iran", "code"=>"IRN"},
|
146
|
+
"score1"=>nil,
|
147
|
+
"score2"=>nil,
|
148
|
+
"score1i"=>nil,
|
149
|
+
"score2i"=>nil,
|
150
|
+
"group"=>"Group B",
|
151
|
+
"stadium"=>{"key"=>"saintpetersburg", "name"=>"Saint Petersburg Stadium"},
|
152
|
+
"city"=>"Saint Petersburg",
|
153
|
+
"timezone"=>"UTC+3"}]}
|
43
154
|
=end
|
44
155
|
|
45
|
-
assert_equal '
|
46
|
-
assert_equal '
|
47
|
-
|
48
|
-
|
156
|
+
assert_equal 'EGY', h['matches'][0]['team1']['code']
|
157
|
+
assert_equal 'URU', h['matches'][0]['team2']['code']
|
158
|
+
assert_nil h['matches'][0]['score1']
|
159
|
+
assert_nil h['matches'][0]['score2']
|
49
160
|
end
|
50
161
|
|
162
|
+
|
51
163
|
end # class TestClient
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -66,8 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.16'
|
69
|
-
description: footty -
|
70
|
-
|
69
|
+
description: footty - football.db command line client for world cup (russia 2018)
|
70
|
+
and more - who is playing today?
|
71
71
|
email: opensport@googlegroups.com
|
72
72
|
executables:
|
73
73
|
- footty
|
@@ -112,6 +112,6 @@ rubyforge_project:
|
|
112
112
|
rubygems_version: 2.5.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
|
-
summary: footty -
|
116
|
-
|
115
|
+
summary: footty - football.db command line client for world cup (russia 2018) and
|
116
|
+
more - who is playing today?
|
117
117
|
test_files: []
|