class SportDb::Market::Loader
Attributes
include_path[R]
Public Class Methods
new( include_path )
click to toggle source
# File lib/sportdb/market/loader.rb, line 15 def initialize( include_path ) @include_path = include_path end
Public Instance Methods
load( name )
click to toggle source
# File lib/sportdb/market/loader.rb, line 19 def load( name ) # load from gem (built-in) path = "#{@include_path}/#{name}.rb" puts "*** loading data '#{name}' (#{path})..." code = File.read_utf8( path ) load_worker( code ) ## for builtin fixtures use VERSION of gem ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.market.rb.#{SportDB::Market::VERSION}" ) end
Private Instance Methods
load_worker( code )
click to toggle source
helper
change at/2012_13/bl to at.2012/13.bl or quali_2012_13_europe_c to quali.2012/13.europe.c def fixture_name_to_prop_key( name ) prop_key = name.gsub( '/', '.' ) prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13 prop_key = prop_key.gsub( '_', '.' ) prop_key end
# File lib/sportdb/market/loader.rb, line 52 def load_worker( code ) self.class_eval( code ) end