Class: Evertils::Common::Entity::Stack

Inherits:
Base show all
Defined in:
lib/evertils/common/entity/stack.rb

Overview

Since:

  • 0.3.0

Constant Summary

Constants inherited from Base

Base::REPLACEMENTS

Instance Attribute Summary

Attributes inherited from Base

#entity

Instance Method Summary collapse

Methods inherited from Base

#end_of_day, #initialize, #placeholders_for, #prop, #start_of_day, #symbolize_keys, #to_s

Methods inherited from Generic

#bytesize, #deprecation_notice, #encoding, #force_encoding, #has_required_fields, #initialize

Constructor Details

This class inherits a constructor from Evertils::Common::Entity::Base

Instance Method Details

#create_from_yml(full_path) ⇒ Object

Since:

  • 0.3.0



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/evertils/common/entity/stack.rb', line 5

def create_from_yml(full_path)
  raise "File not found: #{full_path}" unless File.exist? full_path

  begin
    nb = Notebook.new

    conf = YAML::load(File.open(full_path))
    required = %w(name children)

    if has_required_fields(conf, required)
      if !conf["children"].nil?
        conf["children"].each do |name|
          nb.create(name, conf["name"])
        end
      end
    else
      raise ArgumentError, 'Configuration file is missing some required fields'
    end
  rescue ArgumentError => e
    puts e.message
  end
end