Class: S3rbsync::Command
- Inherits:
-
Thor
- Object
- Thor
- S3rbsync::Command
- Includes:
- Thor::Actions
- Defined in:
- lib/s3rbsync/command.rb
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# 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, [:directory]) say "Sync start...", :cyan synchronizer.sync! say "...finish.", :cyan end |
#test ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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 |