Class: Ree::Gen::Package
Constant Summary collapse
- TEMPLATE_NAME =
'package'
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #get_schema ⇒ Object
-
#initialize(package_name, project_path, local_path, locals = {}) ⇒ Package
constructor
A new instance of Package.
Constructor Details
#initialize(package_name, project_path, local_path, locals = {}) ⇒ Package
Returns a new instance of Package.
17 18 19 20 21 22 23 |
# File 'lib/ree/gen/package.rb', line 17 def initialize(package_name, project_path, local_path, locals = {}) @project_path = project_path @package_name = package_name @local_path = local_path @locals = locals @schema = get_schema end |
Class Method Details
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ree/gen/package.rb', line 25 def create if Dir.exist?(File.join(Ree.root_dir, @local_path)) raise Ree::Error.new("Package directory #{@local_path} already exists") end if @package_name.nil? || @package_name.empty? raise Ree::Error.new('Package name was not specified') end if @schema.packages.map(&:name).include?(@package_name) raise Ree::Error.new('Package already exists') end generated_files = Ree::TemplateHandler.generate( template_name: TEMPLATE_NAME, project_path: @project_path, local_path: @local_path, locals: { package_name: @package_name, local_path: @local_path }.merge(@locals) ) generated_files end |