Class: Spade::CLI::ProjectGenerator

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/spade/cli/project_generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thor, name, root) ⇒ ProjectGenerator

Returns a new instance of ProjectGenerator.



9
10
11
12
13
# File 'lib/spade/cli/project_generator.rb', line 9

def initialize(thor, name, root)
  @thor, @name, @root = thor, name, root

  self.destination_root = root
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object (private)



54
55
56
# File 'lib/spade/cli/project_generator.rb', line 54

def method_missing(name, *args, &blk)
  @thor.send(name, *args, &blk)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/spade/cli/project_generator.rb', line 7

def name
  @name
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/spade/cli/project_generator.rb', line 15

def run
  empty_directory '.'
  FileUtils.cd(destination_root)

  template "LICENSE"
  template "README.md"
  template "project.json"

  empty_directory "lib"
  empty_directory "tests"

  inside "lib" do
    template "main.js"
  end

  inside "tests" do
    template "main-test.js"
  end
end