fbtxt-pp 0.0.2

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.
@@ -0,0 +1,136 @@
1
+
2
+
3
+
4
+ module Fbpp ## or use (alternate) Fbtxtpp - why? why not?
5
+
6
+ def self.main( args=ARGV )
7
+
8
+
9
+
10
+ opts = {
11
+ full: false, ## incl. line-ups, penalties, referees, etc.
12
+ min: false, ## (minimal) no dates, no venues, no goals, no half-time score, etc.
13
+
14
+ season: nil,
15
+ ## use/rename to cache_dir - why? why not?
16
+ convert_dir: '/sports/cache.api.fifa',
17
+ }
18
+
19
+
20
+
21
+ parser = OptionParser.new do |parser|
22
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options] NAME"
23
+
24
+ parser.on( "--full",
25
+ "turn on full mode incl. line-up, pens, & more (default: #{opts[:full]})" ) do |full|
26
+ opts[:full] = true
27
+ end
28
+
29
+ parser.on( "--min", "--minimal",
30
+ "turn on min(imal) mode (default: #{opts[:min]})" ) do |min|
31
+ opts[:min] = true
32
+ end
33
+
34
+ parser.on( "--season=SEASON",
35
+ "season (default: #{opts[:season]||'none'})" ) do |season|
36
+ opts[:season] = season
37
+ end
38
+ end
39
+ parser.parse!( args )
40
+
41
+
42
+ puts "OPTS:"
43
+ pp opts
44
+ puts "ARGV:"
45
+ pp args
46
+
47
+ if args.size == 0
48
+ puts " NAME argument required; use:"
49
+ pp CONFIGS.keys
50
+ exit 1
51
+ end
52
+
53
+
54
+ ##
55
+ ## note - all args other than first ignored for now; issue warn - why? why not?
56
+
57
+ key = args[0].downcase.to_sym
58
+ config = CONFIGS[ key ]
59
+ puts "CONFIG:"
60
+ pp config
61
+
62
+ if config.nil?
63
+ ## auto-fill with defaults!!
64
+ config = { slug: key,
65
+ name: "#{key}",
66
+ seasons: [],
67
+ opts: { country: false,
68
+ stadium: false,
69
+ city: false,
70
+ timezone: false,
71
+ },
72
+ opts_full: { country: false,
73
+ },
74
+
75
+ }
76
+ end
77
+
78
+
79
+ slug = config[:slug] ## change to source - why? why not?
80
+ seasons = opts[:season] ? [opts[:season]] : config[:seasons]
81
+
82
+
83
+ ## outdir = "../../openfootball/clubworldcup"
84
+ ## outdir = "."
85
+
86
+ outdir = "./tmp"
87
+
88
+
89
+ seasons.each do |season|
90
+ season = Season(season)
91
+
92
+ name = config[:name].is_a?(Proc) ? config[:name].call( season )
93
+ : config[:name]
94
+
95
+
96
+ page = String.new
97
+ page << "= #{name} #{season}\n"
98
+ page << "\n"
99
+
100
+ buf = if opts[:full]
101
+ pp_matches_full( slug: slug, season: season,
102
+ indir: opts[:convert_dir],
103
+ opts: FormatOpts.build_full( **config[:opts_full] ))
104
+ elsif opts[:min]
105
+ pp_matches_min( slug: slug, season: season,
106
+ indir: opts[:convert_dir],
107
+ opts: FormatOpts.build_min( **config[:opts] ))
108
+ else
109
+ pp_matches( slug: slug, season: season,
110
+ indir: opts[:convert_dir],
111
+ opts: FormatOpts.build(**config[:opts] ))
112
+ end
113
+
114
+ page << buf
115
+
116
+ puts page
117
+
118
+ outpath = if opts[:full]
119
+ "#{outdir}/more/#{season.to_path}_#{slug}-full.txt"
120
+ elsif opts[:min]
121
+ "#{outdir}/min/#{season.to_path}_#{slug}.txt"
122
+ else
123
+ "#{outdir}/more/#{season.to_path}_#{slug}.txt"
124
+ end
125
+
126
+ write_text( outpath, page )
127
+ ## puts " opts:"
128
+ ## pp opts
129
+ puts " written to >#{outpath}<"
130
+ end
131
+
132
+
133
+ puts "bye"
134
+ end
135
+
136
+ end # module Fbpp
@@ -0,0 +1,24 @@
1
+
2
+ module Fbtxt
3
+ module Module
4
+ module Fbpp
5
+ MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
+ MINOR = 0
7
+ PATCH = 2
8
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
9
+
10
+ def self.version
11
+ VERSION
12
+ end
13
+
14
+ def self.banner
15
+ "fbtxt-pp/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
16
+ end
17
+
18
+ def self.root
19
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
20
+ end
21
+
22
+ end # module Fbpp
23
+ end # module Module
24
+ end # module Fbtxt
data/lib/fbtxt-pp.rb ADDED
@@ -0,0 +1,69 @@
1
+ require 'cocos'
2
+ require 'season-formats'
3
+
4
+
5
+
6
+
7
+ require_relative 'fbtxt-pp/version'
8
+ require_relative 'fbtxt-pp/helper'
9
+
10
+
11
+ def norm_name( str )
12
+ ## todo/fix - add/report to console if space collaped or dash trimmed etc.
13
+ ## collapse spaces into one
14
+ ## e.g.
15
+ str = str.gsub( /[ ]+/, ' ' )
16
+ ## remove leading & trailing space around dash (-)
17
+ ## e.g. Callum HUDSON - ODOI => Callum HUDSON-ODOI
18
+ str = str.gsub( / - /, '-' )
19
+ str
20
+ end
21
+
22
+
23
+ def slugify( str )
24
+ str.downcase.gsub( /[^a-z0-9]/, '' )
25
+ end
26
+
27
+
28
+ ## models
29
+ require_relative 'fbtxt-pp/models/document' ## note - document is container for LeagueSeason holding teams, matches, etc.
30
+ require_relative 'fbtxt-pp/models/match'
31
+ require_relative 'fbtxt-pp/models/score'
32
+ require_relative 'fbtxt-pp/models/goals'
33
+ require_relative 'fbtxt-pp/models/penalties'
34
+ require_relative 'fbtxt-pp/models/teams'
35
+ require_relative 'fbtxt-pp/models/players'
36
+ require_relative 'fbtxt-pp/models/officials'
37
+ require_relative 'fbtxt-pp/models/stadiums'
38
+
39
+
40
+
41
+ ## pretty print
42
+ require_relative 'fbtxt-pp/pp/ppopts' ## use ppformat_opts or such - why? why not?
43
+ require_relative 'fbtxt-pp/pp/ppgoals'
44
+ require_relative 'fbtxt-pp/pp/ppstats'
45
+ require_relative 'fbtxt-pp/pp/ppmatch'
46
+ require_relative 'fbtxt-pp/pp/ppmatch_full'
47
+ require_relative 'fbtxt-pp/pp/ppmatch_min'
48
+ require_relative 'fbtxt-pp/pp/pppenalties'
49
+ require_relative 'fbtxt-pp/pp/pplineup'
50
+ require_relative 'fbtxt-pp/pp/ppbookings'
51
+ require_relative 'fbtxt-pp/pp/ppsquads'
52
+
53
+
54
+ require_relative 'fbtxt-pp/config'
55
+ require_relative 'fbtxt-pp/config_worldcup'
56
+ require_relative 'fbtxt-pp/config_more'
57
+
58
+
59
+ require_relative 'fbtxt-pp/tool-fbpp'
60
+
61
+
62
+ ## note - fbhub requires fbup gem for now
63
+ ## must include "manually"
64
+ require_relative 'fbtxt-pp/tool-fbhub'
65
+
66
+
67
+ ##
68
+ ## say hello
69
+ puts Fbtxt::Module::Fbpp.banner
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fbtxt-pp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocos
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: season-formats
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: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '7'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '4.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '7'
61
+ - !ruby/object:Gem::Dependency
62
+ name: hoe
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '4.2'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '4.2'
75
+ description: fbtxt-pp - pretty print (pp) football match fixtures & results in the
76
+ football.txt format
77
+ email: gerald.bauer@gmail.com
78
+ executables:
79
+ - fbhub
80
+ - fbpp
81
+ extensions: []
82
+ extra_rdoc_files:
83
+ - CHANGELOG.md
84
+ - Manifest.txt
85
+ - README.md
86
+ files:
87
+ - CHANGELOG.md
88
+ - Manifest.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/fbhub
92
+ - bin/fbpp
93
+ - lib/fbtxt-pp.rb
94
+ - lib/fbtxt-pp/config.rb
95
+ - lib/fbtxt-pp/config_clubs.csv
96
+ - lib/fbtxt-pp/config_more.rb
97
+ - lib/fbtxt-pp/config_worldcup.rb
98
+ - lib/fbtxt-pp/helper.rb
99
+ - lib/fbtxt-pp/models/document.rb
100
+ - lib/fbtxt-pp/models/goals.rb
101
+ - lib/fbtxt-pp/models/match.rb
102
+ - lib/fbtxt-pp/models/officials.rb
103
+ - lib/fbtxt-pp/models/penalties.rb
104
+ - lib/fbtxt-pp/models/players.rb
105
+ - lib/fbtxt-pp/models/score.rb
106
+ - lib/fbtxt-pp/models/stadiums.rb
107
+ - lib/fbtxt-pp/models/teams.rb
108
+ - lib/fbtxt-pp/pp/ppbookings.rb
109
+ - lib/fbtxt-pp/pp/ppgoals.rb
110
+ - lib/fbtxt-pp/pp/pplineup.rb
111
+ - lib/fbtxt-pp/pp/ppmatch.rb
112
+ - lib/fbtxt-pp/pp/ppmatch_full.rb
113
+ - lib/fbtxt-pp/pp/ppmatch_min.rb
114
+ - lib/fbtxt-pp/pp/ppopts.rb
115
+ - lib/fbtxt-pp/pp/pppenalties.rb
116
+ - lib/fbtxt-pp/pp/ppsquads.rb
117
+ - lib/fbtxt-pp/pp/ppstats.rb
118
+ - lib/fbtxt-pp/tool-fbhub.rb
119
+ - lib/fbtxt-pp/tool-fbpp.rb
120
+ - lib/fbtxt-pp/version.rb
121
+ homepage: https://github.com/sportdb/sport.db
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: fbtxt-pp - pretty print (pp) football match fixtures & results in the football.txt
146
+ format
147
+ test_files: []