Class: PetriDish::Config
- Inherits:
-
Object
- Object
- PetriDish::Config
- Defined in:
- lib/petri_dish/config.rb
Constant Summary collapse
- REQUIRED_KEYS =
%w[name description environment runtime].freeze
- REQUIRED_ENV_KEYS =
%w[name].freeze
- VALID_PROMPT_MODES =
%w[accept deny].freeze
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prompt_mode ⇒ Object
readonly
Returns the value of attribute prompt_mode.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#test_dir ⇒ Object
readonly
Returns the value of attribute test_dir.
Instance Method Summary collapse
-
#initialize(test_dir) ⇒ Config
constructor
A new instance of Config.
- #prompt_path ⇒ Object
Constructor Details
#initialize(test_dir) ⇒ Config
Returns a new instance of Config.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/petri_dish/config.rb', line 14 def initialize(test_dir) @test_dir = Pathname.new(test_dir). config_path = @test_dir / "config.yml" raise "Config not found: #{config_path}" unless config_path.exist? data = YAML.safe_load(config_path.read, permitted_classes: [Symbol]) validate!(data) @name = data["name"] @description = data["description"] @environment = parse_environment(data["environment"]) @runtime = parse_runtime(data["runtime"]) @prompt_mode = parse_prompt_mode(data["prompt_mode"]) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def description @description end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def environment @environment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def name @name end |
#prompt_mode ⇒ Object (readonly)
Returns the value of attribute prompt_mode.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def prompt_mode @prompt_mode end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def runtime @runtime end |
#test_dir ⇒ Object (readonly)
Returns the value of attribute test_dir.
12 13 14 |
# File 'lib/petri_dish/config.rb', line 12 def test_dir @test_dir end |
Instance Method Details
#prompt_path ⇒ Object
29 30 31 |
# File 'lib/petri_dish/config.rb', line 29 def prompt_path test_dir / "prompt.md" end |