From 3daaaef6ee6951c35aba9dff93b90414de4c8a26 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Thu, 28 Jul 2016 22:02:04 +0900 Subject: [PATCH] removed rake contrib files, It should be extracted another gem --- lib/rake/contrib/compositepublisher.rb | 21 ---- lib/rake/contrib/ftptools.rb | 137 ------------------------- lib/rake/contrib/sshpublisher.rb | 60 ----------- 3 files changed, 218 deletions(-) delete mode 100644 lib/rake/contrib/compositepublisher.rb delete mode 100644 lib/rake/contrib/ftptools.rb delete mode 100644 lib/rake/contrib/sshpublisher.rb diff --git a/lib/rake/contrib/compositepublisher.rb b/lib/rake/contrib/compositepublisher.rb deleted file mode 100644 index 69952a080..000000000 --- a/lib/rake/contrib/compositepublisher.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Rake - - # Manage several publishers as a single entity. - class CompositePublisher - def initialize - @publishers = [] - end - - # Add a publisher to the composite. - def add(pub) - @publishers << pub - end - - # Upload all the individual publishers. - def upload - @publishers.each { |p| p.upload } - end - end - -end - diff --git a/lib/rake/contrib/ftptools.rb b/lib/rake/contrib/ftptools.rb deleted file mode 100644 index b178523bc..000000000 --- a/lib/rake/contrib/ftptools.rb +++ /dev/null @@ -1,137 +0,0 @@ -# = Tools for FTP uploading. -# -# This file is still under development and is not released for general -# use. - -require 'date' -require 'net/ftp' -require 'rake/file_list' - -module Rake # :nodoc: - - class FtpFile # :nodoc: all - attr_reader :name, :size, :owner, :group, :time - - def self.date - @date_class ||= Date - end - - def self.time - @time_class ||= Time - end - - def initialize(path, entry) - @path = path - @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') - @size = size.to_i - @time = determine_time(d1, d2, d3) - end - - def path - File.join(@path, @name) - end - - def directory? - @mode[0] == ?d - end - - def mode - parse_mode(@mode) - end - - def symlink? - @mode[0] == ?l - end - - private # -------------------------------------------------------- - - def parse_mode(m) - result = 0 - (1..9).each do |i| - result = 2 * result + ((m[i] == ?-) ? 0 : 1) - end - result - end - - def determine_time(d1, d2, d3) - now = self.class.time.now - if /:/ !~ d3 - result = Time.parse("#{d1} #{d2} #{d3}") - else - result = Time.parse("#{d1} #{d2} #{now.year} #{d3}") - result = Time.parse("#{d1} #{d2} #{now.year - 1} #{d3}") if - result > now - end - result - end - end - - ## - # Manage the uploading of files to an FTP account. - class FtpUploader # :nodoc: - - # Log uploads to standard output when true. - attr_accessor :verbose - - class << FtpUploader - # Create an uploader and pass it to the given block as +up+. - # When the block is complete, close the uploader. - def connect(path, host, account, password) - up = self.new(path, host, account, password) - begin - yield(up) - ensure - up.close - end - end - end - - # Create an FTP uploader targeting the directory +path+ on +host+ - # using the given account and password. +path+ will be the root - # path of the uploader. - def initialize(path, host, account, password) - @created = Hash.new - @path = path - @ftp = Net::FTP.new(host, account, password) - makedirs(@path) - @ftp.chdir(@path) - end - - # Create the directory +path+ in the uploader root path. - def makedirs(path) - route = [] - File.split(path).each do |dir| - route << dir - current_dir = File.join(route) - if @created[current_dir].nil? - @created[current_dir] = true - $stderr.puts "Creating Directory #{current_dir}" if @verbose - @ftp.mkdir(current_dir) rescue nil - end - end - end - - # Upload all files matching +wildcard+ to the uploader's root - # path. - def upload_files(wildcard) - FileList.glob(wildcard).each do |fn| - upload(fn) - end - end - - # Close the uploader. - def close - @ftp.close - end - - private # -------------------------------------------------------- - - # Upload a single file to the uploader's root path. - def upload(file) - $stderr.puts "Uploading #{file}" if @verbose - dir = File.dirname(file) - makedirs(dir) - @ftp.putbinaryfile(file, file) unless File.directory?(file) - end - end -end diff --git a/lib/rake/contrib/sshpublisher.rb b/lib/rake/contrib/sshpublisher.rb deleted file mode 100644 index b0048307c..000000000 --- a/lib/rake/contrib/sshpublisher.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'rake/dsl_definition' -require 'rake/contrib/compositepublisher' - -module Rake - # Publish an entire directory to an existing remote directory using - # SSH. - class SshDirPublisher - include Rake::DSL - - # Creates an SSH publisher which will scp all files in +local_dir+ to - # +remote_dir+ on +host+ - - def initialize(host, remote_dir, local_dir) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - end - - # Uploads the files - - def upload - sh "scp", "-rq", "#{@local_dir}/*", "#{@host}:#{@remote_dir}" - end - end - - # Publish an entire directory to a fresh remote directory using SSH. - class SshFreshDirPublisher < SshDirPublisher - - # Uploads the files after removing the existing remote directory. - - def upload - sh "ssh", @host, "rm", "-rf", @remote_dir rescue nil - sh "ssh", @host, "mkdir", @remote_dir - super - end - end - - # Publish a list of files to an existing remote directory. - class SshFilePublisher - include Rake::DSL - - # Creates an SSH publisher which will scp all +files+ in +local_dir+ to - # +remote_dir+ on +host+. - - def initialize(host, remote_dir, local_dir, *files) - @host = host - @remote_dir = remote_dir - @local_dir = local_dir - @files = files - end - - # Uploads the files - - def upload - @files.each do |fn| - sh "scp", "-q", "#{@local_dir}/#{fn}", "#{@host}:#{@remote_dir}" - end - end - end -end