Class: Grate::NewProject

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/grate/new_project.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



9
10
11
# File 'lib/grate/new_project.rb', line 9

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#copy_binObject



35
36
37
38
39
# File 'lib/grate/new_project.rb', line 35

def copy_bin
  bin_dir = File.join(__dir__, '..', '..', 'bin')
  
  FileUtils.copy_entry(bin_dir, File.join(@project_dir, 'bin'))
end

#create_directoryObject



14
15
16
17
# File 'lib/grate/new_project.rb', line 14

def create_directory
  Dir.mkdir name
  @project_dir = File.join(Dir.pwd, name)
end

#create_filesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/grate/new_project.rb', line 19

def create_files
  @camel_name = classify(name)
  @snake_name = snake_case(name)
  templates_dir = File.join(__dir__, '..', '..', 'templates')
  Find.find(templates_dir) do |file|
    case File.extname(file)
    when '.tt'
      template(file, File.join(@project_dir, to_relative(file).gsub('.tt', '')))
    when '.dot'
      template(file, File.join(@project_dir, ".#{to_relative(file).chomp('.dot')}"))
    when /\.[A-Za-z]+/
      template(file, File.join(@project_dir, to_relative(file)))
    end
  end
end