motion-firebase 3.0.0 → 3.0.1

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: b20746e49429ffd9ecbea7ba992defdb3d70e4d9
4
- data.tar.gz: b476715c9efb45dd9d6876948354c6b7c20188e9
3
+ metadata.gz: 303f35180c398371debc1fe2654063090bf09d30
4
+ data.tar.gz: d6ccacf82662b9152576f3a933816a11eaf67652
5
5
  SHA512:
6
- metadata.gz: 25e5edfd58e5dc43f8602f1ce879c90e56424625becd3370d4f6215432f9ec4d2e190dda858170372851188c938d1f4d753c99bebac1920a615d2f0f3fcceae4
7
- data.tar.gz: 95b3e16250ce1670813d7d76a7581077420f1eb9edf26441e0daecbe27a982f8ebc8c0c560249a09f925ceec33e5585b5ef0c546ce62d6f63a15852fe36c1485
6
+ metadata.gz: c646b5369d682a9a55f497e111d155def0d32aceb2d92b1dc8efb93a4e647dbe727ebc5126250caf1dde239cdad18d8fba0cd923fad7dea3d72242c32f1e9b5a
7
+ data.tar.gz: 0e3b0ef6c29515c7f9aa7062fcd186340e5c78660e8fd62aae2a7228cf44b059f1d865b7e8dc10208b70f7a8f7e142c546489a7731debb12dcef5cd66c7003c2
data/README.md CHANGED
@@ -21,71 +21,71 @@ project, the Firebase SDK gets included automatically.
21
21
  motion-firebase 3.0
22
22
  ========
23
23
 
24
- Lots of changes in this version: <3.0.md>
24
+ Lots of changes in this version: [3.0.md](3.0.md)
25
25
 
26
26
  # SDK
27
27
 
28
28
  ##### Initializing a Firebase object
29
29
 
30
30
  ```ruby
31
- Firebase.new(url)
32
-
33
- # it's common to set a global firebase URL. Set it in your app delegate,
34
- # and calling `new` will use that default URL.
35
- Firebase.url = 'https://your-app.firebaseio.com'
36
- Firebase.url # => 'https://your-app.firebaseio.com'
37
- Firebase.new
38
-
39
- # these all work, too:
40
- Firebase.url = 'your-app.firebaseio.com'
41
- Firebase.url = 'your-app'
42
- Firebase.url # => 'https://your-app.firebaseio.com'
31
+ Firebase.new(url)
32
+
33
+ # it's common to set a global firebase URL. Set it in your app delegate,
34
+ # and calling `new` will use that default URL.
35
+ Firebase.url = 'https://your-app.firebaseio.com'
36
+ Firebase.url # => 'https://your-app.firebaseio.com'
37
+ Firebase.new
38
+
39
+ # these all work, too:
40
+ Firebase.url = 'your-app.firebaseio.com'
41
+ Firebase.url = 'your-app'
42
+ Firebase.url # => 'https://your-app.firebaseio.com'
43
43
  ```
44
44
 
45
45
  ##### Getting references to children locations
46
46
 
47
47
  ```ruby
48
- firebase[path]
49
- firebase[] # childByAutoId
50
- firebase['fred'] # childByAppendingPath('fred')
48
+ firebase[path]
49
+ firebase[] # childByAutoId
50
+ firebase['fred'] # childByAppendingPath('fred')
51
51
  ```
52
52
 
53
53
  ##### Writing data
54
54
 
55
55
  ```ruby
56
- firebase << { key: 'value' }
57
- # => firebase.childByAutoId.setValue({ key: 'value'}), returns the new child
58
-
59
- # Since firebase works with simple objects, this is equivalent to
60
- # => firebase.childByAutoId.setValue({ 'key' => 'value'})
61
-
62
- # set value
63
- firebase.value = value
64
- firebase.set(value)
65
- firebase.set(value) { 'completion block' }
66
- firebase.set(value, priority: priority)
67
- firebase.set(value, priority: priority) { 'completion block' }
68
-
69
- # set value of child node
70
- firebase['first_name'] = 'fred' # childByAppendingPath('fred').set('fred')
71
-
72
- # remove value
73
- firebase.clear!
74
- firebase.clear! { 'completion block' }
75
-
76
- # priority
77
- firebase.priority = priority
78
- firebase.priority(priority)
79
- firebase.priority(priority) { |error| 'completion block' }
80
-
81
- # "updating" is used to update some children, but leaving others unchanged.
82
- # (set, on the other hand, replaces the value entirely, so using set with a
83
- # hash will remove keys that weren't specified in the new hash)
84
- firebase.set({ first_name: 'motion', last_name: 'fireball' })
85
- firebase.update(last_name: 'firebase') # only updates last_name, first_name is left unchanged
86
- firebase.update(last_name: 'firebase') { |error| 'completion block' }
87
- # for comparison:
88
- firebase.set(last_name: 'firebase') # first_name is now 'nil'
56
+ firebase << { key: 'value' }
57
+ # => firebase.childByAutoId.setValue({ key: 'value'}), returns the new child
58
+
59
+ # Since firebase works with simple objects, this is equivalent to
60
+ # => firebase.childByAutoId.setValue({ 'key' => 'value'})
61
+
62
+ # set value
63
+ firebase.value = value
64
+ firebase.set(value)
65
+ firebase.set(value) { 'completion block' }
66
+ firebase.set(value, priority: priority)
67
+ firebase.set(value, priority: priority) { 'completion block' }
68
+
69
+ # set value of child node
70
+ firebase['first_name'] = 'fred' # childByAppendingPath('fred').set('fred')
71
+
72
+ # remove value
73
+ firebase.clear!
74
+ firebase.clear! { 'completion block' }
75
+
76
+ # priority
77
+ firebase.priority = priority
78
+ firebase.priority(priority)
79
+ firebase.priority(priority) { |error| 'completion block' }
80
+
81
+ # "updating" is used to update some children, but leaving others unchanged.
82
+ # (set, on the other hand, replaces the value entirely, so using set with a
83
+ # hash will remove keys that weren't specified in the new hash)
84
+ firebase.set({ first_name: 'motion', last_name: 'fireball' })
85
+ firebase.update(last_name: 'firebase') # only updates last_name, first_name is left unchanged
86
+ firebase.update(last_name: 'firebase') { |error| 'completion block' }
87
+ # for comparison:
88
+ firebase.set(last_name: 'firebase') # first_name is now 'nil'
89
89
  ```
90
90
 
91
91
  ##### Attaching observers to read data
@@ -101,54 +101,54 @@ Lots of changes in this version: <3.0.md>
101
101
  ```
102
102
 
103
103
  ```ruby
104
- handle = firebase.on(event_type) { |snapshot| 'completion block' }
105
- handle = firebase.on(event_type) { |snapshot, previous_sibling_name| 'completion block' }
106
- handle = firebase.on(event_type,
107
- completion: proc { |snapshot, previous_sibling_name| 'completion block' },
108
- disconnect: proc { 'completion block' }
109
- )
110
- handle = firebase.once(event_type) { |snapshot| 'completion block' }
111
- handle = firebase.once(event_type) { |snapshot, previous_sibling_name| 'completion block' }
112
- handle = firebase.once(event_type,
113
- completion: proc { |snapshot, previous_sibling_name| 'completion block' },
114
- disconnect: proc { 'completion block' }
115
- )
104
+ handle = firebase.on(event_type) { |snapshot| 'completion block' }
105
+ handle = firebase.on(event_type) { |snapshot, previous_sibling_name| 'completion block' }
106
+ handle = firebase.on(event_type,
107
+ completion: proc { |snapshot, previous_sibling_name| 'completion block' },
108
+ disconnect: proc { 'completion block' }
109
+ )
110
+ handle = firebase.once(event_type) { |snapshot| 'completion block' }
111
+ handle = firebase.once(event_type) { |snapshot, previous_sibling_name| 'completion block' }
112
+ handle = firebase.once(event_type,
113
+ completion: proc { |snapshot, previous_sibling_name| 'completion block' },
114
+ disconnect: proc { 'completion block' }
115
+ )
116
116
  ```
117
117
 
118
118
  ##### Detaching observers
119
119
 
120
120
  ```ruby
121
- firebase.off
122
- # => firebase.removeAllObservers
121
+ firebase.off
122
+ # => firebase.removeAllObservers
123
123
 
124
- firebase.off(handle)
125
- # => firebase.removeObserverWithHandle(handle)
124
+ firebase.off(handle)
125
+ # => firebase.removeObserverWithHandle(handle)
126
126
  ```
127
127
 
128
128
  ##### Priority and Limiting
129
129
  ###### similar-to-yet-different-than "ORDER BY" and "LIMIT"
130
130
 
131
131
  ```ruby
132
- firebase.start_at(priority)
133
- # => firebase.queryStartingAtPriority(priority)
132
+ firebase.start_at(priority)
133
+ # => firebase.queryStartingAtPriority(priority)
134
134
 
135
- firebase.start_at(priority, child: child_name)
136
- # => firebase.queryStartingAtPriority(priority, andChildName: child_name)
135
+ firebase.start_at(priority, child: child_name)
136
+ # => firebase.queryStartingAtPriority(priority, andChildName: child_name)
137
137
 
138
- firebase.equal_to(priority)
139
- # => firebase.queryEqualToPriority(priority)
138
+ firebase.equal_to(priority)
139
+ # => firebase.queryEqualToPriority(priority)
140
140
 
141
- firebase.equal_to(priority, child: child_name)
142
- # => firebase.queryEqualToPriority(priority, andChildName: child_name)
141
+ firebase.equal_to(priority, child: child_name)
142
+ # => firebase.queryEqualToPriority(priority, andChildName: child_name)
143
143
 
144
- firebase.end_at(priority)
145
- # => firebase.queryEndingAtPriority(priority)
144
+ firebase.end_at(priority)
145
+ # => firebase.queryEndingAtPriority(priority)
146
146
 
147
- firebase.end_at(priority, child: child_name)
148
- # => firebase.queryEndingAtPriority(priority, andChildName: child_name)
147
+ firebase.end_at(priority, child: child_name)
148
+ # => firebase.queryEndingAtPriority(priority, andChildName: child_name)
149
149
 
150
- firebase.limit(limit)
151
- # => firebase.queryLimitedToNumberOfChildren(limit)
150
+ firebase.limit(limit)
151
+ # => firebase.queryLimitedToNumberOfChildren(limit)
152
152
  ```
153
153
 
154
154
  ##### Managing presence
@@ -157,82 +157,82 @@ SOO COOL! Play with these, you can *easily* create a presence system for your
157
157
  real-time app or game.
158
158
 
159
159
  ```ruby
160
- Firebase.online!
161
- Firebase.offline!
162
- Firebase.connected? # returns a Firebase ref that changes value depending on connectivity
163
-
164
- # or you can pass in a block, this block will be called with the connected
165
- # state as a bool:
166
- handler = Firebase.connected? do |connected|
167
- if connected
168
- # so awesome
169
- end
170
- end
171
- # you should turn it off when you're done, otherwise you'll have a memory leak
172
- Firebase.off(handler)
173
-
174
- # so what you do is get a ref to the authenticated user's "presence" value.
175
- # Then, on_disconnect, set the value to 'false'.
176
- firebase.on_disconnect(value) # set the ref to `value` when disconnected
177
- firebase.on_disconnect(value) { |error| 'completion block' }
178
- firebase.on_disconnect(value, priority: priority)
179
- firebase.on_disconnect(value, priority: priority) { |error| 'completion block' }
180
- firebase.on_disconnect(nil)
181
- firebase.on_disconnect(nil) { |error| 'completion block' }
182
- firebase.on_disconnect({ child: values })
183
- firebase.on_disconnect({ child: values }) { |error| 'completion block' }
184
-
185
- # sometimes you need to cancel these 'on_disconnect' operations
186
- firebase.cancel_disconnect
187
- firebase.cancel_disconnect { |error| 'completion block' }
160
+ Firebase.online!
161
+ Firebase.offline!
162
+ Firebase.connected? # returns a Firebase ref that changes value depending on connectivity
163
+
164
+ # or you can pass in a block, this block will be called with the connected
165
+ # state as a bool:
166
+ handler = Firebase.connected? do |connected|
167
+ if connected
168
+ # so awesome
169
+ end
170
+ end
171
+ # you should turn it off when you're done, otherwise you'll have a memory leak
172
+ Firebase.off(handler)
173
+
174
+ # so what you do is get a ref to the authenticated user's "presence" value.
175
+ # Then, on_disconnect, set the value to 'false'.
176
+ firebase.on_disconnect(value) # set the ref to `value` when disconnected
177
+ firebase.on_disconnect(value) { |error| 'completion block' }
178
+ firebase.on_disconnect(value, priority: priority)
179
+ firebase.on_disconnect(value, priority: priority) { |error| 'completion block' }
180
+ firebase.on_disconnect(nil)
181
+ firebase.on_disconnect(nil) { |error| 'completion block' }
182
+ firebase.on_disconnect({ child: values })
183
+ firebase.on_disconnect({ child: values }) { |error| 'completion block' }
184
+
185
+ # sometimes you need to cancel these 'on_disconnect' operations
186
+ firebase.cancel_disconnect
187
+ firebase.cancel_disconnect { |error| 'completion block' }
188
188
  ```
189
189
 
190
190
  ##### Transactions
191
191
 
192
192
  ```ruby
193
- firebase.transaction do |data|
194
- current_value = data.value
195
- current_value += 1
196
- FTransactionResult.successWithValue(current_value)
197
- end
198
- firebase.transaction(local: false) do |data|
199
- #...
200
- end
201
- firebase.transaction(
202
- completion: proc { |error, committed, snapshot| }
203
- ) do |data|
204
- current_value = data.value
205
- current_value += 1
206
- FTransactionResult.successWithValue(current_value)
207
- end
208
- firebase.transaction(
209
- transaction: proc { |data| 'transaction block' },
210
- completion: proc { |error, committed, snapshot| }
211
- local: true || false,
212
- )
193
+ firebase.transaction do |data|
194
+ current_value = data.value
195
+ current_value += 1
196
+ FTransactionResult.successWithValue(current_value)
197
+ end
198
+ firebase.transaction(local: false) do |data|
199
+ #...
200
+ end
201
+ firebase.transaction(
202
+ completion: proc { |error, committed, snapshot| }
203
+ ) do |data|
204
+ current_value = data.value
205
+ current_value += 1
206
+ FTransactionResult.successWithValue(current_value)
207
+ end
208
+ firebase.transaction(
209
+ transaction: proc { |data| 'transaction block' },
210
+ completion: proc { |error, committed, snapshot| }
211
+ local: true || false,
212
+ )
213
213
  ```
214
214
 
215
215
  ##### Retrieving String Representation
216
216
 
217
217
  ```ruby
218
- firebase.to_s
219
- firebase.inspect
218
+ firebase.to_s
219
+ firebase.inspect
220
220
  ```
221
221
 
222
222
  ##### Properties
223
223
 
224
224
  ```ruby
225
- firebase.parent
226
- firebase.root
227
- firebase.name
225
+ firebase.parent
226
+ firebase.root
227
+ firebase.name
228
228
  ```
229
229
 
230
230
  ##### Global configuration and settings
231
231
 
232
232
  ```ruby
233
- Firebase.dispatch_queue=(queue)
234
- Firebase.sdkVersion
235
- Motion::Firebase::SdkVersion # this string is more human readable than sdkVersion
233
+ Firebase.dispatch_queue=(queue)
234
+ Firebase.sdkVersion
235
+ Motion::Firebase::SdkVersion # this string is more human readable than sdkVersion
236
236
  ```
237
237
 
238
238
 
@@ -244,30 +244,30 @@ set a default `Firebase.url`
244
244
  ##### Checking current authentication status
245
245
 
246
246
  ```ruby
247
- Firebase.authenticated? # => true/false
248
- # you pretty much always need to hold a reference to the "handler"
249
- auth_handler = Firebase.authenticated? do |auth_data|
250
- if auth_data
251
- # authenticated!
252
- else
253
- # not so much
254
- end
255
- end
256
- # turn off the handler, otherwise, yeah, memory leaks.
257
- Firebase.off_auth(auth_handler)
247
+ Firebase.authenticated? # => true/false
248
+ # you pretty much always need to hold a reference to the "handler"
249
+ auth_handler = Firebase.authenticated? do |auth_data|
250
+ if auth_data
251
+ # authenticated!
252
+ else
253
+ # not so much
254
+ end
255
+ end
256
+ # turn off the handler, otherwise, yeah, memory leaks.
257
+ Firebase.off_auth(auth_handler)
258
258
  ```
259
259
 
260
260
  ##### Authenticate with previous token
261
261
 
262
262
  ```ruby
263
- Firebase.auth(token) do |error, auth_data|
264
- end
263
+ Firebase.authenticate(token) do |error, auth_data|
264
+ end
265
265
  ```
266
266
 
267
267
  ##### Removing any existing authentication
268
268
 
269
269
  ```ruby
270
- Firebase.logout
270
+ Firebase.logout
271
271
  ```
272
272
 
273
273
  ## Email/password authentication methods
@@ -276,14 +276,14 @@ This is the most common way to login. It allows Firebase to create users and
276
276
  tokens.
277
277
 
278
278
  ```ruby
279
- Firebase.create_user(email: 'hello@example.com', password: '12345') { |error, auth_data| }
280
- Firebase.remove_user(email: 'hello@example.com', password: '12345') { |error, auth_data| }
281
- Firebase.login(email: 'hello@example.com', password: '12345') { |error, auth_data| }
282
- Firebase.login_anonymously { |error, auth_data| }
283
- Firebase.update_user(email: 'hello@example.com', old_password: '12345', new_password: '54321') { |error, success| }
284
-
285
- auth_data.uid # is a globally unique user identifier
286
- auth_data.token # can be stored (in a keychain!) to authenticate the same user again later
279
+ Firebase.create_user(email: 'hello@example.com', password: '12345') { |error, auth_data| }
280
+ Firebase.remove_user(email: 'hello@example.com', password: '12345') { |error, auth_data| }
281
+ Firebase.login(email: 'hello@example.com', password: '12345') { |error, auth_data| }
282
+ Firebase.login_anonymously { |error, auth_data| }
283
+ Firebase.update_user(email: 'hello@example.com', old_password: '12345', new_password: '54321') { |error, success| }
284
+
285
+ auth_data.uid # is a globally unique user identifier
286
+ auth_data.token # can be stored (in a keychain!) to authenticate the same user again later
287
287
  ```
288
288
 
289
289
  See <https://www.firebase.com/docs/ios/api/#fauthdata_properties> for other
@@ -298,11 +298,11 @@ This Facebook helper is a port of the Objective-C code from
298
298
  <https://www.firebase.com/docs/ios/guide/login/facebook.html>.
299
299
 
300
300
  ```ruby
301
- Firebase.open_facebook_session(
302
- permissions: ['public_profile'], # these are the default values. if
303
- allow_login_ui: true, # you're OK with them, they are
304
- ) do |error, auth_data| # optional, so just provide a block.
305
- end
301
+ Firebase.open_facebook_session(
302
+ permissions: ['public_profile'], # these are the default values. if
303
+ allow_login_ui: true, # you're OK with them, they are
304
+ ) do |error, auth_data| # optional, so just provide a block.
305
+ end
306
306
  ```
307
307
 
308
308
  ##### Twitter authentication
@@ -314,41 +314,41 @@ little streamlined here, since `open_twitter_session` returns a block that you
314
314
  can call with the chosen account.
315
315
 
316
316
  ```ruby
317
- # it's nice to be able to set-and-forget the twitter_api_key (in your
318
- # application delegate, for example)
319
- Firebase.twitter_api_key = 'your key!'
320
-
321
- # You must set Firebase.url=, or call open_twitter_session on an existing
322
- # Firebase ref. The first step is to get the Twitter accounts on this
323
- # device. Even if there is just one, you need to "choose" it here. Also,
324
- # you can pass the twitter api_key as an option, otherwise this method will
325
- # use Firebase.twitter_api_key
326
- Firebase.open_twitter_session(api_key: 'your key!') do |error, accounts, next_step|
327
- # next_step is a block you call with the chosen twitter account and a
328
- # firebase handler for the authentication success or failure
317
+ # it's nice to be able to set-and-forget the twitter_api_key (in your
318
+ # application delegate, for example)
319
+ Firebase.twitter_api_key = 'your key!'
320
+
321
+ # You must set Firebase.url=, or call open_twitter_session on an existing
322
+ # Firebase ref. The first step is to get the Twitter accounts on this
323
+ # device. Even if there is just one, you need to "choose" it here. Also,
324
+ # you can pass the twitter api_key as an option, otherwise this method will
325
+ # use Firebase.twitter_api_key
326
+ Firebase.open_twitter_session(api_key: 'your key!') do |error, accounts, next_step|
327
+ # next_step is a block you call with the chosen twitter account and a
328
+ # firebase handler for the authentication success or failure
329
+ if error
330
+ # obviously do some stuff here
331
+ else
332
+ present_twitter_chooser(accounts, next_step) do |error, auth_data|
333
+ # this block is passed to next_step in present_twitter_chooser
329
334
  if error
330
- # obviously do some stuff here
331
- else
332
- present_twitter_chooser(accounts, next_step) do |error, auth_data|
333
- # this block is passed to next_step in present_twitter_chooser
334
- if error
335
- # bummer
336
- else
337
- # awesome!
338
- end
339
- end
340
- else
341
- end
342
-
343
- def present_twitter_chooser(accounts, next_step, &firebase_handler)
344
- if accounts.length == 1
345
- next_step.call(accounts[0], &firebase_handler)
335
+ # bummer
346
336
  else
347
- # present a controller or action sheet or something like that
348
- ... awesome twitter account chooser code ...
349
- next_step.call(account, &firebase_handler)
337
+ # awesome!
350
338
  end
351
339
  end
340
+ else
341
+ end
342
+
343
+ def present_twitter_chooser(accounts, next_step, &firebase_handler)
344
+ if accounts.length == 1
345
+ next_step.call(accounts[0], &firebase_handler)
346
+ else
347
+ # present a controller or action sheet or something like that
348
+ ... awesome twitter account chooser code ...
349
+ next_step.call(account, &firebase_handler)
350
+ end
351
+ end
352
352
  ```
353
353
 
354
354
  ##### Github authentication
@@ -358,9 +358,9 @@ a github access token from the user... but anyway here's the `motion-firebase`
358
358
  code based on <https://www.firebase.com/docs/ios/guide/login/github.html>.
359
359
 
360
360
  ```ruby
361
- Firebase.github_token = 'github oauth token'
362
- Firebase.open_github_session do |error, auth_data|
363
- end
361
+ Firebase.github_token = 'github oauth token'
362
+ Firebase.open_github_session do |error, auth_data|
363
+ end
364
364
  ```
365
365
 
366
366
  ##### Google authentication
@@ -371,9 +371,9 @@ take the time to port the code this time, but I hope someone does someday! 😄
371
371
  You can read Firebase's instructions here: <https://www.firebase.com/docs/ios/guide/login/google.html>
372
372
 
373
373
  ```ruby
374
- Firebase.google_token = 'google oauth token'
375
- Firebase.open_google_session do |error, auth_data|
376
- end
374
+ Firebase.google_token = 'google oauth token'
375
+ Firebase.open_google_session do |error, auth_data|
376
+ end
377
377
  ```
378
378
 
379
379
  ##### Generic OAuth Authentication
@@ -382,22 +382,22 @@ Usually you will use the helpers from above, but here are some lower level
382
382
  methods:
383
383
 
384
384
  ```ruby
385
- # using a token
386
- firebase_ref.login_to_oauth(provider, token: token) do |error, auth_data| .. end
387
- firebase_ref.login_to_oauth(provider, token) do |error, auth_data| .. end
388
-
389
- # using parameters
390
- firebase_ref.login_to_oauth(provider, oauth_token: token, oauth_token_secret: secret) do |error, auth_data| .. end
391
- params = { ... }
392
- firebase_ref.login_to_oauth(provider, params) do |error, auth_data| .. end
393
-
394
- # which is a wrapper for these SDK methods:
395
- firebase_ref.authWithOAuthProvider(provider, token: token, withCompletionBlock: block)
396
- firebase_ref.authWithOAuthProvider(provider, parameters: params, withCompletionBlock: block)
397
-
398
- # Again, the `open_*_session` methods are even more convenient.
399
- firebase_ref.login_to_facebook(facebook_access_token, &block)
400
- firebase_ref.login_to_twitter(token: token, secret: secret, &block)
401
- firebase_ref.login_to_github(github_oauth_token, &block)
402
- firebase_ref.login_to_google(google_oauth_token, &block)
385
+ # using a token
386
+ firebase_ref.login_to_oauth(provider, token: token) do |error, auth_data| .. end
387
+ firebase_ref.login_to_oauth(provider, token) do |error, auth_data| .. end
388
+
389
+ # using parameters
390
+ firebase_ref.login_to_oauth(provider, oauth_token: token, oauth_token_secret: secret) do |error, auth_data| .. end
391
+ params = { ... }
392
+ firebase_ref.login_to_oauth(provider, params) do |error, auth_data| .. end
393
+
394
+ # which is a wrapper for these SDK methods:
395
+ firebase_ref.authWithOAuthProvider(provider, token: token, withCompletionBlock: block)
396
+ firebase_ref.authWithOAuthProvider(provider, parameters: params, withCompletionBlock: block)
397
+
398
+ # Again, the `open_*_session` methods are even more convenient.
399
+ firebase_ref.login_to_facebook(facebook_access_token, &block)
400
+ firebase_ref.login_to_twitter(token: token, secret: secret, &block)
401
+ firebase_ref.login_to_github(github_oauth_token, &block)
402
+ firebase_ref.login_to_google(google_oauth_token, &block)
403
403
  ```
@@ -27,7 +27,7 @@ class Firebase
27
27
  raise "Invalid URL #{url.inspect} in #{__method__}: URL scheme should be 'https://', not 'http://'"
28
28
  elsif url.start_with?('https://')
29
29
  # all good
30
- elsif url =~ '^\w+://'
30
+ elsif url =~ %r'^\w+://'
31
31
  raise "Invalid URL #{url.inspect} in #{__method__}: URL scheme should be 'https://', not '#{$~}'"
32
32
  else
33
33
  url = "https://#{url}"
@@ -36,9 +36,6 @@ class Firebase
36
36
  # should we support `Firebase.url = 'myapp/path/to/child/'` ? I'm gonna say
37
37
  # NO for now...
38
38
  unless url.include?('.firebaseio.com')
39
- if url.include?('/')
40
- raise "Invalid URL #{url.inspect} in #{__method__}: URL does not include 'firebaseio.com'"
41
- end
42
39
  url = "#{url}.firebaseio.com"
43
40
  end
44
41
 
@@ -10,15 +10,15 @@ class Firebase
10
10
  end
11
11
 
12
12
  # @example
13
- # Firebase.auth('secrettoken') do |error, auth_data|
13
+ # Firebase.authenticate('secrettoken') do |error, auth_data|
14
14
  # if auth_data
15
15
  # # authenticated
16
16
  # end
17
17
  # end
18
- def self.auth(token, options={}, &block)
19
- Firebase.new.auth(token, options, &block)
18
+ def self.authenticate(token, options={}, &block)
19
+ Firebase.new.authenticate(token, options, &block)
20
20
  end
21
- def auth(token, options={}, &and_then)
21
+ def authenticate(token, options={}, &and_then)
22
22
  and_then ||= options[:completion]
23
23
  disconnect_block = options[:disconnect]
24
24
  if disconnect || and_then.arity < 2
@@ -46,12 +46,12 @@ class Firebase
46
46
  def self.authenticated?(&block)
47
47
  Firebase.new.authenticated?(&block)
48
48
  end
49
- # checks the auth status. If you pass a block the observeAuthEventWithBlock
50
- # is used to determine the status. If you don't pass a block, this method
51
- # returns true or false.
49
+ # checks the authenticated status. If you pass a block the
50
+ # observeAuthEventWithBlock is used to determine the status. If you don't
51
+ # pass a block, this method returns true or false.
52
52
  def authenticated?(&block)
53
53
  if block
54
- observeAuthEventWithBlock(:value, block)
54
+ observeAuthEventWithBlock(block)
55
55
  else
56
56
  !!authData
57
57
  end
@@ -160,7 +160,7 @@ class TwitterAuthHelper
160
160
  if params['oauth_token_secret'] && params['oauth_token']
161
161
  params
162
162
  else
163
- { 'error': account_data }
163
+ { 'error' => account_data }
164
164
  end
165
165
  end
166
166
 
@@ -1,6 +1,6 @@
1
1
  module Motion
2
2
  module Firebase
3
- Version = '3.0.0' # motion-firebase gem version
3
+ Version = '3.0.1' # motion-firebase gem version
4
4
  SdkVersion = '1.2.2' # firebase framework version
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-firebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray