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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa3708f265e85ff08b23288dbb6a0d9a9d99892e
4
- data.tar.gz: 0143b37e2c0eeab01bde7aaa6d66619bd81f5a4e
3
+ metadata.gz: 5f0d4c37492676024c57f08909596a413991d8b9
4
+ data.tar.gz: 7793d7a13474b8a2cea45b94fcbd4261b7e87984
5
5
  SHA512:
6
- metadata.gz: b7835c911d31c45e12a4a4d07f29188f4bbd95cbf1a8534ed5dd025f42e02f39832763ccaf73c35847be8f4a89ef004ca7d33103ae28a7a17faf602b503d901d
7
- data.tar.gz: 072c3f07aebb20fc10bb6df827d4a87274aa7dce0c5ad7ad9dd78c2f2555103084a871b24fa9c22b9b1c021da443343704a3ee75f66cebc9c760494e92d39966
6
+ metadata.gz: 275bf0569a3622579837ce8866621365176d7c91d6655a5051e3163ef000b86210fb88afc34da2edf873e219e13f2841ad2c15d925bbfc5f19a61deab0de6d6c
7
+ data.tar.gz: ff8bb5dafa8741e6e5d3c514ee32ec67cbd74c2a8a40d2f8af19cb2ac0f212741de72c2e29da12765ec6b0ac3b10845f0c83891ecfa67b3ae2514699b32b119b
@@ -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
- config = {
87
- adapter: 'postgresql',
88
- host: db.host,
89
- port: db.port,
90
- username: db.user,
91
- password: db.password,
92
- database: db.path[1..-1],
93
- encoding: 'utf8'
94
- }
95
- else # assume sqlite3
96
- config = {
97
- adapter: db.scheme, # sqlite3
98
- database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
99
- }
100
- end
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
- puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
107
- require 'jdbc/sqlite3'
108
- require 'active_record/connection_adapters/jdbc_adapter'
109
- require 'active_record/connection_adapters/jdbcsqlite3_adapter'
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] == 'sqlite3'
119
- ## check/todo: if in memory e.g. ':memory:' no pragma needed!!
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 Models
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 Models
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
- def over?() play_at <= Time.now; end
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
@@ -5,7 +5,7 @@ module Module
5
5
  module Models
6
6
  MAJOR = 2
7
7
  MINOR = 0
8
- PATCH = 0
8
+ PATCH = 1
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
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.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-05-24 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: worlddb-models