Class: RailsDoctor::Finding

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails_doctor/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Finding

Returns a new instance of Finding.



31
32
33
34
35
36
37
38
# File 'lib/rails_doctor/models.rb', line 31

def initialize(**kwargs)
  super
  self.id ||= self.class.generate_id(kwargs)
  self.severity ||= "medium"
  self.confidence ||= "medium"
  self.suggested_commands ||= []
  self. ||= {}
end

Instance Attribute Details

#agent_instructionObject

Returns the value of attribute agent_instruction

Returns:

  • (Object)

    the current value of agent_instruction



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def agent_instruction
  @agent_instruction
end

#categoryObject

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def category
  @category
end

#confidenceObject

Returns the value of attribute confidence

Returns:

  • (Object)

    the current value of confidence



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def confidence
  @confidence
end

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def file
  @file
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def id
  @id
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def line
  @line
end

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def message
  @message
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def 
  @metadata
end

#recommendationObject

Returns the value of attribute recommendation

Returns:

  • (Object)

    the current value of recommendation



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def recommendation
  @recommendation
end

#severityObject

Returns the value of attribute severity

Returns:

  • (Object)

    the current value of severity



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def severity
  @severity
end

#suggested_commandsObject

Returns the value of attribute suggested_commands

Returns:

  • (Object)

    the current value of suggested_commands



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def suggested_commands
  @suggested_commands
end

#toolObject

Returns the value of attribute tool

Returns:

  • (Object)

    the current value of tool



16
17
18
# File 'lib/rails_doctor/models.rb', line 16

def tool
  @tool
end

Class Method Details

.generate_id(attrs) ⇒ Object



57
58
59
60
# File 'lib/rails_doctor/models.rb', line 57

def self.generate_id(attrs)
  seed = [attrs[:tool], attrs[:category], attrs[:file], attrs[:line], attrs[:message]].join(":")
  "rd-#{seed.hash.abs.to_s(36)}"
end

Instance Method Details

#to_hObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rails_doctor/models.rb', line 40

def to_h
  {
    id: id,
    severity: severity,
    category: category,
    tool: tool,
    file: file,
    line: line,
    confidence: confidence,
    message: message,
    recommendation: recommendation,
    agent_instruction: agent_instruction,
    suggested_commands: suggested_commands,
    metadata: 
  }.compact
end