Class: Optimize::Demo::Walkthrough
- Inherits:
-
Object
- Object
- Optimize::Demo::Walkthrough
- Defined in:
- lib/optimize/demo/walkthrough.rb
Defined Under Namespace
Classes: InvalidSidecar
Constant Summary collapse
- REQUIRED_FIELDS =
%w[fixture entry_setup entry_call walkthrough].freeze
Instance Attribute Summary collapse
-
#entry_call ⇒ Object
readonly
Returns the value of attribute entry_call.
-
#entry_setup ⇒ Object
readonly
Returns the value of attribute entry_setup.
-
#fixture ⇒ Object
readonly
Returns the value of attribute fixture.
-
#sidecar_path ⇒ Object
readonly
Returns the value of attribute sidecar_path.
-
#walkthrough ⇒ Object
readonly
Returns the value of attribute walkthrough.
Class Method Summary collapse
Instance Method Summary collapse
- #fixture_path ⇒ Object
-
#initialize(sidecar_path:, fixture:, entry_setup:, entry_call:, walkthrough:) ⇒ Walkthrough
constructor
A new instance of Walkthrough.
Constructor Details
#initialize(sidecar_path:, fixture:, entry_setup:, entry_call:, walkthrough:) ⇒ Walkthrough
Returns a new instance of Walkthrough.
39 40 41 42 43 44 45 |
# File 'lib/optimize/demo/walkthrough.rb', line 39 def initialize(sidecar_path:, fixture:, entry_setup:, entry_call:, walkthrough:) @sidecar_path = sidecar_path @fixture = fixture @entry_setup = entry_setup @entry_call = entry_call @walkthrough = walkthrough end |
Instance Attribute Details
#entry_call ⇒ Object (readonly)
Returns the value of attribute entry_call.
13 14 15 |
# File 'lib/optimize/demo/walkthrough.rb', line 13 def entry_call @entry_call end |
#entry_setup ⇒ Object (readonly)
Returns the value of attribute entry_setup.
13 14 15 |
# File 'lib/optimize/demo/walkthrough.rb', line 13 def entry_setup @entry_setup end |
#fixture ⇒ Object (readonly)
Returns the value of attribute fixture.
13 14 15 |
# File 'lib/optimize/demo/walkthrough.rb', line 13 def fixture @fixture end |
#sidecar_path ⇒ Object (readonly)
Returns the value of attribute sidecar_path.
13 14 15 |
# File 'lib/optimize/demo/walkthrough.rb', line 13 def sidecar_path @sidecar_path end |
#walkthrough ⇒ Object (readonly)
Returns the value of attribute walkthrough.
13 14 15 |
# File 'lib/optimize/demo/walkthrough.rb', line 13 def walkthrough @walkthrough end |
Class Method Details
.load(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/optimize/demo/walkthrough.rb', line 15 def self.load(path) data = Psych.safe_load_file(path, permitted_classes: []) raise InvalidSidecar, "sidecar is not a mapping: #{path}" unless data.is_a?(Hash) missing = REQUIRED_FIELDS - data.keys raise InvalidSidecar, "missing fields #{missing.inspect} in #{path}" unless missing.empty? wt_names = Array(data["walkthrough"]).map(&:to_sym) valid = Pipeline.default.passes.map(&:name) unknown = wt_names - valid unless unknown.empty? raise InvalidSidecar, "unknown pass name(s) in #{path}: #{unknown.inspect}; valid: #{valid.inspect}" end new( sidecar_path: path, fixture: data["fixture"], entry_setup: data["entry_setup"].to_s, entry_call: data["entry_call"], walkthrough: wt_names, ) end |
Instance Method Details
#fixture_path ⇒ Object
47 48 49 |
# File 'lib/optimize/demo/walkthrough.rb', line 47 def fixture_path File.(@fixture, File.dirname(@sidecar_path)) end |