Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* 1 major enhancement

  * Create trunk/branches/tags subfolders using -s/--svn option
* 6 minor enhancements
  * Modified spec.rb template for new rpec syntax (describe "..." { it "..." }) [thx Aslak Hellesøy]


git-svn-id: svn+ssh://rubyforge.org/var/svn/newgem/trunk@84 b8dfb574-5f1f-0410-9469-b441dc4e948f
  • Loading branch information...
commit 1e79cf8253b63bb0919fe9fb7ca909a78e5d6764 1 parent c7a31fb
nicwilliams authored
View
9 History.txt
@@ -1,11 +1,14 @@
-== TRUNK
+== 0.11.0
-* 5 minor enhancements
+* 1 major enhancement
+ * Create trunk/branches/tags subfolders using -s/--svn option
+* 6 minor enhancements
+ * Added dependency to activesupport gem
+ * Modified spec.rb template for new rpec syntax (describe "..." { it "..." }) [thx Aslak Hellesøy]
* Added 'email.txt' to the CLEAN list to be removed on 'rake clean'
* Added --delete-excluded to the rsync command [thx Jeroen Janssen]
* On template: "Version" is in <p>'s
* Specified CLEAN is added/or'd with default Hoe clean_globs (via |=)
- * Added dependency to activesupport gem
* 1 website enhancement
* Refreshed the example output as its a big old (CHANGELOG -> History.txt)
* Removed the "click anywhere" javascript in version box - it was playing up with the link to the book
View
6 Todo.txt
@@ -1,2 +1,4 @@
-+ can generate rspec default tests (or still test::unit tests) using --with-test=rspec [thx Robby Russell]
-+ website components are now optional (-w/--no-website)
+== Todo list
+* can generate rspec default tests (or still test::unit tests) using --with-test=rspec [thx Robby Russell]
+* website components are now optional (-w/--no-website)
+* provide option to generate <gemname>/trunk,branches,tags structure and insert files into trunk [-s/--svn]
View
536 bin/newgem
@@ -1,262 +1,276 @@
-#!/usr/bin/env ruby
-
-begin
- require 'rubygems'
-rescue LoadError
- # no rubygems to load, so we fail silently
-end
-
-require 'fileutils'
-require 'active_support'
-require 'optparse'
-
-require 'newgem'
-
-templates = File.dirname(__FILE__) + '/../templates/'
-
-OPTIONS = {
- :import_path => nil,
- :version => '0.0.1',
- :full_name => nil,
- :email => nil,
- :bin_name => nil,
- :test_framework => 'test::unit'
-}
-parser = OptionParser.new do |opts|
- opts.banner = <<BANNER
-Take any library or Rails plugin or command line application,
-gemify it, and easily share it with the Ruby world.
-
-Usage: #{File.basename($0)} [options] <name of gem>
-
-Options are:
-BANNER
- opts.separator ""
- opts.on("-b", "--bin-name=BIN_NAME[,BIN_NAME2]", String,
- "Sets up executable scripts in the bin folder.",
- "Default: none") { |OPTIONS[:bin_name]| }
- opts.on("-i", "--import_path=PATH", String,
- "Path where your files could be copied from.",
- "Default: none") { |OPTIONS[:import_path]| }
- opts.on("-n", "--full_name=PATH", String,
- "Your name to be inserted into generated files.",
- "Default: ~/.rubyforge/user-config.yml[user_name]") { |OPTIONS[:full_name]| }
- opts.on("-e", "--email=PATH", String,
- "Your email to be inserted into generated files.",
- "Default: ~/.rubyforge/user-config.yml[email]") { |OPTIONS[:email]| }
- opts.on("-t", "--test-with=TEST_FRAMEWORK", String,
- "Your preferred testing framework: Options: test::unit (default), rspec.",
- "Default: test::unit") { |OPTIONS[:test_framework]| }
- opts.on("-v", "--version=YOUR_VERSION", String,
- "Version of the gem you are creating.",
- "Default: 0.0.1") { |OPTIONS[:version]| }
- opts.on("-h", "--help",
- "Show this help message.") { puts opts; exit }
- opts.parse!(ARGV)
-end
-OPTIONS[:version] = OPTIONS[:version].to_s.split(/\./)
-version_str = OPTIONS[:version].join('.')
-author = OPTIONS[:full_name]
-email = OPTIONS[:email]
-unless author && email
- rubyforge_config = Newgem::Rubyforge.new
- author ||= rubyforge_config.full_name
- email ||= rubyforge_config.email
-end
-test_framework = OPTIONS[:test_framework]
-
-gem_name = project_name = ARGV[0]
-parser.parse!(["-h"]) unless gem_name
-
-module_name = project_name.classify
-lib = project_name + '/lib'
-lib_project_name = project_name + '/lib/' + project_name
-version = project_name + "/lib/" + project_name + "/version.rb"
-readme, setup = %w(README.txt setup.rb).
- collect {|f| project_name + '/' + f}
-template_files = %w(Rakefile History.txt License.txt Manifest.txt scripts/txt2html website/index.txt website/index.html website/template.rhtml)
-copy_files = %w(website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css)
-
-main = project_name + "/lib/" + project_name + ".rb"
-
-examples = project_name + '/examples'
-bin = project_name + '/bin'
-folders = %w( scripts website website/javascripts website/stylesheets)
-
-FileUtils.rm_rf project_name
-
-puts "creating: " + project_name
-Dir.mkdir project_name
-
-puts "creating: " + readme
-File.open(readme, 'w') do |file|
- file << <<-eos
-README for #{project_name}
-===========#{'=' * project_name.length}
-
-eos
-end
-
-
-puts "creating: " + lib
-FileUtils.mkdir_p lib
-
-folders.each do |folder|
- new_folder = project_name + '/' + folder
- puts "creating: " + new_folder
- FileUtils.mkdir_p new_folder
-end
-
-if OPTIONS[:import_path]
- require 'fileutils'
- OPTIONS[:import_path].chomp! if OPTIONS[:import_path][-1] == 47 # /
- FileUtils.cp_r OPTIONS[:import_path] + '/.', lib, :preserve => true
-end
-
-puts "creating: " + lib_project_name
-FileUtils.mkdir_p lib_project_name
-
-puts "creating: " + main
-File.open(main, 'w') do |file|
- file << <<-EOS
-module #{module_name}
-end
-
-require '#{project_name}/version'
- EOS
-end
-
-puts "creating: " + version
-File.open(version, 'w') do |file|
- file << <<-EOS
-module #{module_name} #:nodoc:
- module VERSION #:nodoc:
- MAJOR = #{OPTIONS[:version][0] || '0'}
- MINOR = #{OPTIONS[:version][1] || '0'}
- TINY = #{OPTIONS[:version][2] || '0'}
-
- STRING = [MAJOR, MINOR, TINY].join('.')
- end
-end
- EOS
-end
-
-puts "creating: " + bin
-Dir.mkdir bin
-
-if OPTIONS[:bin_name]
- bin_names_list = OPTIONS[:bin_name].split(',')
- template = File.open(templates + 'app.rb','r') {|f| f.readlines.join}
- bin_names_list.each do |bin_name|
- puts "creating: " + bin + '/' + bin_name
- File.open(bin + '/' + bin_name, 'w') do |file|
- file << eval('"' + template.gsub(/"/, '\"') + '"')
- end
- end
- bin_names = bin_names_list.join(' ')
-else
- bin_names = ''
- bin_names_list = []
-end
-
-# Setup spec/test::unit environments
-# Would like to refactor this...
-if test_framework == 'rspec'
- test = project_name + "/spec"
- test_helper = test + "/spec_helper.rb"
- test_template = 'spec.rb'
- unit_test = test + "/" + project_name + "_spec.rb"
- test_file_prefix = 'spec/NAME_spec'
- spec_opts = 'spec.opts'
- unit_test_template = <<-eos
-require 'spec'
-eos
- requirements = <<-eos
-begin
- require 'spec/rake/spectask'
-rescue LoadError
- puts 'To use rspec for testing you must install rspec gem:'
- puts '$ sudo gem install rspec'
- exit
-end
- eos
- test_task = <<-eos
-desc "Run the specs under spec/models"
-Spec::Rake::SpecTask.new do |t|
- t.spec_opts = ['--options', "spec/spec.opts"]
- t.spec_files = FileList['spec/*_spec.rb']
-end
-
-desc "Default task is to run specs"
-task :default => :spec
- eos
-else
- test = project_name + "/test"
- test_helper = test + "/test_helper.rb"
- test_template = 'test.rb'
- unit_test = test + "/test_" + project_name + ".rb"
- test_file_prefix = 'test/test_NAME'
- unit_test_template = <<-eos
-require 'test/unit'
-require File.dirname(__FILE__) + '/../lib/#{project_name}'
-eos
- requirements = ''
- test_task = ''
-end
-
-puts "creating: " + test
-Dir.mkdir test
-
-puts "creating: " + test_helper
-File.open(test_helper, 'w') do |file|
- file << unit_test_template
-end
-
-puts "creating: " + unit_test
-
-template = File.open(templates + test_template,'r') {|f| f.readlines.join}
-File.open(unit_test, 'w') do |file|
- file << eval('"' + template.gsub(/"/, '\"') + '"')
-end
-
-if test_framework == 'rspec'
- spec_opts_file = test + "/" + spec_opts
- puts "creating: " + spec_opts_file
- template = File.open(templates + spec_opts, 'r') { |f| f.readlines.join }
- File.open(spec_opts_file, 'w') do |file|
- file << eval('"' + template.gsub(/"/, '\""') + '"')
- end
-end
-
-puts "creating: " + examples
-Dir.mkdir examples
-
-puts "creating: " + setup
-template = File.open(templates + 'setup.rb','r') {|f| f.readlines.join}
-File.open(setup, 'w') do |file|
- file << template
-end
-
-bin_names_list = bin_names_list.collect {|name| 'bin/' + name }.join("\n")
-bin_names_list += "\n" if bin_names_list.size > 0
-test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| test_file_prefix.gsub('NAME', name) }.join("\n")
-
-template_files.each do |template_file|
- puts "creating: " + project_name + '/' + template_file
- template = File.open(templates + template_file,'r') {|f| f.readlines.join}
- File.open(project_name + '/' + template_file, 'w') do |file|
- file << eval('"' + template.gsub(/"/, '\"') + '"')
- end
-end
-
-copy_files.each do |file|
- puts "copying: " + project_name + '/' + file
- template = File.open(templates + file,'r') {|f| f.readlines.join}
- File.open(project_name + '/' + file, 'w') do |file|
- file << template
- end
-end
-
-
-
+#!/usr/bin/env ruby
+
+begin
+ require 'rubygems'
+rescue LoadError
+ # no rubygems to load, so we fail silently
+end
+
+require 'fileutils'
+require 'active_support'
+require 'optparse'
+
+require 'newgem'
+
+templates = File.dirname(__FILE__) + '/../templates/'
+
+OPTIONS = {
+ :import_path => nil,
+ :version => '0.0.1',
+ :full_name => nil,
+ :email => nil,
+ :bin_name => nil,
+ :svn_struct => nil,
+ :test_framework => 'test::unit'
+}
+parser = OptionParser.new do |opts|
+ opts.banner = <<BANNER
+Take any library or Rails plugin or command line application,
+gemify it, and easily share it with the Ruby world.
+
+Usage: #{File.basename($0)} [options] <gemname>
+
+Options are:
+BANNER
+ opts.separator ""
+ opts.on("-b", "--bin-name=BIN_NAME[,BIN_NAME2]", String,
+ "Sets up executable scripts in the bin folder.",
+ "Default: none") { |OPTIONS[:bin_name]| }
+ opts.on("-i", "--import_path=PATH", String,
+ "Path where your files could be copied from.",
+ "Default: none") { |OPTIONS[:import_path]| }
+ opts.on("-n", "--full_name=PATH", String,
+ "Your name to be inserted into generated files.",
+ "Default: ~/.rubyforge/user-config.yml[user_name]") { |OPTIONS[:full_name]| }
+ opts.on("-e", "--email=PATH", String,
+ "Your email to be inserted into generated files.",
+ "Default: ~/.rubyforge/user-config.yml[email]") { |OPTIONS[:email]| }
+ opts.on("-s", "--svn",
+ "Creates trunk/branches/tags folders beneath <gemname> folder.",
+ "Generated gem placed in trunk folder.") { |OPTIONS[:svn_struct]| }
+ opts.on("-t", "--test-with=TEST_FRAMEWORK", String,
+ "Select your preferred testing framework.",
+ "Options: test::unit (default), rspec.") { |OPTIONS[:test_framework]| }
+ opts.on("-v", "--version=YOUR_VERSION", String,
+ "Version of the gem you are creating.",
+ "Default: 0.0.1") { |OPTIONS[:version]| }
+ opts.on("-h", "--help",
+ "Show this help message.") { puts opts; exit }
+ opts.parse!(ARGV)
+end
+OPTIONS[:version] = OPTIONS[:version].to_s.split(/\./)
+version_str = OPTIONS[:version].join('.')
+author = OPTIONS[:full_name]
+email = OPTIONS[:email]
+svn_struct = OPTIONS[:svn_struct]
+unless author && email
+ rubyforge_config = Newgem::Rubyforge.new
+ author ||= rubyforge_config.full_name
+ email ||= rubyforge_config.email
+end
+test_framework = OPTIONS[:test_framework]
+
+gem_name = project_name = ARGV[0]
+parser.parse!(["-h"]) unless gem_name
+
+module_name = project_name.classify
+root = project_name + (svn_struct ? '/trunk' : '')
+lib = root + '/lib'
+lib_project_name = root + '/lib/' + project_name
+version = root + "/lib/" + project_name + "/version.rb"
+readme, setup = %w(README.txt setup.rb).
+ collect {|f| root + '/' + f}
+template_files = %w(Rakefile History.txt License.txt Manifest.txt scripts/txt2html website/index.txt website/index.html website/template.rhtml)
+copy_files = %w(website/javascripts/rounded_corners_lite.inc.js website/stylesheets/screen.css)
+
+main = root + "/lib/" + project_name + ".rb"
+
+examples = root + '/examples'
+bin = root + '/bin'
+folders = %w( scripts website website/javascripts website/stylesheets)
+
+FileUtils.rm_rf project_name
+
+puts "creating: " + project_name
+Dir.mkdir project_name
+
+if svn_struct
+ %w[trunk branches tags].each do |folder|
+ folder_path = File.join(project_name, folder)
+ puts "creating: " + folder_path
+ Dir.mkdir folder_path
+ end
+end
+
+puts "creating: " + readme
+File.open(readme, 'w') do |file|
+ file << <<-eos
+README for #{project_name}
+===========#{'=' * project_name.length}
+
+eos
+end
+
+
+puts "creating: " + lib
+FileUtils.mkdir_p lib
+
+folders.each do |folder|
+ new_folder = root + '/' + folder
+ puts "creating: " + new_folder
+ FileUtils.mkdir_p new_folder
+end
+
+if OPTIONS[:import_path]
+ require 'fileutils'
+ OPTIONS[:import_path].chomp! if OPTIONS[:import_path][-1] == 47 # /
+ FileUtils.cp_r OPTIONS[:import_path] + '/.', lib, :preserve => true
+end
+
+puts "creating: " + lib_project_name
+FileUtils.mkdir_p lib_project_name
+
+puts "creating: " + main
+File.open(main, 'w') do |file|
+ file << <<-EOS
+module #{module_name}
+end
+
+require '#{project_name}/version'
+ EOS
+end
+
+puts "creating: " + version
+File.open(version, 'w') do |file|
+ file << <<-EOS
+module #{module_name} #:nodoc:
+ module VERSION #:nodoc:
+ MAJOR = #{OPTIONS[:version][0] || '0'}
+ MINOR = #{OPTIONS[:version][1] || '0'}
+ TINY = #{OPTIONS[:version][2] || '0'}
+
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+end
+ EOS
+end
+
+puts "creating: " + bin
+Dir.mkdir bin
+
+if OPTIONS[:bin_name]
+ bin_names_list = OPTIONS[:bin_name].split(',')
+ template = File.open(templates + 'app.rb','r') {|f| f.readlines.join}
+ bin_names_list.each do |bin_name|
+ puts "creating: " + bin + '/' + bin_name
+ File.open(bin + '/' + bin_name, 'w') do |file|
+ file << eval('"' + template.gsub(/"/, '\"') + '"')
+ end
+ end
+ bin_names = bin_names_list.join(' ')
+else
+ bin_names = ''
+ bin_names_list = []
+end
+
+# Setup spec/test::unit environments
+# Would like to refactor this...
+if test_framework == 'rspec'
+ test = root + "/spec"
+ test_helper = test + "/spec_helper.rb"
+ test_template = 'spec.rb'
+ unit_test = test + "/" + project_name + "_spec.rb"
+ test_file_prefix = 'spec/NAME_spec'
+ spec_opts = 'spec.opts'
+ unit_test_template = <<-eos
+require 'spec'
+eos
+ requirements = <<-eos
+begin
+ require 'spec/rake/spectask'
+rescue LoadError
+ puts 'To use rspec for testing you must install rspec gem:'
+ puts '$ sudo gem install rspec'
+ exit
+end
+ eos
+ test_task = <<-eos
+desc "Run the specs under spec/models"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_opts = ['--options', "spec/spec.opts"]
+ t.spec_files = FileList['spec/*_spec.rb']
+end
+
+desc "Default task is to run specs"
+task :default => :spec
+ eos
+else
+ test = root + "/test"
+ test_helper = test + "/test_helper.rb"
+ test_template = 'test.rb'
+ unit_test = test + "/test_" + project_name + ".rb"
+ test_file_prefix = 'test/test_NAME'
+ unit_test_template = <<-eos
+require 'test/unit'
+require File.dirname(__FILE__) + '/../lib/#{project_name}'
+eos
+ requirements = ''
+ test_task = ''
+end
+
+puts "creating: " + test
+Dir.mkdir test
+
+puts "creating: " + test_helper
+File.open(test_helper, 'w') do |file|
+ file << unit_test_template
+end
+
+puts "creating: " + unit_test
+
+template = File.open(templates + test_template,'r') {|f| f.readlines.join}
+File.open(unit_test, 'w') do |file|
+ file << eval('"' + template.gsub(/"/, '\"') + '"')
+end
+
+if test_framework == 'rspec'
+ spec_opts_file = test + "/" + spec_opts
+ puts "creating: " + spec_opts_file
+ template = File.open(templates + spec_opts, 'r') { |f| f.readlines.join }
+ File.open(spec_opts_file, 'w') do |file|
+ file << eval('"' + template.gsub(/"/, '\""') + '"')
+ end
+end
+
+puts "creating: " + examples
+Dir.mkdir examples
+
+puts "creating: " + setup
+template = File.open(templates + 'setup.rb','r') {|f| f.readlines.join}
+File.open(setup, 'w') do |file|
+ file << template
+end
+
+bin_names_list = bin_names_list.collect {|name| 'bin/' + name }.join("\n")
+bin_names_list += "\n" if bin_names_list.size > 0
+test_names_list = ['helper.rb',"#{project_name}.rb"].sort.collect {|name| test_file_prefix.gsub('NAME', name) }.join("\n")
+
+template_files.each do |template_file|
+ puts "creating: " + root + '/' + template_file
+ template = File.open(templates + template_file,'r') {|f| f.readlines.join}
+ File.open(root + '/' + template_file, 'w') do |file|
+ file << eval('"' + template.gsub(/"/, '\"') + '"')
+ end
+end
+
+copy_files.each do |file|
+ puts "copying: " + root + '/' + file
+ template = File.open(templates + file,'r') {|f| f.readlines.join}
+ File.open(root + '/' + file, 'w') do |file|
+ file << template
+ end
+end
+
+
+
puts "NOW - update #{gem_name}/Rakefile with gem description, etc"
View
4 lib/newgem/version.rb
@@ -1,8 +1,8 @@
module Newgem #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
- MINOR = 10
- TINY = 4
+ MINOR = 11
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
6 templates/spec.rb
@@ -2,10 +2,10 @@
# Time to add your specs!
# http://rspec.rubyforge.org/
-context "Place your specs here" do
+describe "Place your specs here" do
- specify "find this spec in spec directory" do
- violate "Be sure to write your specs"
+ it "find this spec in spec directory" do
+ violated "Be sure to write your specs"
end
end
View
7 website/index.html
@@ -33,7 +33,7 @@
<h1>New Gem Generator</h1>
<div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
<p>Get Version</p>
- <a href="http://rubyforge.org/projects/newgem" class="numbers">0.10.4</a>
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">0.11.0</a>
<p>Featured in</p>
<a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
</div>
@@ -104,6 +104,9 @@
<p>As of 0.10.0 &#8211; you can generate test::unit or rspec test stubs via the <code>-t</code> or <code>--test-with</code> options. For example, <code>-t rspec</code> generates a <code>spec</code> folder with some test stubs.</p>
+ <p>As of 0.11.0 &#8211; you can generate <code>wizzo/trunk|branches|tags</code> subfolders using the <code>-s</code> or <code>--svn</code> options. If used, the generated files will be populated within <code>&lt;gemname&gt;/trunk</code></p>
+
+
<h3>Setup</h3>
@@ -310,7 +313,7 @@
<p>Comments are welcome. Send an email to <a href="mailto:drnicwilliams@gmail.com">Dr Nic Williams</a>.</p>
<p class="coda">
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 2nd June 2007<br>
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 6th June 2007<br>
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
</p>
</div>
View
2  website/index.txt
@@ -55,6 +55,8 @@ NOW - update wizzo/Rakefile with gem description, etc
As of 0.10.0 - you can generate test::unit or rspec test stubs via the <code>-t</code> or <code>--test-with</code> options. For example, <code>-t rspec</code> generates a <code>spec</code> folder with some test stubs.
+As of 0.11.0 - you can generate <code>wizzo/trunk|branches|tags</code> subfolders using the <code>-s</code> or <code>--svn</code> options. If used, the generated files will be populated within <code><gemname>/trunk</code>
+
h3. Setup
Now modify the constants at the top of *Rakefile*, with your name, email and the location where you'll host your website for the gem. The defaults are tied to RubyForge for uploading the gems and the website (see below).
View
2  website/rubyforge.html
@@ -33,7 +33,7 @@
<h1>New Gem Generator</h1>
<div id="version"> <!-- class="clickable" onclick='document.location = "http://rubyforge.org/projects/newgem"; return true' -->
<p>Get Version</p>
- <a href="http://rubyforge.org/projects/newgem" class="numbers">0.10.4</a>
+ <a href="http://rubyforge.org/projects/newgem" class="numbers">0.11.0</a>
<p>Featured in</p>
<a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FBeginning-Ruby-Novice-Professional-Experts%2Fdp%2F1590597664%2F&tag=drnic-20&linkCode=ur2&camp=1789&creative=9325" class="book"><img src="images/beginning-ruby.jpg" /></a>
</div>
View
2  website/version-raw.js
@@ -1,3 +1,3 @@
// Announcement JS file
-var version = "0.10.4";
+var version = "0.11.0";
MagicAnnouncement.show('compositekeys', version);
View
2  website/version.js
@@ -1,4 +1,4 @@
// Version JS file
-var version = "0.10.4";
+var version = "0.11.0";
document.write(" - " + version);
Please sign in to comment.
Something went wrong with that request. Please try again.