Class: Metrics::Loader
- Inherits:
-
Object
- Object
- Metrics::Loader
- Defined in:
- lib/compose_compiler_metrics/metrics.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Loader
constructor
A new instance of Loader.
- #load ⇒ Object
- #metrics_hash ⇒ Object
Constructor Details
#initialize(path) ⇒ Loader
Returns a new instance of Loader.
54 55 56 |
# File 'lib/compose_compiler_metrics/metrics.rb', line 54 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
52 53 54 |
# File 'lib/compose_compiler_metrics/metrics.rb', line 52 def path @path end |
Instance Method Details
#load ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/compose_compiler_metrics/metrics.rb', line 62 def load advanced_metrics_hash = metrics_hash.each.with_object({}) do |(k, v), h| h[k] = v case k when "skippableComposables" h["unskippableComposables"] = metrics_hash["totalComposables"] - metrics_hash["skippableComposables"] when "restartableComposables" h["unrestartableComposables"] = metrics_hash["totalComposables"] - metrics_hash["restartableComposables"] end end Metrics.new(advanced_metrics_hash) end |
#metrics_hash ⇒ Object
58 59 60 |
# File 'lib/compose_compiler_metrics/metrics.rb', line 58 def metrics_hash @metrics_hash ||= JSON.parse(File.read(path)) end |