Class: EhcCommandTasks
- Inherits:
-
Object
- Object
- EhcCommandTasks
- Defined in:
- lib/ehc_command_tasks.rb
Constant Summary collapse
- 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
- #generate ⇒ Object
- #help ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ EhcCommandTasks
constructor
A new instance of EhcCommandTasks.
- #parse_command ⇒ Object
- #print_error(command) ⇒ Object
- #server ⇒ Object
Constructor Details
#initialize ⇒ EhcCommandTasks
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
#generate ⇒ Object
62 63 64 65 |
# File 'lib/ehc_command_tasks.rb', line 62 def generate require 'generator/generator' Generator::Generator.new.generate end |
#help ⇒ Object
49 50 51 |
# File 'lib/ehc_command_tasks.rb', line 49 def help puts HELP_MESSAGE end |
#init ⇒ Object
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 websites" init_dev_root init_web_root puts "All done, use \e[32m'ehc server'\e[0m to start the development server." end |
#parse_command ⇒ Object
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 |
#print_error(command) ⇒ Object
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 |
#server ⇒ Object
67 68 69 70 |
# File 'lib/ehc_command_tasks.rb', line 67 def server $options = require 'easy_html_creator' end |