Class: RailsDoctor::Coverage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Coverage

Returns a new instance of Coverage.



164
165
166
167
168
169
170
171
# File 'lib/rails_doctor/models.rb', line 164

def initialize(**kwargs)
  super
  self.available = false if available.nil?
  self.thresholds ||= {}
  self.top_files ||= []
  self.changed_files_below_threshold ||= []
  self. ||= {}
end

Instance Attribute Details

#availableObject

Returns the value of attribute available

Returns:

  • (Object)

    the current value of available



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def available
  @available
end

#branch_percentObject

Returns the value of attribute branch_percent

Returns:

  • (Object)

    the current value of branch_percent



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def branch_percent
  @branch_percent
end

#changed_files_below_thresholdObject

Returns the value of attribute changed_files_below_threshold

Returns:

  • (Object)

    the current value of changed_files_below_threshold



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def changed_files_below_threshold
  @changed_files_below_threshold
end

#covered_branchesObject

Returns the value of attribute covered_branches

Returns:

  • (Object)

    the current value of covered_branches



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def covered_branches
  @covered_branches
end

#covered_linesObject

Returns the value of attribute covered_lines

Returns:

  • (Object)

    the current value of covered_lines



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def covered_lines
  @covered_lines
end

#line_percentObject

Returns the value of attribute line_percent

Returns:

  • (Object)

    the current value of line_percent



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def line_percent
  @line_percent
end

#low_file_countObject

Returns the value of attribute low_file_count

Returns:

  • (Object)

    the current value of low_file_count



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def low_file_count
  @low_file_count
end

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def 
  @metadata
end

#missed_branchesObject

Returns the value of attribute missed_branches

Returns:

  • (Object)

    the current value of missed_branches



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def missed_branches
  @missed_branches
end

#missed_linesObject

Returns the value of attribute missed_lines

Returns:

  • (Object)

    the current value of missed_lines



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def missed_lines
  @missed_lines
end

#report_pathObject

Returns the value of attribute report_path

Returns:

  • (Object)

    the current value of report_path



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def report_path
  @report_path
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def source
  @source
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def status
  @status
end

#thresholdsObject

Returns the value of attribute thresholds

Returns:

  • (Object)

    the current value of thresholds



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def thresholds
  @thresholds
end

#top_filesObject

Returns the value of attribute top_files

Returns:

  • (Object)

    the current value of top_files



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def top_files
  @top_files
end

#total_branchesObject

Returns the value of attribute total_branches

Returns:

  • (Object)

    the current value of total_branches



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def total_branches
  @total_branches
end

#total_linesObject

Returns the value of attribute total_lines

Returns:

  • (Object)

    the current value of total_lines



144
145
146
# File 'lib/rails_doctor/models.rb', line 144

def total_lines
  @total_lines
end

Instance Method Details

#summaryObject



173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/rails_doctor/models.rb', line 173

def summary
  {
    available: available,
    status: status,
    source: source,
    line_percent: line_percent,
    branch_percent: branch_percent,
    thresholds: thresholds,
    low_file_count: low_file_count || top_files.count { |file| file[:below_threshold] },
    changed_file_low_count: changed_files_below_threshold.size
  }.compact
end

#to_hObject



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/rails_doctor/models.rb', line 186

def to_h
  {
    available: available,
    status: status,
    source: source,
    report_path: report_path,
    line_percent: line_percent,
    branch_percent: branch_percent,
    covered_lines: covered_lines,
    missed_lines: missed_lines,
    total_lines: total_lines,
    covered_branches: covered_branches,
    missed_branches: missed_branches,
    total_branches: total_branches,
    thresholds: thresholds,
    top_files: top_files,
    low_file_count: low_file_count,
    changed_files_below_threshold: changed_files_below_threshold,
    metadata: 
  }.compact
end