Sha256: a645d7424784f1c850c20b0d7d04f422be5c125ebf3f26487ccb3cd744916c22

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

module SportDb

class Builder

  include LogUtils::Logging

  def initialize()
    @datasets = []
  end

  def self.load_file( path )
    code = File.read_utf8( path )
    self.load( code )
  end

  def self.load( code )
    builder = Builder.new
    builder.instance_eval( code )
    builder
  end


  def football( name, opts={} )
    logger.info( "[builder] add football-dataset '#{@name}'" )
    @datasets << FootballDataset.new( name, opts )
  end

  def world( name, opts={} )
    logger.info( "[builder] add world-dataset '#{@name}'" )
    @datasets << WorldDataset.new( name, opts )
  end


  def run()
    logger.info( "[builder] begin - run" )
    download()   # step 1 - download zips for datasets
    read()       # step 2 - read in datasets from zips
    logger.info( "[builder] end - run" )
  end

  def download()
    logger.info( "[builder] dowload" )
    @datasets.each do |dataset|
      dataset.download()
    end
  end

  def read()
    logger.info( "[builder] read" )
    @datasets.each do |dataset|
      dataset.read()
    end
  end

end # class Builder
end # module SportDb

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sportdb-1.9.13 lib/sportdb/builder/builder.rb
sportdb-1.9.12 lib/sportdb/builder/builder.rb
sportdb-1.9.11 lib/sportdb/builder/builder.rb