ruby-ext-js 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -61,6 +61,22 @@ Examples:
61
61
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
62
62
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
63
63
 
64
+ # Version history
65
+
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
+
68
+ ## 0.2.0
69
+
70
+ * `ExtJs::Mongo.conditions` now returns a hash with string keys only instead of mixed string / symbol keys for better consistency with the [MongoDB Ruby driver](http://api.mongodb.org/ruby/1.2.0/index.html)
71
+
72
+ ## 0.1.0
73
+
74
+ * All-new API for `ExtJs::Mongo` to match with MongoDB's Ruby drivers better.
75
+
76
+ ## 0.0.1
77
+
78
+ * Initial release. Basic Postgres / Mongo adapters.
79
+
64
80
  # Copyright
65
81
 
66
82
  Copyright (c) 2011 CrowdFlower. See LICENSE.txt for
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/ruby-ext-js.rb CHANGED
@@ -22,7 +22,7 @@ module ExtJs
22
22
  {
23
23
  :order => [order],
24
24
  :offset => offset,
25
- :limit => limit
25
+ "limit" => limit
26
26
  }
27
27
  end
28
28
 
@@ -70,7 +70,10 @@ module ExtJs
70
70
  DEFAULT_LIMIT = 50
71
71
 
72
72
  def initialize( params )
73
- @params = params
73
+ @params = {}
74
+ params.each do |k, v|
75
+ @params[k.to_s] = v
76
+ end
74
77
  end
75
78
 
76
79
  # @return [Hash] `find()` conditions for `Mongo::Collection.find( conditions, opts )`
@@ -97,13 +100,13 @@ module ExtJs
97
100
  protected
98
101
 
99
102
  def self.skip_param( params )
100
- return { :skip => DEFAULT_SKIP } unless params.key?( "start" ) && params.key?( "limit" )
101
- { :skip => [params["start"].to_i, 0].max }
103
+ return { "skip" => DEFAULT_SKIP } unless params.key?( "start" ) && params.key?( "limit" )
104
+ { "skip" => [params["start"].to_i, 0].max }
102
105
  end
103
106
 
104
107
  def self.limit_param( params )
105
- return { :limit => DEFAULT_LIMIT } unless params.key?( "limit" ) && params["limit"].to_i > 0
106
- { :limit => [params["limit"].to_i, MAX_LIMIT].min }
108
+ return { "limit" => DEFAULT_LIMIT } unless params.key?( "limit" ) && params["limit"].to_i > 0
109
+ { "limit" => [params["limit"].to_i, MAX_LIMIT].min }
107
110
  end
108
111
 
109
112
  def self.sort_param( params )
@@ -112,7 +115,7 @@ module ExtJs
112
115
  sort = params["sort"] ? params["sort"].to_sym : :id
113
116
  dir = params["dir"] =~ /desc/i ? :desc : :asc
114
117
 
115
- { :sort => [sort, dir] }
118
+ { "sort" => [sort, dir] }
116
119
  end
117
120
 
118
121
  def self.search_param( params )
data/ruby-ext-js.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-ext-js}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
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"]
12
- s.date = %q{2011-01-20}
12
+ s.date = %q{2011-01-21}
13
13
  s.description = %q{Ultra-basic classes for working with Ext.js requests and translating them to DataMapper / Mongood query opts.}
14
14
  s.email = %q{tyson@doloreslabs.com}
15
15
  s.extra_rdoc_files = [
@@ -4,7 +4,7 @@ describe "ExtJs" do
4
4
  # describe "Postgres" do
5
5
  # it "sorts on id when you ask it to sort on created_at" do
6
6
  # ExtJs::Postgres.pagination_opts({
7
- # :sort => "created_at",
7
+ # "sort" => "created_at",
8
8
  # :order => "desc"
9
9
  # })[:order].should == [:id.asc]
10
10
  # end
@@ -91,25 +91,25 @@ describe "ExtJs" do
91
91
  class TestMongo < ExtJs::Mongo; end
92
92
 
93
93
  it "handles empty params with sensible defaults" do
94
- TestMongo.new( {} ).options.should == { :limit => 50, :skip => 0 }
94
+ TestMongo.new( {} ).options.should == { "limit" => 50, "skip" => 0 }
95
95
  end
96
96
 
97
97
  it "handles pagination" do
98
- TestMongo.new( "start" => "50", "limit" => "10" ).options.should == { :limit => 10, :skip => 50 }
99
- TestMongo.new( "start" => "10" ).options.should == { :limit => 50, :skip => 0 }
100
- TestMongo.new( "limit" => "10" ).options.should == { :limit => 10, :skip => 0 }
98
+ TestMongo.new( "start" => "50", "limit" => "10" ).options.should == { "limit" => 10, "skip" => 50 }
99
+ TestMongo.new( "start" => "10" ).options.should == { "limit" => 50, "skip" => 0 }
100
+ TestMongo.new( "limit" => "10" ).options.should == { "limit" => 10, "skip" => 0 }
101
101
  end
102
102
 
103
103
  it "handles sorting" do
104
- TestMongo.new( "sort" => "foo" ).options.should == { :limit => 50, :skip => 0, :sort => [:foo, :asc] }
105
- TestMongo.new( "sort" => "foo", "dir" => "desc" ).options.should == { :limit => 50, :skip => 0, :sort => [:foo, :desc] }
106
- TestMongo.new( "sort" => "foo", "dir" => "no idea" ).options.should == { :limit => 50, :skip => 0, :sort => [:foo, :asc] }
107
- TestMongo.new( "dir" => "asc" ).options.should == { :limit => 50, :skip => 0 }
104
+ TestMongo.new( "sort" => "foo" ).options.should == { "limit" => 50, "skip" => 0, "sort" => [:foo, :asc] }
105
+ TestMongo.new( "sort" => "foo", "dir" => "desc" ).options.should == { "limit" => 50, "skip" => 0, "sort" => [:foo, :desc] }
106
+ TestMongo.new( "sort" => "foo", "dir" => "no idea" ).options.should == { "limit" => 50, "skip" => 0, "sort" => [:foo, :asc] }
107
+ TestMongo.new( "dir" => "asc" ).options.should == { "limit" => 50, "skip" => 0 }
108
108
  end
109
109
 
110
110
  it "prevents dumb queries" do
111
- TestMongo.new( "start" => "9999999", "limit" => "9999999" ).options.should == { :limit => 500, :skip => 9999999 }
112
- TestMongo.new( "start" => "-200", "limit" => "-200" ).options.should == { :limit => 50, :skip => 0 }
111
+ TestMongo.new( "start" => "9999999", "limit" => "9999999" ).options.should == { "limit" => 500, "skip" => 9999999 }
112
+ TestMongo.new( "start" => "-200", "limit" => "-200" ).options.should == { "limit" => 50, "skip" => 0 }
113
113
  end
114
114
  end
115
115
  end
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: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyson Tate
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-20 00:00:00 -08:00
18
+ date: 2011-01-21 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency