lib/datapimp/sync/s3_bucket.rb in datapimp-1.0.8 vs lib/datapimp/sync/s3_bucket.rb in datapimp-1.0.9
- old
+ new
@@ -6,10 +6,18 @@
# returns the s3 bucket via fog
def s3
@s3 ||= Datapimp::Sync.amazon.storage.directories.get(remote)
end
+ def website_hostname
+ "#{s3.key}.s3-website-#{ s3.location }.amazonaws.com"
+ end
+
+ def website_url(proto="http")
+ "#{proto}://#{ website_hostname }"
+ end
+
def local_path
Pathname(local)
end
def deploy_manifest_path
@@ -99,17 +107,28 @@
log "Saving deploy manifest. #{ deploy_manifest.keys.length } entries"
deploy_manifest_path.open("w+") {|fh| fh.write(deploy_manifest.to_json) }
end
def run_pull_action(options={})
+ end
+ def run_create_action(options={})
+ directories = Datapimp::Sync.amazon.storage.directories
+
+ if existing = directories.get(remote)
+ return existing
+ else
+ directories.create(key:remote)
+ end
end
def run(action, options={})
action = action.to_sym
if action == :push
run_push_action(options)
+ elsif action == :create
+ run_create_action(options)
elsif action == :update_acl
run_update_acl_action(options={})
elsif action == :pull
run_pull_action
end