class Scatter::CLI
Public Instance Methods
alias(from, *to)
click to toggle source
# File lib/scatter/cli.rb, line 50 def alias(from, *to) config = Config.get config['aliases'] ||= {} config['aliases'][from] = to.join ' ' Config.save config say Config.show 'aliases' end
cap(*cmd)
click to toggle source
# File lib/scatter/cli.rb, line 34 def cap(*cmd) exec "cap", cmd end
capfile?()
click to toggle source
# File lib/scatter/cli.rb, line 106 def capfile? File.exists? "#{project_deploy_dir}/Capfile" end
config(*args)
click to toggle source
# File lib/scatter/cli.rb, line 61 def config(*args) unless options.show abort "Incorrect number of arguments" unless args.length == 2 setting = args.first value = args.last Config.set setting, value end say Config.show end
deploy()
click to toggle source
# File lib/scatter/cli.rb, line 28 def deploy run end
exec(*cmd)
click to toggle source
# File lib/scatter/cli.rb, line 39 def exec(*cmd) run cmd.join ' ' end
executable?()
click to toggle source
# File lib/scatter/cli.rb, line 110 def executable? deploy = "#{project_deploy_dir}/deploy" return false unless File.exists? deploy unless File.executable? deploy abort "It looks like you have a deploy file, but it's not executable. Try something like: chmod +x #{deploy}" end return true end
generate_command()
click to toggle source
# File lib/scatter/cli.rb, line 121 def generate_command return "./#{options.shared} #{project_path}" if options.shared return "./deploy #{project_path}" if executable? return "cap deploy" if capfile? end
git?()
click to toggle source
# File lib/scatter/cli.rb, line 82 def git? unless system "which git >/dev/null 2>&1" abort "Scatter requires Git if you want it to find projects automatically" end `git rev-parse --is-inside-work-tree 2>/dev/null`.match "^true" end
method_missing(method, *args)
click to toggle source
Process aliases
Calls superclass method
# File lib/scatter/cli.rb, line 74 def method_missing(method, *args) aliases = Config.get 'aliases' _method = method.to_s return super unless aliases.has_key?(_method) and aliases[_method].is_a?(String) system "scatter #{aliases[_method]} #{args.join ' '}" end
project_deploy_dir()
click to toggle source
# File lib/scatter/cli.rb, line 98 def project_deploy_dir if options.shared "#{options.directory}/__shared" elsif project_path "#{options.directory}/#{File.basename project_path}" end end
project_path()
click to toggle source
# File lib/scatter/cli.rb, line 90 def project_path if options.project File.expand_path options.project elsif git? `git rev-parse --show-toplevel`.chomp end end
run(command=nil)
click to toggle source
# File lib/scatter/cli.rb, line 127 def run(command=nil) abort "No deploy directory found" unless project_deploy_dir abort "No deploy command found" unless command ||= generate_command if options.dry_run say "success" else system "cd #{project_deploy_dir} && #{command}" end end
version()
click to toggle source
# File lib/scatter/cli.rb, line 45 def version say Scatter::VERSION end