lib/middleman-deploy/commands.rb in middleman-deploy-0.1.2 vs lib/middleman-deploy/commands.rb in middleman-deploy-0.1.3

- old
+ new

@@ -74,23 +74,25 @@ # To deploy the build directory to a remote host via ftp: activate :deploy do |deploy| deploy.method = :ftp # host, user, passwword and path *must* be set deploy.host = "ftp.example.com" + deploy.path = "/srv/www/site" deploy.user = "tvaughan" deploy.password = "secret" - deploy.path = "/srv/www/site" end # To deploy the build directory to a remote host via sftp: activate :deploy do |deploy| deploy.method = :sftp # host, user, passwword and path *must* be set deploy.host = "sftp.example.com" + deploy.path = "/srv/www/site" + # user is optional (no default) deploy.user = "tvaughan" + # password is optional (no default) deploy.password = "secret" - deploy.path = "/srv/www/site" end EOF end def inst @@ -100,26 +102,26 @@ def deploy_options options = nil begin options = inst.options - rescue + rescue NoMethodError print_usage_and_die "You need to activate the deploy extension in config.rb." end if (!options.method) print_usage_and_die "The deploy extension requires you to set a method." end case options.method - when :rsync + when :rsync, :sftp if (!options.host || !options.path) - print_usage_and_die "The rsync deploy method requires host and path to be set." + print_usage_and_die "The #{options.method} method requires host and path to be set." end - when :ftp, :sftp + when :ftp if (!options.host || !options.user || !options.password || !options.path) - print_usage_and_die "The #{options.method} method requires host, user, password, and path to be set." + print_usage_and_die "The ftp deploy method requires host, path, user, and password to be set." end end options end @@ -247,9 +249,10 @@ pass = self.deploy_options.password path = self.deploy_options.path puts "## Deploying via sftp to #{user}@#{host}:#{path}" + # `nil` is a valid value for user and/or pass. Net::SFTP.start(host, user, :password => pass) do |sftp| sftp.mkdir(path) Dir.chdir(self.inst.build_dir) do files = Dir.glob('**/*', File::FNM_DOTMATCH) files.reject { |a| a =~ Regexp.new('\.$') }.each do |f|