Class: Rdm::Gen::Package
- Inherits:
-
Object
- Object
- Rdm::Gen::Package
- Defined in:
- lib/rdm/gen/package.rb
Constant Summary collapse
- TEMPLATE_NAME =
'package'
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #get_source ⇒ Object
-
#initialize(package_name, current_path, local_path, locals = {}) ⇒ Package
constructor
A new instance of Package.
Constructor Details
#initialize(package_name, current_path, local_path, locals = {}) ⇒ Package
Returns a new instance of Package.
15 16 17 18 19 20 21 |
# File 'lib/rdm/gen/package.rb', line 15 def initialize(package_name, current_path, local_path, locals = {}) @current_path = current_path @package_name = package_name @local_path = local_path @locals = locals @source = get_source end |
Class Method Details
Instance Method Details
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rdm/gen/package.rb', line 23 def create raise Rdm::Errors::PackageDirExists.new(@local_path) if Dir.exist?(File.join(@source.root_path, @local_path)) raise Rdm::Errors::PackageNameNotSpecified if @package_name.nil? || @package_name.empty? raise Rdm::Errors::PackageExists if @source.packages.keys.include?(@package_name) generated_files = Rdm::Handlers::TemplateHandler.generate( template_name: TEMPLATE_NAME, current_path: @current_path, local_path: @local_path, locals: { package_name: @package_name }.merge(@locals) ) Rdm::SourceModifier.add_package(@local_path, get_source.root_path) generated_files end |
#get_source ⇒ Object
40 41 42 |
# File 'lib/rdm/gen/package.rb', line 40 def get_source @source ||= Rdm::SourceParser.read_and_init_source(Rdm::SourceLocator.locate(@current_path)) end |