Sha256: 9120e6694d689312b8c806d6599b54a80035555afa50dd15d188e48b64544f3a

Contents?: true

Size: 563 Bytes

Versions: 22

Compression:

Stored size: 563 Bytes

Contents

module Ruboty
  class Env
    attr_reader :key, :description, :options

    def initialize(key, description, options = {})
      @key = key.to_s
      @description = description
      @options = options
    end

    def validate
      error if required? && missing?
    end

    def to_usage
      "    %-30s - %s" % [key, description]
    end

    private

    def required?
      !options[:optional]
    end

    def missing?
      !ENV[key]
    end

    def error
      raise MissingRequiredKeyError, %<ENV["#{key}"] is required but missing>
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ruboty-1.3.1 lib/ruboty/env.rb
ruboty-1.3.0 lib/ruboty/env.rb
ruboty-1.2.4 lib/ruboty/env.rb
ruboty-1.2.3 lib/ruboty/env.rb
ruboty-1.2.2 lib/ruboty/env.rb
ruboty-1.2.1 lib/ruboty/env.rb
ruboty-1.2.0 lib/ruboty/env.rb
ruboty-1.1.9 lib/ruboty/env.rb
ruboty-1.1.8 lib/ruboty/env.rb
ruboty-1.1.7 lib/ruboty/env.rb
ruboty-1.1.6 lib/ruboty/env.rb
ruboty-1.1.5 lib/ruboty/env.rb
ruboty-1.1.4 lib/ruboty/env.rb
ruboty-1.1.3 lib/ruboty/env.rb
ruboty-1.1.2 lib/ruboty/env.rb
ruboty-1.1.1 lib/ruboty/env.rb
ruboty-1.1.0 lib/ruboty/env.rb
ruboty-1.0.4 lib/ruboty/env.rb
ruboty-1.0.3 lib/ruboty/env.rb
ruboty-1.0.2 lib/ruboty/env.rb