Class: Spade::CLI::ProjectGenerator

Inherits:
Object
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/spade/packager/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.



67
68
69
70
71
# File 'lib/spade/packager/cli/project_generator.rb', line 67

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)



112
113
114
# File 'lib/spade/packager/cli/project_generator.rb', line 112

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



65
66
67
# File 'lib/spade/packager/cli/project_generator.rb', line 65

def name
  @name
end

Instance Method Details

#runObject



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/spade/packager/cli/project_generator.rb', line 73

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