Module: BaseCommands
Defined Under Namespace
Classes: BaseDSLCommands
Instance Method Summary collapse
-
#accesslog(bucket = nil) ⇒ Object
(also: #logging)
Enable/disable bucket access logging.
-
#cp(src_bucket, dest_bucket) ⇒ Object
(also: #copy)
Make a copy of a file (cp) or move a file (mv).
-
#del(object = nil) ⇒ Object
(also: #delete, #rm, #delete_object, #delete_file, #remove)
Delete file from bucket.
-
#du(bucket = nil) ⇒ Object
(also: #disk_usage)
Disk usage - amount of data stored in S3.
-
#fixbucket(bucket = nil) ⇒ Object
(also: #fix)
Fix invalid file names in a bucket.
-
#get(object = nil, files = nil) ⇒ Object
(also: #download)
Get file from bucket (i.e. download from S3).
-
#info(bucket = nil) ⇒ Object
Get various information about a Bucket or Object.
-
#la ⇒ Object
(also: #list_all, #list_all_objects)
List all object in all buckets.
-
#ls(bucket = nil) ⇒ Object
(also: #list_bucket, #list)
List objects or buckets.
-
#mb(bucket = nil) ⇒ Object
(also: #create_new_bucket, #make_bucket, #mkdir, #create_bucket)
Make bucket.
-
#mv(src_bucket, dest_bucket) ⇒ Object
(also: #move)
Make a copy of a file (cp) or move a file (mv).
-
#put(files = nil, bucket = nil) ⇒ Object
(also: #upload)
Put file into bucket (i.e. upload to S3).
-
#rb(bucket = nil) ⇒ Object
(also: #remove_bucket, #rmdir, #delete_bucket)
Remove bucket.
-
#setacl(bucket = nil) ⇒ Object
(also: #set_access_control_list)
Modify Access control list for Bucket or Files.
-
#sign(string) ⇒ Object
(also: #secretkey)
Sign arbitrary string using the secret key.
-
#sync(src_object, dest_object) ⇒ Object
(also: #sync_directory, #sync_dir, #synchronize)
Backup a directory tree to S3 Restore a tree from S3 to local directory.
Methods included from DSLCommands
Instance Method Details
#accesslog(bucket = nil) ⇒ Object Also known as: logging
Enable/disable bucket access logging
171 172 173 174 |
# File 'lib/dsl/commands/base_commands.rb', line 171 def accesslog(bucket = nil) @commands[:accesslog] = @bucket || bucket self end |
#cp(src_bucket, dest_bucket) ⇒ Object Also known as: copy
Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).
135 136 137 138 |
# File 'lib/dsl/commands/base_commands.rb', line 135 def cp(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2] @commands[:cp] = "#{src_bucket} #{dest_bucket}" self end |
#del(object = nil) ⇒ Object Also known as: delete, rm, delete_object, delete_file, remove
Delete file from bucket
112 113 114 115 |
# File 'lib/dsl/commands/base_commands.rb', line 112 def del(object = nil) # s3://BUCKET/OBJECT @commands[:del] = @bucket || object self end |
#du(bucket = nil) ⇒ Object Also known as: disk_usage
Disk usage - amount of data stored in S3
164 165 166 167 |
# File 'lib/dsl/commands/base_commands.rb', line 164 def du(bucket = nil) # [s3://BUCKET[/PREFIX]] @commands[:du] = @bucket || bucket self end |
#fixbucket(bucket = nil) ⇒ Object Also known as: fix
Fix invalid file names in a bucket
185 186 187 188 |
# File 'lib/dsl/commands/base_commands.rb', line 185 def fixbucket(bucket = nil) @commands[:fixbucket] = @bucket || bucket self end |
#get(object = nil, files = nil) ⇒ Object Also known as: download
Get file from bucket (i.e. download from S3)
102 103 104 105 106 107 108 |
# File 'lib/dsl/commands/base_commands.rb', line 102 def get(object = nil, files = nil) # s3://BUCKET/OBJECT LOCAL_FILE get_files = @files || files get_object = @bucket || object @commands[:get] = "#{get_object} #{get_files}" self end |
#info(bucket = nil) ⇒ Object
Get various information about a Bucket or Object
158 159 160 161 |
# File 'lib/dsl/commands/base_commands.rb', line 158 def info(bucket = nil) # s3://BUCKET[/OBJECT] @commands[:info] = @bucket || bucket self end |
#la ⇒ Object Also known as: list_all, list_all_objects
List all object in all buckets
84 85 86 87 |
# File 'lib/dsl/commands/base_commands.rb', line 84 def la @commands[:la] = '' self end |
#ls(bucket = nil) ⇒ Object Also known as: list_bucket, list
List objects or buckets
76 77 78 79 |
# File 'lib/dsl/commands/base_commands.rb', line 76 def ls(bucket = nil) # s3://BUCKET[/PREFIX]] @commands[:ls] = bucket || @bucket self end |
#mb(bucket = nil) ⇒ Object Also known as: create_new_bucket, make_bucket, mkdir, create_bucket
Make bucket
57 58 59 60 |
# File 'lib/dsl/commands/base_commands.rb', line 57 def mb(bucket = nil) # s3://BUCKET @commands[:mb] = bucket || @bucket self end |
#mv(src_bucket, dest_bucket) ⇒ Object Also known as: move
Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).
144 145 146 147 |
# File 'lib/dsl/commands/base_commands.rb', line 144 def mv(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2] @commands[:mv] = "#{src_bucket} #{dest_bucket}" self end |
#put(files = nil, bucket = nil) ⇒ Object Also known as: upload
Put file into bucket (i.e. upload to S3)
92 93 94 95 96 97 98 |
# File 'lib/dsl/commands/base_commands.rb', line 92 def put(files = nil, bucket = nil) # FILE [FILE...] s3://BUCKET[/PREFIX] put_files = @files || files put_bucket = @bucket || bucket @commands[:put] = "#{put_files} #{put_bucket}" self end |
#rb(bucket = nil) ⇒ Object Also known as: remove_bucket, rmdir, delete_bucket
Remove bucket
67 68 69 70 |
# File 'lib/dsl/commands/base_commands.rb', line 67 def rb(bucket = nil) # s3://BUCKET @commands[:rb] = bucket || @bucket self end |
#setacl(bucket = nil) ⇒ Object Also known as: set_access_control_list
Modify Access control list for Bucket or Files. Use with –acl-public or –acl-private
151 152 153 154 |
# File 'lib/dsl/commands/base_commands.rb', line 151 def setacl(bucket = nil) # s3://BUCKET[/OBJECT] @commands[:setacl] = @bucket || bucket self end |
#sign(string) ⇒ Object Also known as: secretkey
Sign arbitrary string using the secret key
178 179 180 181 |
# File 'lib/dsl/commands/base_commands.rb', line 178 def sign(string) @commands[:sign] = string self end |
#sync(src_object, dest_object) ⇒ Object Also known as: sync_directory, sync_dir, synchronize
Backup a directory tree to S3 Restore a tree from S3 to local directory
124 125 126 127 |
# File 'lib/dsl/commands/base_commands.rb', line 124 def sync(src_object, dest_object) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR @commands[:sync] = "#{src_object} #{dest_object}" self end |