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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name, repo, rulesets, fix = false) ⇒ Base

Returns a new instance of Base.



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

def initialize(client, name, repo, rulesets, fix = false)
  @client = client
  @name = name
  @repo = repo
  @repo_name = repo.full_name
  @rulesets = rulesets
  @fix = fix
  @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

#fixObject (readonly)

Returns the value of attribute fix.



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

def fix
  @fix
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



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

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

.tagsObject



54
55
56
# File 'lib/way_of_working/audit/github/rules/base.rb', line 54

def self.tags
  [:way_of_working]
end

Instance Method Details

#statusObject



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

def status
  @status ||= begin
    result = validate

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

#tagsObject



58
59
60
# File 'lib/way_of_working/audit/github/rules/base.rb', line 58

def tags
  self.class.tags
end

#validateObject



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

def validate
  $stdout.puts "Rule#valid? has been deprecated, use \"validate\" in #{self.class.name}"
  valid?
end