Class: S3Sync::CLI::CreateBucket
- Defined in:
- lib/s3sync/cli.rb
Instance Attribute Summary collapse
-
#acl ⇒ Object
Returns the value of attribute acl.
Instance Method Summary collapse
-
#initialize ⇒ CreateBucket
constructor
A new instance of CreateBucket.
- #run(s3, bucket, key, file, args) ⇒ Object
Methods inherited from BaseCmd
#execute, #has_options?, #has_prefix?, #usage
Constructor Details
#initialize ⇒ CreateBucket
Returns a new instance of CreateBucket.
119 120 121 122 123 124 125 126 127 |
# File 'lib/s3sync/cli.rb', line 119 def initialize super 'createbucket', false, false @short_desc = "Create a new bucket under your user account" self. = CmdParse::OptionParserWrapper.new do |opt| parse_acl(opt) end end |
Instance Attribute Details
#acl ⇒ Object
Returns the value of attribute acl.
117 118 119 |
# File 'lib/s3sync/cli.rb', line 117 def acl @acl end |
Instance Method Details
#run(s3, bucket, key, file, args) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/s3sync/cli.rb', line 129 def run s3, bucket, key, file, args raise WrongUsage.new(nil, "You need to inform a bucket") if not bucket begin params = {} if @acl raise WrongUsage.new(nil, "Invalid ACL `#{@acl}'. Should be any of #{AVAILABLE_ACLS.join ', '}") if not AVAILABLE_ACLS.include? @acl params.merge!({:acl => @acl}) end s3.buckets.create bucket, params rescue AWS::S3::Errors::BucketAlreadyExists raise FailureFeedback.new("Bucket `#{bucket}' already exists") end end |