Class: EPC::Command::DetachLibraryCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::DetachLibraryCommand
- Defined in:
- lib/epc/command/detach_library_command.rb
Constant Summary
Constants inherited from BaseCommand
BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
Methods inherited from BaseCommand
#go, inherited, #initialize, required_options
Methods included from PersistentAttributes
#auth_token, #caller_id, #target_url
Constructor Details
This class inherits a constructor from EPC::Command::BaseCommand
Instance Method Details
#execute(name = nil, version = nil, group = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/epc/command/detach_library_command.rb', line 4 def execute(name = nil, version = nil, group = nil) path = File.(".") raise FatalError, "You must specify the library to be detached." if name.nil? solution_name = @options[:solution_name] project_name = @options[:project_name] solution_id, solution_name = infer_solution_context(solution_name, path) project_id, project_name = infer_project_context(project_name, path, solution_id) raise FatalError, "Project could not be inferred" if project_id.nil? if numeric?(name) library_id = name.to_i else library_id = retrieve_libraries([{:name => name, :library_version => version, :group => group}]).first rescue nil end raise FatalError, "Could not determine library" if library_id.nil? status, response, headers = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}/detach_library/#{library_id}") if status.successful? say("Library detached from project.") else say("Request failed: [#{response[:message]}]") end return status end |