Sha256: b02d2b288890b2c9af04d65ab8cb3e49fa02f61918f659ded647e0dd1d50ae48

Contents?: true

Size: 685 Bytes

Versions: 11

Compression:

Stored size: 685 Bytes

Contents

module Ellen
  class Env
    module Validatable
      extend ActiveSupport::Concern

      module ClassMethods
        def envs
          @envs ||= []
        end

        def env(key, description, options = {})
          envs << Env.new(key, description, options)
        end

        def usage
          envs.map(&:to_usage).join("\n")
        end
      end

      def validate
        self.class.envs.each(&:validate)
      rescue MissingRequiredKeyError => exception
        raise ValidationError, "#{exception}\n#{self.class.usage}"
      end

      def validate!
        validate
      rescue ValidationError => exception
        Ellen.die(exception)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ellen-0.2.8 lib/ellen/env/validatable.rb
ellen-0.2.7 lib/ellen/env/validatable.rb
ellen-0.2.6 lib/ellen/env/validatable.rb
ellen-0.2.5 lib/ellen/env/validatable.rb
ellen-0.2.4 lib/ellen/env/validatable.rb
ellen-0.2.3 lib/ellen/env/validatable.rb
ellen-0.2.2 lib/ellen/env/validatable.rb
ellen-0.2.1 lib/ellen/env/validatable.rb
ellen-0.2.0 lib/ellen/env/validatable.rb
ellen-0.1.3 lib/ellen/env/validatable.rb
ellen-0.1.2 lib/ellen/env/validatable.rb