lib/sportdb/cli/runner.rb in sportdb-0.3.0 vs lib/sportdb/cli/runner.rb in sportdb-0.3.1

- old
+ new

@@ -1,10 +1,15 @@ module SportDB class Runner + +## make models available in sportdb module by default with namespace +# e.g. lets you use Team instead of Models::Team + include SportDB::Models + def initialize @logger = Logger.new(STDOUT) @logger.level = Logger::INFO @opts = Opts.new @@ -37,11 +42,11 @@ cmd.on( "--verbose", "Show debug trace" ) do logger.datetime_format = "%H:%H:%S" logger.level = Logger::DEBUG - ## todo: set ActiveRecord Logger to stdout?? + ActiveRecord::Base.logger = Logger.new(STDOUT) end cmd.on_tail( "-h", "--help", "Show this message" ) do puts <<EOS @@ -117,11 +122,15 @@ puts "*** loading data '#{name}' (#{path})..." text = File.read( path ) - SportDB.module_eval( text ) + # SportDB.module_eval( text ) + + ## evaluate in class context of SportDB::Runner + ## change to loader class later + self.class_eval( text ) # NB: same as # # module SportDB # <code here> @@ -139,9 +148,10 @@ def dump_stats # todo: use %5d or similar to format string puts "Stats:" puts " #{Event.count} events" puts " #{Team.count} teams" + puts " #{Country.count} countries" puts " #{Game.count} games" end def dump_props # todo: use %5 or similar to format string \ No newline at end of file