Sha256: edd4a199743bc7e1a85a7f27bc79f9301e07cfb0b1a596ee20bd5840fa057171

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'fileutils'

module CapistranoExtensions
  module Files
    module Local

      include FileUtils::Verbose

      public *COMMANDS.flatten
      public :pwd

      FILE_TESTS.each do |m,t|
        class_eval <<-EODEF, __FILE__, __LINE__
          def #{m}(a, options={})
            logger.trace "test #{t} \#{a.gsub ' ', '\\ '}" if logger 
            File.#{m} a
          end
        EODEF
      end

      def tail_f(file, n=10)
        unless defined? File::Tail::Logfile then gem 'file-tail'; require 'file/tail' end
        File::Tail::Logfile.tail(file, :backward=>n) do |line| puts line end
      rescue Interrupt
        logger.trace "interrupted (Ctrl-C)" if logger
      end

      def upload(from, to)
        cp from, to
      end

      def download(from, to)
        cp from, to
      end

      def cd(dir, options={})
        if block_given?
          dir, dir2 = pwd, dir
          cd dir2
          yield
        end  
        cd dir
      end

    end
  end
end

Capistrano.plugin :local_files, CapistranoExtensions::Files::Local

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joekhoobyar-capistrano-extensions-0.0.5 lib/capistrano_extensions/files/local.rb
joekhoobyar-capistrano-extensions-0.0.7 lib/capistrano_extensions/files/local.rb
joekhoobyar-capistrano-extensions-0.0.8 lib/capistrano_extensions/files/local.rb