Class: Pronto::Message
- Inherits:
-
Object
- Object
- Pronto::Message
- Defined in:
- lib/pronto/message.rb
Constant Summary collapse
- LEVELS =
%i[info warning error fatal].freeze
Instance Attribute Summary collapse
-
#commit_sha ⇒ Object
readonly
Returns the value of attribute commit_sha.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#runner ⇒ Object
readonly
Returns the value of attribute runner.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #full_path ⇒ Object
- #hash ⇒ Object
-
#initialize(path, line, level, msg, commit_sha = nil, runner = nil) ⇒ Message
constructor
A new instance of Message.
- #repo ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(path, line, level, msg, commit_sha = nil, runner = nil) ⇒ Message
Returns a new instance of Message.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pronto/message.rb', line 7 def initialize(path, line, level, msg, commit_sha = nil, runner = nil) unless LEVELS.include?(level) raise ::ArgumentError, "level should be set to one of #{LEVELS}" end @path = path @line = line @level = level @msg = msg @runner = runner @commit_sha = commit_sha @commit_sha ||= line.commit_sha if line end |
Instance Attribute Details
#commit_sha ⇒ Object (readonly)
Returns the value of attribute commit_sha.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def commit_sha @commit_sha end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def level @level end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def line @line end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def msg @msg end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def path @path end |
#runner ⇒ Object (readonly)
Returns the value of attribute runner.
3 4 5 |
# File 'lib/pronto/message.rb', line 3 def runner @runner end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
29 30 31 32 33 |
# File 'lib/pronto/message.rb', line 29 def ==(other) comparison_attributes.all? do |attribute| send(attribute) == other.send(attribute) end end |
#full_path ⇒ Object
21 22 23 |
# File 'lib/pronto/message.rb', line 21 def full_path repo.path.join(path) if repo end |
#hash ⇒ Object
37 38 39 40 41 |
# File 'lib/pronto/message.rb', line 37 def hash comparison_attributes.reduce(0) do |hash, attribute| hash ^ send(attribute).hash end end |
#repo ⇒ Object
25 26 27 |
# File 'lib/pronto/message.rb', line 25 def repo line.patch.repo if line end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pronto/message.rb', line 43 def to_h { path: path, line: line, level: level, msg: msg, commit_sha: commit_sha, runner: @runner && @runner.title } end |