footty 0.4.0 → 2024.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/{HISTORY.md → CHANGELOG.md} +1 -0
- data/Manifest.txt +1 -3
- data/README.md +18 -24
- data/Rakefile +5 -5
- data/bin/footty +3 -0
- data/lib/footty/client.rb +32 -29
- data/lib/footty/version.rb +5 -5
- data/lib/footty.rb +33 -24
- metadata +22 -19
- data/test/helper.rb +0 -10
- data/test/test_client.rb +0 -163
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34ac44dbe56d51fad5a516b69331ab594243cbac79f5c4b63f69271455773cd5
|
4
|
+
data.tar.gz: 428605f76f7713f3e61f8cf53cf80d5c8c3d6add43f649a0d701e9ca465d4259
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359ab0cc33ca8b8482a1d2e9cb60ea58e96c95c5494dc35232018dba09fe164f22a8a167afc1536e90ed9dabb600fe412fab6d0c7aa1a4afa3e3967e3c857907
|
7
|
+
data.tar.gz: 344366274d54e0721d8a718af983dd555009db88a8d11f89e56149bef17cb24ff23e17c772ca133a31bef0e0ac65a1dc68207b45e3c9a4c9c429241d30398599
|
data/{HISTORY.md → CHANGELOG.md}
RENAMED
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
# footty - football.db command line client for
|
1
|
+
# footty - football.db command line client for european ("euro") championship 2024 and more
|
2
2
|
|
3
3
|
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
4
4
|
* bugs :: [github.com/sportdb/footty/issues](https://github.com/sportdb/footty/issues)
|
5
5
|
* gem :: [rubygems.org/gems/footty](https://rubygems.org/gems/footty)
|
6
6
|
* rdoc :: [rubydoc.info/gems/footty](http://rubydoc.info/gems/footty)
|
7
|
-
* forum :: [opensport](http://groups.google.com/group/opensport)
|
8
7
|
|
9
8
|
|
10
9
|
|
@@ -15,27 +14,12 @@
|
|
15
14
|
The footty command line tool lets you query the online football.db HTTP JSON API services
|
16
15
|
for upcoming or past matches. For example:
|
17
16
|
|
18
|
-
$ footty # Defaults to today's
|
17
|
+
$ footty # Defaults to today's euro 2024 matches
|
19
18
|
|
20
|
-
prints on Jun/14
|
19
|
+
prints on Jun/14 2024:
|
21
20
|
|
22
|
-
#1
|
23
|
-
|
24
|
-
|
25
|
-
prints on Jun/15 2018:
|
26
|
-
|
27
|
-
#2 Fri Jun/15 Egypt (EGY) vs Uruguay (URU) Group A @ Ekaterinburg Arena, Ekaterinburg
|
28
|
-
#3 Fri Jun/15 Portugal (POR) vs Spain (ESP) Group B @ Fisht Stadium, Sochi
|
29
|
-
#4 Fri Jun/15 Morocco (MAR) vs Iran (IRN) Group B @ Saint Petersburg Stadium, Saint Petersburg
|
30
|
-
|
31
|
-
prints on Jun/16:
|
32
|
-
|
33
|
-
#5 Sat Jun/16 France (FRA) vs Australia (AUS) Group C @ Kazan Arena, Kazan
|
34
|
-
#6 Sat Jun/16 Peru (PER) vs Denmark (DEN) Group C @ Mordovia Arena, Saransk
|
35
|
-
#7 Sat Jun/16 Argentina (ARG) vs Iceland (ISL) Group D @ Spartak Stadium, Moscow
|
36
|
-
#8 Sat Jun/16 Croatia (CRO) vs Nigeria (NGA) Group D @ Kaliningrad Stadium, Kaliningrad
|
37
|
-
|
38
|
-
and so on.
|
21
|
+
#1 Fri Jun/14 Germany (GER) vs Scotland (SCO) Group A / Matchday 1
|
22
|
+
|
39
23
|
Use `tomorrow` or `t` or `+1` to print tomorrow's matches e.g.:
|
40
24
|
|
41
25
|
$ footty tomorrow # -or-
|
@@ -60,6 +44,13 @@ Use `past` or `p` to print all past matches e.g.:
|
|
60
44
|
That's it. Enjoy the beautiful game.
|
61
45
|
|
62
46
|
|
47
|
+
|
48
|
+
|
49
|
+
## Trivia
|
50
|
+
|
51
|
+
Why tty? tty stands for teletype (tty) writer and is the old traditional (short) name for the unix command line.
|
52
|
+
|
53
|
+
|
63
54
|
## Install
|
64
55
|
|
65
56
|
Just install the gem:
|
@@ -73,8 +64,11 @@ The `footty` scripts are dedicated to the public domain.
|
|
73
64
|
Use it as you please with no restrictions whatsoever.
|
74
65
|
|
75
66
|
|
67
|
+
|
68
|
+
|
69
|
+
|
76
70
|
## Questions? Comments?
|
77
71
|
|
78
|
-
|
79
|
-
[
|
80
|
-
|
72
|
+
Yes, you can. More than welcome.
|
73
|
+
See [Help & Support »](https://github.com/openfootball/help)
|
74
|
+
|
data/Rakefile
CHANGED
@@ -5,17 +5,17 @@ Hoe.spec 'footty' do
|
|
5
5
|
|
6
6
|
self.version = Footty::VERSION
|
7
7
|
|
8
|
-
self.summary = 'footty - football.db command line client for
|
8
|
+
self.summary = 'footty - football.db command line client for european "euro" championship 2024 and more - who is playing today?'
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls =
|
11
|
+
self.urls = { home: 'https://github.com/sportdb/footty' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'opensport@googlegroups.com'
|
15
15
|
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
|
-
self.readme_file
|
18
|
-
self.history_file = '
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
20
|
self.extra_deps = [
|
21
21
|
['logutils' ],
|
@@ -25,6 +25,6 @@ Hoe.spec 'footty' do
|
|
25
25
|
self.licenses = ['Public Domain']
|
26
26
|
|
27
27
|
self.spec_extras = {
|
28
|
-
:
|
28
|
+
required_ruby_version: '>= 2.3'
|
29
29
|
}
|
30
30
|
end
|
data/bin/footty
CHANGED
data/lib/footty/client.rb
CHANGED
@@ -1,58 +1,66 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Footty
|
4
2
|
|
3
|
+
|
5
4
|
class Client
|
6
5
|
|
7
6
|
include LogUtils::Logging
|
8
7
|
|
9
|
-
API_BASE = 'https://raw.githubusercontent.com/openfootball/world-cup.json/master/2018'
|
10
8
|
|
11
|
-
def initialize(
|
12
|
-
@opts = opts
|
9
|
+
def initialize( league:, year: )
|
13
10
|
@worker = Fetcher::Worker.new
|
11
|
+
|
12
|
+
@league = league
|
13
|
+
@year = year
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
|
+
APIS = {
|
18
|
+
worldcup: 'https://github.com/openfootball/worldcup.json/raw/master/$year$/worldcup.json',
|
19
|
+
euro: 'https://github.com/openfootball/euro.json/raw/master/$year$/euro.json'
|
20
|
+
}
|
17
21
|
|
18
22
|
### note:
|
19
|
-
## cache ALL methods - only do one web request for
|
20
|
-
def
|
21
|
-
@
|
23
|
+
## cache ALL methods - only do one web request for match schedule & results
|
24
|
+
def get_matches
|
25
|
+
@data ||= begin
|
26
|
+
str = APIS[ @league.downcase.to_sym ]
|
27
|
+
str = str.gsub( '$year$', @year.to_s )
|
28
|
+
|
29
|
+
get( str ) ## use "memoized" / cached result
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
33
|
|
25
34
|
|
26
35
|
|
27
|
-
|
28
36
|
## for testing lets you use /round/1 etc.
|
29
|
-
def
|
30
|
-
h =
|
37
|
+
def round( num )
|
38
|
+
h = get_matches
|
31
39
|
matches = h[ 'rounds' ][ num-1 ] ## note: rounds hash starts with zero (not 1)
|
32
40
|
matches
|
33
41
|
end
|
34
42
|
|
35
43
|
|
36
|
-
def
|
37
|
-
def
|
38
|
-
def
|
44
|
+
def todays_matches( date: Date.today ) matches_for( date ); end
|
45
|
+
def tomorrows_matches( date: Date.today ) matches_for( date+1 ); end
|
46
|
+
def yesterdays_matches( date: Date.today ) matches_for( date-1 ); end
|
39
47
|
|
40
|
-
def
|
41
|
-
hash =
|
48
|
+
def matches_for( date )
|
49
|
+
hash = get_matches
|
42
50
|
matches = select_matches( hash[ 'rounds' ] ) { |match| date == Date.parse( match['date'] ) }
|
43
51
|
matches
|
44
52
|
end
|
45
53
|
|
46
54
|
|
47
|
-
def
|
55
|
+
def upcoming_matches( date: Date.today )
|
48
56
|
## note: includes todays matches for now
|
49
|
-
hash =
|
57
|
+
hash = get_matches
|
50
58
|
matches = select_matches( hash[ 'rounds' ] ) { |match| date <= Date.parse( match['date'] ) }
|
51
59
|
matches
|
52
60
|
end
|
53
61
|
|
54
|
-
def
|
55
|
-
hash =
|
62
|
+
def past_matches( date: Date.today )
|
63
|
+
hash = get_matches
|
56
64
|
matches = select_matches( hash[ 'rounds' ] ) { |match| date > Date.parse( match['date'] ) }
|
57
65
|
## note reveserve matches (chronological order/last first)
|
58
66
|
matches.reverse
|
@@ -76,17 +84,14 @@ private
|
|
76
84
|
matches
|
77
85
|
end
|
78
86
|
|
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
87
|
|
84
|
-
|
88
|
+
def get( str )
|
89
|
+
response = @worker.get_response( str )
|
85
90
|
|
86
91
|
if response.code == '200'
|
87
92
|
##
|
88
|
-
## todo/check:
|
89
|
-
## do we need to force utf-8 encoding?
|
93
|
+
## fix/fix/todo/check:
|
94
|
+
## do we need to force utf-8 encoding? yes!!!!
|
90
95
|
## check for teams w/ non-ascii names
|
91
96
|
hash = JSON.parse( response.body )
|
92
97
|
## pp hash
|
@@ -98,6 +103,4 @@ private
|
|
98
103
|
end
|
99
104
|
|
100
105
|
end # class Client
|
101
|
-
|
102
|
-
|
103
106
|
end # module Footty
|
data/lib/footty/version.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
|
4
2
|
module Footty
|
5
|
-
VERSION = '
|
3
|
+
VERSION = '2024.5.10'
|
6
4
|
|
7
5
|
def self.banner
|
8
|
-
"footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
6
|
+
"footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
|
9
7
|
end
|
10
8
|
|
11
9
|
def self.root
|
12
|
-
|
10
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
13
11
|
end
|
14
12
|
end
|
13
|
+
|
14
|
+
|
data/lib/footty.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
1
|
## stdlibs
|
5
2
|
|
6
3
|
require 'net/http'
|
@@ -15,8 +12,8 @@ require 'pp'
|
|
15
12
|
require 'logutils'
|
16
13
|
require 'fetcher'
|
17
14
|
|
18
|
-
# our own code
|
19
15
|
|
16
|
+
# our own code
|
20
17
|
require 'footty/version' # let it always go first
|
21
18
|
require 'footty/client'
|
22
19
|
|
@@ -24,7 +21,8 @@ require 'footty/client'
|
|
24
21
|
module Footty
|
25
22
|
|
26
23
|
def self.client
|
27
|
-
|
24
|
+
## note: hard code tournament / league for now
|
25
|
+
@client ||= Client.new( league: 'euro', year: 2024 ) ## use "singelton" / shared client
|
28
26
|
end
|
29
27
|
|
30
28
|
|
@@ -38,43 +36,47 @@ module Footty
|
|
38
36
|
## in the future make today "configurable" as param - why? why not?
|
39
37
|
today = Date.today
|
40
38
|
|
41
|
-
if ['yesterday', 'y', '-1'].include? what
|
42
|
-
matches = client.
|
39
|
+
if ['yesterday', 'y', '-1'].include?( what )
|
40
|
+
matches = client.yesterdays_matches
|
43
41
|
if matches.empty?
|
44
42
|
puts "** No matches played yesterday.\n"
|
45
43
|
end
|
46
|
-
elsif ['tomorrow', 't', '+1', '1'].include? what
|
47
|
-
matches = client.
|
44
|
+
elsif ['tomorrow', 't', '+1', '1'].include?( what )
|
45
|
+
matches = client.tomorrows_matches
|
48
46
|
if matches.empty?
|
49
47
|
puts "** No matches scheduled tomorrow.\n"
|
50
48
|
end
|
51
|
-
elsif ['past', 'p', 'prev'].include? what
|
52
|
-
matches = client.
|
49
|
+
elsif ['past', 'p', 'prev'].include?( what )
|
50
|
+
matches = client.past_matches
|
53
51
|
if matches.empty?
|
54
52
|
puts "** No matches played yet.\n"
|
55
53
|
end
|
56
|
-
elsif ['upcoming', 'up', 'u', 'next', 'n'].include? what
|
57
|
-
matches = client.
|
54
|
+
elsif ['upcoming', 'up', 'u', 'next', 'n'].include?( what )
|
55
|
+
matches = client.upcoming_matches
|
58
56
|
if matches.empty?
|
59
57
|
puts "** No more matches scheduled.\n"
|
60
58
|
end
|
61
59
|
else
|
62
|
-
matches = client.
|
60
|
+
matches = client.todays_matches
|
63
61
|
|
64
62
|
## no matches today
|
65
63
|
if matches.empty?
|
66
64
|
puts "** No matches scheduled today.\n"
|
67
65
|
|
68
|
-
|
66
|
+
## note: was world cup 2018 - end date -- Date.new( 2018, 7, 11 )
|
67
|
+
## note: was euro 2020 (in 2021) - end date -- Date.new( 2021, 7, 11 )
|
68
|
+
if Date.today > Date.new( 2024, 7, 14 ) ## tournament is over, look back
|
69
69
|
puts "Past matches:"
|
70
|
-
matches = client.
|
70
|
+
matches = client.past_matches
|
71
71
|
else ## world cup is upcoming /in-progress,look forward
|
72
72
|
puts "Upcoming matches:"
|
73
|
-
matches = client.
|
73
|
+
matches = client.upcoming_matches
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
|
79
|
+
|
78
80
|
print_matches( matches )
|
79
81
|
end
|
80
82
|
|
@@ -95,25 +97,32 @@ module Footty
|
|
95
97
|
print "%10s" % "(in #{diff}d) "
|
96
98
|
end
|
97
99
|
|
98
|
-
print "%
|
100
|
+
print "%22s" % "#{match['team1']['name']} (#{match['team1']['code']})"
|
99
101
|
|
102
|
+
## todo/fix: add support for knockout scores
|
103
|
+
## with score1et/score1p (extra time and penalty)
|
100
104
|
if match['score1'] && match['score2']
|
101
105
|
print " #{match['score1']}-#{match['score2']} "
|
106
|
+
print "(#{match['score1i']}-#{match['score2i']}) "
|
102
107
|
else
|
103
|
-
print "
|
108
|
+
print " vs "
|
104
109
|
end
|
105
110
|
|
106
|
-
print "
|
111
|
+
print "%-22s" % "#{match['team2']['name']} (#{match['team2']['code']})"
|
107
112
|
|
108
113
|
if match['group']
|
109
|
-
print " #{match['group']} " ## group phase/stage
|
110
|
-
|
111
|
-
|
114
|
+
print " #{match['group']} /" ## group phase/stage
|
115
|
+
end
|
116
|
+
|
117
|
+
print " #{match['round']} " ## knock out (k.o.) phase/stage
|
118
|
+
|
119
|
+
if match['stadium']
|
120
|
+
print " @ #{match['stadium']['name']}, #{match['city']}"
|
112
121
|
end
|
113
122
|
|
114
|
-
print " @ #{match['stadium']['name']}, #{match['city']}"
|
115
123
|
print "\n"
|
116
124
|
|
125
|
+
|
117
126
|
if match['goals1'] && match['goals2']
|
118
127
|
print " ["
|
119
128
|
match['goals1'].each_with_index do |goal,i|
|
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:
|
4
|
+
version: 2024.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -42,42 +42,48 @@ dependencies:
|
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '7'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: hoe
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '4.1'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description: footty - football.db command line client for
|
70
|
-
and more - who is playing today?
|
74
|
+
version: '4.1'
|
75
|
+
description: footty - football.db command line client for european "euro" championship
|
76
|
+
2024 and more - who is playing today?
|
71
77
|
email: opensport@googlegroups.com
|
72
78
|
executables:
|
73
79
|
- footty
|
74
80
|
extensions: []
|
75
81
|
extra_rdoc_files:
|
76
|
-
-
|
82
|
+
- CHANGELOG.md
|
77
83
|
- Manifest.txt
|
78
84
|
- README.md
|
79
85
|
files:
|
80
|
-
-
|
86
|
+
- CHANGELOG.md
|
81
87
|
- Manifest.txt
|
82
88
|
- README.md
|
83
89
|
- Rakefile
|
@@ -85,13 +91,11 @@ files:
|
|
85
91
|
- lib/footty.rb
|
86
92
|
- lib/footty/client.rb
|
87
93
|
- lib/footty/version.rb
|
88
|
-
- test/helper.rb
|
89
|
-
- test/test_client.rb
|
90
94
|
homepage: https://github.com/sportdb/footty
|
91
95
|
licenses:
|
92
96
|
- Public Domain
|
93
97
|
metadata: {}
|
94
|
-
post_install_message:
|
98
|
+
post_install_message:
|
95
99
|
rdoc_options:
|
96
100
|
- "--main"
|
97
101
|
- README.md
|
@@ -108,10 +112,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
112
|
- !ruby/object:Gem::Version
|
109
113
|
version: '0'
|
110
114
|
requirements: []
|
111
|
-
|
112
|
-
|
113
|
-
signing_key:
|
115
|
+
rubygems_version: 3.4.10
|
116
|
+
signing_key:
|
114
117
|
specification_version: 4
|
115
|
-
summary: footty - football.db command line client for
|
116
|
-
more - who is playing today?
|
118
|
+
summary: footty - football.db command line client for european "euro" championship
|
119
|
+
2024 and more - who is playing today?
|
117
120
|
test_files: []
|
data/test/helper.rb
DELETED
data/test/test_client.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
|
6
|
-
|
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
|
73
|
-
pp ary
|
74
|
-
|
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']
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
def test_world_2018_round_2
|
109
|
-
h = @client.get_round( 2 )
|
110
|
-
|
111
|
-
## pp h
|
112
|
-
=begin
|
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"}]}
|
154
|
-
=end
|
155
|
-
|
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']
|
160
|
-
end
|
161
|
-
|
162
|
-
|
163
|
-
end # class TestClient
|