Class: InspectedBy::Inspection

Inherits:
Object
  • Object
show all
Defined in:
lib/inspected_by/core.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, params) ⇒ Inspection

Returns a new instance of Inspection.



64
65
66
67
68
69
70
71
72
# File 'lib/inspected_by/core.rb', line 64

def initialize(repo, params)
  @repo            = repo
  @comment         = params['comment']
  @inspected_at    = params['inspected_at']
  @inspector_email = params['inspector_email']
  @inspector_name  = params['inspector_name']
  @guid            = params['guid']
  @sha             = params['sha']
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def comment
  @comment
end

#guidObject (readonly)

Returns the value of attribute guid.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def guid
  @guid
end

#inspected_atObject (readonly)

Returns the value of attribute inspected_at.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def inspected_at
  @inspected_at
end

#inspector_emailObject (readonly)

Returns the value of attribute inspector_email.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def inspector_email
  @inspector_email
end

#inspector_nameObject (readonly)

Returns the value of attribute inspector_name.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def inspector_name
  @inspector_name
end

#shaObject (readonly)

Returns the value of attribute sha.



62
63
64
# File 'lib/inspected_by/core.rb', line 62

def sha
  @sha
end

Class Method Details

.find_all(repo, sha) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/inspected_by/core.rb', line 74

def self.find_all(repo, sha)
  repo.git.notes({raise: true, ref: 'inspected-by'}, ['show', sha]).
    split("\n").
    map {|note| Inspection.new(repo, JSON.parse(note)) }
rescue Grit::Git::CommandFailed => e
  if /No note found for object/ === e.message
    []
  else
    raise e
  end
end

Instance Method Details

#appendObject



86
87
88
89
# File 'lib/inspected_by/core.rb', line 86

def append
  @repo.git.notes({raise: true, ref: 'inspected-by'},
    ['append', "--message=#{shell_escaped_message}", @sha])
end