motion-firebase 2.0.12 → 2.0.13

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3b32b99f22fae62ac309cea83f3b1578185bdc3
4
- data.tar.gz: abc29d1f8fe7fa220ceb124f8148a105002aede1
3
+ metadata.gz: 8c0f4469915f65382c3b1a45f6f6c345e550ee57
4
+ data.tar.gz: 83bd04d12af915d09f67e393ad65c6a5f85cab1b
5
5
  SHA512:
6
- metadata.gz: 35f11ca42152420cca26752ec82d3c87b659b64e64c37feec3b353f3a17778062ac582825789c6899e239838f4f6cd06456660601436f30fdac8f844ccddf264
7
- data.tar.gz: f722e4602095fd37f14736f84303feed8e0a1775be02068102b4e290553e767a036d8bb9c8f727dc7056b7d7cee5645c591f0d103b149a1744497e22fcdb96de
6
+ metadata.gz: 9928740e5bad2f92ab37c7bbc4a8d37104d0e1a012253ef93887f1c7fa143e2fd5825dc90835909520ddcd612ab130fdbae58591026e29e85ca8f6f5bc218e96
7
+ data.tar.gz: f6add052649f31c0d975d51c0620433d1e59aff4d15c367b81b7f670802e2d3f44883f3e81cb6949dfba5fd1999d78b5925e3f4b1bab6ca1e510d3004c64beda
data/README.md CHANGED
@@ -20,18 +20,26 @@ SDK
20
20
 
21
21
  ##### Initializing a Firebase object
22
22
 
23
+ ```ruby
23
24
  Firebase.new(url)
25
+ ```
24
26
 
25
27
  ##### Getting references to children locations
26
28
 
29
+ ```ruby
27
30
  firebase[path]
28
31
  firebase[] # childByAutoId
29
32
  firebase['fred'] # childByAppendingPath('fred')
33
+ ```
30
34
 
31
35
  ##### Writing data
32
36
 
33
- firebase << {'key': 'value'}
34
- # => firebase.childByAutoId.updateChildValues(values), returns the new child
37
+ ```ruby
38
+ firebase << { key: 'value' }
39
+ # => firebase.childByAutoId.setValue({ key: 'value'}), returns the new child
40
+
41
+ # Since firebase works with simple objects, this is equivalent to
42
+ # => firebase.childByAutoId.setValue({ 'key' => 'value'})
35
43
 
36
44
  # set value
37
45
  firebase.value = value
@@ -52,11 +60,19 @@ SDK
52
60
  firebase.priority(priority)
53
61
  firebase.priority(priority) { |error| 'completion block' }
54
62
 
55
- firebase.update(values)
56
- firebase.update(values) { |error| 'completion block' }
63
+ # "updating" is used to update some children, but leaving others unchanged.
64
+ # (set, on the other hand, replaces the value entirely, so using set with a
65
+ # hash will remove keys that weren't specified in the new hash)
66
+ firebase.set({ first_name: 'motion', last_name: 'fireball' })
67
+ firebase.update(last_name: 'firebase') # only updates last_name, first_name is left unchanged
68
+ firebase.update(last_name: 'firebase') { |error| 'completion block' }
69
+ # for comparison:
70
+ firebase.set(last_name: 'firebase') # first_name is now 'nil'
71
+ ```
57
72
 
58
73
  ##### Attaching observers to read data
59
74
 
75
+ ```ruby
60
76
  handle = firebase.on(event_type) { |snapshot| 'completion block' }
61
77
  handle = firebase.on(event_type) { |snapshot, previous_sibling_name| 'completion block' }
62
78
  handle = firebase.on(event_type,
@@ -69,24 +85,41 @@ SDK
69
85
  completion: proc { |snapshot, previous_sibling_name| 'completion block' },
70
86
  disconnect: proc { 'completion block' }
71
87
  )
88
+ ```
72
89
 
73
90
  ##### Detaching observers
74
91
 
92
+ ```ruby
75
93
  firebase.off
94
+ # => firebase.removeAllObservers
95
+
76
96
  firebase.off(handle)
97
+ # => firebase.removeObserverWithHandle(handle)
98
+ ```
99
+
100
+ ##### Priority and Limiting
101
+ ###### similar-to-yet-different-than "ORDER BY" and "LIMIT"
102
+
103
+ ```ruby
104
+ firebase.start_at(priority)
105
+ # => firebase.queryStartingAtPriority(priority)
106
+
107
+ firebase.start_at(priority, child: child_name)
108
+ # => firebase.queryStartingAtPriority(priority, andChildName: child_name)
109
+
110
+ firebase.end_at(priority)
111
+ # => firebase.queryEndingAtPriority(priority)
77
112
 
78
- ##### Querying and limiting
113
+ firebase.end_at(priority, child: child_name)
114
+ # => firebase.queryEndingAtPriority(priority, andChildName: child_name)
79
115
 
80
- # these are not wrapped at the moment, because I don't completely understand
81
- # what they do.
82
- # firebase.queryStartingAtPriority()
83
- # firebase.queryStartingAtPriority(andChildName:)
84
- # firebase.queryEndingAtPriority()
85
- # firebase.queryEndingAtPriority(andChildName:)
86
- # firebase.queryLimitedToNumberOfChildren()
116
+ firebase.limit(limit)
117
+ # => firebase.queryLimitedToNumberOfChildren(limit)
118
+ ```
87
119
 
88
120
  ##### Managing presence
89
121
 
122
+ ```ruby
90
123
  firebase.online!
91
124
  firebase.offline!
92
125
  firebase.on_disconnect(value)
@@ -99,9 +132,11 @@ SDK
99
132
  firebase.on_disconnect({ child: values }) { |error| 'completion block' }
100
133
  firebase.cancel_disconnect
101
134
  firebase.cancel_disconnect { |error| 'completion block' }
135
+ ```
102
136
 
103
137
  ##### Authenticating
104
138
 
139
+ ```ruby
105
140
  firebase.auth(credential)
106
141
  firebase.auth(credential) { |error, data| 'completion block' }
107
142
  firebase.auth(credential,
@@ -124,6 +159,7 @@ SDK
124
159
 
125
160
  ##### Transactions
126
161
 
162
+ ```ruby
127
163
  firebase.run { |data| 'transaction block' }
128
164
  firebase.run(
129
165
  transaction: proc { |data| 'transaction block' },
@@ -137,17 +173,20 @@ SDK
137
173
 
138
174
  ##### Retrieving String Representation
139
175
 
176
+ ```ruby
140
177
  firebase.to_s
141
178
  firebase.inspect
142
179
 
143
180
  ##### Properties
144
181
 
182
+ ```ruby
145
183
  firebase.parent
146
184
  firebase.root
147
185
  firebase.name
148
186
 
149
187
  ##### Global configuration and settings
150
188
 
189
+ ```ruby
151
190
  Firebase.dispatch_queue=(queue)
152
191
  Firebase.sdkVersion
153
192
 
@@ -156,15 +195,18 @@ SDK
156
195
 
157
196
  ##### Initializing a FirebaseSimpleLogin instance
158
197
 
198
+ ```ruby
159
199
  ref = Firebase.new(url)
160
200
  auth = FirebaseSimpleLogin.new(ref)
161
201
 
162
202
  ##### Checking current authentication status
163
203
 
204
+ ```ruby
164
205
  auth.check { |error, user| }
165
206
 
166
207
  ##### Removing any existing authentication
167
208
 
209
+ ```ruby
168
210
  auth.logout
169
211
 
170
212
  ##### Email/password authentication methods
@@ -173,6 +215,7 @@ SDK
173
215
  For `update`, `credentials` should include `:email`, `:old_password` and
174
216
  `:new_password`.
175
217
 
218
+ ```ruby
176
219
  auth.create(email: 'hello@example.com', password: '12345') { |error, user| }
177
220
  auth.remove(email: 'hello@example.com', password: '12345') { |error, user| }
178
221
  auth.login(email: 'hello@example.com', password: '12345') { |error, user| }
@@ -182,6 +225,7 @@ For `update`, `credentials` should include `:email`, `:old_password` and
182
225
 
183
226
  `credentials` should include `:app_id` and `:permissions`
184
227
 
228
+ ```ruby
185
229
  auth.login_to_facebook(app_id: '123abc', permissions: ['email']) { |error, user| }
186
230
 
187
231
  ##### Twitter authentication methods
@@ -190,13 +234,16 @@ For `update`, `credentials` should include `:email`, `:old_password` and
190
234
  `:on_multiple` block is called when more than one account is found. It is
191
235
  passed an array of usernames and should return an index or `NSNotFound`.
192
236
 
237
+ ```ruby
193
238
  auth.login_to_twitter(app_id: '123abc', on_multiple: ->(usernames) { return 0 }) { |error, user| }
194
239
 
195
240
  ##### Global configuration and settings
196
241
 
242
+ ```ruby
197
243
  FirebaseSimpleLogin.sdkVersion
198
244
 
199
245
  ##### Retrieving String Representation
200
246
 
247
+ ```ruby
201
248
  firebase.to_s
202
249
  firebase.inspect
@@ -114,13 +114,13 @@ class Firebase
114
114
 
115
115
  def <<(value)
116
116
  ref = childByAutoId
117
- ref.update(value)
117
+ ref.set(value)
118
118
  return ref
119
119
  end
120
120
 
121
121
  def push(value, &and_then)
122
122
  ref = childByAutoId
123
- ref.update(value, &and_then)
123
+ ref.set(value, &and_then)
124
124
  return ref
125
125
  end
126
126
 
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  module Firebase
3
- Version = '2.0.12'
3
+ Version = '2.0.13'
4
4
  end
5
5
  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: 2.0.12
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray