In Files

Parent

Class Index [+]

Quicksearch

Object

Public Instance Methods

_cset(name, *args, &block) click to toggle source
    # File lib/capistrano/recipes/deploy.rb, line 6
 6: def _cset(name, *args, &block)
 7:   unless exists?(name)
 8:     set(name, *args, &block)
 9:   end
10: end
depend(location, type, *args) click to toggle source

Auxiliary helper method for the `deploy:check’ task. Lets you set up your own dependencies.

    # File lib/capistrano/recipes/deploy.rb, line 84
84: def depend(location, type, *args)
85:   deps = fetch(:dependencies, {})
86:   deps[location] ||= {}
87:   deps[location][type] ||= []
88:   deps[location][type] << args
89:   set :dependencies, deps
90: end
run_locally(cmd) click to toggle source

logs the command then executes it locally. returns the command output as a string

     # File lib/capistrano/recipes/deploy.rb, line 103
103: def run_locally(cmd)
104:   logger.trace "executing locally: #{cmd.inspect}" if logger
105:   output_on_stdout = nil
106:   elapsed = Benchmark.realtime do
107:     output_on_stdout = `#{cmd}`
108:   end
109:   if $?.to_i > 0 # $? is command exit code (posix style)
110:     raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}"
111:   end
112:   logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger
113:   output_on_stdout
114: end
try_runner(*args) click to toggle source

Same as sudo, but tries sudo with :as set to the value of the :runner variable (which defaults to “app”).

     # File lib/capistrano/recipes/deploy.rb, line 150
150: def try_runner(*args)
151:   options = args.last.is_a?(Hash) ? args.pop : {}
152:   args << options.merge(:as => fetch(:runner, "app"))
153:   try_sudo(*args)
154: end
try_sudo(*args) click to toggle source

If a command is given, this will try to execute the given command, as described below. Otherwise, it will return a string for use in embedding in another command, for executing that command as described below.

If :run_method is :sudo (or :use_sudo is true), this executes the given command via sudo. Otherwise is uses run. If :as is given as a key, it will be passed as the user to sudo as, if using sudo. If the :as key is not given, it will default to whatever the value of the :admin_runner variable is, which (by default) is unset.

THUS, if you want to try to run something via sudo, and what to use the root user, you’d just to try_sudo(‘something’). If you wanted to try_sudo as someone else, you’d just do try_sudo(‘something’, :as => “bob”). If you always wanted sudo to run as a particular user, you could do set(:admin_runner, “bob”).

     # File lib/capistrano/recipes/deploy.rb, line 132
132: def try_sudo(*args)
133:   options = args.last.is_a?(Hash) ? args.pop : {}
134:   command = args.shift
135:   raise ArgumentError, "too many arguments" if args.any?
136: 
137:   as = options.fetch(:as, fetch(:admin_runner, nil))
138:   via = fetch(:run_method, :sudo)
139:   if command
140:     invoke_command(command, :via => via, :as => as)
141:   elsif via == :sudo
142:     sudo(:as => as)
143:   else
144:     ""
145:   end
146: end
with_env(name, value) click to toggle source

Temporarily sets an environment variable, yields to a block, and restores the value when it is done.

    # File lib/capistrano/recipes/deploy.rb, line 94
94: def with_env(name, value)
95:   saved, ENV[name] = ENV[name], value
96:   yield
97: ensure
98:   ENV[name] = saved
99: end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.