Class: Sign::Runner
- Inherits:
-
Object
- Object
- Sign::Runner
- Defined in:
- lib/sign/runner.rb
Instance Method Summary collapse
- #create_license(argv) ⇒ Object
- #parse_argument(arg) ⇒ Object
- #show_help ⇒ Object
- #show_list ⇒ Object
- #show_version ⇒ Object
- #start ⇒ Object
Instance Method Details
#create_license(argv) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/sign/runner.rb', line 47 def create_license(argv) license = Sign::Fetcher.new.get_license(argv[0]) name = !!argv[1] ? parse_argument(argv[1]) : nil year = !!argv[2] ? parse_argument(argv[2]) : nil Sign::Generator.new.create(license, name, year) end |
#parse_argument(arg) ⇒ Object
55 56 57 |
# File 'lib/sign/runner.rb', line 55 def parse_argument(arg) arg.scan(/=(.*)/).last[0] end |
#show_help ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sign/runner.rb', line 19 def show_help puts "" puts " Generate a license for your project in a matter of seconds." puts "" puts " Usage:" puts "" puts " sign [option] <license>" puts "" puts " Options:" puts "" puts " --version display version number" puts " --help display help information" puts " --list display list of licenses" puts "" end |
#show_list ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/sign/runner.rb', line 35 def show_list puts "" puts "List of available licenses:" puts "" Sign::Fetcher.get_list puts "" end |
#show_version ⇒ Object
43 44 45 |
# File 'lib/sign/runner.rb', line 43 def show_version puts "Sign v#{Sign::VERSION}" end |
#start ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sign/runner.rb', line 3 def start argv = ARGV.clone argv << "--help" if argv.empty? case argv[0] when "--help" show_help when "--version" show_version when "--list" show_list else create_license(argv) end end |