Class: Dbmanager::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/dbmanager/runner.rb

Direct Known Subclasses

Dumper, Importer, Loader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = STDIN, output = STDOUT) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
9
# File 'lib/dbmanager/runner.rb', line 5

def initialize(input=STDIN, output=STDOUT)
  @input        = input
  @output       = output
  @environments = YmlParser.environments
end

Instance Attribute Details

#environmentsObject (readonly)

Returns the value of attribute environments.



3
4
5
# File 'lib/dbmanager/runner.rb', line 3

def environments
  @environments
end

#inputObject (readonly)

Returns the value of attribute input.



3
4
5
# File 'lib/dbmanager/runner.rb', line 3

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



3
4
5
# File 'lib/dbmanager/runner.rb', line 3

def output
  @output
end

Instance Method Details

#get_env(type) ⇒ Object



11
12
13
14
# File 'lib/dbmanager/runner.rb', line 11

def get_env(type)
  output.puts "\nPlease choose #{type} db:\n\n"
  choose_environment
end

#get_filename(type, default_filename) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/dbmanager/runner.rb', line 16

def get_filename(type, default_filename)
  output.print "\nPlease choose #{type} file (defaults to #{default_filename}): "
  filename = get_input
  if filename.blank?
    default_filename
  else
    absolute_path(filename)
  end
end