Sha256: fb31cf11669904e44304e71be9a39bbd94a99d92b4a96aafced04ece22c1e32c

Contents?: true

Size: 727 Bytes

Versions: 8

Compression:

Stored size: 727 Bytes

Contents

require 'psych'

module Canals
  class CanalEnvironmentError < StandardError; end

  class Environment
    attr_reader :name, :user, :hostname, :pem
    def initialize(args)
      @args = validate?(args)
      @name = @args["name"]
      @user = @args["user"]
      @hostname = @args["hostname"]
      @pem = @args["pem"]
    end

    def validate?(args)
      vargs = args.dup
      raise CanalEnvironmentError.new("Missing option: \"name\" in environment creation") if args["name"].nil?
      vargs
    end

    def default=(val)
      @args["default"] = !!val
    end

    def is_default?
      !!@args["default"]
    end

    def to_yaml
      Psych.dump(@args)
    end

    def to_hash
      @args.dup
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
canals-0.8.7 lib/canals/environment.rb
canals-0.8.6 lib/canals/environment.rb
canals-0.8.5 lib/canals/environment.rb
canals-0.8.4 lib/canals/environment.rb
canals-0.8.3 lib/canals/environment.rb
canals-0.8.2 lib/canals/environment.rb
canals-0.8.1 lib/canals/environment.rb
canals-0.8.0 lib/canals/environment.rb