Class: Roger::Generators::NewGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/roger/generators/new.rb

Overview

Generator to create a new HTML project based on an existing skeleton

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#source_pathsObject (readonly)

Returns the value of attribute source_paths.



18
19
20
# File 'lib/roger/generators/new.rb', line 18

def source_paths
  @source_paths
end

Instance Method Details

#create_projectObject



51
52
53
# File 'lib/roger/generators/new.rb', line 51

def create_project
  directory(".", ".")
end

#setup_variablesObject



20
21
22
23
24
25
26
27
# File 'lib/roger/generators/new.rb', line 20

def setup_variables
  self.destination_root = path

  @source_paths = []

  # Stuff to rm -rf later
  @cleanup = []
end

#validate_path_is_emptyObject



29
30
31
32
33
34
# File 'lib/roger/generators/new.rb', line 29

def validate_path_is_empty
  return unless File.directory?(destination_root)

  say "Directory #{destination_root} already exists, please only use this to create new projects"
  exit(1)
end

#validate_template_pathObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/roger/generators/new.rb', line 36

def validate_template_path
  template = options[:template] || File.dirname(__FILE__) + "/../../../examples/default_template"

  if File.exist?(template)
    say "Taking template from #{template}"
    @source_paths << template
  else
    say "Getting template from git remote #{template}"
    @source_paths << git_clone_template(template)
  end
rescue StandardError => e
  puts e
  puts e.backtrace.join("\n")
end