Class: Pronto::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/message.rb

Constant Summary collapse

LEVELS =
[:info, :warning, :error, :fatal]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, line, level, msg, commit_sha = nil) ⇒ Message


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pronto/message.rb', line 7

def initialize(path, line, level, msg, commit_sha = nil)
  unless LEVELS.include?(level)
    raise ::ArgumentError, "level should be set to one of #{LEVELS}"
  end

  @path = path
  @line = line
  @level = level
  @msg = msg
  @commit_sha = commit_sha
  @commit_sha ||= line.commit_sha if line
end

Instance Attribute Details

#commit_shaObject (readonly)

Returns the value of attribute commit_sha


3
4
5
# File 'lib/pronto/message.rb', line 3

def commit_sha
  @commit_sha
end

#levelObject (readonly)

Returns the value of attribute level


3
4
5
# File 'lib/pronto/message.rb', line 3

def level
  @level
end

#lineObject (readonly)

Returns the value of attribute line


3
4
5
# File 'lib/pronto/message.rb', line 3

def line
  @line
end

#msgObject (readonly)

Returns the value of attribute msg


3
4
5
# File 'lib/pronto/message.rb', line 3

def msg
  @msg
end

#pathObject (readonly)

Returns the value of attribute path


3
4
5
# File 'lib/pronto/message.rb', line 3

def path
  @path
end

Instance Method Details

#full_pathObject


20
21
22
# File 'lib/pronto/message.rb', line 20

def full_path
  repo.path.join(path) if repo
end

#repoObject


24
25
26
# File 'lib/pronto/message.rb', line 24

def repo
  line.patch.repo if line
end