Class: EPC::Command::AttachLibrarysetCommand

Inherits:
BaseCommand show all
Defined in:
lib/epc/command/attach_libraryset_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #options

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(set = nil) ⇒ Object

Raises:



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
# File 'lib/epc/command/attach_libraryset_command.rb', line 4

def execute(set = nil)
  path = File.expand_path(".")
  solution_id, solution_name = infer_solution_context(@options[:solution_name], path)
  project_id, project_name = infer_project_context(@options[:project_name], path, solution_id)

  raise InputError, "Project could not be inferred" if project_id.nil?

  set_id = retrieve_identifier_for("LibrarySet", set)

  if @options[:detach].present? && @options[:detach]
    status, response, headers = client.delete(EPC::Config::PROJECTS_PATH + "/#{project_id}/detach_set/#{set_id}")
  else
    status, response, headers = client.post(EPC::Config::PROJECTS_PATH + "/#{project_id}/attach_set/#{set_id}")
  end

  if status.successful?
    say("Library set #{@options[:detach] ? "detached" : "attached"}")
  else
    say("Request failed: [#{response[:message]}]")
  end

  return status
   

end