Module: SportDB
- Defined in:
- lib/sportdb.rb
Class Method Summary collapse
- .banner ⇒ Object
- .config_path ⇒ Object
- .create ⇒ Object
-
.delete! ⇒ Object
delete ALL records (use with care!).
- .lang ⇒ Object
- .load_plugins ⇒ Object
- .main ⇒ Object
- .props ⇒ Object
-
.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.
-
.read_all(include_path) ⇒ Object
convenience helper.
- .read_setup(setup, include_path) ⇒ Object
- .root ⇒ Object
- .stats ⇒ Object
- .tables ⇒ Object
Class Method Details
.banner ⇒ Object
78 79 80 |
# File 'lib/sportdb.rb', line 78 def self. "sportdb #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]" end |
.config_path ⇒ Object
86 87 88 |
# File 'lib/sportdb.rb', line 86 def self.config_path "#{root}/config" end |
.create ⇒ Object
104 105 106 107 |
# File 'lib/sportdb.rb', line 104 def self.create CreateDb.new.up WorldDb::Models::Prop.create!( key: 'db.schema.sport.version', value: VERSION ) end |
.delete! ⇒ Object
delete ALL records (use with care!)
131 132 133 134 |
# File 'lib/sportdb.rb', line 131 def self.delete! puts '*** deleting sport table records/data...' Deleter.new.run end |
.lang ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/sportdb.rb', line 90 def self.lang # todo/fix: find a better way for single instance ?? if @lang.nil? @lang = Lang.new end @lang end |
.load_plugins ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/sportdb.rb', line 153 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 ## todo: extract version and name of gem? 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.}. skipping..." end end end |
.main ⇒ Object
99 100 101 102 |
# File 'lib/sportdb.rb', line 99 def self.main ## Runner.new.run(ARGV) - old code require 'sportdb/cli/main' end |
.props ⇒ Object
147 148 149 |
# File 'lib/sportdb.rb', line 147 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.
124 125 126 127 |
# File 'lib/sportdb.rb', line 124 def self.read( ary, include_path ) reader = Reader.new( include_path ) reader.load( ary ) end |
.read_all(include_path) ⇒ Object
convenience helper
114 115 116 |
# File 'lib/sportdb.rb', line 114 def self.read_all( include_path ) # convenience helper read_setup( 'setups/all', include_path ) end |
.read_setup(setup, include_path) ⇒ Object
109 110 111 112 |
# File 'lib/sportdb.rb', line 109 def self.read_setup( setup, include_path ) reader = Reader.new( include_path ) reader.load_setup( setup ) end |
.root ⇒ Object
82 83 84 |
# File 'lib/sportdb.rb', line 82 def self.root "#{File.( File.dirname(File.dirname(__FILE__)) )}" end |
.stats ⇒ Object
137 138 139 140 141 |
# File 'lib/sportdb.rb', line 137 def self.stats stats = Stats.new stats.tables stats.props end |
.tables ⇒ Object
143 144 145 |
# File 'lib/sportdb.rb', line 143 def self.tables Stats.new.tables end |