Sha256: 58f71a9dcbe1d24362bede01775c81adac716c086c84b907e4b327f9329e01cb

Contents?: true

Size: 899 Bytes

Versions: 3

Compression:

Stored size: 899 Bytes

Contents

module Evertils
  module Common
    module Entity
      class Stack < Entity::Base

        def create_from_yml(full_path)
          begin
            nb = Notebook.new

            if File.exist? full_path
              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
            else
              raise ArgumentError, "File not found: #{full_path}"
            end
          rescue ArgumentError => e
            puts e.message
          end
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
evertils-common-0.3.1 lib/evertils/common/entity/stack.rb
evertils-common-0.3.0 lib/evertils/common/entity/stack.rb
evertils-common-0.2.9 lib/evertils/common/entity/stack.rb