Class: Gem::Commands::SkeletonCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::SkeletonCommand
- Defined in:
- lib/rubygems/commands/skeleton_command.rb
Defined Under Namespace
Classes: TemplateRenderer
Instance Method Summary collapse
- #arguments ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ SkeletonCommand
constructor
A new instance of SkeletonCommand.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ SkeletonCommand
Returns a new instance of SkeletonCommand.
8 9 10 |
# File 'lib/rubygems/commands/skeleton_command.rb', line 8 def initialize super 'skeleton', 'Create the skeleton for a new gem' end |
Instance Method Details
#arguments ⇒ Object
12 13 14 |
# File 'lib/rubygems/commands/skeleton_command.rb', line 12 def arguments 'GEMNAME name of gem to create a skeleton for' end |
#execute ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rubygems/commands/skeleton_command.rb', line 20 def execute gem_name = get_all_gem_names[0] camelized_gem_name = gem_name.camelize # make directory for gem if File.exists?(gem_name) raise "#{gem_name} directory already exists" else Dir.mkdir gem_name end safe_create_dir(File.join(gem_name, 'lib')) safe_create_dir(File.join(gem_name, 'lib', gem_name)) safe_create_dir(File.join(gem_name, 'spec')) renderer = TemplateRenderer.new(gem_name) renderer.render('gitignore', '.gitignore') renderer.render('Gemfile', 'Gemfile') renderer.render('README.rdoc', 'README.rdoc') renderer.render('CHANGELOG.rdoc', 'CHANGELOG.rdoc') renderer.render('LICENSE.txt', 'LICENSE.txt') renderer.render('Rakefile', 'Rakefile') renderer.render('lib_base.rb', File.join('lib', "#{gem_name}.rb")) renderer.render('version.rb', File.join('lib', gem_name, 'version.rb')) renderer.render('spec_helper.rb', File.join('spec', 'spec_helper.rb')) renderer.render('gemspec', "#{gem_name}.gemspec") puts renderer.render('POST_INSTALL_MESSAGE') end |
#usage ⇒ Object
16 17 18 |
# File 'lib/rubygems/commands/skeleton_command.rb', line 16 def usage "#{program_name} GEMNAME" end |