footty 0.0.1 → 0.2.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 -4
- data/Manifest.txt +4 -0
- data/README.md +43 -39
- data/Rakefile +30 -29
- data/bin/footty +5 -0
- data/lib/footty/client.rb +74 -0
- data/lib/footty/version.rb +2 -22
- data/lib/footty.rb +48 -4
- data/test/helper.rb +12 -0
- data/test/test_client.rb +51 -0
- metadata +44 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4384a2834474830dc629a0549d6de29a32cb5daa
|
4
|
+
data.tar.gz: fe65f1ab2b2772e7b39fad7ac7954473ba82e48e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6760c4248f92e86b911402afb4594df202f292f351548972d88e1b5e757e4625b0b14dbb639c23c044e88cccadf87ad4dddf8d5190c938bdd54ee25076c48ef
|
7
|
+
data.tar.gz: 4b87ff15d20cf9c1a56d0b65489bd403b175940ed2ba40ab5e68bddfc99cef9f4883ab56f6f6288f860694c61b5e7a661c29c9275b502527e8573c57931bd11a
|
data/HISTORY.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
### 0.0
|
2
|
-
|
3
|
-
* Everything is new. First release
|
4
|
-
|
1
|
+
### 1.0.0 / 2018-06-09
|
2
|
+
|
3
|
+
* Everything is new (again). First release.
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,43 @@
|
|
1
|
-
# footty - football.db command line
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*
|
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
|
-
|
1
|
+
# footty - sport.db (incl. 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
|
+
## Usage - Who's playing today?
|
13
|
+
|
14
|
+
The footty gem lets you query online sport.db (incl. football.db) HTTP JSON API services
|
15
|
+
for upcoming matches. For example,
|
16
|
+
|
17
|
+
$ footty # Defaults to today's world cup 2018 matches
|
18
|
+
|
19
|
+
prints on Jun/14 2018:
|
20
|
+
|
21
|
+
Russia (RUS) vs Saudi Arabia (KSA) @ Luzhniki Stadium, Moscow
|
22
|
+
|
23
|
+
That's it.
|
24
|
+
|
25
|
+
|
26
|
+
## Install
|
27
|
+
|
28
|
+
Just install the gem:
|
29
|
+
|
30
|
+
$ gem install footty
|
31
|
+
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The `footty` scripts are dedicated to the public domain.
|
36
|
+
Use it as you please with no restrictions whatsoever.
|
37
|
+
|
38
|
+
|
39
|
+
## Questions? Comments?
|
40
|
+
|
41
|
+
Send them along to the
|
42
|
+
[Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
|
43
|
+
Thanks!
|
data/Rakefile
CHANGED
@@ -1,29 +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 =
|
9
|
-
self.description = summary
|
10
|
-
|
11
|
-
self.urls
|
12
|
-
|
13
|
-
self.author
|
14
|
-
self.email
|
15
|
-
|
16
|
-
# switch extension to .markdown for gihub formatting
|
17
|
-
self.readme_file
|
18
|
-
self.history_file = 'HISTORY.md'
|
19
|
-
|
20
|
-
self.extra_deps = [
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
self.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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 - sport.db (incl. 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
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Footty
|
4
|
+
|
5
|
+
class Client
|
6
|
+
|
7
|
+
include LogUtils::Logging
|
8
|
+
|
9
|
+
API_BASE = 'http://footballdb.herokuapp.com/api/v1'
|
10
|
+
|
11
|
+
def initialize( opts={} )
|
12
|
+
@opts = opts
|
13
|
+
@worker = Fetcher::Worker.new
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def get_todays_round
|
18
|
+
event_key = 'world.2014'
|
19
|
+
get( "event/#{event_key}/round/today" )
|
20
|
+
end
|
21
|
+
|
22
|
+
## for testing lets you use /round/1 etc.
|
23
|
+
def get_round( num )
|
24
|
+
event_key = 'world.2014'
|
25
|
+
get( "event/#{event_key}/round/#{num}" )
|
26
|
+
end
|
27
|
+
|
28
|
+
### todo/fix:
|
29
|
+
## add a new services for todays games only (not todays round w/ all games)
|
30
|
+
def get_todays_games
|
31
|
+
round_hash = get_todays_round()
|
32
|
+
games = select_todays_games( round_hash[ 'games' ] )
|
33
|
+
games
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def select_todays_games( all_games )
|
38
|
+
games = []
|
39
|
+
all_games.each do |game|
|
40
|
+
play_at = Date.parse( game['play_at'] )
|
41
|
+
if play_at == Date.today
|
42
|
+
games << game
|
43
|
+
else
|
44
|
+
## puts " skipping game play_at #{play_at}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
games
|
48
|
+
end
|
49
|
+
|
50
|
+
def get( path )
|
51
|
+
## uri = URI.parse( "#{API_BASE}/#{path}" )
|
52
|
+
# fix: use is_a? URI in fetcher
|
53
|
+
uri_string = "#{API_BASE}/#{path}"
|
54
|
+
|
55
|
+
response = @worker.get_response( uri_string )
|
56
|
+
|
57
|
+
if response.code == '200'
|
58
|
+
##
|
59
|
+
## todo/check:
|
60
|
+
## do we need to force utf-8 encoding?
|
61
|
+
## check for teams w/ non-ascii names
|
62
|
+
hash = JSON.parse( response.body )
|
63
|
+
## pp hash
|
64
|
+
hash
|
65
|
+
else
|
66
|
+
logger.error "fetch HTTP - #{response.code} #{response.message}"
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end # class Client
|
72
|
+
|
73
|
+
|
74
|
+
end # module Footty
|
data/lib/footty/version.rb
CHANGED
@@ -1,24 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
|
4
2
|
module Footty
|
5
|
-
|
6
|
-
|
7
|
-
MINOR = 0
|
8
|
-
PATCH = 1
|
9
|
-
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
10
|
-
|
11
|
-
def self.version
|
12
|
-
VERSION
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.banner
|
16
|
-
"footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.root
|
20
|
-
"#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
|
21
|
-
end
|
22
|
-
|
23
|
-
end # module Footty
|
24
|
-
|
3
|
+
VERSION = '0.2.0'
|
4
|
+
end
|
data/lib/footty.rb
CHANGED
@@ -1,11 +1,55 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
|
4
|
-
##
|
5
|
-
require 'footty/version' # note: let version always go first
|
4
|
+
## stdlibs
|
6
5
|
|
6
|
+
require 'net/http'
|
7
|
+
require 'uri'
|
8
|
+
require 'json'
|
9
|
+
require 'pp'
|
7
10
|
|
8
11
|
|
12
|
+
## 3rd party gems/libs
|
13
|
+
## require 'props'
|
9
14
|
|
10
|
-
|
11
|
-
|
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.banner
|
27
|
+
"footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.root
|
31
|
+
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.main
|
35
|
+
puts banner # say hello
|
36
|
+
|
37
|
+
client = Client.new
|
38
|
+
games = client.get_todays_games()
|
39
|
+
## pp games
|
40
|
+
|
41
|
+
## print games
|
42
|
+
games.each do |game|
|
43
|
+
print " "
|
44
|
+
print "#{game['team1_title']} (#{game['team1_code']})"
|
45
|
+
print " vs "
|
46
|
+
print "#{game['team2_title']} (#{game['team2_code']})"
|
47
|
+
print "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end # module Footty
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
Footty.main if __FILE__ == $0
|
data/test/helper.rb
ADDED
data/test/test_client.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
require 'helper'
|
5
|
+
|
6
|
+
class TestClient < MiniTest::Unit::TestCase
|
7
|
+
|
8
|
+
def test_todays_games
|
9
|
+
client = Footty::Client.new
|
10
|
+
ary = client.get_todays_games()
|
11
|
+
## note: returns empty array if no games scheduled/playing today
|
12
|
+
pp ary
|
13
|
+
|
14
|
+
assert_equal Array, ary.class ## for now just check return type (e.g. assume Array for parsed JSON data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_world_2014_round_1
|
18
|
+
client = Footty::Client.new
|
19
|
+
h = client.get_round( 1 )
|
20
|
+
|
21
|
+
## pp h
|
22
|
+
=begin
|
23
|
+
{"event"=>{"key"=>"world.2014", "title"=>"World Cup 2014"},
|
24
|
+
"round"=>
|
25
|
+
{"pos"=>1,
|
26
|
+
"title"=>"Matchday 1",
|
27
|
+
"start_at"=>"2014/06/12",
|
28
|
+
"end_at"=>"2014/06/12"},
|
29
|
+
"games"=>
|
30
|
+
[{"team1_key"=>"bra",
|
31
|
+
"team1_title"=>"Brazil",
|
32
|
+
"team1_code"=>"BRA",
|
33
|
+
"team2_key"=>"cro",
|
34
|
+
"team2_title"=>"Croatia",
|
35
|
+
"team2_code"=>"CRO",
|
36
|
+
"play_at"=>"2014/06/12",
|
37
|
+
"score1"=>3,
|
38
|
+
"score2"=>1,
|
39
|
+
"score1ot"=>nil,
|
40
|
+
"score2ot"=>nil,
|
41
|
+
"score1p"=>nil,
|
42
|
+
"score2p"=>nil}]}
|
43
|
+
=end
|
44
|
+
|
45
|
+
assert_equal 'bra', h['games'][0]['team1_key']
|
46
|
+
assert_equal 'cro', h['games'][0]['team2_key']
|
47
|
+
assert_equal 3, h['games'][0]['score1']
|
48
|
+
assert_equal 1, h['games'][0]['score2']
|
49
|
+
end
|
50
|
+
|
51
|
+
end # class TestClient
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logutils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fetcher
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rdoc
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,18 +58,19 @@ dependencies:
|
|
30
58
|
requirements:
|
31
59
|
- - "~>"
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
61
|
+
version: '3.16'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
41
|
-
description: footty - football.db command line
|
42
|
-
|
68
|
+
version: '3.16'
|
69
|
+
description: footty - sport.db (incl. football.db) command line client for world cup
|
70
|
+
(russia 2018) and more - who is playing today?
|
43
71
|
email: opensport@googlegroups.com
|
44
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- footty
|
45
74
|
extensions: []
|
46
75
|
extra_rdoc_files:
|
47
76
|
- HISTORY.md
|
@@ -52,8 +81,12 @@ files:
|
|
52
81
|
- Manifest.txt
|
53
82
|
- README.md
|
54
83
|
- Rakefile
|
84
|
+
- bin/footty
|
55
85
|
- lib/footty.rb
|
86
|
+
- lib/footty/client.rb
|
56
87
|
- lib/footty/version.rb
|
88
|
+
- test/helper.rb
|
89
|
+
- test/test_client.rb
|
57
90
|
homepage: https://github.com/sportdb/footty
|
58
91
|
licenses:
|
59
92
|
- Public Domain
|
@@ -68,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
101
|
requirements:
|
69
102
|
- - ">="
|
70
103
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
104
|
+
version: '2.3'
|
72
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
106
|
requirements:
|
74
107
|
- - ">="
|
@@ -76,9 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
109
|
version: '0'
|
77
110
|
requirements: []
|
78
111
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.2
|
112
|
+
rubygems_version: 2.5.2
|
80
113
|
signing_key:
|
81
114
|
specification_version: 4
|
82
|
-
summary: footty - football.db command line
|
83
|
-
|
115
|
+
summary: footty - sport.db (incl. football.db) command line client for world cup (russia
|
116
|
+
2018) and more - who is playing today?
|
84
117
|
test_files: []
|