Class: Hackpad::Migration::Runner

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hackpad/migration/runner.rb

Instance Method Summary collapse

Instance Method Details

#migrateObject



15
16
17
18
19
20
21
22
23
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/hackpad/migration/runner.rb', line 15

def migrate
  out_file = options['output'].nil? ? 'result.json' : options['output']
  last_result = Result.new(out_file)
  if last_result.user_options['source_site'].nil?
    last_result.user_options['source_site'] = ask 'Please entry the source site that you want to migrate (example: https://example.hackpad.com): '
    last_result.write!
  end
  if last_result.user_options['source_client_id'].nil?
    last_result.user_options['source_client_id'] = ask 'Please entry the client id that you want to migrate (example: xLR8qInsYLG): '
    last_result.write!
  end
  if last_result.user_options['source_secret'].nil?
    last_result.user_options['source_secret'] = ask 'Please entry the secret that you want to migrate (example: XsDYswLE1QogALkdFgsfvhRW4YJUvGre): '
    last_result.write!
  end
  if last_result.user_options['target_site'].nil?
    last_result.user_options['target_site'] = ask 'Please entry the target site that you want to migrate (example: https://example.hackpad.com): '
    last_result.write!
  end
  if last_result.user_options['target_client_id'].nil?
    last_result.user_options['target_client_id'] = ask 'Please entry the client id that you want to migrate (example: xLR8qInsYLG): '
    last_result.write!
  end
  if last_result.user_options['target_secret'].nil?
    last_result.user_options['target_secret'] = ask 'Please entry the secret that you want to migrate (example: XsDYswLE1QogALkdFgsfvhRW4YJUvGre): '
    last_result.write!
  end
  begin
    Hackpad::Migration::Migrator.new(last_result).migrate
  rescue Errno::ECONNREFUSED => e
    puts e
  end
end