interpreted_date 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,6 +60,15 @@ class InterpretedDate
60
60
  end
61
61
  end
62
62
 
63
+ def self.from_json(json)
64
+ d = InterpretedDate.new
65
+ d.decade = json['decade']
66
+ d.year = json['year']
67
+ d.month = json['month']
68
+ d.day = json['day']
69
+ d
70
+ end
71
+
63
72
  def as_json(options = {})
64
73
  {
65
74
  'string' => self.to_s,
@@ -90,4 +99,8 @@ class InterpretedDate
90
99
  [decade, year, month, day].any?(&:present?)
91
100
  end
92
101
 
102
+ def ==(other_date)
103
+ self.decade == other_date.decade && self.year == other_date.year && self.month == other_date.month && self.day == other_date.day
104
+ end
105
+
93
106
  end
@@ -1,3 +1,3 @@
1
1
  class InterpretedDate
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -94,4 +94,12 @@ describe InterpretedDate do
94
94
  end
95
95
  end
96
96
 
97
+ describe "#from_json" do
98
+ subject { InterpretedDate.new({:year => 2012, :month => 2, :day => 31}) }
99
+
100
+ it "correctly parses the json" do
101
+ subject.should == InterpretedDate.from_json('year' => 2012, 'month' => 2, 'day' => 31)
102
+ end
103
+ end
104
+
97
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interpreted_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-13 00:00:00.000000000 Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec