lib/sportdb/cli/main.rb in sportdb-1.9.15 vs lib/sportdb/cli/main.rb in sportdb-1.9.16
- old
+ new
@@ -74,47 +74,25 @@
def connect_to_db( options )
puts SportDb.banner
puts "working directory: #{Dir.pwd}"
- db_config = {
- :adapter => 'sqlite3',
- :database => "#{options.db_path}/#{options.db_name}"
- }
+ SportDb.connect( adapter: 'sqlite3',
+ database: "#{options.db_path}/#{options.db_name}" )
- ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
- if RUBY_PLATFORM =~ /java/ && db_config[:adapter] == 'sqlite3'
- # quick hack for JRuby sqlite3 support via jdbc
- puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
- require 'jdbc/sqlite3'
- require 'active_record/connection_adapters/jdbc_adapter'
- require 'active_record/connection_adapters/jdbcsqlite3_adapter'
- end
-
-
- puts "Connecting to db using settings: "
- pp db_config
-
- ActiveRecord::Base.establish_connection( db_config )
-
- LogDb.setup # start logging to db
+ LogDb.setup # start logging to db (that is, save logs in logs table in db)
end
desc 'Create DB schema'
command [:create] do |c|
c.action do |g,o,args|
connect_to_db( opts )
-
- LogDb.create
- ConfDb.create
- TagDb.create
- WorldDb.create
- PersonDb.create
- SportDb.create
-
+
+ SportDb.create_all
+
SportDb.read_builtin # e.g. seasons.txt etc
puts 'Done.'
end # action
end # command create
@@ -128,16 +106,11 @@
datafile = Datafile::Datafile.load_file( './Datafile' )
datafile.download # datafile step 1 - download all datasets/zips
connect_to_db( opts )
- LogDb.create
- ConfDb.create
- TagDb.create
- WorldDb.create
- PersonDb.create
- SportDb.create
+ SportDb.create_all
SportDb.read_builtin # e.g. seasons.txt etc
datafile.read # datafile step 2 - read all datasets
@@ -192,16 +165,11 @@
datafile = Datafile::Datafile.load_file( './Datafile' )
datafile.download # datafile step 1 - download all datasets/zips
connect_to_db( opts ) ### todo: check let connect go first?? - for logging (logs) to db ???
- LogDb.create
- ConfDb.create
- TagDb.create
- WorldDb.create
- PersonDb.create
- SportDb.create
+ SportDb.create_all
SportDb.read_builtin # e.g. seasons.txt etc
datafile.read # datafile step 2 - read all datasets
@@ -229,16 +197,11 @@
connect_to_db( opts )
## todo: document optional setup profile arg (defaults to all)
setup = args[0] || 'all'
- LogDb.create
- ConfDb.create
- TagDb.create
- WorldDb.create
- PersonDb.create
- SportDb.create
+ SportDb.create_all
SportDb.read_builtin # e.g. seasons.txt etc
WorldDb.read_all( opts.world_data_path )
SportDb.read_setup( "setups/#{setup}", opts.data_path )
@@ -394,11 +357,12 @@
command :props do |c|
c.action do |g,o,args|
connect_to_db( opts )
- SportDb.props
-
+ ### fix: SportDb.props
+ ## use ConfDb.props or similar!!!
+
puts 'Done.'
end
end
\ No newline at end of file