Class: WayOfWorking::Audit::Github::Auditor

Inherits:
Object
  • Object
show all
Defined in:
lib/way_of_working/audit/github/auditor.rb

Overview

This auditor runs all the rules against any given GitHub repository

Instance Method Summary collapse

Constructor Details

#initialize(access_token, organisation_name) ⇒ Auditor

Returns a new instance of Auditor.



9
10
11
12
# File 'lib/way_of_working/audit/github/auditor.rb', line 9

def initialize(access_token, organisation_name)
  @access_token = access_token
  @organisation_name = organisation_name
end

Instance Method Details

#audit(repository) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/way_of_working/audit/github/auditor.rb', line 14

def audit(repository)
  # Get all the rules once, rather than repeatedly in individual rules
  rulesets = @client.get("repos/#{repository.full_name}/rulesets").map do |rule|
    @client.get("repos/#{repository.full_name}/rulesets/#{rule[:id]}")
  end

  Array(Rules::Registry.rules).each do |rule_name, klass|
    rule = klass.new(client, rule_name, repository, rulesets)

    yield rule
  end
end

#repositoriesObject



27
28
29
# File 'lib/way_of_working/audit/github/auditor.rb', line 27

def repositories
  @repositories ||= client.org_repos(@organisation_name)
end