Class: Thor::Actions::NewProject

Inherits:
Object
  • Object
show all
Includes:
Angus::FileHandler, Angus::HelperMethods
Defined in:
lib/angus/generator/thor/new_project.rb

Overview

:nodoc:

Constant Summary collapse

FILE_MAPPINGS =
{
  'services/service.rb.erb' => -> command, app_name { File.join(Angus::CommandProcessor::SERVICES_DIR, "#{command.underscore(command.classify(app_name))}.rb") },
  'resources/resource.rb.erb' => -> command, name { "#{command.underscore(command.classify(name))}.rb" },
  'definitions/operations.yml.erb' => -> command, _ { File.join(command.resource_name, 'operations.yml') }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Angus::FileHandler

#copy_erb_file, #filename_resolver, #is_erb?

Methods included from Angus::HelperMethods

#classify, #pluralize, #underscore

Constructor Details

#initialize(base, name, config) ⇒ NewProject

Creates a new project.

Parameters:

  • base (Thor::Base)

    A Thor::Base instance



35
36
37
38
39
# File 'lib/angus/generator/thor/new_project.rb', line 35

def initialize(base, name, config)
  @base, @config   = base, { :verbose => true }.merge(config)

  self.app_name = name
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



30
31
32
# File 'lib/angus/generator/thor/new_project.rb', line 30

def app_name
  @app_name
end

#baseObject

Returns the value of attribute base.



30
31
32
# File 'lib/angus/generator/thor/new_project.rb', line 30

def base
  @base
end

#configObject

Returns the value of attribute config.



30
31
32
# File 'lib/angus/generator/thor/new_project.rb', line 30

def config
  @config
end

Instance Method Details

#invoke!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/angus/generator/thor/new_project.rb', line 41

def invoke!
  base.empty_directory(app_name)

  new_app_directories.each do |directory|
    base.empty_directory(File.join(app_name, directory))
  end

  new_app_files.each do |file|
    if is_erb?(file)
      copy_erb_file(file, app_name)
    else
      base.copy_file(file, File.join(app_name, file))
    end
  end
end

#mappingObject



61
62
63
# File 'lib/angus/generator/thor/new_project.rb', line 61

def mapping
  FILE_MAPPINGS
end

#revoke!Object



57
58
59
# File 'lib/angus/generator/thor/new_project.rb', line 57

def revoke!

end