usergrid_iron 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -0
- data/lib/usergrid/core/collection.rb +17 -6
- data/lib/usergrid/version.rb +1 -1
- data/spec/usergrid/core/collection_spec.rb +4 -3
- metadata +4 -4
data/README.md
CHANGED
@@ -3,7 +3,6 @@ module Usergrid
|
|
3
3
|
include Enumerable
|
4
4
|
|
5
5
|
attr_accessor :iterator_follows_cursor
|
6
|
-
attr_reader :query_params
|
7
6
|
|
8
7
|
def initialize(url, api_url, options={}, response=nil)
|
9
8
|
super url, api_url, options, response
|
@@ -55,16 +54,16 @@ module Usergrid
|
|
55
54
|
# options: 'reversed', 'start', 'cursor', 'limit', 'permission'
|
56
55
|
def update_query(updates, query=nil, options={})
|
57
56
|
options = options.symbolize_keys
|
58
|
-
|
59
|
-
self.put(updates, {params:
|
57
|
+
query_params = query ? options.merge({ql: query}) : options
|
58
|
+
self.put(updates, {params: query_params })
|
60
59
|
self
|
61
60
|
end
|
62
61
|
|
63
62
|
# options: 'reversed', 'start', 'cursor', 'limit', 'permission'
|
64
63
|
def query(query=nil, options={})
|
65
64
|
options = options.symbolize_keys
|
66
|
-
|
67
|
-
self.get({params:
|
65
|
+
query_params = query ? options.merge({ql: query}) : options
|
66
|
+
self.get({params: query_params })
|
68
67
|
self
|
69
68
|
end
|
70
69
|
|
@@ -81,7 +80,19 @@ module Usergrid
|
|
81
80
|
end
|
82
81
|
|
83
82
|
def next_page
|
84
|
-
query(nil,
|
83
|
+
query(nil, query_params.merge({cursor: cursor}))
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
def query_params
|
89
|
+
params = {}
|
90
|
+
if response.data['params']
|
91
|
+
response.data['params'].each do |k,v|
|
92
|
+
params[k] = v[0]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
params
|
85
96
|
end
|
86
97
|
end
|
87
98
|
end
|
data/lib/usergrid/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe Usergrid::Collection do
|
|
8
8
|
@entity_data = (1..25).collect do |i|
|
9
9
|
{ name: "name_#{i}", value: "value_#{i+1}" }
|
10
10
|
end
|
11
|
+
(1..3).each {|i| @entity_data[i]['three'] = 3}
|
11
12
|
@collection.create_entities @entity_data
|
12
13
|
end
|
13
14
|
|
@@ -63,10 +64,10 @@ describe Usergrid::Collection do
|
|
63
64
|
end
|
64
65
|
|
65
66
|
it "should be able to page forward by cursor" do
|
66
|
-
@collection.query
|
67
|
+
@collection.query 'select * where three = 3', limit: 2
|
67
68
|
@collection.next_page
|
68
|
-
@collection.size.should eq
|
69
|
-
@collection[0].name.should eq @entity_data[
|
69
|
+
@collection.size.should eq 1
|
70
|
+
@collection[0].name.should eq @entity_data[3][:name]
|
70
71
|
end
|
71
72
|
|
72
73
|
it "should be able to update based on a query" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usergrid_iron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
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:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: -759495065477750704
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
version: '0'
|
159
159
|
segments:
|
160
160
|
- 0
|
161
|
-
hash:
|
161
|
+
hash: -759495065477750704
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
164
|
rubygems_version: 1.8.24
|