Class: DBGet::Runner
- Inherits:
-
Object
- Object
- DBGet::Runner
- Defined in:
- lib/dbget/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
- #format_date(date) ⇒ Object
- #get_dbget_path ⇒ Object
- #get_final_collection(collection) ⇒ Object
- #init_config(dbget_path) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #prepare_dump_options ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
19 20 21 |
# File 'lib/dbget/runner.rb', line 19 def initialize() @options = end |
Class Method Details
.boot(user, options) ⇒ Object
3 4 5 |
# File 'lib/dbget/runner.rb', line 3 def self.boot(user, ) self.new((user, )).run! end |
.parse_options(user, options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dbget/runner.rb', line 7 def self.(user, ) opts = {} opts['user'] = user .each do |o| k, v = o.split('=') opts[k] = v end opts end |
Instance Method Details
#dump ⇒ Object
51 52 53 |
# File 'lib/dbget/runner.rb', line 51 def dump Controller.boot(@options) end |
#format_date(date) ⇒ Object
45 46 47 48 49 |
# File 'lib/dbget/runner.rb', line 45 def format_date(date) unless date == 'xxxx-xx-xx' Date.strptime(date, "%Y-%m-%d") end end |
#get_dbget_path ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/dbget/runner.rb', line 55 def get_dbget_path if ENV.include?('DBGET_PATH') ENV['DBGET_PATH'] else raise "DBGET_PATH not defined" end end |
#get_final_collection(collection) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/dbget/runner.rb', line 37 def get_final_collection(collection) unless collection == 'EMPTY' collection.split(',') else [] end end |
#init_config(dbget_path) ⇒ Object
63 64 65 |
# File 'lib/dbget/runner.rb', line 63 def init_config(dbget_path) DBGet.read_config(dbget_path) end |
#prepare_dump_options ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/dbget/runner.rb', line 29 def @options['collections'] = get_final_collection(@options['collections']) @options['date'] = format_date(@options['date']) @options['clean'] = Utils.to_bool(@options['clean']) @options['verbose'] = Utils.to_bool(@options['verbose']) @options['append_date'] = Utils.to_bool(@options['append_date']) end |
#run! ⇒ Object
23 24 25 26 27 |
# File 'lib/dbget/runner.rb', line 23 def run! init_config(get_dbget_path) dump end |