schema 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,11 @@ end
26
26
 
27
27
  class DateTime
28
28
  def self.from val
29
- parse val
29
+ case val
30
+ when DateTime
31
+ val
32
+ else
33
+ parse val.to_s
34
+ end
30
35
  end
31
36
  end
@@ -26,4 +26,8 @@ module Schema
26
26
  schema.from(object)
27
27
  end
28
28
  end
29
+
30
+ def self.include!
31
+ Object.send :include, Schema::Include
32
+ end
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module Schema
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{schema}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Daniel Kirsch"]
12
+ s.date = %q{2010-12-01}
13
+ s.description = %q{Deep type conversion through schemas for hashes}
14
+ s.email = %q{danishkirel@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "autotest/discover.rb",
25
+ "lib/schema.rb",
26
+ "lib/schema/core_ext.rb",
27
+ "lib/schema/include.rb",
28
+ "lib/schema/schema.rb",
29
+ "lib/schema/version.rb",
30
+ "schema.gemspec",
31
+ "spec/schema_spec.rb",
32
+ "spec/spec_helper.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/kirel/schema}
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.7}
37
+ s.summary = %q{Schemas for hashes}
38
+ s.test_files = [
39
+ "spec/schema_spec.rb",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+
43
+ if s.respond_to? :specification_version then
44
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_development_dependency(%q<rspec>, ["~> 2.2"])
49
+ s.add_development_dependency(%q<yard>, [">= 0"])
50
+ else
51
+ s.add_dependency(%q<rspec>, ["~> 2.2"])
52
+ s.add_dependency(%q<yard>, [">= 0"])
53
+ end
54
+ else
55
+ s.add_dependency(%q<rspec>, ["~> 2.2"])
56
+ s.add_dependency(%q<yard>, [">= 0"])
57
+ end
58
+ end
59
+
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- Object.send :include, Schema::Include
3
+ Schema.include!
4
4
 
5
5
  describe "Schema" do
6
6
 
@@ -14,6 +14,8 @@ describe "Schema" do
14
14
  end
15
15
 
16
16
  it "should cast dates" do
17
+ dt = DateTime.now
18
+ dt.transform(DateTime).should == dt
17
19
  '2010-12-01T12:00:00+01:00'.transform(DateTime).should == DateTime.parse('2010-12-01T12:00:00+01:00')
18
20
  '2010-12-01'.transform(Date).should == Date.parse('2010-12-01')
19
21
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Kirsch
@@ -64,6 +64,7 @@ files:
64
64
  - lib/schema/include.rb
65
65
  - lib/schema/schema.rb
66
66
  - lib/schema/version.rb
67
+ - schema.gemspec
67
68
  - spec/schema_spec.rb
68
69
  - spec/spec_helper.rb
69
70
  has_rdoc: true