Class: Bard::CLI::Data

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bardObject

Returns the value of attribute bard

Returns:

  • (Object)

    the current value of bard



2
3
4
# File 'lib/bard/data.rb', line 2

def bard
  @bard
end

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



2
3
4
# File 'lib/bard/data.rb', line 2

def from
  @from
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



2
3
4
# File 'lib/bard/data.rb', line 2

def to
  @to
end

Instance Method Details

#callObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bard/data.rb', line 3

def call
  if to == "production"
    server = bard.instance_variable_get(:@config).servers[to.to_sym]
    url = server.normalized_ping
    puts bard.yellow("WARNING: You are about to push data to production, overwriting everything that is there!")
    answer = bard.ask("If you really want to do this, please type in the full HTTPS url of the production server:")
    if answer != url
      puts bard.red("!!! ") + "Failed! We expected #{url}. Is this really where you want to overwrite all the data?"
      exit 1
    end
  end

  if to == "local"
    data_pull_db from.to_sym
    data_pull_assets from.to_sym
  elsif from == "local"
    data_push_db to.to_sym
    data_push_assets to.to_sym
  else
    data_move_db from.to_sym, to.to_sym
    data_move_assets from.to_sym, to.to_sym
  end
end