Class: EhcCommandTasks
- Inherits:
-
Object
- Object
- EhcCommandTasks
- Defined in:
- lib/ehc_command_tasks.rb
Constant Summary
- COMMAND_WHITELIST =
%w(init generate server help)
- HELP_MESSAGE =
<<-EOT Usage: ehc COMMAND [ARGS] The avalible commands are: init Initialize 'dev_root' and 'web_root' with a demo website generate Only generate output files (short-cut alias: "g") server Start the wserver (short-cut alias: "s") help Shows this message EOT
Instance Method Summary (collapse)
- - (Object) generate
- - (Object) help
- - (Object) init
-
- (EhcCommandTasks) initialize
constructor
A new instance of EhcCommandTasks.
- - (Object) parse_command
- - (Object) print_error(command)
- - (Object) server
Constructor Details
- (EhcCommandTasks) initialize
Returns a new instance of EhcCommandTasks
18 19 20 21 22 23 24 25 |
# File 'lib/ehc_command_tasks.rb', line 18 def initialize command = parse_command if COMMAND_WHITELIST.include?(command) send(command) else print_error(command) end end |
Instance Method Details
- (Object) generate
62 63 64 65 |
# File 'lib/ehc_command_tasks.rb', line 62 def generate require 'generator/generator' Generator::Generator.new.generate end |
- (Object) help
49 50 51 |
# File 'lib/ehc_command_tasks.rb', line 49 def help puts HELP_MESSAGE end |
- (Object) init
53 54 55 56 57 58 59 60 |
# File 'lib/ehc_command_tasks.rb', line 53 def init puts "Creating dev_root and web_root with sample website" init_dev_root init_web_root puts "All done, use 'ehc server' to start the development server." end |
- (Object) parse_command
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ehc_command_tasks.rb', line 27 def parse_command return "" if ARGV.empty? command = ARGV.first if command == 'g' command = 'generate' elsif command == 's' command = 'server' end return command end |
- (Object) print_error(command)
40 41 42 43 44 45 46 47 |
# File 'lib/ehc_command_tasks.rb', line 40 def print_error(command) if command.empty? puts 'no command given' else puts "command '#{command}' not valid" end if help end |
- (Object) server
67 68 69 70 |
# File 'lib/ehc_command_tasks.rb', line 67 def server $options = require 'easy_html_creator' end |