ruby-ext-js 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -65,6 +65,10 @@ Examples:
65
65
 
66
66
  Version number conventions: Patch-level bumps for bug fixes, minor-level bumps for changes that break backwards-compatibility, major-level bumps for major new features.
67
67
 
68
+ ## 0.3.1
69
+
70
+ * Use `Time.utc` instead of `Date` for `ExtJs::Mongo` date range filters.
71
+
68
72
  ## 0.3.0
69
73
 
70
74
  * `ExtJs::Mongo` now supports 'date' filter params with "gt" and "lt" params.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/lib/ruby-ext-js.rb CHANGED
@@ -150,8 +150,14 @@ module ExtJs
150
150
 
151
151
  case hash["data"]["type"]
152
152
  when "date"
153
- values.map!{ |date| Date.parse( date ) }
154
- values = { comparison => values[0] }
153
+ values.map!{ |date| date = Date.parse( date ); Time.utc( date.year, date.month, date.day ) }
154
+ if comparison == "=="
155
+ start_time = values[0]
156
+ end_time = Time.utc( start_time.year, start_time.month, start_time.day, 23, 59, 59 )
157
+ values = { comparison_for( "gt" ) => start_time, comparison_for( "lt" ) => end_time }
158
+ else
159
+ values = { comparison => values[0] }
160
+ end
155
161
  else
156
162
  if values.size == 1
157
163
  values = values[0]
@@ -165,8 +171,9 @@ module ExtJs
165
171
 
166
172
  def self.comparison_for( str )
167
173
  case str
168
- when "lt"; "$lt"
169
- when "gt"; "$gt"
174
+ when "lt"; "$lte"
175
+ when "gt"; "$gte"
176
+ when "eq"; "=="
170
177
  else; "$in"
171
178
  end
172
179
  end
data/ruby-ext-js.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-ext-js}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tyson Tate"]
@@ -89,6 +89,8 @@ describe "ExtJs" do
89
89
 
90
90
  it "handles date range params" do
91
91
  date = Date.parse "11/26/2010"
92
+ start_time = Time.utc( date.year, date.month, date.day )
93
+ end_time = Time.utc( date.year, date.month, date.day, 23, 59, 59 )
92
94
 
93
95
  params = { "filter" => {
94
96
  "0" => {
@@ -100,9 +102,8 @@ describe "ExtJs" do
100
102
  "field" => "inserted_at"
101
103
  }
102
104
  }}
103
-
104
105
  mongo = TestMongoWithFilters.new( params )
105
- mongo.conditions.should == { "inserted_at" => { "$lt" => date } }
106
+ mongo.conditions.should == { "inserted_at" => { "$lte" => start_time } }
106
107
 
107
108
  params = { "filter" => {
108
109
  "0" => {
@@ -114,13 +115,26 @@ describe "ExtJs" do
114
115
  "field" => "inserted_at"
115
116
  }
116
117
  }}
118
+ mongo = TestMongoWithFilters.new( params )
119
+ mongo.conditions.should == { "inserted_at" => { "$gte" => start_time } }
117
120
 
121
+ params = { "filter" => {
122
+ "0" => {
123
+ "data" => {
124
+ "type" => "date",
125
+ "value" => "11/26/2010",
126
+ "comparison" => "eq"
127
+ },
128
+ "field" => "inserted_at"
129
+ }
130
+ }}
118
131
  mongo = TestMongoWithFilters.new( params )
119
- mongo.conditions.should == { "inserted_at" => { "$gt" => date } }
132
+ mongo.conditions.should == { "inserted_at" => { "$gte" => start_time, "$lte" => end_time } }
120
133
  end
121
134
 
122
135
  it "handles invalid comparison operators by falling back to $in" do
123
136
  date = Date.parse "11/26/2010"
137
+ start_time = Time.utc( date.year, date.month, date.day )
124
138
 
125
139
  params = { "filter" => {
126
140
  "0" => {
@@ -134,7 +148,7 @@ describe "ExtJs" do
134
148
  }}
135
149
 
136
150
  mongo = TestMongoWithFilters.new( params )
137
- mongo.conditions.should == { "inserted_at" => { "$in" => date } }
151
+ mongo.conditions.should == { "inserted_at" => { "$in" => start_time } }
138
152
  end
139
153
  end
140
154
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ext-js
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyson Tate