sportdb-models 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c8072de5db8829c62e3b726472af30146ebf320
4
- data.tar.gz: ad299b7cd1fe9e2e604ac09d69894df443a6d46b
3
+ metadata.gz: a2dca58496a25d977a305dabb59fb4068f6a27d0
4
+ data.tar.gz: 454d482974847f5fee5d025e03449f9058c0b48f
5
5
  SHA512:
6
- metadata.gz: 34d296b375d07d2b3345796fb13d85482f27b46d36b954d65eff33db37d35a8debde350032bc55e5f21e62eb4efbdea9911498c9bb37f0a4d7b99ec720420337
7
- data.tar.gz: ceadae3f743055cc344fff0badf8a43f145f9390cee78b9e64f7725768e3cbb00fd6a0899e9e52e8ffc67f4520f8d585efdae23fec6eb6bb72471f7d736b8d32
6
+ metadata.gz: 2588e9757f5277b9f2088cd4b2222cb2712372a25b8ab01cb8346ae908c6c2c8ea8e3a7b9dd3e93d2a69117d30158dfc92a1d914dcb638826d34ecbf90619ecb
7
+ data.tar.gz: 517e715c5c132c1ae5e9c5794ec91f556a5b2bc56efe3b9429df1f4f50cdecc0bd3fcf48a3bae7c41e3407eeb2198a744a2aec1004ac6968d34e61aa3b36470a
@@ -1,21 +1,21 @@
1
- ### 0.4.0 / 2012-10-16
2
-
3
- * Add plain text fixture reader/loader
4
- * Add --generate/g option for generating fixtures from the DB using templates
5
-
6
- ### 0.3.1 / 2012-10-14
7
-
8
- * Move models into its own namespace, that is, SportDB::Models
9
- * Add ActiveRecord logging for --verbose option
10
-
11
- ### 0.3.0 / 2012-10-07
12
-
13
- * Add --delete option to delete all records
14
-
15
- ### 0.2.0 / 2012-10-06
16
-
17
- * Add --load option for builtin fixtures
18
-
19
- ### 0.1.0 / 2012-10-06
20
-
1
+ ### 0.4.0 / 2012-10-16
2
+
3
+ * Add plain text fixture reader/loader
4
+ * Add --generate/g option for generating fixtures from the DB using templates
5
+
6
+ ### 0.3.1 / 2012-10-14
7
+
8
+ * Move models into its own namespace, that is, SportDB::Models
9
+ * Add ActiveRecord logging for --verbose option
10
+
11
+ ### 0.3.0 / 2012-10-07
12
+
13
+ * Add --delete option to delete all records
14
+
15
+ ### 0.2.0 / 2012-10-06
16
+
17
+ * Add --load option for builtin fixtures
18
+
19
+ ### 0.1.0 / 2012-10-06
20
+
21
21
  * Everything is new. First release
data/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # sportdb-models gem - sport.db schema 'n' models for easy (re)use
2
-
3
- <!--
4
- [![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
5
- -->
6
-
7
- * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
8
- * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
9
- * gem :: [rubygems.org/gems/sportdb-models](https://rubygems.org/gems/sportdb-models)
10
- * rdoc :: [rubydoc.info/gems/sportdb-models](http://rubydoc.info/gems/sportdb-models)
11
- * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
12
-
13
-
14
- ## Usage Models
15
-
16
- ![](sportdb-models.png)
17
-
18
-
19
- ## License
20
-
21
- ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
22
-
23
- The `sportdb-models` scripts are dedicated to the public domain.
24
- Use it as you please with no restrictions whatsoever.
25
-
26
-
27
- ## Questions? Comments?
28
-
29
- Send them along to the
30
- [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
31
- Thanks!
1
+ # sportdb-models gem - sport.db schema 'n' models for easy (re)use
2
+
3
+ <!--
4
+ [![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
5
+ -->
6
+
7
+ * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
8
+ * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
9
+ * gem :: [rubygems.org/gems/sportdb-models](https://rubygems.org/gems/sportdb-models)
10
+ * rdoc :: [rubydoc.info/gems/sportdb-models](http://rubydoc.info/gems/sportdb-models)
11
+ * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
12
+
13
+
14
+ ## Usage Models
15
+
16
+ ![](sportdb-models.png)
17
+
18
+
19
+ ## License
20
+
21
+ ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
22
+
23
+ The `sportdb-models` scripts are dedicated to the public domain.
24
+ Use it as you please with no restrictions whatsoever.
25
+
26
+
27
+ ## Questions? Comments?
28
+
29
+ Send them along to the
30
+ [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
31
+ Thanks!
data/Rakefile CHANGED
@@ -1,32 +1,32 @@
1
- require 'hoe'
2
- require './lib/sportdb/models/version.rb'
3
-
4
-
5
- Hoe.spec 'sportdb-models' do
6
-
7
- self.version = SportDb::Module::Models::VERSION
8
-
9
- self.summary = "sportdb-models - sport.db schema 'n' models for easy (re)use"
10
- self.description = summary
11
-
12
- self.urls = ['https://github.com/sportdb/sport.db']
13
-
14
- self.author = 'Gerald Bauer'
15
- self.email = 'opensport@googlegroups.com'
16
-
17
- # switch extension to .markdown for gihub formatting
18
- # -- NB: auto-changed when included in manifest
19
- self.readme_file = 'README.md'
20
- self.history_file = 'CHANGELOG.md'
21
-
22
- self.extra_deps = [
23
- ['worlddb-models', '>= 2.4.0'], # Note: pull in all (extra) dependencies va worlddb-models
24
- ['persondb-models', '>= 0.5.0'], # persons (people) table
25
- ]
26
-
27
- self.licenses = ['Public Domain']
28
-
29
- self.spec_extras = {
30
- required_ruby_version: '>= 2.2.2'
31
- }
32
- end
1
+ require 'hoe'
2
+ require './lib/sportdb/models/version.rb'
3
+
4
+
5
+ Hoe.spec 'sportdb-models' do
6
+
7
+ self.version = SportDb::Module::Models::VERSION
8
+
9
+ self.summary = "sportdb-models - sport.db schema 'n' models for easy (re)use"
10
+ self.description = summary
11
+
12
+ self.urls = { home: 'https://github.com/sportdb/sport.db' }
13
+
14
+ self.author = 'Gerald Bauer'
15
+ self.email = 'opensport@googlegroups.com'
16
+
17
+ # switch extension to .markdown for gihub formatting
18
+ # -- NB: auto-changed when included in manifest
19
+ self.readme_file = 'README.md'
20
+ self.history_file = 'CHANGELOG.md'
21
+
22
+ self.extra_deps = [
23
+ ['worlddb-models', '>= 2.4.0'], # Note: pull in all (extra) dependencies va worlddb-models
24
+ ['persondb-models', '>= 0.5.0'], # persons (people) table
25
+ ]
26
+
27
+ self.licenses = ['Public Domain']
28
+
29
+ self.spec_extras = {
30
+ required_ruby_version: '>= 2.2.2'
31
+ }
32
+ end
@@ -1,179 +1,212 @@
1
- # encoding: utf-8
2
-
3
-
4
- # core and stlibs (note: get included via worlddb-models gem; see worlddb-models gem/lib)
5
- require 'worlddb/models' # NOTE: include worlddb-models gem (not cli tools gem, that is, worlddb)
6
- require 'persondb/models'
7
-
8
-
9
- # our own code
10
-
11
- require 'sportdb/models/version' # let version always go first
12
-
13
- require 'sportdb/models/formats'
14
- require 'sportdb/models/models/forward'
15
-
16
- require 'sportdb/models/models/world/city'
17
- require 'sportdb/models/models/world/country'
18
- require 'sportdb/models/models/world/continent'
19
- require 'sportdb/models/models/world/state'
20
-
21
- require 'sportdb/models/models/assoc'
22
- require 'sportdb/models/models/badge'
23
- require 'sportdb/models/models/event'
24
- require 'sportdb/models/models/goal'
25
- require 'sportdb/models/models/ground'
26
- require 'sportdb/models/models/group'
27
- require 'sportdb/models/models/league'
28
- require 'sportdb/models/models/lineup'
29
- require 'sportdb/models/models/match'
30
- require 'sportdb/models/models/person'
31
- require 'sportdb/models/models/round'
32
- require 'sportdb/models/models/season'
33
- require 'sportdb/models/models/stage'
34
- require 'sportdb/models/models/team'
35
-
36
- require 'sportdb/models/models/stats/alltime_standing'
37
- require 'sportdb/models/models/stats/event_standing'
38
- require 'sportdb/models/models/stats/group_standing'
39
-
40
- require 'sportdb/models/schema' # note: requires sportdb/models (include SportDB::Models)
41
-
42
- require 'sportdb/models/utils' # e.g. MatchCursor
43
-
44
- require 'sportdb/models/deleter'
45
- require 'sportdb/models/stats'
46
-
47
-
48
- module SportDb
49
-
50
- def self.create
51
- CreateDb.new.up
52
- ConfDb::Model::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
53
- end
54
-
55
- def self.create_all
56
- ## build schema - convenience helper
57
- LogDb.create
58
- ConfDb.create
59
- TagDb.create
60
- WorldDb.create
61
- PersonDb.create
62
- SportDb.create
63
- end
64
-
65
- # delete ALL records (use with care!)
66
- def self.delete!
67
- puts '*** deleting sport table records/data...'
68
- Deleter.new.run
69
- end # method delete!
70
-
71
-
72
- def self.tables
73
- Stats.new.tables
74
- end
75
-
76
-
77
- def self.connect( config={} )
78
-
79
- if config.empty?
80
- puts "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
81
-
82
- ### change default to ./sport.db ?? why? why not?
83
- db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///sport.db' )
84
-
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
103
- end
104
-
105
-
106
- ## todo/check/fix: move jruby "hack" to attic - why? why not?
107
- ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
108
- ## if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
109
- # quick hack for JRuby sqlite3 support via jdbc
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
115
-
116
- puts "Connecting to db using settings: "
117
- pp config
118
- ActiveRecord::Base.establish_connection( config )
119
- # ActiveRecord::Base.logger = Logger.new( STDOUT )
120
-
121
- ## if sqlite3 add (use) some pragmas for speedups
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
127
- con = ActiveRecord::Base.connection
128
- con.execute( 'PRAGMA synchronous=OFF;' )
129
- con.execute( 'PRAGMA journal_mode=OFF;' )
130
- con.execute( 'PRAGMA temp_store=MEMORY;' )
131
- end
132
- end
133
-
134
-
135
- def self.setup_in_memory_db
136
- # Database Setup & Config
137
- ActiveRecord::Base.logger = Logger.new( STDOUT )
138
- ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
139
-
140
- connect( adapter: 'sqlite3',
141
- database: ':memory:' )
142
-
143
- ## build schema
144
- create_all
145
- end # setup_in_memory_db (using SQLite :memory:)
146
-
147
-
148
- end # module SportDb
149
-
150
-
151
-
152
- module SportDb
153
- module Model
154
- ##################
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
-
164
- Competition = Event
165
- Comp = Event
166
-
167
- LineUp = Lineup
168
- Squad = Lineup
169
-
170
- Game = Match ## add (old) alias - why? why not?
171
- end # module Model
172
- end # module SportDb
173
-
174
-
175
-
176
- ## say hello
177
- puts SportDb::Module::Models.banner
178
-
179
-
1
+ # core and stlibs (note: get included via worlddb-models gem; see worlddb-models gem/lib)
2
+ require 'worlddb/models' # NOTE: include worlddb-models gem (not cli tools gem, that is, worlddb)
3
+ require 'persondb/models'
4
+
5
+
6
+ # our own code
7
+
8
+ require 'sportdb/models/version' # let version always go first
9
+
10
+ require 'sportdb/models/formats'
11
+ require 'sportdb/models/models/forward'
12
+
13
+ require 'sportdb/models/models/world/city'
14
+ require 'sportdb/models/models/world/country'
15
+ require 'sportdb/models/models/world/continent'
16
+ require 'sportdb/models/models/world/state'
17
+
18
+ require 'sportdb/models/models/assoc'
19
+ require 'sportdb/models/models/badge'
20
+ require 'sportdb/models/models/event'
21
+ require 'sportdb/models/models/goal'
22
+ require 'sportdb/models/models/ground'
23
+ require 'sportdb/models/models/group'
24
+ require 'sportdb/models/models/league'
25
+ require 'sportdb/models/models/lineup'
26
+ require 'sportdb/models/models/match'
27
+ require 'sportdb/models/models/person'
28
+ require 'sportdb/models/models/round'
29
+ require 'sportdb/models/models/season'
30
+ require 'sportdb/models/models/stage'
31
+ require 'sportdb/models/models/team'
32
+
33
+ require 'sportdb/models/models/stats/alltime_standing'
34
+ require 'sportdb/models/models/stats/event_standing'
35
+ require 'sportdb/models/models/stats/group_standing'
36
+
37
+ require 'sportdb/models/schema' # note: requires sportdb/models (include SportDB::Models)
38
+
39
+ require 'sportdb/models/utils' # e.g. MatchCursor
40
+
41
+ require 'sportdb/models/deleter'
42
+ require 'sportdb/models/stats'
43
+
44
+
45
+ module SportDb
46
+
47
+ def self.create
48
+ CreateDb.new.up
49
+ ConfDb::Model::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
50
+ end
51
+
52
+ def self.create_all
53
+ ## build schema - convenience helper
54
+ LogDb.create
55
+ ConfDb.create
56
+ TagDb.create
57
+ WorldDb.create
58
+ PersonDb.create
59
+ SportDb.create
60
+ end
61
+
62
+ def self.auto_migrate!
63
+ ### todo/fix:
64
+ ## check props table and versions!!!!!
65
+
66
+ # first time? - auto-run db migratation, that is, create db tables
67
+ unless LogDb::Model::Log.table_exists?
68
+ LogDb.create # add logs table
69
+ end
70
+
71
+ unless ConfDb::Model::Prop.table_exists?
72
+ ConfDb.create # add props table
73
+ end
74
+
75
+
76
+ unless TagDb::Model::Tag.table_exists?
77
+ TagDb.create # add tags & taggings tables
78
+ end
79
+
80
+ unless WorldDb::Model::Place.table_exists?
81
+ WorldDb.create # add places, & co. tables
82
+ end
83
+
84
+ unless PersonDb::Model::Person.table_exists?
85
+ PersonDb.create # add persons table
86
+ end
87
+
88
+ unless SportDb::Model::League.table_exists?
89
+ SportDb.create
90
+ end
91
+ end # method auto_migrate!
92
+
93
+
94
+ # delete ALL records (use with care!)
95
+ def self.delete!
96
+ puts '*** deleting sport table records/data...'
97
+ Deleter.new.run
98
+ end # method delete!
99
+
100
+
101
+ def self.tables
102
+ Stats.new.tables
103
+ end
104
+
105
+
106
+ def self.connect!( config={} ) # convenience shortcut w/ automigrate
107
+ connect( config )
108
+ auto_migrate!
109
+ end
110
+
111
+ def self.connect( config={} )
112
+ if config.empty?
113
+ puts "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
114
+
115
+ ### change default to ./sport.db ?? why? why not?
116
+ db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///sport.db' )
117
+
118
+ config = if db.scheme == 'postgres'
119
+ { adapter: 'postgresql',
120
+ host: db.host,
121
+ port: db.port,
122
+ username: db.user,
123
+ password: db.password,
124
+ database: db.path[1..-1],
125
+ encoding: 'utf8'
126
+ }
127
+ else # assume sqlite3
128
+ { adapter: db.scheme, # sqlite3
129
+ database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
130
+ }
131
+ end
132
+ else
133
+ ## note: for compatibility lets you also pass-in/use string keys
134
+ ## e.g. YAML.load uses/returns always string keys - always auto-convert to symbols
135
+ config = config.symbolize_keys
136
+ end
137
+
138
+
139
+ ## todo/check/fix: move jruby "hack" to attic - why? why not?
140
+ ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
141
+ ## if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
142
+ # quick hack for JRuby sqlite3 support via jdbc
143
+ ## puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
144
+ ## require 'jdbc/sqlite3'
145
+ ## require 'active_record/connection_adapters/jdbc_adapter'
146
+ ## require 'active_record/connection_adapters/jdbcsqlite3_adapter'
147
+ ## end
148
+
149
+ puts "Connecting to db using settings: "
150
+ pp config
151
+ ActiveRecord::Base.establish_connection( config )
152
+ # ActiveRecord::Base.logger = Logger.new( STDOUT )
153
+
154
+ ## if sqlite3 add (use) some pragmas for speedups
155
+ if config[:adapter] == 'sqlite3' &&
156
+ config[:database] != ':memory:'
157
+ ## note: if in memory database e.g. ':memory:' no pragma needed!!
158
+ ## try to speed up sqlite
159
+ ## see http://www.sqlite.org/pragma.html
160
+ con = ActiveRecord::Base.connection
161
+ con.execute( 'PRAGMA synchronous=OFF;' )
162
+ con.execute( 'PRAGMA journal_mode=OFF;' )
163
+ con.execute( 'PRAGMA temp_store=MEMORY;' )
164
+ end
165
+ end
166
+
167
+
168
+ def self.setup_in_memory_db
169
+ # Database Setup & Config
170
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
171
+ ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
172
+
173
+ connect( adapter: 'sqlite3',
174
+ database: ':memory:' )
175
+
176
+ ## build schema
177
+ create_all
178
+ end # setup_in_memory_db (using SQLite :memory:)
179
+
180
+
181
+ end # module SportDb
182
+
183
+
184
+
185
+ module SportDb
186
+ module Model
187
+ ##################
188
+ # add alias why? why not?
189
+ #
190
+ # more aliases to consider:
191
+ # - Tournament for Event?
192
+ # - Cup for League?
193
+ # - Roster for Lineup?
194
+ # - Stadium for Ground? - why? why not?
195
+
196
+
197
+ Competition = Event
198
+ Comp = Event
199
+
200
+ LineUp = Lineup
201
+ Squad = Lineup
202
+
203
+ Game = Match ## add (old) alias - why? why not?
204
+ end # module Model
205
+ end # module SportDb
206
+
207
+
208
+
209
+ ## say hello
210
+ puts SportDb::Module::Models.banner
211
+
212
+