Class: S3rbsync::Command

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/s3rbsync/command.rb

Instance Method Summary collapse

Instance Method Details

#initObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/s3rbsync/command.rb', line 8

def init
  if yes? "Do you wish to continue [yes(y) / no(n)] ?", :cyan
    access_key  = ask("aws_access_key:")
    secret_key  = ask("aws_secret_access_key:")
    region      = ask("regin:")
    bucket_name = ask("bucket_name:")
    create_file "~/.aws.yml" do
      <<-"YAML"
:aws_access_key:         #{access_key}
:aws_secret_access_key:  #{secret_key}
:regin:                  #{region}
:bucket_name:            #{bucket_name}
      YAML
    end
  else
    puts "...exit"
  end
end

#testObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/s3rbsync/command.rb', line 28

def test
  say "\nChecking config...\n", :cyan
  conf = S3rbsync::Configure.new
  print "Config file: "
  if conf.valid_yaml_file?
    say "OK\n", :green
  else
    say "NG\n", :red
    say "\n...Done\n", :cyan
    exit 1
  end

  print "Test connection: "
  if conf.connected?
    say "OK", :green
    #...
  else
    say "NG", :red
    say "  -> Connection falid: Chack config file, or 's3rbsync init'", :yellow
  end
  say "\n...Done\n", :cyan
end