Sha256: 8d7c5144b3e07f9d5dc577bfc28ca490282d540a388cf581a06f951446196892

Contents?: true

Size: 1.23 KB

Versions: 361

Compression:

Stored size: 1.23 KB

Contents

module Capistrano
  module Deploy
    class LocalDependency
      attr_reader :configuration
      attr_reader :message

      def initialize(configuration)
        @configuration = configuration
        @success = true
      end

      def command(command)
        @message ||= "`#{command}' could not be found in the path on the local host"
        @success = find_in_path(command)
        self
      end

      def or(message)
        @message = message
        self
      end

      def pass?
        @success
      end

    private

      # Searches the path, looking for the given utility. If an executable
      # file is found that matches the parameter, this returns true.
      def find_in_path(utility)
        path = (ENV['PATH'] || "").split(File::PATH_SEPARATOR)
        suffixes = self.class.on_windows? ? self.class.windows_executable_extensions : [""]

        path.each do |dir|
          suffixes.each do |sfx|
            file = File.join(dir, utility + sfx)
            return true if File.executable?(file)
          end
        end

        false
      end

      def self.on_windows?
        RUBY_PLATFORM =~ /mswin|mingw/
      end

      def self.windows_executable_extensions
        %w(.exe .bat .com .cmd)
      end
    end
  end
end

Version data entries

361 entries across 361 versions & 12 rubygems

Version Path
capistrano-2.15.11 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.10 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.9 lib/capistrano/recipes/deploy/local_dependency.rb
wulffeld-capistrano-2.5.8.3 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.8 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.5.22 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.7 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.6 lib/capistrano/recipes/deploy/local_dependency.rb
dan-capistrano-2.5.6 lib/capistrano/recipes/deploy/local_dependency.rb
fotonauts-capistrano-2.5.2 lib/capistrano/recipes/deploy/local_dependency.rb
mbailey-capistrano-2.5.5 lib/capistrano/recipes/deploy/local_dependency.rb
mbailey-capistrano-2.5.6 lib/capistrano/recipes/deploy/local_dependency.rb
mbailey-capistrano-2.5.7 lib/capistrano/recipes/deploy/local_dependency.rb
sneakin-capistrano-2.5.5 lib/capistrano/recipes/deploy/local_dependency.rb
thoughtbot-capistrano-2.5.5 lib/capistrano/recipes/deploy/local_dependency.rb
thoughtbot-capistrano-2.5.6 lib/capistrano/recipes/deploy/local_dependency.rb
wulffeld-capistrano-2.5.8.1 lib/capistrano/recipes/deploy/local_dependency.rb
wulffeld-capistrano-2.5.8 lib/capistrano/recipes/deploy/local_dependency.rb
capistrano-2.15.5 lib/capistrano/recipes/deploy/local_dependency.rb
minmb-capistrano-2.15.4 lib/capistrano/recipes/deploy/local_dependency.rb