dm-parse 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.13
1
+ 0.3.14
data/dm-parse.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dm-parse"
8
- s.version = "0.3.13"
8
+ s.version = "0.3.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zhi-Qiang Lei"]
@@ -5,6 +5,8 @@ module DataMapper
5
5
 
6
6
  def dump(value)
7
7
  case value
8
+ when ::Date
9
+ {"__type" => "Date", "iso" => value.to_datetime.utc.iso8601(3)}
8
10
  when ::DateTime
9
11
  {"__type" => "Date", "iso" => value.utc.iso8601(3)}
10
12
  when ::Hash
@@ -31,8 +31,16 @@ describe DataMapper::Adapters::ParseAdapter do
31
31
 
32
32
  [:gt, :gte, :lt, :lte].each do |slug|
33
33
  context "when query has #{slug} comparison" do
34
- let(:query) { model.all(:id => "z", :rank.send(slug) => 5).query }
35
- it { should eq("objectId" => "z", "rank" => {"$#{slug}" => 5}) }
34
+ let(:closed_at) { DateTime.parse("2011-08-21T18:02:52.249Z") }
35
+ let(:query) { model.all(:id => "z", :closed_at.send(slug) => closed_at).query }
36
+
37
+ it { should eq("objectId" => "z", "closedAt" => {"$#{slug}" => {"__type" => "Date", "iso" => closed_at.utc.iso8601(3)}}) }
38
+
39
+ context "when closed_at is a Date" do
40
+ let(:closed_at) { Date.parse "2011-08-21" }
41
+
42
+ it { should eq("objectId" => "z", "closedAt" => {"$#{slug}" => {"__type" => "Date", "iso" => closed_at.to_datetime.utc.iso8601(3)}}) }
43
+ end
36
44
  end
37
45
  end
38
46
 
@@ -16,6 +16,12 @@ describe DataMapper::Property::ParseDate do
16
16
 
17
17
  it { should be_nil }
18
18
  end
19
+
20
+ context "when value is Date" do
21
+ let(:value) { Date.parse "2011-08-21" }
22
+
23
+ it { should eq("__type" => "Date", "iso" => value.to_datetime.utc.iso8601(3)) }
24
+ end
19
25
  end
20
26
 
21
27
  describe "#load" do
data/spec/spec_helper.rb CHANGED
@@ -40,7 +40,7 @@ class Article
40
40
  property :title, String
41
41
  property :body, Text
42
42
  property :rank, Integer
43
- property :closed_at, ParseDate
43
+ property :closed_at, ParseDate, field: "closedAt"
44
44
  property :attachment, ParseFile
45
45
 
46
46
  has n, :comments
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-parse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -258,7 +258,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
258
  version: '0'
259
259
  segments:
260
260
  - 0
261
- hash: 761272249426178735
261
+ hash: 1932617468942195095
262
262
  required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  none: false
264
264
  requirements: