configit 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/configit.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{configit}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Kris Rasmussen"]
9
- s.date = %q{2009-12-22}
9
+ s.date = %q{2010-02-17}
10
10
  s.default_executable = %q{configit}
11
11
  s.description = %q{The purpose of this gem is to make it very easy to consume configuration files
12
12
  and define them.}
data/lib/configit.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module Configit
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -30,7 +30,9 @@ module Configit
30
30
 
31
31
  # Returns an error string if the value is not valid per this AttributeDefinition
32
32
  def validate(value)
33
- return "#{name} is a required attribute" if required? && value == nil || value == ""
33
+ if required? && (value == nil || value == "") && (default == nil || default == "")
34
+ return "#{name} is a required attribute"
35
+ end
34
36
  # TODO: add type validation here
35
37
  nil
36
38
  end
@@ -90,6 +90,12 @@ describe Configit::Base do
90
90
  config = FooConfig.load_from_string("")
91
91
  config.valid?.should be_false
92
92
  end
93
+
94
+ it "should be valid when required attributes with default values are absent" do
95
+ FooConfig.attribute :foo, :required => true, :default => "foo"
96
+ config = FooConfig.load_from_string("")
97
+ config.valid?.should be_true
98
+ end
93
99
 
94
100
  it "should be valid when non required attributes are abset" do
95
101
  FooConfig.attribute :foo, :required => false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Rasmussen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 -08:00
12
+ date: 2010-02-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency