Class: Dri::Commands::Fetch::Quarantines
- Inherits:
-
Dri::Command
- Object
- Dri::Command
- Dri::Commands::Fetch::Quarantines
- Includes:
- Utils::Constants::Triage::Labels, Utils::Table
- Defined in:
- lib/dri/commands/fetch/quarantines.rb
Constant Summary
Constants included from Utils::Constants::Triage::Labels
Utils::Constants::Triage::Labels::FAILURE, Utils::Constants::Triage::Labels::FAILURE_NEW, Utils::Constants::Triage::Labels::FOUND, Utils::Constants::Triage::Labels::INCIDENT, Utils::Constants::Triage::Labels::QA, Utils::Constants::Triage::Labels::QUALITY, Utils::Constants::Triage::Labels::QUARANTINE, Utils::Constants::Triage::Labels::SERVICE
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options, search: '[QUARANTINE]') ⇒ Quarantines
constructor
A new instance of Quarantines.
Methods included from Utils::Table
Methods inherited from Dri::Command
#add_color, #api_client, #command, #config, #cursor, #editor, #emoji, #handover_report_path, #logger, #ops_token, #pastel, #profile, #prompt, #spinner, #timezone, #token, #username, #verify_config_exists
Constructor Details
#initialize(options, search: '[QUARANTINE]') ⇒ Quarantines
Returns a new instance of Quarantines.
15 16 17 18 19 20 |
# File 'lib/dri/commands/fetch/quarantines.rb', line 15 def initialize(, search: '[QUARANTINE]') @options = @search = search @today_iso_format = Time.now.strftime('%Y-%m-%dT00:00:00Z') end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
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 |
# File 'lib/dri/commands/fetch/quarantines.rb', line 22 def execute(input: $stdin, output: $stdout) verify_config_exists title = add_color('Example name', :bright_yellow) url = add_color('URL', :bright_yellow) headers = [title, url] mrs = [] logger.info "Fetching #{@search} MRs..." spinner.run do response = api_client.fetch_mrs( project_id: 'gitlab-org/gitlab', labels: "#{QA},#{QUALITY}", search: @search, in: :title, state: :opened ) mrs = response.each_with_object([]) do |mr, found_mrs| title = mr.title[13..].truncate(60) # remove the "[QUARANTINE] " prefix url = mr.web_url found_mrs << [title, url] end end print_table(headers, mrs, alignments: [:left, :left]) output.puts "Found #{mrs.size} open #{@search} MRs" end |