Class: MultiRepo::Service::CodeClimate
- Inherits:
-
Object
- Object
- MultiRepo::Service::CodeClimate
- Defined in:
- lib/multi_repo/service/code_climate.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Class Method Summary collapse
- .api_token ⇒ Object
- .api_token=(token) ⇒ Object
- .badge_details(repo) ⇒ Object
- .badge_name ⇒ Object
- .coverage_badge_details(repo) ⇒ Object
- .coverage_badge_name ⇒ Object
Instance Method Summary collapse
- #badge_details ⇒ Object
- #coverage_badge_details ⇒ Object
- #create_repo_secret ⇒ Object
- #enable ⇒ Object
-
#initialize(repo, dry_run: false, **_) ⇒ CodeClimate
constructor
A new instance of CodeClimate.
- #save! ⇒ Object
- #test_reporter_id ⇒ Object
Constructor Details
#initialize(repo, dry_run: false, **_) ⇒ CodeClimate
Returns a new instance of CodeClimate.
37 38 39 40 |
# File 'lib/multi_repo/service/code_climate.rb', line 37 def initialize(repo, dry_run: false, **_) @repo = repo @dry_run = dry_run end |
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
35 36 37 |
# File 'lib/multi_repo/service/code_climate.rb', line 35 def dry_run @dry_run end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
35 36 37 |
# File 'lib/multi_repo/service/code_climate.rb', line 35 def repo @repo end |
Class Method Details
.api_token ⇒ Object
3 4 5 |
# File 'lib/multi_repo/service/code_climate.rb', line 3 def self.api_token @api_token ||= ENV["CODECLIMATE_API_TOKEN"] end |
.api_token=(token) ⇒ Object
7 8 9 |
# File 'lib/multi_repo/service/code_climate.rb', line 7 def self.api_token=(token) @api_token = token end |
.badge_details(repo) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/multi_repo/service/code_climate.rb', line 15 def self.badge_details(repo) { "description" => badge_name, "image" => "https://codeclimate.com/github/#{repo.name}.svg", "url" => "https://codeclimate.com/github/#{repo.name}" } end |
.badge_name ⇒ Object
11 12 13 |
# File 'lib/multi_repo/service/code_climate.rb', line 11 def self.badge_name "Code Climate" end |
.coverage_badge_details(repo) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/multi_repo/service/code_climate.rb', line 27 def self.coverage_badge_details(repo) { "description" => coverage_badge_name, "image" => "https://codeclimate.com/github/#{repo.name}/badges/coverage.svg", "url" => "https://codeclimate.com/github/#{repo.name}/coverage" } end |
.coverage_badge_name ⇒ Object
23 24 25 |
# File 'lib/multi_repo/service/code_climate.rb', line 23 def self.coverage_badge_name "Test Coverage" end |
Instance Method Details
#badge_details ⇒ Object
51 52 53 |
# File 'lib/multi_repo/service/code_climate.rb', line 51 def badge_details self.class.badge_details(repo) end |
#coverage_badge_details ⇒ Object
55 56 57 |
# File 'lib/multi_repo/service/code_climate.rb', line 55 def coverage_badge_details self.class.coverage_badge_details(repo) end |
#create_repo_secret ⇒ Object
64 65 66 |
# File 'lib/multi_repo/service/code_climate.rb', line 64 def create_repo_secret Github.new(dry_run: dry_run).create_or_update_repository_secret(repo.name, "CC_TEST_REPORTER_ID", test_reporter_id) end |
#enable ⇒ Object
47 48 49 |
# File 'lib/multi_repo/service/code_climate.rb', line 47 def enable ensure_enabled end |
#save! ⇒ Object
42 43 44 45 |
# File 'lib/multi_repo/service/code_climate.rb', line 42 def save! write_codeclimate_yaml write_rubocop_yamls end |
#test_reporter_id ⇒ Object
59 60 61 62 |
# File 'lib/multi_repo/service/code_climate.rb', line 59 def test_reporter_id ensure_enabled @response.dig("data", 0, "attributes", "test_reporter_id") end |