Class: ModuleInstaller
- Inherits:
-
Object
- Object
- ModuleInstaller
- Defined in:
- lib/module_installer.rb
Instance Method Summary collapse
-
#initialize ⇒ ModuleInstaller
constructor
A new instance of ModuleInstaller.
- #install_module(module_name_or_path, module_version = nil) ⇒ Object
- #module_installed?(module_name, module_version = nil) ⇒ Boolean
- #uninstall_module(module_name, module_version) ⇒ Object
Constructor Details
#initialize ⇒ ModuleInstaller
Returns a new instance of ModuleInstaller.
7 8 9 |
# File 'lib/module_installer.rb', line 7 def initialize set_gem_home end |
Instance Method Details
#install_module(module_name_or_path, module_version = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 56 57 58 59 60 61 62 63 |
# File 'lib/module_installer.rb', line 11 def install_module(module_name_or_path, module_version = nil) brpm_content_spec = nil if true #TODO: support no-gem-install mode module_spec, specs = install_gem(module_name_or_path, module_version) brpm_content_spec = specs.find { |spec| spec.name == "brpm_content" } if specs install_bundle_if_necessary(module_spec) else module_name = module_name_or_path module_spec = Gem::Specification.find_by_name(module_name) end if brpm_installed_locally? BrpmAuto.log "A BRPM instance is installed locally" if brpm_content_spec if brpm_content_spec.version > Gem::Version.new(BrpmAuto.version) or ! File.exist?(get_symlink_path) BrpmAuto.log "Updating the symlink to brpm_content-latest..." update_symlink_to_brpm_content(brpm_content_spec.gem_dir) end if brpm_content_spec.version > Gem::Version.new(BrpmAuto.version) or ! File.exist?("#{ENV["BRPM_HOME"]}/automation_results/log.html") BrpmAuto.log "Copying the log.html file to te automation_results directory..." FileUtils.cp("#{brpm_content_spec.gem_dir}/infrastructure/log.html", "#{ENV["BRPM_HOME"]}/automation_results") end end BrpmAuto.log "Preparing the connectivity to BRPM..." if prepare_brpm_connection BrpmAuto.log "Creating an automation error for '******** ERROR ********' if one doesn't exist yet..." create_automation_error_if_not_exists("******** ERROR ********") module_friendly_name = get_module_friendly_name(module_spec) BrpmAuto.log "Creating an automation category for #{module_friendly_name} if one doesn't exist yet..." create_automation_category_if_not_exists(module_friendly_name) BrpmAuto.log "Retrieving the integration servers..." integration_servers = @brpm_rest_client.get_project_servers BrpmAuto.log "Installing the automation script wrappers in the local BRPM instance..." failed_scripts = each_auto_script_wrapper(module_spec.gem_dir) do |auto_script_path, automation_type| BrpmAuto.log "Installing automation script wrapper for script #{auto_script_path}..." install_auto_script_wrapper(auto_script_path, automation_type, module_spec.name, module_friendly_name, integration_servers) end if failed_scripts.size > 0 return false end end end end |
#module_installed?(module_name, module_version = nil) ⇒ Boolean
98 99 100 |
# File 'lib/module_installer.rb', line 98 def module_installed?(module_name, module_version = nil) Gem::Specification.find_by_name(module_name).size > 0 end |
#uninstall_module(module_name, module_version) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/module_installer.rb', line 65 def uninstall_module(module_name, module_version) if brpm_installed_locally? BrpmAuto.log "A BRPM instance is installed locally" BrpmAuto.log "Preparing the connectivity to BRPM..." if prepare_brpm_connection version_req = Gem::Requirement.create(Gem::Version.new(module_version)) module_spec = Gem::Specification.find_by_name(module_name, version_req) module_friendly_name = get_module_friendly_name(module_spec) BrpmAuto.log "Uninstalling the automation script wrappers in the local BRPM instance..." failed_scripts = each_auto_script_wrapper(module_spec.gem_dir) do |auto_script_path, automation_type| BrpmAuto.log "Uninstalling automation script wrapper for script #{auto_script_path}..." uninstall_auto_script_wrapper(auto_script_path, automation_type, module_friendly_name) end if failed_scripts.size > 0 BrpmAuto.log "Aborting the uninstall." return false end BrpmAuto.log "Deleting the automation category for #{module_friendly_name}..." delete_automation_category(module_friendly_name) end end BrpmAuto.log "Uninstalling gem #{module_name} #{module_version}..." BrpmAuto.log `gem uninstall #{module_name} -v #{module_version} -x` return true end |