Class: Fiveruns::Tuneup::RootStep
- Inherits:
-
Object
- Object
- Fiveruns::Tuneup::RootStep
- Defined in:
- lib/fiveruns/tuneup/step.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #<<(child) ⇒ Object
- #child_times_by_layer ⇒ Object
- #children ⇒ Object
- #children_with_disparity ⇒ Object
- #depth ⇒ Object
- #leaf? ⇒ Boolean
- #leaves ⇒ Object
- #percentages_by_layer ⇒ Object
- #schemas ⇒ Object
- #size ⇒ Object
- #time ⇒ Object
Class Method Details
.framework_layers ⇒ Object
13 14 15 |
# File 'lib/fiveruns/tuneup/step.rb', line 13 def self.framework_layers [:model, :view, :controller] end |
.layers ⇒ Object
9 10 11 |
# File 'lib/fiveruns/tuneup/step.rb', line 9 def self.layers framework_layers + [:other] end |
Instance Method Details
#<<(child) ⇒ Object
29 30 31 32 |
# File 'lib/fiveruns/tuneup/step.rb', line 29 def <<(child) child.depth = depth + 1 children << child end |
#child_times_by_layer ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/fiveruns/tuneup/step.rb', line 60 def child_times_by_layer @child_times_by_layer ||= children.inject(Hash.new(0)) do |totals, child| child.percentages_by_layer.each do |layer, percentage| totals[layer] += child.time * percentage end totals end end |
#children ⇒ Object
42 43 44 |
# File 'lib/fiveruns/tuneup/step.rb', line 42 def children @children ||= [] end |
#children_with_disparity ⇒ Object
38 39 40 |
# File 'lib/fiveruns/tuneup/step.rb', line 38 def children_with_disparity children + [Step.disparity(disparity, self)] end |
#depth ⇒ Object
25 26 27 |
# File 'lib/fiveruns/tuneup/step.rb', line 25 def depth @depth ||= 0 end |
#leaf? ⇒ Boolean
46 47 48 |
# File 'lib/fiveruns/tuneup/step.rb', line 46 def leaf? children.blank? end |
#leaves ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/fiveruns/tuneup/step.rb', line 50 def leaves @leaves ||= begin if children.blank? [self] else children.map(&:leaves).flatten end end end |
#percentages_by_layer ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/fiveruns/tuneup/step.rb', line 69 def percentages_by_layer @percentages_by_layer ||= begin percentages = self.class.framework_layers.inject({}) do |map, layer| map[layer] = if leaf? self.layer == layer ? 1.0 : 0 else result = child_times_by_layer[layer] / self.time result = nil unless result.to_s =~ /\d/ result.is_a?(Numeric) ? result : 0 # TODO: Fix issue at source end map end fill percentages end end |
#schemas ⇒ Object
17 18 19 |
# File 'lib/fiveruns/tuneup/step.rb', line 17 def schemas @schemas ||= {} end |
#size ⇒ Object
34 35 36 |
# File 'lib/fiveruns/tuneup/step.rb', line 34 def size children.map(&:size).sum || 0 end |
#time ⇒ Object
21 22 23 |
# File 'lib/fiveruns/tuneup/step.rb', line 21 def time children.map(&:time).sum || 0 end |