sportdb-models 2.0.0 → 2.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.
- checksums.yaml +4 -4
- data/lib/sportdb/models.rb +41 -27
- data/lib/sportdb/models/models/match.rb +2 -1
- data/lib/sportdb/models/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: 5f0d4c37492676024c57f08909596a413991d8b9
|
4
|
+
data.tar.gz: 7793d7a13474b8a2cea45b94fcbd4261b7e87984
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275bf0569a3622579837ce8866621365176d7c91d6655a5051e3163ef000b86210fb88afc34da2edf873e219e13f2841ad2c15d925bbfc5f19a61deab0de6d6c
|
7
|
+
data.tar.gz: ff8bb5dafa8741e6e5d3c514ee32ec67cbd74c2a8a40d2f8af19cb2ac0f212741de72c2e29da12765ec6b0ac3b10845f0c83891ecfa67b3ae2514699b32b119b
|
data/lib/sportdb/models.rb
CHANGED
@@ -82,32 +82,36 @@ module SportDb
|
|
82
82
|
### change default to ./sport.db ?? why? why not?
|
83
83
|
db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///sport.db' )
|
84
84
|
|
85
|
-
if db.scheme == 'postgres'
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
85
|
+
config = if db.scheme == 'postgres'
|
86
|
+
{ adapter: 'postgresql',
|
87
|
+
host: db.host,
|
88
|
+
port: db.port,
|
89
|
+
username: db.user,
|
90
|
+
password: db.password,
|
91
|
+
database: db.path[1..-1],
|
92
|
+
encoding: 'utf8'
|
93
|
+
}
|
94
|
+
else # assume sqlite3
|
95
|
+
{ adapter: db.scheme, # sqlite3
|
96
|
+
database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
|
97
|
+
}
|
98
|
+
end
|
99
|
+
else
|
100
|
+
## note: for compatibility lets you also pass-in/use string keys
|
101
|
+
## e.g. YAML.load uses/returns always string keys - always auto-convert to symbols
|
102
|
+
config = config.symbolize_keys
|
101
103
|
end
|
102
104
|
|
105
|
+
|
106
|
+
## todo/check/fix: move jruby "hack" to attic - why? why not?
|
103
107
|
## todo/check: use if defined?( JRUBY_VERSION ) instead ??
|
104
|
-
if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
|
108
|
+
## if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
|
105
109
|
# quick hack for JRuby sqlite3 support via jdbc
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
110
|
+
## puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
|
111
|
+
## require 'jdbc/sqlite3'
|
112
|
+
## require 'active_record/connection_adapters/jdbc_adapter'
|
113
|
+
## require 'active_record/connection_adapters/jdbcsqlite3_adapter'
|
114
|
+
## end
|
111
115
|
|
112
116
|
puts "Connecting to db using settings: "
|
113
117
|
pp config
|
@@ -115,8 +119,11 @@ module SportDb
|
|
115
119
|
# ActiveRecord::Base.logger = Logger.new( STDOUT )
|
116
120
|
|
117
121
|
## if sqlite3 add (use) some pragmas for speedups
|
118
|
-
if config[:adapter]
|
119
|
-
|
122
|
+
if config[:adapter] == 'sqlite3' &&
|
123
|
+
config[:database] != ':memory:'
|
124
|
+
## note: if in memory database e.g. ':memory:' no pragma needed!!
|
125
|
+
## try to speed up sqlite
|
126
|
+
## see http://www.sqlite.org/pragma.html
|
120
127
|
con = ActiveRecord::Base.connection
|
121
128
|
con.execute( 'PRAGMA synchronous=OFF;' )
|
122
129
|
con.execute( 'PRAGMA journal_mode=OFF;' )
|
@@ -126,7 +133,6 @@ module SportDb
|
|
126
133
|
|
127
134
|
|
128
135
|
def self.setup_in_memory_db
|
129
|
-
|
130
136
|
# Database Setup & Config
|
131
137
|
ActiveRecord::Base.logger = Logger.new( STDOUT )
|
132
138
|
## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
|
@@ -144,9 +150,17 @@ end # module SportDb
|
|
144
150
|
|
145
151
|
|
146
152
|
module SportDb
|
147
|
-
module
|
153
|
+
module Model
|
148
154
|
##################
|
149
155
|
# add alias why? why not?
|
156
|
+
#
|
157
|
+
# more aliases to consider:
|
158
|
+
# - Tournament for Event?
|
159
|
+
# - Cup for League?
|
160
|
+
# - Roster for Lineup?
|
161
|
+
# - Stadium for Ground? - why? why not?
|
162
|
+
|
163
|
+
|
150
164
|
Competition = Event
|
151
165
|
Comp = Event
|
152
166
|
|
@@ -154,7 +168,7 @@ LineUp = Lineup
|
|
154
168
|
Squad = Lineup
|
155
169
|
|
156
170
|
Game = Match ## add (old) alias - why? why not?
|
157
|
-
end # module
|
171
|
+
end # module Model
|
158
172
|
end # module SportDb
|
159
173
|
|
160
174
|
|
@@ -127,7 +127,8 @@ class Match < ActiveRecord::Base
|
|
127
127
|
|
128
128
|
|
129
129
|
# match over?
|
130
|
-
|
130
|
+
## todo/fix: add back time (hours/minutes) to date if present!!!!
|
131
|
+
def over?() date <= Date.today; end
|
131
132
|
|
132
133
|
## fix/todo: already added by ar magic ??? remove code
|
133
134
|
def knockout?() knockout == true; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
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-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: worlddb-models
|