Class: MetricFu::HotspotRankedProblemLocation
- Inherits:
-
Object
- Object
- MetricFu::HotspotRankedProblemLocation
- Defined in:
- lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb
Instance Attribute Summary collapse
-
#granularity ⇒ Object
readonly
Returns the value of attribute granularity.
-
#sub_table ⇒ Object
readonly
Returns the value of attribute sub_table.
Instance Method Summary collapse
- #assert_sub_table_has_data ⇒ Object
- #class_location ⇒ Object
- #class_name ⇒ Object
- #file_location ⇒ Object
- #file_path ⇒ Object
- #first_row ⇒ Object
-
#initialize(sub_table, granularity) ⇒ HotspotRankedProblemLocation
constructor
A new instance of HotspotRankedProblemLocation.
- #location ⇒ Object
- #method_location ⇒ Object
- #method_name ⇒ Object
-
#problems ⇒ Object
Note that the other option for ‘details’ is :detailed (this isn’t at all clear from this method itself.
- #stringify_keys(hash) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(sub_table, granularity) ⇒ HotspotRankedProblemLocation
Returns a new instance of HotspotRankedProblemLocation.
7 8 9 10 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 7 def initialize(sub_table, granularity) @sub_table = sub_table @granularity = granularity end |
Instance Attribute Details
#granularity ⇒ Object (readonly)
Returns the value of attribute granularity.
6 7 8 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 6 def granularity @granularity end |
#sub_table ⇒ Object (readonly)
Returns the value of attribute sub_table.
6 7 8 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 6 def sub_table @sub_table end |
Instance Method Details
#assert_sub_table_has_data ⇒ Object
72 73 74 75 76 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 72 def assert_sub_table_has_data if (sub_table.length == 0) raise MetricFu::AnalysisError, "The #{item} '#{value}' does not have any rows in the analysis table" end end |
#class_location ⇒ Object
63 64 65 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 63 def class_location MetricFu::Location.get(file_path, class_name, nil) end |
#class_name ⇒ Object
47 48 49 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 47 def class_name first_row.class_name end |
#file_location ⇒ Object
55 56 57 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 55 def file_location MetricFu::Location.get(file_path, nil, nil) end |
#file_path ⇒ Object
43 44 45 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 43 def file_path first_row.file_path end |
#first_row ⇒ Object
67 68 69 70 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 67 def first_row assert_sub_table_has_data @first_row ||= sub_table[0] end |
#location ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 34 def location @location ||= case granularity when :class then class_location when :method then method_location when :file then file_location else raise ArgumentError, "Item must be :class, :method, or :file" end end |
#method_location ⇒ Object
59 60 61 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 59 def method_location MetricFu::Location.get(file_path, class_name, method_name) end |
#method_name ⇒ Object
51 52 53 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 51 def method_name first_row.method_name end |
#problems ⇒ Object
TODO:
redo as item,value, options = {}
Note that the other option for ‘details’ is :detailed (this isn’t at all clear from this method itself
30 31 32 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 30 def problems @problems ||= MetricFu::HotspotProblems.new(sub_table).problems end |
#stringify_keys(hash) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 19 def stringify_keys(hash) result = {} hash.each do |key, value| result[key.to_s] = value end result end |
#to_hash ⇒ Object
12 13 14 15 16 17 |
# File 'lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb', line 12 def to_hash { "location" => location.to_hash, "details" => stringify_keys(problems), } end |