Class: LicenseGenerator::App

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/license-generator/app.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



20
21
22
23
# File 'lib/license-generator/app.rb', line 20

def method_missing(meth, *args)
  self.authors = args.empty? ? option(:authors) : args.join(', ')
  template "#{meth}.erb", "LICENSE"
end

Instance Attribute Details

#authorsObject

Returns the value of attribute authors.



6
7
8
# File 'lib/license-generator/app.rb', line 6

def authors
  @authors
end

Class Method Details

.source_rootObject

Path to the templates



9
10
11
# File 'lib/license-generator/app.rb', line 9

def self.source_root
  File.expand_path('../../templates', File.dirname(__FILE__))
end

Instance Method Details

#help(task = nil) ⇒ Object

Override Thor#help to include templates.



26
27
28
29
30
31
32
33
34
# File 'lib/license-generator/app.rb', line 26

def help(task = nil)
  super
  unless task
    say "Templates:"
    templates.each do |template|
      say "  licgen #{template}\t# Generate #{template} license"
    end
  end
end

#listObject



14
15
16
17
18
# File 'lib/license-generator/app.rb', line 14

def list
  templates.each do |template|
    say template
  end
end