[前][次][番号順一覧][スレッド一覧]

ruby-changes:13441

From: nobu <ko1@a...>
Date: Sun, 4 Oct 2009 00:40:36 +0900 (JST)
Subject: [ruby-changes:13441] Ruby:r25214 (trunk): * lib/rake/contrib: added.

nobu	2009-10-04 00:40:20 +0900 (Sun, 04 Oct 2009)

  New Revision: 25214

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25214

  Log:
    * lib/rake/contrib: added.  [ruby-core:25918]

  Added directories:
    trunk/lib/rake/contrib/
  Added files:
    trunk/lib/rake/contrib/compositepublisher.rb
    trunk/lib/rake/contrib/ftptools.rb
    trunk/lib/rake/contrib/publisher.rb
    trunk/lib/rake/contrib/rubyforgepublisher.rb
    trunk/lib/rake/contrib/sshpublisher.rb
  Modified files:
    trunk/ChangeLog
    trunk/version.h

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25213)
+++ ChangeLog	(revision 25214)
@@ -1,3 +1,7 @@
+Sun Oct  4 00:40:18 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/rake/contrib: added.  [ruby-core:25918]
+
 Sat Oct  3 22:14:18 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (bv_decls, bvar): fix for block variables.
Index: lib/rake/contrib/publisher.rb
===================================================================
--- lib/rake/contrib/publisher.rb	(revision 0)
+++ lib/rake/contrib/publisher.rb	(revision 25214)
@@ -0,0 +1,73 @@
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@w...)
+# All rights reserved.
+
+# Permission is granted for use, copying, modification, distribution,
+# and distribution of modified versions of this work as long as the
+# above copyright notice is included.
+
+# Configuration information about an upload host system.
+# * name   :: Name of host system.
+# * webdir :: Base directory for the web information for the
+#             application.  The application name (APP) is appended to
+#             this directory before using.
+# * pkgdir :: Directory on the host system where packages can be
+#             placed.
+HostInfo = Struct.new(:name, :webdir, :pkgdir)
+
+# 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
+
+# Publish an entire directory to an existing remote directory using
+# SSH.
+class SshDirPublisher
+  def initialize(host, remote_dir, local_dir)
+    @host = host
+    @remote_dir = remote_dir
+    @local_dir = local_dir
+  end
+
+  def upload
+    run %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}}
+  end
+end
+
+# Publish an entire directory to a fresh remote directory using SSH.
+class SshFreshDirPublisher < SshDirPublisher
+  def upload
+    run %{ssh #{@host} rm -rf #{@remote_dir}} rescue nil
+    run %{ssh #{@host} mkdir #{@remote_dir}}
+    super
+  end
+end
+
+# Publish a list of files to an existing remote directory.
+class SshFilePublisher
+  # Create a publisher using the give host information.
+  def initialize(host, remote_dir, local_dir, *files)
+    @host = host
+    @remote_dir = remote_dir
+    @local_dir = local_dir
+    @files = files
+  end
+
+  # Upload the local directory to the remote directory.
+  def upload
+    @files.each do |fn|
+      run %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
+    end
+  end
+end

Property changes on: lib/rake/contrib/publisher.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: lib/rake/contrib/compositepublisher.rb
===================================================================
--- lib/rake/contrib/compositepublisher.rb	(revision 0)
+++ lib/rake/contrib/compositepublisher.rb	(revision 25214)
@@ -0,0 +1,20 @@
+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

Property changes on: lib/rake/contrib/compositepublisher.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: lib/rake/contrib/rubyforgepublisher.rb
===================================================================
--- lib/rake/contrib/rubyforgepublisher.rb	(revision 0)
+++ lib/rake/contrib/rubyforgepublisher.rb	(revision 25214)
@@ -0,0 +1,16 @@
+require 'rake/contrib/sshpublisher'
+
+module Rake
+
+  class RubyForgePublisher < SshDirPublisher
+    attr_reader :project, :proj_id, :user
+
+    def initialize(projname, user)
+      super(
+        "#{user}@rubyforge.org",
+        "/var/www/gforge-projects/#{projname}",
+        "html")
+    end
+  end
+
+end

Property changes on: lib/rake/contrib/rubyforgepublisher.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: lib/rake/contrib/ftptools.rb
===================================================================
--- lib/rake/contrib/ftptools.rb	(revision 0)
+++ lib/rake/contrib/ftptools.rb	(revision 25214)
@@ -0,0 +1,151 @@
+# = Tools for FTP uploading.
+#
+# This file is still under development and is not released for general
+# use.
+
+require 'date'
+require 'net/ftp'
+
+module Rake # :nodoc:
+
+  ####################################################################
+  # <b>Note:</b> <em> Not released for general use.</em>
+  class FtpFile
+    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, line, @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
+        h, m = d3.split(':')
+        result = Time.parse("#{d1} #{d2} #{now.year} #{d3}")
+        if result > now
+          result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}")
+        end
+      else
+        result = Time.parse("#{d1} #{d2} #{d3}")
+      end
+      result
+#       elements = ParseDate.parsedate("#{d1} #{d2} #{d3}")
+#       if elements[0].nil?
+#         today = self.class.date.today
+#         if elements[1] > today.month
+#           elements[0] = today.year - 1
+#         else
+#           elements[0] = today.year
+#         end
+#       end
+#       elements = elements.collect { |el| el.nil? ? 0 : el }
+#       Time.mktime(*elements[0,7])
+    end
+  end
+
+  ####################################################################
+  # Manage the uploading of files to an FTP account.
+  class FtpUploader
+
+    # 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 targetting 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
+          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)
+      Dir[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)
+      puts "Uploading #{file}" if @verbose
+      dir = File.dirname(file)
+      makedirs(dir)
+      @ftp.putbinaryfile(file, file) unless File.directory?(file)
+    end
+  end
+end

Property changes on: lib/rake/contrib/ftptools.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: lib/rake/contrib/sshpublisher.rb
===================================================================
--- lib/rake/contrib/sshpublisher.rb	(revision 0)
+++ lib/rake/contrib/sshpublisher.rb	(revision 25214)
@@ -0,0 +1,45 @@
+require 'rake/contrib/compositepublisher'
+
+module Rake
+
+  # Publish an entire directory to an existing remote directory using
+  # SSH.
+  class SshDirPublisher
+    def initialize(host, remote_dir, local_dir)
+      @host = host
+      @remote_dir = remote_dir
+      @local_dir = local_dir
+    end
+
+    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
+    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
+    # Create a publisher using the give host information.
+    def initialize(host, remote_dir, local_dir, *files)
+      @host = host
+      @remote_dir = remote_dir
+      @local_dir = local_dir
+      @files = files
+    end
+
+    # Upload the local directory to the remote directory.
+    def upload
+      @files.each do |fn|
+        sh %{scp -q #{@local_dir}/#{fn} #{@host}:#{@remote_dir}}
+      end
+    end
+  end
+end

Property changes on: lib/rake/contrib/sshpublisher.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: version.h
===================================================================
--- version.h	(revision 25213)
+++ version.h	(revision 25214)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_RELEASE_DATE "2009-10-03"
+#define RUBY_RELEASE_DATE "2009-10-04"
 #define RUBY_PATCHLEVEL -1
 #define RUBY_BRANCH_NAME "trunk"
 
@@ -8,7 +8,7 @@
 #define RUBY_VERSION_TEENY 1
 #define RUBY_RELEASE_YEAR 2009
 #define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 3
+#define RUBY_RELEASE_DAY 4
 
 #include "ruby/version.h"
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]