Class: EPC::Command::ShowProjectCommand
- Inherits:
-
ShowCommand
- Object
- BaseCommand
- ShowCommand
- EPC::Command::ShowProjectCommand
- Defined in:
- lib/epc/command/project/show_project_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(object_id = nil, *args) ⇒ Object
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 97 98 99 100 101 102 103 104 |
# File 'lib/epc/command/project/show_project_command.rb', line 6 def execute(object_id = nil, *args) @showable_translations = { :config => :config_values, :services => :service_versions } path = File.(".") ids = object_id.split(":") rescue [nil, nil] if ids.size == 1 project_name = ids[0] solution_name = nil elsif ids.size == 2 solution_name, project_name = ids end 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 found" if project_id.nil? || project_id == 0 @showables = args[1..-1].map(&:to_sym) rescue [] status, response, = client.get(EPC::Config::PROJECTS_PATH + "/#{project_id}?include=dependencies,roles,config_values,service_versions,libraries") if status.failure? say("Request failed: [#{response[:message]}]") return status end response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p") response[:last_build_date] = Time.parse(response[:last_build_date]).strftime("%m/%d/%Y %I:%M%p") unless response[:last_build_date].nil? || response[:last_build_date] == "N/A" response[:last_push_date] = Time.parse(response[:last_push_date]).strftime("%m/%d/%Y %I:%M%p") unless response[:last_push_date].nil? || response[:last_push_date] == "N/A" response[:last_build_status] = nil if response[:last_build_status] == "N/A" # temp hack response[:last_build_status] = (response[:last_build_status] ? "BUILT" : "FAILED" rescue nil) unless response[:last_build_status].nil? response[:last_push_by_id] = response[:last_push_by][:id] response[:last_push_by_name] = response[:last_push_by][:name] response[:dependencies] = [] response[:dependency_definitions].each do |dep_def| response[:dependencies] << { id: dep_def[:dependency_id], project_id: dep_def[:dependency][:id], name: dep_def[:dependency][:name], type: dep_def[:dependency_kind] } end @response = response projects_table = EPC::TabularOutputter.new([response], {:id => "ID", :name => "NAME", :uri_name => "URI NAME", :created_at => "CREATED AT", :last_build_status => "BUILD STATUS", :last_build_date => "BUILD DATE", :last_build_version => "BUILD VERSION"}) last_push_table = EPC::TabularOutputter.new([response], {:last_push_by_id => "USER ID", :last_push_by_name => "USER NAME", :last_push_date => "DATE"}) dependencies_table = EPC::TabularOutputter.new(response[:dependencies], [:id, :project_id, :name, :type]) config_values_table = EPC::TabularOutputter.new(response[:config_values], [:id, :name, :no_override, :value, :value_type, :required]) roles_table = EPC::TabularOutputter.new(response[:roles], [:id, :name]) services_table = EPC::TabularOutputter.new(response[:service_versions], [:id, :label, :definition_name]) libraries_table = EPC::TabularOutputter.new(response[:libraries], [:id, :name, :language, :library_version, :group]) if @showables.blank? say("\nProject details:") say(projects_table.print) say("\nLast push info:") say(last_push_table.print) end if show? :dependencies say("\nDependencies:") say(dependencies_table.print) end if show? :config say("\nConfig values:") say(config_values_table.print) end if show? :roles say("\nRoles:") say(roles_table.print) end if show? :services say("\nServices:") say(services_table.print) end if show? :libraries say("\nLibraries:") say(libraries_table.print) end return status end |