Class: Rdm::Gen::Init
- Inherits:
-
Object
- Object
- Rdm::Gen::Init
- Defined in:
- lib/rdm/gen/init.rb
Constant Summary collapse
- TEMPLATE_NAME =
'init'
- INIT_PATH =
'./'
- LOCAL_TEMPLATES_PATH =
'.rdm/templates'
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(current_path, test, console) ⇒ Init
constructor
A new instance of Init.
Constructor Details
#initialize(current_path, test, console) ⇒ Init
Returns a new instance of Init.
17 18 19 20 21 22 |
# File 'lib/rdm/gen/init.rb', line 17 def initialize(current_path, test, console) @current_path = current_path @test = test @console = console @template_detector = Rdm::Templates::TemplateDetector.new(current_path) end |
Class Method Details
Instance Method Details
#generate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rdm/gen/init.rb', line 24 def generate if @current_path.nil? || @current_path.empty? raise Rdm::Errors::InvalidParams, "Error. Project folder not specified. Type path to rdm project, ex: 'rdm init .'" end raise Rdm::Errors::InvalidProjectDir, @current_path unless Dir.exist?(@current_path) if File.exist?(File.join(@current_path, Rdm::SOURCE_FILENAME)) raise Rdm::Errors::ProjectAlreadyInitialized, "#{@current_path} has already #{Rdm::SOURCE_FILENAME}" end FileUtils.mkdir_p(local_templates_path) FileUtils.cp_r( @template_detector.gem_template_folder('package'), @template_detector.project_template_folder('package') ) Rdm::Handlers::TemplateHandler.generate( template_name: TEMPLATE_NAME, current_path: @current_path, local_path: INIT_PATH, ignore_source_file: true ) end |