Class: Bartask::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bartask/base.rb

Direct Known Subclasses

Dumper, Restorer

Instance Method Summary collapse

Constructor Details

#initialize(config_file_path: nil, dump_file_path: nil) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/bartask/base.rb', line 10

def initialize(config_file_path: nil, dump_file_path: nil)
  @config_file_path = config_file_path || Pathname.new("config/database.yml")
  @specified_dump_file_path = dump_file_path
  parse_config_file
end

Instance Method Details

#dump_file_pathObject



16
17
18
19
20
21
22
23
# File 'lib/bartask/base.rb', line 16

def dump_file_path
  @dump_file_path ||= begin
    return @specified_dump_file_path unless @specified_dump_file_path.nil?

    suffix = branch_name.empty? ? "" : "_#{branch_name}"
    Pathname.new("tmp/#{@config["database"]}#{suffix}.dump")
  end
end