motion-firebase 3.0.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 066ba16ed6cbd362da36f99fd21f67d612448e4a
4
- data.tar.gz: 081d92fe4423446906f32ada90afb492dc712466
3
+ metadata.gz: 7013544f3915514408c9cd0e5d26b30430a8d627
4
+ data.tar.gz: 1c07a8bf3388e49d5d592fc2490e5bf7f6e76aac
5
5
  SHA512:
6
- metadata.gz: 760c222fa74c30b5ce626295fde2557e824d2202ca1b578e8f384e198fc2d58447e0524ef2385f6eff40854662dfcb8cfb72f6394b99eaedc2838c0ff46f59e1
7
- data.tar.gz: 7be9163a2d8d3c5dedb2d26877bdc7275bbcecdd13155df19b79ef103898273f386bfcf997f5a3ba5c8eaca954b4ceac98e59c7c9a9ceb04166e0c496c7ebd77
6
+ metadata.gz: b93a6c8dffc7ba0b852bb2dcd9e57e0bf5a7d5c34ff4f6892b7c6538215f5dd3c81f1bf960bae10846e9a7f8bd025d36172049144dd4378ae0160ff9bad7818e
7
+ data.tar.gz: c49f30050e8f6c0c91f88c8d13fb5c096c3102b62d9cd1757ced67cfedb63092ba1eeb5e4ca6b7f52b7a2fa54e5acfa1025be2636c47cfde7029372d3effb58d
data/README.md CHANGED
@@ -157,6 +157,52 @@ firebase.limit(limit)
157
157
  # => firebase.queryLimitedToNumberOfChildren(limit)
158
158
  ```
159
159
 
160
+ ##### Querying
161
+
162
+ ```ruby
163
+ firebase.query(order_by_key: true)
164
+ # => firebase.queryOrderedByKey
165
+
166
+ firebase.query(order_by_priority: true)
167
+ # => firebase.queryOrderedByPriority
168
+
169
+ firebase.query(order_by: 'key')
170
+ # => firebase.queryOrderedByChild('key')
171
+
172
+ firebase.query(first: value)
173
+ # => firebase.queryLimitedToFirst(value)
174
+
175
+ firebase.query(last: value)
176
+ # => firebase.queryLimitedToLast(value)
177
+
178
+ firebase.query(starting_at: value)
179
+ firebase.query(starting_at: value, child: 'key')
180
+ # => firebase.queryStartingAtValue(value)
181
+ # => firebase.queryStartingAtValue(value, childKey: 'key')
182
+
183
+ firebase.query(ending_at: value)
184
+ firebase.query(ending_at: value, child: 'key')
185
+ # => firebase.queryEndingAtValue(value)
186
+ # => firebase.queryEndingAtValue(value, childKey: 'key')
187
+
188
+ firebase.query(equal_to: value)
189
+ firebase.query(equal_to: value, child: 'key')
190
+ # => firebase.queryEqualToValue(value)
191
+ # => firebase.queryEqualToValue(value, childKey: 'key')
192
+
193
+ # and of course these can all be combined into one call:
194
+ firebase.query(
195
+ first: 5, # last: 6,
196
+ starting_at: 'foo',
197
+ ending_at: 'bar')
198
+
199
+ # => firebase.queryLimitedToFirst(5)
200
+ # .queryLimitedToLast(6)
201
+ # .queryStartingAtValue('foo')
202
+ # .queryEndingAtValue('bar')
203
+
204
+ ```
205
+
160
206
  ##### Managing presence
161
207
 
162
208
  SOO COOL! Play with these, you can *easily* create a presence system for your
@@ -1,5 +1,10 @@
1
1
  class FQuery
2
2
 
3
+ # previously the 'key' method was called 'name'
4
+ def name
5
+ self.key
6
+ end
7
+
3
8
  def on(event_type, options={}, &and_then)
4
9
  and_then = and_then || options[:completion]
5
10
  raise "event handler is required" unless and_then
@@ -88,4 +93,48 @@ class FQuery
88
93
  queryLimitedToNumberOfChildren(limit)
89
94
  end
90
95
 
96
+ def query(options={})
97
+ fb_query = self
98
+
99
+ if options[:order_by_key]
100
+ fb_query = fb_query.queryOrderedByKey
101
+ end
102
+
103
+ if options[:order_by_priority]
104
+ fb_query = fb_query.queryOrderedByPriority
105
+ end
106
+
107
+ if options[:order_by]
108
+ fb_query = fb_query.queryOrderedByChild(options[:order_by])
109
+ end
110
+
111
+ if options[:first]
112
+ fb_query = fb_query.queryLimitedToFirst(options[:first])
113
+ end
114
+
115
+ if options[:last]
116
+ fb_query = fb_query.queryLimitedToLast(options[:last])
117
+ end
118
+
119
+ if options[:starting_at] && options[:key]
120
+ fb_query = fb_query.queryStartingAtValue(options[:starting_at], childKey: options[:key])
121
+ elsif options[:starting_at]
122
+ fb_query = fb_query.queryStartingAtValue(options[:starting_at])
123
+ end
124
+
125
+ if options[:ending_at] && options[:key]
126
+ fb_query = fb_query.queryEndingAtValue(options[:ending_at], childKey: options[:key])
127
+ elsif options[:ending_at]
128
+ fb_query = fb_query.queryEndingAtValue(options[:ending_at])
129
+ end
130
+
131
+ if options[:equal_to] && options[:key]
132
+ fb_query = fb_query.queryEqualToValue(options[:equal_to], childKey: options[:key])
133
+ elsif options[:equal_to]
134
+ fb_query = fb_query.queryEqualToValue(options[:equal_to])
135
+ end
136
+
137
+ fb_query
138
+ end
139
+
91
140
  end
@@ -1,6 +1,6 @@
1
1
  module Motion
2
2
  module Firebase
3
- Version = '3.0.2' # motion-firebase gem version
3
+ Version = '3.1.0' # motion-firebase gem version
4
4
  SdkVersion = '1.2.2' # firebase framework version
5
5
  end
6
6
  end
@@ -4,7 +4,7 @@ end
4
4
 
5
5
 
6
6
  Motion::Project::App.setup do |app|
7
- app.info 'Firebase', 'As of version 1.2.2 of Firebase (motion-firebase version 3.0.0), you no'
8
- app.info '', 'longer need to include motion-firebase-auth, because FirebaseSimpleLogin'
9
- app.info '', 'is part of the core Firebase SDK.'
7
+ app.warn 'Firebase', 'As of version 1.2.2 of Firebase (motion-firebase version 3.0.0), you no'
8
+ app.warn '', 'longer need to include motion-firebase-auth, because FirebaseSimpleLogin'
9
+ app.warn '', 'is part of the core Firebase SDK.'
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-firebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-15 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec