lib/middleman-deploy/commands.rb in middleman-deploy-0.2.4 vs lib/middleman-deploy/commands.rb in middleman-deploy-0.3.0
- old
+ new
@@ -1,15 +1,14 @@
-require "middleman-core/cli"
+require 'middleman-core/cli'
-require "middleman-deploy/extension"
-require "middleman-deploy/methods"
-require "middleman-deploy/strategies"
-require "middleman-deploy/pkg-info"
+require 'middleman-deploy/pkg-info'
+require 'middleman-deploy/extension'
+require 'middleman-deploy/methods'
+require 'middleman-deploy/strategies'
module Middleman
module Cli
-
# This class provides a "deploy" command for the middleman CLI.
class Deploy < Thor
include Thor::Actions
check_unknown_options!
@@ -19,36 +18,33 @@
# Tell Thor to exit with a nonzero exit code on failure
def self.exit_on_failure?
true
end
- desc "deploy [options]", Middleman::Deploy::TAGLINE
- method_option "build_before",
- :type => :boolean,
- :aliases => "-b",
- :desc => "Run `middleman build` before the deploy step"
+ desc 'deploy [options]', Middleman::Deploy::TAGLINE
+ method_option 'build_before',
+ type: :boolean,
+ aliases: '-b',
+ desc: 'Run `middleman build` before the deploy step'
def deploy
build_before(options)
process
end
protected
- def build_before(options={})
+ def build_before(options = {})
build_enabled = options.fetch('build_before', self.deploy_options.build_before)
if build_enabled
# http://forum.middlemanapp.com/t/problem-with-the-build-task-in-an-extension
run('middleman build') || exit(1)
end
end
def print_usage_and_die(message)
- usage_path = File.join(File.dirname(__FILE__), '..', '..', 'USAGE')
- usage_message = File.read(usage_path)
-
- raise Error, "ERROR: #{message}\n#{usage_message}"
+ raise Error, "ERROR: #{message}\n#{Middleman::Deploy::README}"
end
def process
server_instance = ::Middleman::Application.server.inst
@@ -63,31 +59,31 @@
options = nil
begin
options = ::Middleman::Application.server.inst.options
rescue NoMethodError
- print_usage_and_die "You need to activate the deploy extension in config.rb."
+ print_usage_and_die 'You need to activate the deploy extension in config.rb.'
end
unless options.method
- print_usage_and_die "The deploy extension requires you to set a method."
+ print_usage_and_die 'The deploy extension requires you to set a method.'
end
case options.method
when :rsync, :sftp
unless options.host && options.path
print_usage_and_die "The #{options.method} method requires host and path to be set."
end
when :ftp
unless options.host && options.user && options.password && options.path
- print_usage_and_die "The ftp deploy method requires host, path, user, and password to be set."
+ print_usage_and_die 'The ftp deploy method requires host, path, user, and password to be set.'
end
end
options
end
end
# Alias "d" to "deploy"
- Base.map({ "d" => "deploy" })
+ Base.map('d' => 'deploy')
end
end