Class: Corundum::CLI::Skelfiles
- Inherits:
-
Object
- Object
- Corundum::CLI::Skelfiles
- Defined in:
- lib/corundum/cli/skelfiles.rb
Defined Under Namespace
Classes: Skelfile, SkelfileScope
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
- #default_project_name ⇒ Object
- #go ⇒ Object
-
#initialize(args) ⇒ Skelfiles
constructor
A new instance of Skelfiles.
- #options ⇒ Object
- #parse_args ⇒ Object
- #scope ⇒ Object
- #skelfiles ⇒ Object
Constructor Details
#initialize(args) ⇒ Skelfiles
Returns a new instance of Skelfiles.
37 38 39 |
# File 'lib/corundum/cli/skelfiles.rb', line 37 def initialize(args) @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
40 41 42 |
# File 'lib/corundum/cli/skelfiles.rb', line 40 def args @args end |
Instance Method Details
#default_project_name ⇒ Object
63 64 65 |
# File 'lib/corundum/cli/skelfiles.rb', line 63 def default_project_name File.basename(Dir.pwd) end |
#go ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/corundum/cli/skelfiles.rb', line 85 def go parse_args skelfiles.each do |skelfile| skelfile.create!(scope) puts skelfile. end end |
#options ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/corundum/cli/skelfiles.rb', line 44 def ||= OptionParser.new do |opti| opti. = "Spits out skeleton files to start a gem with.\nUsage: #$0 [options]" opti.on("-h", "--help", "This help message") do puts opti puts "Will emit these files:" puts skelfiles.map{|desc| desc.target}.join(", ") puts puts "Files are copied from the skel-files directory out of this search path:" puts Corundum.configuration_store.valise exit 0 end opti.on("-p", "--project NAME", "Sets the name of the project (defaults to dirname, i.e. '#{default_project_name}')") do |name| #ok scope.project_name = name end end end |
#parse_args ⇒ Object
81 82 83 |
# File 'lib/corundum/cli/skelfiles.rb', line 81 def parse_args .parse(args) end |
#scope ⇒ Object
67 68 69 |
# File 'lib/corundum/cli/skelfiles.rb', line 67 def scope @scope ||= SkelfileScope.new(default_project_name) end |
#skelfiles ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/corundum/cli/skelfiles.rb', line 71 def skelfiles @skelfiles ||= [ Skelfile.new( 'rakefile', 'Rakefile', Rake::Application::DEFAULT_RAKEFILES), Skelfile.new( 'simplecov', '.simplecov', %w[.simplecov] ), Skelfile.new( 'travis', '.travis.yml', %w[.travis.yml] ), Skelfile.new( 'gemspec', "#{scope.project_name}.gemspec", %w{gemspec.rb *.gemspec} ), Skelfile.new( 'gemfile', 'Gemfile', %w[Gemfile] ) ] end |