lib/nanoc/extra/deployers/fog.rb in nanoc-3.6.6 vs lib/nanoc/extra/deployers/fog.rb in nanoc-3.6.7
- old
+ new
@@ -21,14 +21,14 @@
# @see Nanoc::Extra::Deployer#run
def run
require 'fog'
- # Get params
+ # Get params, unsetting anything we don't want to pass through to fog.
src = File.expand_path(self.source_path)
bucket = self.config.delete(:bucket) || self.config.delete(:bucket_name)
- path = self.config[:path]
+ path = self.config.delete(:path)
self.config.delete(:kind)
# Validate params
error 'The path requires no trailing slash' if path && path[-1,1] == '/'
@@ -43,19 +43,19 @@
connection = ::Fog::Storage.new(self.config)
# Get bucket
puts "Getting bucket"
begin
- directory = connection.directories.get(bucket)
+ directory = connection.directories.get(bucket, :prefix => path)
rescue ::Excon::Errors::NotFound
should_create_bucket = true
end
should_create_bucket = true if directory.nil?
# Create bucket if necessary
if should_create_bucket
- directory = connection.directories.create(:key => bucket)
+ directory = connection.directories.create(:key => bucket, :prefix => path)
end
# Get list of remote files
files = directory.files
truncated = files.respond_to?(:is_truncated) && files.is_truncated
@@ -69,10 +69,10 @@
# Upload all the files in the output folder to the clouds
puts "Uploading local files"
FileUtils.cd(src) do
files = Dir['**/*'].select { |f| File.file?(f) }
files.each do |file_path|
- key = "#{path}#{file_path}"
+ key = path ? File.join(path, file_path) : file_path
directory.files.create(
:key => key,
:body => File.open(file_path),
:public => true)
keys_to_destroy.delete(key)