football-to-sqlite 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/football2sqlite +1 -1
- data/lib/football-to-sqlite.rb +34 -22
- data/lib/football-to-sqlite/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d29ed5da5ccbe1e428ddc5b95c2e31b0d48bb63
|
4
|
+
data.tar.gz: f452ef032cfdbe2443f1717c8fa27a64bce067d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37536591b5ba24d020d7db075027b165d5c1838b960748a4de5ab8eb30267d6231774fdf7d9dd122224eec26691a21f68ef3e2b04c43ca582ea49453c779bd25
|
7
|
+
data.tar.gz: b13d42d79be8f053ad70ef3005d19cbc6016472ec9f4355b2563ff92bab5cad4c899d14f89dbfb5e7f761413bb39101422d1dac2b7d85750aa3fa71842db8334
|
data/bin/football2sqlite
CHANGED
data/lib/football-to-sqlite.rb
CHANGED
@@ -22,41 +22,36 @@ end
|
|
22
22
|
def connect( dbpath )
|
23
23
|
puts "working directory: #{Dir.pwd}"
|
24
24
|
|
25
|
-
##
|
25
|
+
## note:
|
26
|
+
## File.dirname( 'test.db' ) returns '.'
|
27
|
+
## thus, use expand_path first to get full path
|
28
|
+
##
|
29
|
+
## todo/check: move mkdir into connect (for (re)use) - why? why not?
|
30
|
+
FileUtils.mkdir_p( File.dirname( File.expand_path( dbpath ))) ## make sure path exists
|
31
|
+
|
26
32
|
SportDb.connect( adapter: 'sqlite3',
|
27
|
-
|
33
|
+
database: dbpath )
|
34
|
+
|
35
|
+
SportDb.auto_migrate!
|
28
36
|
|
29
|
-
## todo/fix: auto-migrate !!!!
|
30
|
-
SportDb.create_all
|
31
37
|
LogDb.setup # start logging to db (that is, save logs in logs table in db)
|
32
38
|
end
|
33
39
|
|
34
40
|
|
35
41
|
def run( args )
|
36
42
|
|
37
|
-
puts "-- optparse:"
|
38
43
|
opts = {}
|
39
44
|
optparser = OptionParser.new do |parser|
|
40
|
-
parser.banner = "Usage: football-to-sqlite [options]
|
41
|
-
|
42
|
-
# parser.on( "-d", "--download", "Download web pages" ) do |download|
|
43
|
-
# opts[:download] = download
|
44
|
-
# end
|
45
|
-
|
46
|
-
# parser.on( "-p", "--push", "(Commit &) push changes to git" ) do |push|
|
47
|
-
# opts[:push] = push
|
48
|
-
# end
|
49
|
-
|
45
|
+
parser.banner = "Usage: football-to-sqlite [options] DATABASE PATHS..."
|
50
46
|
end
|
51
47
|
optparser.parse!( args )
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
if args.empty?
|
50
|
+
puts "!! ERROR - sqlite database name/path expected (e.g. sport.db)"
|
51
|
+
puts optparser.help
|
52
|
+
exit 1
|
53
|
+
end
|
57
54
|
|
58
|
-
puts "-------"
|
59
|
-
puts
|
60
55
|
dbpath = args.shift
|
61
56
|
puts "dbpath: >#{dbpath}<"
|
62
57
|
puts "args:"
|
@@ -66,9 +61,26 @@ def run( args )
|
|
66
61
|
|
67
62
|
args.each do |arg|
|
68
63
|
puts "reading #{arg}..."
|
69
|
-
|
64
|
+
## note: only support reading matchfiles for now (NOT zips & dirs or clubs & leagues etc.)
|
65
|
+
# SportDb.read_match( arg )
|
66
|
+
end
|
67
|
+
|
68
|
+
## todo: check if stdin is always utf-8 or such?
|
69
|
+
unless STDIN.tty?
|
70
|
+
puts "reading STDIN..."
|
71
|
+
## assume/ read stdin as utf8 - possible?
|
72
|
+
txt = STDIN.read
|
73
|
+
puts "[------------->>>"
|
74
|
+
puts txt
|
75
|
+
puts "<<<-------------]"
|
76
|
+
# SportDb.parse_match( txt )
|
77
|
+
puts "encoding: #{txt.encoding}"
|
70
78
|
end
|
71
79
|
|
80
|
+
|
81
|
+
## print some stats
|
82
|
+
SportDb.tables
|
83
|
+
|
72
84
|
puts "Done."
|
73
85
|
end # method run
|
74
86
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: football-to-sqlite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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: 2020-10-
|
11
|
+
date: 2020-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-readers
|