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
79 80 81 |
# File 'lib/sportdb.rb', line 79 def self. "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
105 106 107 108 |
# File 'lib/sportdb.rb', line 105 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!)
132 133 134 135 |
# File 'lib/sportdb.rb', line 132 def self.delete! puts '*** deleting sport table records/data...' Deleter.new.run end |
.lang ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/sportdb.rb', line 91 def self.lang # todo/fix: find a better way for single instance ?? if @lang.nil? @lang = Lang.new end @lang end |
.load_plugins ⇒ Object
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 185 |
# File 'lib/sportdb.rb', line 154 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
100 101 102 103 |
# File 'lib/sportdb.rb', line 100 def self.main ## Runner.new.run(ARGV) - old code require 'sportdb/cli/main' end |
.props ⇒ Object
148 149 150 |
# File 'lib/sportdb.rb', line 148 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.
125 126 127 128 |
# File 'lib/sportdb.rb', line 125 def self.read( ary, include_path ) reader = Reader.new( include_path ) reader.load( ary ) end |
.read_all(include_path) ⇒ Object
convenience helper
115 116 117 |
# File 'lib/sportdb.rb', line 115 def self.read_all( include_path ) # convenience helper read_setup( 'setups/all', include_path ) end |
.read_setup(setup, include_path) ⇒ Object
110 111 112 113 |
# File 'lib/sportdb.rb', line 110 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.( File.dirname(File.dirname(__FILE__)) )}" end |
.stats ⇒ Object
138 139 140 141 142 |
# File 'lib/sportdb.rb', line 138 def self.stats stats = Stats.new stats.tables stats.props end |
.tables ⇒ Object
144 145 146 |
# File 'lib/sportdb.rb', line 144 def self.tables Stats.new.tables end |