fbtxt2json 0.0.1

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.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Manifest.txt +5 -0
  4. data/README.md +120 -0
  5. data/Rakefile +29 -0
  6. data/bin/fbtxt2json +94 -0
  7. metadata +101 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8956db527655b3b148c5e0ee4d456cbb26ce6444d382ae65c9a651c6e3c29a1b
4
+ data.tar.gz: 695ffa9fff51b0f0e0e0751d7a3366344ccf13a2524abe87a10264a3c6087ffd
5
+ SHA512:
6
+ metadata.gz: 54a88a9c80c4113334ae6c6a4ba1381349bcb6b17ded024381fdc95bd9706e71a8ab4e87e586f2e0e8610a8c5db7db0d9fbcca232fcb65e6343cd3ec166c5bba
7
+ data.tar.gz: 1d890a6514ab755a99f188c67974fc160f55a8e34ef946e926186754a0d0dd4110ce359920a1aadebfd0f50b7e9a50419acba7952af4323c796d490739ac590b
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### 0.0.1 / 2024-09-28
2
+
3
+ * Everything is new. First release.
data/Manifest.txt ADDED
@@ -0,0 +1,5 @@
1
+ CHANGELOG.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ bin/fbtxt2json
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # fbtxt2json - convert football.txt match schedules & more to json
2
+
3
+
4
+
5
+ ## Step 0 - Installation Via Gems
6
+
7
+ To install the command-line tool via gems (ruby's package manager) use:
8
+
9
+ ```
10
+ $ gem install fbtxt2json
11
+ ```
12
+
13
+
14
+ ## Usage
15
+
16
+ Try in your shell / terminal:
17
+
18
+ ```
19
+ $ fbtxt2json -h
20
+ ```
21
+
22
+ resulting in:
23
+
24
+ ```
25
+ Usage: fbtxt2json [options] PATH
26
+ --verbose, --debug turn on verbose / debug output (default: false)
27
+ -o, --output PATH output to file
28
+ ```
29
+
30
+
31
+ Let's try to convert the "Euro" European Championship 2024
32
+ in the Football.TXT format (see [`euro/2024--germany/euro.txt`](https://github.com/openfootball/euro/blob/master/2024--germany/euro.txt)) to JSON:
33
+
34
+ ```
35
+ $ fbtxt2json euro/2024--germany/euro.txt
36
+ ```
37
+
38
+ resulting in:
39
+
40
+ ``` json
41
+ {
42
+ "name": "Euro 2024",
43
+ "matches": [
44
+ {
45
+ "num": 1,
46
+ "round": "Matchday 1",
47
+ "date": "2024-06-14", "time": "21:00",
48
+ "team1": "Germany",
49
+ "team2": "Scotland",
50
+ "score": { "ht": [3,0], "ft": [5,1] },
51
+ "group": "Group A"
52
+ },
53
+ {
54
+ "num": 2,
55
+ "round": "Matchday 1",
56
+ "date": "2024-06-15", "time": "15:00",
57
+ "team1": "Hungary",
58
+ "team2": "Switzerland",
59
+ "score": { "ht": [0,2], "ft": [1,3] },
60
+ "group": "Group A"
61
+ },
62
+ // ...
63
+ ]
64
+ }
65
+ ```
66
+
67
+ to output into a file use the `-o/--output` option:
68
+
69
+ ```
70
+ $ fbtxt2json euro/2024--germany/euro.txt -o euro.json
71
+ ```
72
+
73
+
74
+ Let's try to convert the English Premier League 2024/25
75
+ in the Football.TXT format (see [`england/2024-25/1-premierleague.txt`](https://github.com/openfootball/england/blob/master/2024-25/1-premierleague.txt)) to JSON:
76
+
77
+ ```
78
+ $ fbtxt2json england/2024-25/1-premierleague.txt
79
+ ```
80
+
81
+ resulting in:
82
+
83
+ ``` json
84
+ {
85
+ "name": "English Premier League 2024/25",
86
+ "matches": [
87
+ {
88
+ "round": "Matchday 1",
89
+ "date": "2024-08-16", "time": "20:00",
90
+ "team1": "Manchester United FC",
91
+ "team2": "Fulham FC",
92
+ "score": { "ht": [0,0], "ft": [1,0] }
93
+ },
94
+ {
95
+ "round": "Matchday 1",
96
+ "date": "2024-08-17", "time": "12:30",
97
+ "team1": "Ipswich Town FC",
98
+ "team2": "Liverpool FC",
99
+ "score": { "ht": [0,0], "ft": [0,2]}
100
+ },
101
+ // ...
102
+ ]
103
+ }
104
+ ```
105
+
106
+ to output into a file use the `-o/--output` option:
107
+
108
+ ```
109
+ $ fbtxt2json england/2024-25/1-premierleague.txt -o en.json
110
+ ```
111
+
112
+ That's it.
113
+
114
+
115
+
116
+
117
+ ## Questions? Comments?
118
+
119
+ Yes, you can. More than welcome.
120
+ See [Help & Support »](https://github.com/openfootball/help)
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'hoe'
2
+
3
+
4
+ Hoe.spec 'fbtxt2json' do
5
+
6
+ self.version = '0.0.1'
7
+
8
+ self.summary = "fbtxt2json - convert football.txt match schedules & more to json"
9
+ self.description = summary
10
+
11
+ self.urls = { home: 'https://github.com/sportdb/sport.db' }
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'gerald.bauer@gmail.com'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
+
20
+ self.licenses = ['Public Domain']
21
+
22
+ self.extra_deps = [
23
+ ['sportdb-quick', '>= 0.2.0'],
24
+ ]
25
+
26
+ self.spec_extras = {
27
+ required_ruby_version: '>= 3.1.0'
28
+ }
29
+ end
data/bin/fbtxt2json ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ## tip: to test run:
4
+ ## ruby -I ./lib bin/fbtxt2json
5
+
6
+
7
+ ## our own code
8
+ require 'sportdb/quick'
9
+
10
+
11
+
12
+ require 'optparse'
13
+
14
+
15
+
16
+ args = ARGV
17
+ opts = { debug: false,
18
+ output: nil,
19
+ }
20
+
21
+ parser = OptionParser.new do |parser|
22
+ parser.banner = "Usage: #{$PROGRAM_NAME} [options] PATH"
23
+
24
+ ##
25
+ ## check if git has a offline option?? (use same)
26
+ ## check for other tools - why? why not?
27
+ # parser.on( "-q", "--quiet",
28
+ # "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
29
+ # opts[:debug] = false
30
+ # end
31
+
32
+ parser.on( "--verbose", "--debug",
33
+ "turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
34
+ opts[:debug] = true
35
+ end
36
+
37
+ parser.on( "-o PATH", "--output PATH",
38
+ "output to file" ) do |output|
39
+ opts[:output] = output
40
+ end
41
+ end
42
+ parser.parse!( args )
43
+
44
+ puts "OPTS:"
45
+ p opts
46
+ puts "ARGV:"
47
+ p args
48
+
49
+
50
+ path = if args.empty?
51
+ '../../../openfootball/euro/2021--europe/euro.txt'
52
+ elsif args.size == 1
53
+ args[0]
54
+ else
55
+ puts "!! wrong number of args, got #{args.size} - #{args.inspect} - only one arg supported/expected"
56
+ exit 1
57
+ end
58
+
59
+
60
+ if opts[:debug]
61
+ SportDb::QuickMatchReader.debug = true
62
+ SportDb::MatchParser.debug = true
63
+ else
64
+ SportDb::QuickMatchReader.debug = false
65
+ SportDb::MatchParser.debug = false
66
+ LogUtils::Logger.root.level = :info
67
+ end
68
+
69
+
70
+ puts "==> reading >#{path}<..."
71
+ quick = SportDb::QuickMatchReader.new( read_text( path ) )
72
+ matches = quick.parse
73
+ name = quick.league_name ## quick hack - get league+season via league_name
74
+
75
+ data = { 'name' => name,
76
+ 'matches' => matches.map {|match| match.as_json }}
77
+ pp data
78
+ puts
79
+ puts " #{matches.size} match(es)"
80
+
81
+ if quick.errors?
82
+ puts "!! #{quick.errors.size} parse error(s):"
83
+ pp quick.errors
84
+ exit 1
85
+ end
86
+
87
+ if opts[:output]
88
+ puts "==> writing matches to #{opts[:output]}"
89
+ write_json( opts[:output], data )
90
+ end
91
+
92
+
93
+ puts "bye"
94
+
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fbtxt2json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sportdb-quick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.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.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '4.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7'
47
+ - !ruby/object:Gem::Dependency
48
+ name: hoe
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '4.1'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '4.1'
61
+ description: fbtxt2json - convert football.txt match schedules & more to json
62
+ email: gerald.bauer@gmail.com
63
+ executables:
64
+ - fbtxt2json
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - CHANGELOG.md
68
+ - Manifest.txt
69
+ - README.md
70
+ files:
71
+ - CHANGELOG.md
72
+ - Manifest.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/fbtxt2json
76
+ homepage: https://github.com/sportdb/sport.db
77
+ licenses:
78
+ - Public Domain
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options:
82
+ - "--main"
83
+ - README.md
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.1.0
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.4.10
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: fbtxt2json - convert football.txt match schedules & more to json
101
+ test_files: []