lib/ronin/gen/generators/repository.rb in ronin-gen-1.0.0.pre1 vs lib/ronin/gen/generators/repository.rb in ronin-gen-1.0.0.pre2
- old
+ new
@@ -41,42 +41,46 @@
# Default license to use
DEFAULT_LICENSE = 'CC-by'
# Default authors to use
- DEFAULT_AUTHORS = {'Name' => 'name@example.com'}
+ DEFAULT_AUTHORS = ['Anonymous']
# Default description to use
DEFAULT_DESCRIPTION = 'This is a Ronin Repository'
desc 'Generates a new Ronin Repository'
class_option :title, :type => :string
class_option :uri, :type => :string
class_option :source, :type => :string
class_option :website, :type => :string
- class_option :license, :type => :string, :default => DEFAULT_LICENSE
- class_option :description, :type => :string, :default => DEFAULT_DESCRIPTION
- class_option :authors, :type => :hash, :default => DEFAULT_AUTHORS, :banner => 'NAME:EMAIL ...'
- class_option :test_suite, :type => :string, :banner => 'test_unit|rspec'
+
+ class_option :license, :type => :string,
+ :default => DEFAULT_LICENSE,
+ :banner => 'LICENSE'
+
+ class_option :description, :type => :string,
+ :default => DEFAULT_DESCRIPTION,
+ :banner => 'TEXT'
+
+ class_option :authors, :type => :array,
+ :default => DEFAULT_AUTHORS,
+ :banner => 'NAME [...]'
+
+ class_option :tests, :type => :boolean
class_option :docs, :type => :boolean
def setup
@title = options[:title]
@uri = options[:uri]
@source = options[:source]
@website = options[:website]
@license = options[:license]
@description = options[:description]
@authors = options[:authors]
- @gems = options[:gems]
- @test_suite = case options[:test_suite]
- when 'test', 'test_unit'
- :test_unit
- when 'spec', 'rspec'
- :rspec
- end
+ @test_suite = options[:test]
@docs = options[:docs]
@title ||= File.basename(self.path).gsub(/[_\s]+/,' ').capitalize
@website ||= @source
end
@@ -95,25 +99,33 @@
#
# Generates the Rakefile of the repository.
#
def rakefile
- erb File.join('ronin','gen','repository','Rakefile.erb'), 'Rakefile'
+ erb File.join('ronin','gen','repository','Rakefile.erb'),
+ 'Rakefile'
end
#
- # Generates a base test suite for the repository.
+ # Generates a base RSpec test-suite for the repository.
#
- def test_suite
- case @test_suite
- when :test_unit
- mkdir 'test'
- when :rspec
+ def tests
+ if options.tests?
cp File.join('ronin','gen','repository','.rspec'), '.rspec'
mkdir 'spec'
cp File.join('ronin','gen','repository','spec','spec_helper.rb'),
File.join('spec','spec_helper.rb')
+ end
+ end
+
+ #
+ # Generate files needed for documentation.
+ #
+ def docs
+ if options.docs?
+ erb File.join('ronin','gen','repository','.yardopts.erb'),
+ '.yardopts'
end
end
#
# Generates the XML metadata file for the repository.