Class: Lemon::CLI::Generate
Overview
Generate Command
Direct Known Subclasses
Instance Method Summary collapse
- #command_parse(argv) ⇒ Object
-
#command_run(files) ⇒ Object
Generate test templates.
- #generate_output(render_map) ⇒ Object
-
#option_caps ⇒ Object
-C –caps.
-
#option_group ⇒ Object
-f –file.
- #setup_options ⇒ Object
Methods inherited from Base
#initialize, #option_coverage, #option_dryrun, #option_format, #option_loadpath, #option_namespaces, #option_output, #option_parser, #option_private, #option_requires, #option_verbose, #option_zealous, #options, run, #run
Constructor Details
This class inherits a constructor from Lemon::CLI::Base
Instance Method Details
#command_parse(argv) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/lemon/cli/generate.rb', line 47 def command_parse(argv) option_parser. = "Usage: lemons generate [options] [files ...]" option_parser.parse!(argv) end |
#command_run(files) ⇒ Object
Generate test templates.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lemon/cli/generate.rb', line 12 def command_run(files) if i = files.index('-') [:files] = files[0...i] [:tests] = files[i+1..-1] else [:files] = files [:tests] = [] end require 'lemon/coverage/generator' loadpath = [:loadpath] || [] requires = [:requires] || [] loadpath.each{ |path| $LOAD_PATH.unshift(path) } requires.each{ |path| require(path) } generator = Lemon::Generator.new() render_map = generator.generate generate_output(render_map) end |
#generate_output(render_map) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/lemon/cli/generate.rb', line 37 def generate_output(render_map) render_map.each do |group, test| puts "# --- #{group} ---" puts puts test puts end end |
#option_caps ⇒ Object
-C –caps
76 77 78 79 80 |
# File 'lib/lemon/cli/generate.rb', line 76 def option_caps option_parser.on('-C', '--caps', 'use capitalized test terms') do [:caps] = true end end |
#option_group ⇒ Object
-f –file
66 67 68 69 70 71 72 73 |
# File 'lib/lemon/cli/generate.rb', line 66 def option_group option_parser.on('-f', '--file', 'group tests by file') do [:group] = :file end #option_parser.on('-c', '--case', 'group tests by case') do # options[:group] = :case #end end |
#setup_options ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/lemon/cli/generate.rb', line 56 def option_group option_namespaces option_private option_caps option_loadpath option_requires end |