Module: SportDb
- Defined in:
- lib/sportdb.rb,
lib/sportdb/lang.rb,
lib/sportdb/stats.rb,
lib/sportdb/reader.rb,
lib/sportdb/schema.rb,
lib/sportdb/deleter.rb,
lib/sportdb/version.rb,
lib/sportdb/cli/opts.rb,
lib/sportdb/data/fixtures.rb
Defined Under Namespace
Modules: FixtureHelpers, Fixtures, Keys, Matcher, Models
Classes: CreateDb, Deleter, Lang, LangChecker, Opts, Reader, Stats
Constant Summary
collapse
- VERSION =
'1.7.0'
Class Method Summary
collapse
Class Method Details
.banner ⇒ Object
79
80
81
|
# File 'lib/sportdb.rb', line 79
def self.banner
"sportdb #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
end
|
.config_path ⇒ Object
87
88
89
|
# File 'lib/sportdb.rb', line 87
def self.config_path
"#{root}/config"
end
|
.create ⇒ Object
109
110
111
112
|
# File 'lib/sportdb.rb', line 109
def self.create
CreateDb.new.up
WorldDb::Models::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
end
|
.data_path ⇒ Object
91
92
93
|
# File 'lib/sportdb.rb', line 91
def self.data_path
"#{root}/data"
end
|
.delete! ⇒ Object
delete ALL records (use with care!)
143
144
145
146
|
# File 'lib/sportdb.rb', line 143
def self.delete!
puts '*** deleting sport table records/data...'
Deleter.new.run
end
|
.lang ⇒ Object
95
96
97
98
99
100
101
|
# File 'lib/sportdb.rb', line 95
def self.lang
if @lang.nil?
@lang = Lang.new
end
@lang
end
|
.load_plugins ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/sportdb.rb', line 165
def self.load_plugins
@found ||= []
@loaded ||= {}
@files ||= Gem.find_files( 'sportdb_plugin.rb' )
puts "#{@files.size} plugin files found:"
@files.each do |file|
puts " >#{file}<"
end
puts "normalized/match pattern:"
@files.each do |file|
if file =~ /sportdb-([a-z]+)-(\d\.\d.\d)/
puts " >#{$1}< | >#{$2}<"
@found << file
else
puts "*** error: ignoring plugin script >#{file}< not matching gem naming pattern"
end
end
@found.each do |file|
begin
puts "loading plugin script #{file}"
require file
rescue LoadError => e
puts "*** error loading plugin script #{file.inspect}: #{e.message}. skipping..."
end
end
end
|
.main ⇒ Object
104
105
106
107
|
# File 'lib/sportdb.rb', line 104
def self.main
require 'sportdb/cli/main'
end
|
.props ⇒ Object
159
160
161
|
# File 'lib/sportdb.rb', line 159
def self.props
Stats.new.props
end
|
.read(ary, include_path) ⇒ Object
load built-in (that is, bundled within the gem) named plain text seeds
-
pass in an array of pairs of event/seed names e.g. [[‘at.2012/13’, ‘at/2012_13/bl’],
['cl.2012/13', 'cl/2012_13/cl']] etc.
133
134
135
136
137
138
139
|
# File 'lib/sportdb.rb', line 133
def self.read( ary, include_path )
reader = Reader.new( include_path )
ary.each do |name|
reader.load( name )
end
end
|
.read_all(include_path) ⇒ Object
119
120
121
|
# File 'lib/sportdb.rb', line 119
def self.read_all( include_path ) read_setup( 'setups/all', include_path )
end
|
.read_builtin ⇒ Object
123
124
125
|
# File 'lib/sportdb.rb', line 123
def self.read_builtin
read_setup( 'setups/all', data_path )
end
|
.read_setup(setup, include_path) ⇒ Object
114
115
116
117
|
# File 'lib/sportdb.rb', line 114
def self.read_setup( setup, include_path )
reader = Reader.new( include_path )
reader.load_setup( setup )
end
|
.root ⇒ Object
83
84
85
|
# File 'lib/sportdb.rb', line 83
def self.root
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
end
|
.stats ⇒ Object
149
150
151
152
153
|
# File 'lib/sportdb.rb', line 149
def self.stats
stats = Stats.new
stats.tables
stats.props
end
|
.tables ⇒ Object
155
156
157
|
# File 'lib/sportdb.rb', line 155
def self.tables
Stats.new.tables
end
|