RubyForge create_project patch
--- ./bin/rubyforge.org 2007-07-03 08:19:46.437500000 +0900
+++ ./bin/rubyforge 2007-07-03 09:56:21.328125000 +0900
@@ -52,0 +53,7 @@
+ create_project(full_name, purpose, license, description, unix_name, scm)
+ creates a new project with the spec.
+
+ example :
+ #{ PROGRAM } create_project 'new project' 'purpose' 'Ruby License'
+ 'description' newproject svn
+
@@ -174,0 +182,13 @@
+when %r/create_project/
+ full_name, purpose, license, description, unix_name, scm = ARGV
+
+ abort "no <full_name>" unless full_name
+ abort "no <purpose>" unless purpose
+ abort "no <license>" unless license
+ abort "no <description>" unless description
+ abort "Maximum length for <description> is 255 chars" if 255 < description.length
+ abort "no <unix_name>" unless unix_name
+ abort "no <scm>" unless scm
+
+ rubyforge.create_project full_name, purpose, license, description,
+ unix_name, scm
--- ./lib/rubyforge.rb.org 2007-06-12 21:04:27.000000000 +0900
+++ ./lib/rubyforge.rb 2007-07-03 10:09:23.468750000 +0900
@@ -154,0 +155,74 @@
+ LICENSE = {
+ "None" => 100,
+ "GNU General Public License (GPL)" => 101,
+ "GNU Library Public License (LGPL)" => 102,
+ "BSD License" => 103,
+ "MIT License" => 104,
+ "Artistic License" => 105,
+ "Mozilla Public License 1.0 (MPL)" => 106,
+ "Qt Public License (QPL)" => 107,
+ "IBM Public License" => 108,
+ "MITRE Collaborative Virtual Workspace License (CVW License)" => 109,
+ "Ricoh Source Code Public License" => 110,
+ "Python License" => 111,
+ "zlib/libpng License" => 112,
+ "Apache Software License" => 113,
+ "Vovida Software License 1.0" => 114,
+ "Sun Internet Standards Source License (SISSL)" => 115,
+ "Intel Open Source License" => 116,
+ "Mozilla Public License 1.1 (MPL 1.1)" => 117,
+ "Jabber Open Source License" => 118,
+ "Nokia Open Source License" => 119,
+ "Sleepycat License" => 120,
+ "Nethack General Public License" => 121,
+ "IBM Common Public License" => 122,
+ "Apple Public Source License" => 123,
+ "Public Domain" => 124,
+ "Website Only" => 125,
+ "Other/Proprietary License" => 126,
+ "Ruby License" => 127,
+ }
+
+ def get_license(license)
+ LICENSE.each {|k, v|
+ if /#{license}/i =~ k
+ return v.to_s, ''
+ end
+ }
+ return '', license
+ end
+
+ def create_project(full_name, purpose, license, description, unix_name, scm)
+ # $DEBUG = true
+ page = '/register/projectinfo.php'
+
+ scm = 'scmcvs' if /\Acvs\z/i =~ scm
+ scm = 'scmsvn' if /\Asvn\z/i =~ scm
+
+ form = {
+ 'full_name' => full_name,
+ 'purpose' => purpose,
+ 'description' => description,
+ 'unix_name' => unix_name,
+ 'scm' => scm,
+ 'submit' => 'Submit',
+ }
+
+ form['license'], form['license_other'] = get_license(license)
+
+ response = run page, form
+ if $DEBUG
+ if response.include?('Unix name already taken')
+ puts 'Error: Unix name already taken'
+ elsif response.include?('Maximum length for Project Description is 255 chars')
+ puts 'Error: Maximum length for Project Description is 255 chars'
+ elsif response.include?('ERROR: Could not create group')
+ puts 'Error: Could not create group'
+ elsif response.include?('Your project has been submitted to the RubyForge administrators.')
+ puts 'Your project has been submitted to the RubyForge administrators. Within 72 hours, you will receive notification of their decision and further instructions.'
+ else
+ puts 'Error.'
+ end
+ end
+ end
+
--- ./test/test_rubyforge.rb.org 2007-06-12 21:04:27.015625000 +0900
+++ ./test/test_rubyforge.rb 2007-07-03 09:14:56.296875000 +0900
@@ -72,0 +73,25 @@
+ def test_create_project
+ @rubyforge.create_project('A new project', 'This is a new project.',
+ 'Ruby License',
+ 'A sample for creating a new project',
+ 'anewproject', 'svn')
+
+ util_run('/register/projectinfo.php',
+ 'full_name' =>'A new project',
+ 'purpose' =>'This is a new project.',
+ 'description' =>'A sample for creating a new project',
+ 'unix_name' =>'anewproject',
+ 'license' =>'127',
+ 'license_other' =>'',
+ 'scm' =>'scmsvn',
+ 'submit' =>'Submit')
+ end
+
+ def test_get_license
+ assert_equal(['127', ''], @rubyforge.get_license('Ruby License'))
+ assert_equal(['127', ''], @rubyforge.get_license('ruby license'))
+ assert_equal(['127', ''], @rubyforge.get_license('ruby'))
+ assert_equal(["", "Ruby's"], @rubyforge.get_license("Ruby's"))
+ assert_equal(['102', ''], @rubyforge.get_license('gpl'))
+ end
+
Last modified: 2007-07-03