Class: Roger::Generators::NewGenerator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Roger::Generators::NewGenerator
- 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
-
#source_paths ⇒ Object
readonly
Returns the value of attribute source_paths.
Instance Method Summary collapse
- #create_project ⇒ Object
- #setup_variables ⇒ Object
- #validate_path_is_empty ⇒ Object
- #validate_template_path ⇒ Object
Instance Attribute Details
#source_paths ⇒ Object (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_project ⇒ Object
51 52 53 |
# File 'lib/roger/generators/new.rb', line 51 def create_project directory(".", ".") end |
#setup_variables ⇒ Object
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_empty ⇒ Object
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_path ⇒ Object
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 = [: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 |