Class: Tooler::CLI

Inherits:
Object
  • Object
show all
Includes:
Template
Defined in:
lib/tooler/cli.rb

Instance Method Summary collapse

Methods included from Template

#config_ru, #copy_template_cuba, #copy_template_sinatra, #create_dir, #file_read, #file_write, #gemfile, #gitignore, #license, #procfile, #readme, #template

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
10
11
12
13
# File 'lib/tooler/cli.rb', line 6

def initialize args
  @options = {template: "", name: ""}
  parse args[:arguments]
  @options[:pwd] = ::FileUtils.pwd + "/"
  @options[:name] = @options[:pwd].split('/').last
  @options[:root_path] = Tooler.root
  @options[:template_path] = @options[:root_path] + "/templates/"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



33
34
35
36
37
38
39
40
# File 'lib/tooler/cli.rb', line 33

def method_missing method_name, *args, &block
  p "method_missing #{method_name}"
  if method_name[/^copy_template_/]
    raise Tooler::Error, "Invalid template"
  else
    super
  end
end

Instance Method Details

#startObject



15
16
17
18
19
20
21
22
# File 'lib/tooler/cli.rb', line 15

def start
  begin
    require "tooler/#{@options[:template]}_template"
  rescue LoadError
    raise Tooler::Error, "Invalid template"
  end
  send("copy_template_#{@options[:template]}")
end