Class: Neetob::CLI::Github::Labels::Upsert

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/github/labels/upsert.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods inherited from Base

#check_for_apps_and_all_neeto_repos_option

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(apps, required_labels_json_file_path = "", sandbox = false, all_neeto_repos = false) ⇒ Upsert

Returns a new instance of Upsert.



14
15
16
17
18
19
20
# File 'lib/neetob/cli/github/labels/upsert.rb', line 14

def initialize(apps, required_labels_json_file_path = "", sandbox = false, all_neeto_repos = false)
  super()
  @apps = apps
  @required_labels_json_file_path = required_labels_json_file_path
  @sandbox = sandbox
  @all_neeto_repos = all_neeto_repos
end

Instance Attribute Details

#all_neeto_reposObject

Returns the value of attribute all_neeto_repos.



12
13
14
# File 'lib/neetob/cli/github/labels/upsert.rb', line 12

def all_neeto_repos
  @all_neeto_repos
end

#appsObject

Returns the value of attribute apps.



12
13
14
# File 'lib/neetob/cli/github/labels/upsert.rb', line 12

def apps
  @apps
end

#required_labels_json_file_pathObject

Returns the value of attribute required_labels_json_file_path.



12
13
14
# File 'lib/neetob/cli/github/labels/upsert.rb', line 12

def required_labels_json_file_path
  @required_labels_json_file_path
end

#sandboxObject

Returns the value of attribute sandbox.



12
13
14
# File 'lib/neetob/cli/github/labels/upsert.rb', line 12

def sandbox
  @sandbox
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/neetob/cli/github/labels/upsert.rb', line 22

def run
  check_for_apps_and_all_neeto_repos_option(apps, all_neeto_repos)
  matching_apps = find_all_matching_apps(apps, :github, sandbox, false, all_neeto_repos)
  inform_about_default_labels_file
  matching_apps.each do |app|
    ui.info("\n Working on #{app} repo \n")
    begin
      required_labels = read_json_file(required_labels_json_file_path || default_labels_file_path)
      required_labels.each do |label|
        create_or_update_label(app, label)
      end
    rescue StandardError => e
      ExceptionHandler.new(e).process
    end
  end
end