Class: Rdm::CLI::GenPackage
- Inherits:
-
Object
- Object
- Rdm::CLI::GenPackage
- Defined in:
- lib/rdm/cli/gen_package.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(package_name, current_path, path, locals, stdout) ⇒ GenPackage
constructor
A new instance of GenPackage.
- #run ⇒ Object
Constructor Details
#initialize(package_name, current_path, path, locals, stdout) ⇒ GenPackage
Returns a new instance of GenPackage.
10 11 12 13 14 15 16 |
# File 'lib/rdm/cli/gen_package.rb', line 10 def initialize(package_name, current_path, path, locals, stdout) @current_path = current_path @path = path @package_name = package_name @locals = locals @stdout = stdout end |
Class Method Details
.run(package_name:, current_path:, path:, locals: {}, stdout: $stdout) ⇒ Object
5 6 7 |
# File 'lib/rdm/cli/gen_package.rb', line 5 def run(package_name:, current_path:, path:, locals: {}, stdout: $stdout) Rdm::CLI::GenPackage.new(package_name, current_path, path, locals, stdout).run end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rdm/cli/gen_package.rb', line 18 def run generated_files_list = Rdm::Gen::Package.generate( current_path: @current_path, local_path: @path, package_name: @package_name, locals: @locals ) generated_files_list.compact.each { |file| @stdout.puts "Generated: #{file}" } rescue Errno::ENOENT => e @stdout.puts "Error occurred. Possible reasons:\n #{Rdm::SOURCE_FILENAME} not found. Please run on directory containing #{Rdm::SOURCE_FILENAME} \n#{e.inspect}" rescue Rdm::Errors::PackageExists @stdout.puts 'Error. Package already exist. Package was not generated' rescue Rdm::Errors::PackageNameNotSpecified @stdout.puts "Package name was not specified!" rescue Rdm::Errors::SourceFileDoesNotExist => e @stdout.puts "Rdm.packages was not found. Run 'rdm init' to create it" rescue Rdm::Errors::PackageDirExists => e @stdout.puts "Error. Directory #{e.} exists. Package was not generated" rescue NoMethodError => e @stdout.puts e. end |