Class: Ree::Gen::Init
Constant Summary collapse
- TEMPLATE_NAME =
'init'
- INIT_PATH =
'./'
- LOCAL_TEMPLATES_PATH =
'.ree/templates'
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(project_path, test, console, stdout) ⇒ Init
constructor
A new instance of Init.
Constructor Details
#initialize(project_path, test, console, stdout) ⇒ Init
Returns a new instance of Init.
19 20 21 22 23 24 25 |
# File 'lib/ree/gen/init.rb', line 19 def initialize(project_path, test, console, stdout) @project_path = project_path @test = test @console = console @template_detector = Ree::TemplateDetector.new(project_path) @stdout = stdout end |
Class Method Details
Instance Method Details
#generate ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ree/gen/init.rb', line 27 def generate if @project_path.nil? || @project_path.empty? raise Ree::Error.new("Project folder not specified. Type path to ree project, ex: 'ree init .'") end if !Dir.exist?(@project_path) raise Ree::Error.new("#{@project_path} doesn't exist. Initialize new ree project with existing directory") end if File.exist?(File.join(@project_path, Ree::PACKAGES_SCHEMA_FILE)) raise Ree::Error.new("#{@project_path} has already #{Ree::PACKAGES_SCHEMA_FILE}") end generated_files = Ree::TemplateHandler.generate( template_name: TEMPLATE_NAME, project_path: @project_path, local_path: INIT_PATH, stdout: @stdout ) FileUtils.mkdir_p(local_templates_path) FileUtils.cp_r( @template_detector.gem_template_folder('package'), File.dirname(@template_detector.project_template_folder('package')) ) generated_files end |