class S3rbsync::Command

Public Instance Methods

init() click to toggle source
# File lib/s3rbsync/command.rb, line 8
    def init
      if yes? "Do you wish to continue [yes(y) / no(n)] ?", :cyan
        say "-------- Input AWS kyes --------", :bold
        access_key  = ask("AWS ACCESS KEY:", :bold)
        secret_key  = ask("AWS SECRET ACCESS KEY:", :bold)
        say "-------- Select region --------", :bold
        print_table(print_region)
        begin
          region  = ask("\nRegin:", :bold)
        end until Region.names.include?(region)
        bucket_name = ask("Bucket name:", :bold)
        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
sync() click to toggle source
# File lib/s3rbsync/command.rb, line 34
def sync
  conf = S3rbsync::Configure.new
  unless conf.valid?
    say "Sync failed!: configure is invalid.", :red
    exit 1
  end
  synchronizer = S3rbsync::Synchronizer.new(conf, options[:directory])
  say "Sync start...", :cyan
  synchronizer.sync!
  say "...finish.", :cyan
end
test() click to toggle source
# File lib/s3rbsync/command.rb, line 47
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

Private Instance Methods

print_region() click to toggle source