lib/conker.rb in conker-0.13.1 vs lib/conker.rb in conker-0.14.1

- old
+ new

@@ -34,10 +34,11 @@ def initialize(type); super("unknown type #{type}"); end end class MissingDefault < Error def initialize; super("missing default value"); end end + class IncompatibleType < Error; end class << self # Parse a multi-key hash into globals and raise an informative error message on failure. def setup_config!(current_env, *args) @@ -116,10 +117,19 @@ :development => "redis://localhost/1", :test => "redis://localhost/3" }.merge(opts)) end + # A couchbase_url is required_in_production with development defaulting to + # localhost/default and test defaulting to localhost/test. + def couchbase_url(opts = {}) + required_in_production({ + :development => 'http://localhost:8091/pools/default/buckets/default', + :test => 'http://localhost:8091/pools/default/buckets/test', + }.merge(opts)) + end + # Declare an environment variable, defaulting to other values if not defined. # # You must either specify a :default, or specify defaults for each of # :production, :test and :development. def optional(declaration_opts = {}) @@ -260,9 +270,14 @@ raise MustBeDefined if value.nil? # there's nothing sensible to default to. Time.iso8601(value.to_s).utc when :string, nil value.to_s # defaults to '' if omitted + when :hash + unless value.is_a? Hash + raise IncompatibleType, "wanted a Hash, got #{value.class}" + end + value else raise UnknownType, type.to_s end end end