Class: EPC::Command::CreateDependencyCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- EPC::Command::CreateDependencyCommand
- Defined in:
- lib/epc/command/create_dependency_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(parent = 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 34 35 36 37 38 39 40 41 |
# File 'lib/epc/command/create_dependency_command.rb', line 4 def execute(parent = nil) path = File.(".") solution_name = [:solution_name] project_name = parent solution_id, solution_name = infer_solution_context(solution_name, path) project_id, project_name = infer_project_context(project_name, path, solution_id) if project_id.nil? || project_id == 0 || solution_id.nil? || solution_id == 0 say("Project/solution could not be inferred") say(EPC::Help::COMMAND_USAGES[:create_dependency]) return 1 end if numeric?([:dependency]) dependency_id = [:dependency].to_i else dependency_id = get_resource_id(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}/projects", "name", [:dependency] ) end if dependency_id.nil? || dependency_id == 0 say("Dependency could not be inferred") say(EPC::Help::COMMAND_USAGES[:create_dependency]) return 1 end dependency_type = [:dependency_type] || 1 status, response, headers = client.post(EPC::Config::PROJECTS_PATH + "/#{project_id}/add_dependency", {:dependency_id => dependency_id, :dependency_kind => dependency_type}) if status.successful? say("Dependency defined") else say("Request failed: [#{response[:message]}]") end return status end |