Sha256: 9b8615984ec605962f24041190d69d65488caef173388cb20cdfb8d4503ab290

Contents?: true

Size: 900 Bytes

Versions: 4

Compression:

Stored size: 900 Bytes

Contents

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

        def create_from_yml(full_path)
          begin
            nb = Notebook.new

            if File.exists? 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

4 entries across 4 versions & 1 rubygems

Version Path
evertils-common-0.2.8.2 lib/evertils/common/entity/stack.rb
evertils-common-0.2.8.1 lib/evertils/common/entity/stack.rb
evertils-common-0.2.8 lib/evertils/common/entity/stack.rb
evertils-common-0.2.7 lib/evertils/common/entity/stack.rb