Class: PgSlice::Client

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

Constant Summary collapse

SQL_FORMAT =
{
  day: "YYYYMMDD",
  month: "YYYYMM"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Client

Returns a new instance of Client.



17
18
19
20
21
22
# File 'lib/pgslice.rb', line 17

def initialize(args)
  $stdout.sync = true
  $stderr.sync = true
  parse_args(args)
  @command = @arguments.shift
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



10
11
12
# File 'lib/pgslice.rb', line 10

def arguments
  @arguments
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/pgslice.rb', line 10

def options
  @options
end

Instance Method Details

#performObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pgslice.rb', line 24

def perform
  return if @exit

  case @command
  when "prep"
    prep
  when "add_partitions"
    add_partitions
  when "fill"
    fill
  when "swap"
    swap
  when "unswap"
    unswap
  when "unprep"
    unprep
  when nil
    log "Commands: add_partitions, fill, prep, swap, unprep, unswap"
  else
    abort "Unknown command: #{@command}"
  end
ensure
  @connection.close if @connection
end