fbcat 0.1.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 +7 -0
- data/CHANGELOG.md +4 -0
- data/Manifest.txt +7 -0
- data/README.md +29 -0
- data/Rakefile +31 -0
- data/bin/fbleagues +113 -0
- data/lib/fbcat/models.rb +125 -0
- data/lib/fbcat.rb +27 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c857b634ea7b16e1abf478500046f9de3aaf66cdad33dece015266b32de3429
|
4
|
+
data.tar.gz: b7f9e0fe6f1a7cc3f56a0db32690667da6f35b8e0ea244ba075ac27d0817d17e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 702df917a4976aed11ef05fc583aa9624a1fb7298a097911ba2b28cec0878aee2aa67b4f875211751342c14d414f38b8382f792ecea9d7c298e3fd8637dc7c28
|
7
|
+
data.tar.gz: af475c0cb5e9841b9b7bc79cfdab72fbb0353cf606c0cd69a8731ae6195449a78bd86f719ba168e335999eb3faf7d9e98c020d6171eabeb03e251ab0e79e3948
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# fbcat - command-line tools for built-in football catalog (reference) dbs incl. leagues, clubs, & more"
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
* home :: [github.com/sportdb/footty](https://github.com/sportdb/footty)
|
6
|
+
* bugs :: [github.com/sportdb/footty/issues](https://github.com/sportdb/footty/issues)
|
7
|
+
* gem :: [rubygems.org/gems/fbcat](https://rubygems.org/gems/fbcat)
|
8
|
+
* rdoc :: [rubydoc.info/gems/fbcat](http://rubydoc.info/gems/fbcat)
|
9
|
+
|
10
|
+
|
11
|
+
## Step 0 - Installation Via Gems
|
12
|
+
|
13
|
+
To install the command-line tool via gems (ruby's package manager) use:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ gem install fbcat
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
...
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
## Questions? Comments?
|
27
|
+
|
28
|
+
Yes, you can. More than welcome.
|
29
|
+
See [Help & Support »](https://github.com/openfootball/help)
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
|
3
|
+
|
4
|
+
Hoe.spec 'fbcat' do
|
5
|
+
self.version = '0.1.0'
|
6
|
+
|
7
|
+
self.summary = "fbcat - command-line tools for built-in football catalog (reference) dbs incl. leagues, clubs, & more"
|
8
|
+
self.description = summary
|
9
|
+
|
10
|
+
self.urls = { home: 'https://github.com/sportdb/footty' }
|
11
|
+
|
12
|
+
self.author = 'Gerald Bauer'
|
13
|
+
self.email = 'gerald.bauer@gmail.com'
|
14
|
+
|
15
|
+
# switch extension to .markdown for gihub formatting
|
16
|
+
self.readme_file = 'README.md'
|
17
|
+
self.history_file = 'CHANGELOG.md'
|
18
|
+
|
19
|
+
self.licenses = ['Public Domain']
|
20
|
+
|
21
|
+
self.extra_deps = [
|
22
|
+
['activerecord'],
|
23
|
+
['sqlite3'],
|
24
|
+
['cocos'],
|
25
|
+
['footballdb-data'],
|
26
|
+
]
|
27
|
+
|
28
|
+
self.spec_extras = {
|
29
|
+
required_ruby_version: '>= 3.1.0'
|
30
|
+
}
|
31
|
+
end
|
data/bin/fbleagues
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
## tip: to test run:
|
4
|
+
## ruby -I ./lib bin/fbleagues
|
5
|
+
|
6
|
+
|
7
|
+
## our own code
|
8
|
+
require 'fbcat'
|
9
|
+
|
10
|
+
|
11
|
+
## default to built-in for now
|
12
|
+
path = "#{FootballDb::Data.data_dir}/catalog.db"
|
13
|
+
### './catalog.db',
|
14
|
+
|
15
|
+
config = {
|
16
|
+
adapter: 'sqlite3',
|
17
|
+
database: path
|
18
|
+
}
|
19
|
+
pp config
|
20
|
+
|
21
|
+
|
22
|
+
args = ARGV
|
23
|
+
|
24
|
+
|
25
|
+
ActiveRecord::Base.establish_connection( config )
|
26
|
+
|
27
|
+
|
28
|
+
puts " #{Country.count} countries"
|
29
|
+
puts " #{CountryName.count} country names"
|
30
|
+
puts " #{Club.count} clubs"
|
31
|
+
puts " #{ClubName.count} club names"
|
32
|
+
puts " #{NationalTeam.count} national teams"
|
33
|
+
puts " #{NationalTeamName.count} national team names"
|
34
|
+
puts " #{League.count} leagues"
|
35
|
+
puts " #{LeagueName.count} league names"
|
36
|
+
puts " #{LeaguePeriod.count} league periods"
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def print_league( league )
|
41
|
+
periods = league.league_periods
|
42
|
+
|
43
|
+
if league.intl?
|
44
|
+
if league.clubs?
|
45
|
+
print "INTL CLUBS"
|
46
|
+
else
|
47
|
+
print "INTL NATIONAL TEAMS"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
print "#{league.country.key}, #{league.country.name} (#{league.country.code})" if league.country
|
52
|
+
print " - "
|
53
|
+
|
54
|
+
print "#{league.name} "
|
55
|
+
print "(#{periods.size}) " if periods.size > 1
|
56
|
+
|
57
|
+
print "\n"
|
58
|
+
periods.each do |period|
|
59
|
+
print " - #{period.tier_key}, "
|
60
|
+
print "#{period.start_season}" if period.start_season
|
61
|
+
print "-"
|
62
|
+
print "#{period.end_season} " if period.end_season
|
63
|
+
print " "
|
64
|
+
if period.name == league.name
|
65
|
+
print '"'
|
66
|
+
else
|
67
|
+
print "#{period.name}"
|
68
|
+
end
|
69
|
+
print " / #{period.qname}" if period.name != period.qname
|
70
|
+
print ", #{period.slug}"
|
71
|
+
print "\n"
|
72
|
+
## pp period
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def print_leagues( leagues )
|
77
|
+
leagues.each do |league|
|
78
|
+
print_league( league )
|
79
|
+
end
|
80
|
+
puts " #{leagues.size} record(s)"
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
if args.size > 0
|
85
|
+
args.each do |arg|
|
86
|
+
## assume arg is country key
|
87
|
+
country = arg
|
88
|
+
puts
|
89
|
+
puts "==> #{country}"
|
90
|
+
leagues = League.where( "country_key = '#{country}'" )
|
91
|
+
print_leagues( leagues )
|
92
|
+
end
|
93
|
+
else
|
94
|
+
puts
|
95
|
+
puts "==> INTL NATIONAL TEAMS"
|
96
|
+
leagues = League.where( 'intl = true AND clubs = false')
|
97
|
+
print_leagues( leagues )
|
98
|
+
|
99
|
+
|
100
|
+
puts
|
101
|
+
puts "==> INTL CLUBS"
|
102
|
+
leagues = League.where( 'intl = true AND clubs = true')
|
103
|
+
print_leagues( leagues)
|
104
|
+
|
105
|
+
puts
|
106
|
+
puts "==> NATIONAL LEAGUES & CUPS"
|
107
|
+
leagues = League.where( 'intl = false AND clubs = true')
|
108
|
+
print_leagues( leagues)
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
puts "bye"
|
113
|
+
|
data/lib/fbcat/models.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
module CatalogDb
|
2
|
+
module Model
|
3
|
+
|
4
|
+
##
|
5
|
+
# setup for multiple database connection support
|
6
|
+
class CatalogRecord < ActiveRecord::Base # ApplicationRecord
|
7
|
+
self.abstract_class = true
|
8
|
+
end
|
9
|
+
|
10
|
+
class Country < CatalogRecord
|
11
|
+
has_many :country_codes, foreign_key: 'key', primary_key: 'key'
|
12
|
+
has_many :country_names, foreign_key: 'key', primary_key: 'key'
|
13
|
+
|
14
|
+
has_many :clubs, foreign_key: 'country_key', primary_key: 'key'
|
15
|
+
has_many :leagues, foreign_key: 'country_key', primary_key: 'key'
|
16
|
+
has_many :grounds, foreign_key: 'country_key', primary_key: 'key'
|
17
|
+
|
18
|
+
has_many :cities, foreign_key: 'country_key', primary_key: 'key'
|
19
|
+
end # class Country
|
20
|
+
|
21
|
+
class CountryCode < CatalogRecord
|
22
|
+
belongs_to :country, foreign_key: 'key', primary_key: 'key'
|
23
|
+
end # class CountryCode
|
24
|
+
|
25
|
+
class CountryName < CatalogRecord
|
26
|
+
belongs_to :country, foreign_key: 'key', primary_key: 'key'
|
27
|
+
end # class CountryName
|
28
|
+
|
29
|
+
|
30
|
+
class City < CatalogRecord
|
31
|
+
has_many :city_names, foreign_key: 'key', primary_key: 'key'
|
32
|
+
|
33
|
+
has_many :grounds, foreign_key: 'city_key', primary_key: 'key'
|
34
|
+
## add has_many :clubs
|
35
|
+
## has_many :ground
|
36
|
+
end # class City
|
37
|
+
|
38
|
+
class CityName < CatalogRecord
|
39
|
+
belongs_to :city, foreign_key: 'key', primary_key: 'key'
|
40
|
+
end # class CityName
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
class Club < CatalogRecord
|
46
|
+
belongs_to :country, foreign_key: 'country_key', primary_key: 'key'
|
47
|
+
|
48
|
+
has_many :club_names, foreign_key: 'key', primary_key: 'key'
|
49
|
+
end
|
50
|
+
|
51
|
+
class ClubName < CatalogRecord
|
52
|
+
belongs_to :club, foreign_key: 'key', primary_key: 'key'
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
class NationalTeam < CatalogRecord
|
57
|
+
belongs_to :country, foreign_key: 'country_key', primary_key: 'key'
|
58
|
+
|
59
|
+
has_many :national_team_names, foreign_key: 'key', primary_key: 'key'
|
60
|
+
end
|
61
|
+
|
62
|
+
class NationalTeamName < CatalogRecord
|
63
|
+
belongs_to :club, foreign_key: 'key', primary_key: 'key'
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
class League < CatalogRecord
|
69
|
+
belongs_to :country, foreign_key: 'country_key', primary_key: 'key'
|
70
|
+
|
71
|
+
has_many :league_periods, foreign_key: 'key', primary_key: 'key'
|
72
|
+
has_many :league_names, foreign_key: 'key', primary_key: 'key'
|
73
|
+
has_many :league_codes, foreign_key: 'key', primary_key: 'key'
|
74
|
+
|
75
|
+
has_many :event_infos, foreign_key: 'league_key', primary_key: 'key'
|
76
|
+
end
|
77
|
+
|
78
|
+
class LeagueName < CatalogRecord
|
79
|
+
belongs_to :league, foreign_key: 'key', primary_key: 'key'
|
80
|
+
end
|
81
|
+
|
82
|
+
class LeagueCode < CatalogRecord
|
83
|
+
belongs_to :league, foreign_key: 'key', primary_key: 'key'
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
## change/rename to LeagueHistory - why? why not?
|
88
|
+
class LeaguePeriod < CatalogRecord
|
89
|
+
belongs_to :league, foreign_key: 'key', primary_key: 'key'
|
90
|
+
|
91
|
+
has_many :league_period_names
|
92
|
+
has_many :league_period_codes
|
93
|
+
end
|
94
|
+
|
95
|
+
class LeaguePeriodName < CatalogRecord
|
96
|
+
belongs_to :league_period
|
97
|
+
end
|
98
|
+
|
99
|
+
class LeaguePeriodCode < CatalogRecord
|
100
|
+
belongs_to :league_period
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
class Ground < CatalogRecord
|
108
|
+
belongs_to :country, foreign_key: 'country_key', primary_key: 'key'
|
109
|
+
belongs_to :city, foreign_key: 'city_key', primary_key: 'key'
|
110
|
+
|
111
|
+
has_many :ground_names, foreign_key: 'key', primary_key: 'key'
|
112
|
+
end
|
113
|
+
|
114
|
+
class GroundName < CatalogRecord
|
115
|
+
belongs_to :ground, foreign_key: 'key', primary_key: 'key'
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
class EventInfo < CatalogRecord
|
120
|
+
belongs_to :league, foreign_key: 'league_key', primary_key: 'key'
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end # module Model
|
125
|
+
end # module CatalogDb
|
data/lib/fbcat.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
require 'active_record' ## todo: add sqlite3? etc.
|
3
|
+
require 'sqlite3'
|
4
|
+
require 'cocos'
|
5
|
+
|
6
|
+
|
7
|
+
## pull-in footballdata
|
8
|
+
require 'footballdb-data'
|
9
|
+
|
10
|
+
|
11
|
+
## our own code
|
12
|
+
## note - a copy of 'lib/sportdb/indexers/models' !!!!!
|
13
|
+
require_relative 'fbcat/models'
|
14
|
+
|
15
|
+
|
16
|
+
Country = CatalogDb::Model::Country
|
17
|
+
CountryName = CatalogDb::Model::CountryName
|
18
|
+
Club = CatalogDb::Model::Club
|
19
|
+
ClubName = CatalogDb::Model::ClubName
|
20
|
+
NationalTeam = CatalogDb::Model::NationalTeam
|
21
|
+
NationalTeamName = CatalogDb::Model::NationalTeamName
|
22
|
+
League = CatalogDb::Model::League
|
23
|
+
LeagueName = CatalogDb::Model::LeagueName
|
24
|
+
LeaguePeriod = CatalogDb::Model::LeaguePeriod
|
25
|
+
|
26
|
+
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fbcat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
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: sqlite3
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cocos
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: footballdb-data
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '7'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '4.0'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '7'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: hoe
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '4.2'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.2'
|
103
|
+
description: fbcat - command-line tools for built-in football catalog (reference)
|
104
|
+
dbs incl. leagues, clubs, & more
|
105
|
+
email: gerald.bauer@gmail.com
|
106
|
+
executables:
|
107
|
+
- fbleagues
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files:
|
110
|
+
- CHANGELOG.md
|
111
|
+
- Manifest.txt
|
112
|
+
- README.md
|
113
|
+
files:
|
114
|
+
- CHANGELOG.md
|
115
|
+
- Manifest.txt
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/fbleagues
|
119
|
+
- lib/fbcat.rb
|
120
|
+
- lib/fbcat/models.rb
|
121
|
+
homepage: https://github.com/sportdb/footty
|
122
|
+
licenses:
|
123
|
+
- Public Domain
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options:
|
127
|
+
- "--main"
|
128
|
+
- README.md
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 3.1.0
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubygems_version: 3.5.22
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: fbcat - command-line tools for built-in football catalog (reference) dbs
|
146
|
+
incl. leagues, clubs, & more
|
147
|
+
test_files: []
|