Class: WayOfWorking::Audit::Github::Rules::Base

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

Overview

This is the base class for GitHub audit rules

Direct Known Subclasses

Unknown

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name, repo, rulesets) ⇒ Base



25
26
27
28
29
30
31
32
33
# File 'lib/way_of_working/audit/github/rules/base.rb', line 25

def initialize(client, name, repo, rulesets)
  @client = client
  @name = name
  @repo = repo
  @repo_name = repo.full_name
  @rulesets = rulesets
  @errors = []
  @warnings = []
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



15
16
17
# File 'lib/way_of_working/audit/github/rules/base.rb', line 15

def errors
  @errors
end

#nameObject

Returns the value of attribute name.



15
16
17
# File 'lib/way_of_working/audit/github/rules/base.rb', line 15

def name
  @name
end

#rulesetsObject

Returns the value of attribute rulesets.



15
16
17
# File 'lib/way_of_working/audit/github/rules/base.rb', line 15

def rulesets
  @rulesets
end

#warningsObject

Returns the value of attribute warnings.



15
16
17
# File 'lib/way_of_working/audit/github/rules/base.rb', line 15

def warnings
  @warnings
end

Class Method Details

.source_root(path = nil) ⇒ Object

Stores and return the source root for this class



19
20
21
22
# File 'lib/way_of_working/audit/github/rules/base.rb', line 19

def source_root(path = nil)
  @source_root = path if path
  @source_root ||= nil
end

.tagsObject



52
53
54
# File 'lib/way_of_working/audit/github/rules/base.rb', line 52

def self.tags
  [:way_of_working]
end

Instance Method Details

#statusObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/way_of_working/audit/github/rules/base.rb', line 35

def status
  @status ||= begin
    result = validate

    if result == :not_applicable
      result
    else
      @errors.empty? ? :passed : :failed
    end
  end
end

#tagsObject



56
57
58
# File 'lib/way_of_working/audit/github/rules/base.rb', line 56

def tags
  self.class.tags
end

#validateObject



47
48
49
50
# File 'lib/way_of_working/audit/github/rules/base.rb', line 47

def validate
  $stdout.puts 'Rule#valid? has been deprecated, use "validate"'
  valid?
end