Class: Object

### Home Classes Methods

### In Files

- lib/capistrano/recipes/deploy.rb
- lib/capistrano/recipes/deploy/assets.rb

### Parent

BasicObject

### Methods

- #_cset
- #depend
- #parse_manifest
- #run_locally
- #scm_default
- #shared_manifest_path
- #try_runner
- #try_sudo
- #with_env

### Files

- help.txt

### Class/Module Index

Quicksearch

- Capistrano
- Capistrano::CLI
- Capistrano::CLI::Execute
- Capistrano::CLI::Execute::ClassMethods
- Capistrano::CLI::Help
- Capistrano::CLI::Options
- Capistrano::CLI::Options::ClassMethods
- Capistrano::CLI::UI
- Capistrano::CLI::UI::ClassMethods
- Capistrano::Callback
- Capistrano::Command
- Capistrano::Command::Tree
- Capistrano::Command::Tree::Branch
- Capistrano::Command::Tree::ConditionBranch
- Capistrano::Command::Tree::ConditionBranch::Evaluator
- Capistrano::Command::Tree::ElseBranch
- Capistrano::Configuration
- Capistrano::Configuration::Actions
- Capistrano::Configuration::Actions::FileTransfer
- Capistrano::Configuration::Actions::Inspect
- Capistrano::Configuration::Actions::Invocation
- Capistrano::Configuration::Actions::Invocation::ClassMethods
- Capistrano::Configuration::AliasTask
- Capistrano::Configuration::Callbacks
- Capistrano::Configuration::Connections
- Capistrano::Configuration::Execution
- Capistrano::Configuration::Loading
- Capistrano::Configuration::Loading::ClassMethods
- Capistrano::Configuration::LogFormatters
- Capistrano::Configuration::Namespaces
- Capistrano::Configuration::Namespaces::Namespace
- Capistrano::Configuration::Roles
- Capistrano::Configuration::Servers
- Capistrano::Configuration::Variables
- Capistrano::Deploy
- Capistrano::Deploy::Dependencies
- Capistrano::Deploy::LocalDependency
- Capistrano::Deploy::RemoteDependency
- Capistrano::Deploy::SCM
- Capistrano::Deploy::SCM::Accurev
- Capistrano::Deploy::SCM::Accurev::InternalRevision
- Capistrano::Deploy::SCM::Base
- Capistrano::Deploy::SCM::Base::LocalProxy
- Capistrano::Deploy::SCM::Bzr
- Capistrano::Deploy::SCM::Cvs
- Capistrano::Deploy::SCM::Darcs
- Capistrano::Deploy::SCM::Git
- Capistrano::Deploy::SCM::Mercurial
- Capistrano::Deploy::SCM::None
- Capistrano::Deploy::SCM::Perforce
- Capistrano::Deploy::SCM::Subversion
- Capistrano::Deploy::Strategy
- Capistrano::Deploy::Strategy::Base
- Capistrano::Deploy::Strategy::Checkout
- Capistrano::Deploy::Strategy::Copy
- Capistrano::Deploy::Strategy::Export
- Capistrano::Deploy::Strategy::Remote
- Capistrano::Deploy::Strategy::RemoteCache
- Capistrano::Deploy::Strategy::UnsharedRemoteCache
- Capistrano::ProcCallback
- Capistrano::Processable
- Capistrano::Processable::SessionAssociation
- Capistrano::RemoteError
- Capistrano::Role
- Capistrano::Role::DynamicServerList
- Capistrano::SSH
- Capistrano::ServerDefinition
- Capistrano::Shell
- Capistrano::TaskCallback
- Capistrano::TaskDefinition
- Capistrano::Transfer
- Capistrano::Transfer::SFTPTransferWrapper
- Capistrano::Version
- Kernel
- Object
- String

No matching classes.

# Object

### Public Instance Methods

_cset(name, *args, &block) click to toggle source

    # File lib/capistrano/recipes/deploy.rb, line 8
    def _cset(name, *args, &block)
      unless exists?(name)
        set(name, *args, &block)
      end
    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 112
    def depend(location, type, *args)
      deps = fetch(:dependencies, {})
      deps[location] ||= {}
      deps[location][type] ||= []
      deps[location][type] << args
      set :dependencies, deps
    end

parse_manifest(str) click to toggle source

Parses manifest and returns array of uncompressed and compressed asset filenames with and without digests "Intelligently" determines format of string - supports YAML and JSON

    # File lib/capistrano/recipes/deploy/assets.rb, line 25
    def parse_manifest(str)
      assets_hash = str[0,1] == '{' ? JSON.parse(str)['assets'] : YAML.load(str)

      assets_hash.to_a.flatten.map {|a| [a, "#{a}.gz"] }.flatten
    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 131
    def run_locally(cmd)
      if dry_run
        return logger.debug "executing locally: #{cmd.inspect}"
      end
      logger.trace "executing locally: #{cmd.inspect}" if logger
      output_on_stdout = nil
      elapsed = Benchmark.realtime do
        output_on_stdout = `#{cmd}`
      end
      if $?.to_i > 0 # $? is command exit code (posix style)
        raise Capistrano::LocalArgumentError, "Command #{cmd} returned status code #{$?}"
      end
      logger.trace "command finished in #{(elapsed * 1000).round}ms" if logger
      output_on_stdout
    end

scm_default() click to toggle source

Checks known version control directories to intelligently set the version control in-use. For example, if a .svn directory exists in the project, it will set the :scm variable to :subversion, if a .git directory exists in the project, it will set the :scm variable to :git and so on. If no directory is found, it will default to :git.

    # File lib/capistrano/recipes/deploy.rb, line 88
    def scm_default
      if File.exist? '.git'
        :git
      elsif File.exist? '.accurev'
        :accurev
      elsif File.exist? '.bzr'
        :bzr
      elsif File.exist? '.cvs'
        :cvs
      elsif File.exist? '_darcs'
        :darcs
      elsif File.exist? '.hg'
        :mercurial
      elsif File.exist? '.perforce'
        :perforce
      elsif File.exist? '.svn'
        :subversion
      else
        :none
      end
    end

shared_manifest_path() click to toggle source

    # File lib/capistrano/recipes/deploy/assets.rb, line 19
    def shared_manifest_path
      @shared_manifest_path ||= capture("ls #{shared_path.shellescape}/#{shared_assets_prefix}/manifest*").strip
    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 181
    def try_runner(*args)
      options = args.last.is_a?(Hash) ? args.pop : {}
      args << options.merge(:as => fetch(:runner, "app"))
      try_sudo(*args)
    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 163
    def try_sudo(*args)
      options = args.last.is_a?(Hash) ? args.pop : {}
      command = args.shift
      raise ArgumentError, "too many arguments" if args.any?

      as = options.fetch(:as, fetch(:admin_runner, nil))
      via = fetch(:run_method, :sudo)
      if command
        invoke_command(command, :via => via, :as => as)
      elsif via == :sudo
        sudo(:as => as)
      else
        ""
      end
    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 122
    def with_env(name, value)
      saved, ENV[name] = ENV[name], value
      yield
    ensure
      ENV[name] = saved
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.