bigbertha 0.0.2 → 0.0.4
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 +8 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +11 -0
- data/README.md +35 -7
- data/Rakefile +8 -0
- data/bigbertha.gemspec +5 -3
- data/bin/bb_auth_token +76 -0
- data/examples/a.rb +1 -1
- data/examples/b.rb +1 -1
- data/examples/c.rb +1 -1
- data/examples/d.rb +1 -1
- data/examples/e.rb +1 -1
- data/examples/f.rb +1 -1
- data/examples/g.rb +1 -1
- data/examples/h.rb +1 -1
- data/examples/i.rb +1 -1
- data/examples/j.rb +1 -1
- data/lib/bigbertha/action.rb +2 -1
- data/lib/bigbertha/core_ext/map.rb +3 -3
- data/lib/bigbertha/ref.rb +23 -11
- data/lib/bigbertha/version.rb +1 -1
- data/lib/tasks/auth_token.rake +9 -0
- data/spec/bigbertha/core_ext/map_spec.rb +4 -4
- data/spec/bigbertha/ref_spec.rb +44 -8
- data/spec/bigbertha/root_spec.rb +6 -6
- metadata +34 -4
- data/lib/bigbertha/load.rb +0 -22
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTRlMmEwMTA3ZTZlMjgxYTMwNTQyMzNjNmY1NmY2ZmNhYWNhZTQ5NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWVhMTQ3NWUyZDMzZmFkZDNhMzhkZDRiNWY1MmVmMjIwNzdjYjMzOQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWRlNjAwMWYxYTM5Nzg5MWM0ZTk5YmJiMzE0MmQ1MDNhN2IxNTI1M2FmNTli
|
10
|
+
OWUyMmY3ZWIwNjZhMWNjZWQzMTVjZGNlNGE3YWY5NjlhMDJmMmUxZmY2Zjkz
|
11
|
+
YzliM2Q5NDgzMjViZWY3ZGNlOTQ1NDNjY2Y2OWE4OTQ0YzE0NmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGRhZDVlODM3OTk4YmIwNTM5N2EyOTQ0YmM4ZDc4MmI0YjdlZThlZDM5Y2Jk
|
14
|
+
MjA1OTM4YzhkNzc3ZjEwMmUxZDFmYTU1ODcwNmIyMTVhZjkxMDg3NzE3NWE5
|
15
|
+
MjNmYzAwOWU3ZmRmZjRmOWI3NzU1M2U3ZTk5OGVlNDE2ZjdjZmQ=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,14 +2,23 @@ GEM
|
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
4
|
ZenTest (4.9.0)
|
5
|
+
arrayfields (4.9.0)
|
5
6
|
autotest (4.4.6)
|
6
7
|
ZenTest (>= 4.4.1)
|
7
8
|
autotest-growl (0.2.16)
|
9
|
+
chronic (0.9.1)
|
8
10
|
diff-lcs (1.2.1)
|
9
11
|
ethon (0.5.10)
|
10
12
|
ffi (~> 1.3.0)
|
11
13
|
mime-types (~> 1.18)
|
14
|
+
fattr (2.2.1)
|
12
15
|
ffi (1.3.1)
|
16
|
+
firebase_token_generator (1.0.1)
|
17
|
+
main (5.2.0)
|
18
|
+
arrayfields (>= 4.7.4)
|
19
|
+
chronic (>= 0.6.2)
|
20
|
+
fattr (>= 2.2.0)
|
21
|
+
map (>= 5.1.0)
|
13
22
|
map (6.3.0)
|
14
23
|
mime-types (1.21)
|
15
24
|
multi_json (1.7.2)
|
@@ -35,6 +44,8 @@ PLATFORMS
|
|
35
44
|
DEPENDENCIES
|
36
45
|
autotest
|
37
46
|
autotest-growl
|
47
|
+
firebase_token_generator
|
48
|
+
main
|
38
49
|
map
|
39
50
|
rspec
|
40
51
|
simplecov
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ sync up across the wire. Checkout http://firebase.com for the firehose...
|
|
12
12
|
- Map
|
13
13
|
- Typhoeus
|
14
14
|
- Values
|
15
|
+
- firebase_token_generator
|
15
16
|
|
16
17
|
## Getting Started
|
17
18
|
|
@@ -29,7 +30,7 @@ In the following code samples, we will use the following as our base url:
|
|
29
30
|
Then you can specify an entry point into the data using the following call:
|
30
31
|
|
31
32
|
```ruby
|
32
|
-
ref = Bigbertha::
|
33
|
+
ref = Bigbertha::Ref.new( 'https://zerodarkthirty.firebaseio.com' )
|
33
34
|
```
|
34
35
|
|
35
36
|
NOTE: You don't have to start a the root, but usually a good idea since this api
|
@@ -157,7 +158,9 @@ ref.set( data )
|
|
157
158
|
```
|
158
159
|
|
159
160
|
```ruby
|
160
|
-
ref.child(
|
161
|
+
ref.child( :a, :a_2 ).read # => 10.5
|
162
|
+
# or...
|
163
|
+
ref.child( :a, :a_2 ).val # => 10.5
|
161
164
|
a_val = ref.child( :a ).read
|
162
165
|
a_val.a_1 # => 'Hello World'
|
163
166
|
a_val[:a_1] # => 'Hello World' or use hash indexing...
|
@@ -259,7 +262,12 @@ ref.set( data )
|
|
259
262
|
|
260
263
|
```ruby
|
261
264
|
a_2_2_ref = ref.child( 'a/a_2/a_2_2' )
|
262
|
-
|
265
|
+
# or...
|
266
|
+
a_2_2_ref = ref.child( :a ).child( :a_2 ).child( :a_2_2 )
|
267
|
+
# or...
|
268
|
+
a_2_2_ref = ref.child( :a, :a_2, :a_2_2 )
|
269
|
+
# or...
|
270
|
+
a_2_2_ref = ref.child( %w(a a_2 a_2_2) )
|
263
271
|
a_2_2_ref.name #=> 'a_2_2'
|
264
272
|
|
265
273
|
a_2_ref = a_2_2_ref.parent
|
@@ -291,12 +299,25 @@ a_ref.parent.read #=> {-IrNhTASqxqEpNMw8NGq: {c: 1, d: 2}, -IrNhT2vsoQ1WlgSG6op:
|
|
291
299
|
You can secure you firebase store using a secret token and grant access for permissions on the store using rules.
|
292
300
|
Please refer to the firebase docs for details.
|
293
301
|
|
302
|
+
Note: We've encapsulated the Firebase auth token generator ruby implementation to make generating tokens
|
303
|
+
more convenient.
|
304
|
+
|
305
|
+
```
|
306
|
+
> bb_auth_token -h
|
307
|
+
> bb_auth_token SECRET --data "{\"user\":\"bozo\"}"
|
308
|
+
```
|
309
|
+
|
294
310
|
```ruby
|
295
|
-
ref = Bigbertha::
|
311
|
+
ref = Bigbertha::Ref.new( 'https://bozo.firebaseio.com', auth_token|secret )
|
296
312
|
ref.set( tmp: { a: 0, b: 1 } )
|
297
313
|
ref.set_rules(
|
298
|
-
{
|
299
|
-
|
314
|
+
{
|
315
|
+
'.read' => true,
|
316
|
+
'.write' => "auth.user == 'bozo'",
|
317
|
+
"tmp" => {
|
318
|
+
'.read' => true,
|
319
|
+
'.write' => false
|
320
|
+
}
|
300
321
|
}
|
301
322
|
)
|
302
323
|
res = ref.child(:tmp).read # => { a: 0, b: 1 }
|
@@ -311,6 +332,9 @@ Fernand Galiana
|
|
311
332
|
- http://twitter.com/kitesurfer
|
312
333
|
- <fernand.galiana@gmail.com>
|
313
334
|
|
335
|
+
Still work in progress. So please feel free to contact me if you run into issues or
|
336
|
+
just want to touch base...
|
337
|
+
|
314
338
|
## License
|
315
339
|
|
316
340
|
Bigbertha is released under the [MIT](http://opensource.org/licenses/MIT) license.
|
@@ -322,4 +346,8 @@ Bigbertha is released under the [MIT](http://opensource.org/licenses/MIT) licens
|
|
322
346
|
+ 0.0.2:
|
323
347
|
+ Clean up and doc updates
|
324
348
|
+ 0.0.3:
|
325
|
-
+ Updated gemspec
|
349
|
+
+ Updated gemspec
|
350
|
+
+ 0.0.4:
|
351
|
+
+ Added command line exec bb_auth_token to generate auth tokens
|
352
|
+
+ Added splat args to child
|
353
|
+
+ Deprecated Load. Use Ref from now on
|
data/Rakefile
CHANGED
@@ -5,6 +5,7 @@ Bundler.require
|
|
5
5
|
Bundler::GemHelper.install_tasks
|
6
6
|
|
7
7
|
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
8
|
+
load 'tasks/auth_token.rake'
|
8
9
|
|
9
10
|
require 'rspec/core/rake_task'
|
10
11
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
@@ -18,4 +19,11 @@ task :clean do
|
|
18
19
|
FileUtils.rm_r( cov ) if File.exists?( cov )
|
19
20
|
end
|
20
21
|
|
22
|
+
desc 'Run samples'
|
23
|
+
task :samples do
|
24
|
+
path = File.expand_path( File.join( %w(.. examples ** *.rb) ), __FILE__ )
|
25
|
+
puts path.inspect
|
26
|
+
Dir.glob(path).sort.each { |example| puts example;%x(ruby #{example}) }
|
27
|
+
end
|
28
|
+
|
21
29
|
task default: :spec
|
data/bigbertha.gemspec
CHANGED
@@ -23,7 +23,9 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
24
|
s.require_paths = ["lib"]
|
25
25
|
|
26
|
-
s.add_dependency '
|
27
|
-
s.add_dependency '
|
28
|
-
s.add_dependency '
|
26
|
+
s.add_dependency 'main' , '~> 5.2.0'
|
27
|
+
s.add_dependency 'map' , '~> 6.3.0'
|
28
|
+
s.add_dependency 'typhoeus' , '~> 0.6.2'
|
29
|
+
s.add_dependency 'values' , '~> 1.5.0'
|
30
|
+
s.add_dependency 'firebase_token_generator', '~> 1.0.1'
|
29
31
|
end
|
data/bin/bb_auth_token
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
Main {
|
6
|
+
argument( 'secret' ) {
|
7
|
+
description 'Specifies the firebase secret token'
|
8
|
+
cast :string
|
9
|
+
}
|
10
|
+
option( 'expiry' ) {
|
11
|
+
description 'Time(int) at which the auth token will be considered invalid'
|
12
|
+
cast :integer
|
13
|
+
argument :optional
|
14
|
+
}
|
15
|
+
option( 'valid_from' ) {
|
16
|
+
description 'Time(int) before which the auth token will be considered invalid'
|
17
|
+
cast :integer
|
18
|
+
argument :optional
|
19
|
+
}
|
20
|
+
option( 'debug' ) {
|
21
|
+
description 'Turns on debuging mode for security rules'
|
22
|
+
argument :optional
|
23
|
+
cast :boolean
|
24
|
+
defaults false
|
25
|
+
}
|
26
|
+
option( 'simulate' ) {
|
27
|
+
description 'Runs security rules but does not change the data'
|
28
|
+
argument :optional
|
29
|
+
cast :boolean
|
30
|
+
defaults false
|
31
|
+
}
|
32
|
+
option( 'admin' ) {
|
33
|
+
description 'Generates auth token for administrator'
|
34
|
+
argument :optional
|
35
|
+
cast :boolean
|
36
|
+
defaults false
|
37
|
+
}
|
38
|
+
option( 'data' ) {
|
39
|
+
description 'Addtional user auth data, specifies has a json'
|
40
|
+
argument :optional
|
41
|
+
cast :string
|
42
|
+
defaults ''
|
43
|
+
}
|
44
|
+
|
45
|
+
def print_summary( opts, data, token )
|
46
|
+
puts "FIREBASE AUTH TOKEN GENERATED!"
|
47
|
+
puts '-'*100
|
48
|
+
puts "o This token was generated with the following:"
|
49
|
+
puts " options: #{opts.inspect}"
|
50
|
+
puts " data: #{data.inspect}"
|
51
|
+
puts '-'*100
|
52
|
+
puts '='*200
|
53
|
+
puts token
|
54
|
+
puts '='*200
|
55
|
+
end
|
56
|
+
|
57
|
+
def run
|
58
|
+
gen = Firebase::FirebaseTokenGenerator.new( params['secret'].value )
|
59
|
+
opts = {}
|
60
|
+
%w(admin simulate debug expiry valid_from).each do |key|
|
61
|
+
opts[key.to_sym] = params[key].value if params[key].value != nil
|
62
|
+
end
|
63
|
+
unless params['data'].value.empty?
|
64
|
+
data = JSON.parse( params['data'].value )
|
65
|
+
else
|
66
|
+
data = {}
|
67
|
+
end
|
68
|
+
token = gen.create_token( data, opts)
|
69
|
+
print_summary( opts, data, token )
|
70
|
+
rescue => boom
|
71
|
+
puts '='*200
|
72
|
+
puts "HOY! Firebase auth token generation failed!"
|
73
|
+
puts boom
|
74
|
+
puts '='*200
|
75
|
+
end
|
76
|
+
}
|
data/examples/a.rb
CHANGED
data/examples/b.rb
CHANGED
data/examples/c.rb
CHANGED
data/examples/d.rb
CHANGED
data/examples/e.rb
CHANGED
data/examples/f.rb
CHANGED
data/examples/g.rb
CHANGED
data/examples/h.rb
CHANGED
data/examples/i.rb
CHANGED
data/examples/j.rb
CHANGED
data/lib/bigbertha/action.rb
CHANGED
@@ -10,6 +10,7 @@ module Bigbertha
|
|
10
10
|
res = handle_response( resp, location )
|
11
11
|
res.is_a?(Map) ? Snapshot.new( res ).to_map : res.is_a?(String) ? res.to_val : res
|
12
12
|
end
|
13
|
+
alias :val :read
|
13
14
|
|
14
15
|
def set( data )
|
15
16
|
location = json_url
|
@@ -65,7 +66,7 @@ module Bigbertha
|
|
65
66
|
end
|
66
67
|
resp = Typhoeus.post( location, gen_opts( opts ) )
|
67
68
|
res = handle_response( resp, location )
|
68
|
-
Bigbertha::
|
69
|
+
Bigbertha::Ref.new( uri.to_s + '/' + res.name )
|
69
70
|
end
|
70
71
|
|
71
72
|
def set_priority( priority )
|
@@ -10,12 +10,12 @@ class Map
|
|
10
10
|
res.each_pair do |k,v|
|
11
11
|
if self[k]
|
12
12
|
if other[k]
|
13
|
-
events << Event.new( Bigbertha::
|
13
|
+
events << Event.new( Bigbertha::Ref.evt_value, k )
|
14
14
|
else
|
15
|
-
events << Event.new( Bigbertha::
|
15
|
+
events << Event.new( Bigbertha::Ref.evt_child_removed, k )
|
16
16
|
end
|
17
17
|
else
|
18
|
-
events << Event.new( Bigbertha::
|
18
|
+
events << Event.new( Bigbertha::Ref.evt_child_added, k )
|
19
19
|
end
|
20
20
|
end
|
21
21
|
events
|
data/lib/bigbertha/ref.rb
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
require 'uri'
|
2
2
|
|
3
3
|
module Bigbertha
|
4
|
-
|
4
|
+
class Ref
|
5
|
+
include Bigbertha::Action
|
6
|
+
|
7
|
+
attr_reader :url, :uri
|
8
|
+
|
9
|
+
def self.evt_value; :value; end
|
10
|
+
def self.evt_child_added; :add_child; end
|
11
|
+
def self.evt_child_changed; :mod_child; end
|
12
|
+
def self.evt_child_removed; :rm_child; end
|
13
|
+
def self.evt_child_moved; :mv_child; end
|
14
|
+
|
15
|
+
def initialize( url, auth_token=nil )
|
16
|
+
@url = url
|
17
|
+
@uri = URI.parse( @url )
|
18
|
+
@auth_token = auth_token
|
19
|
+
end
|
20
|
+
|
5
21
|
def name
|
6
22
|
parse_path[-1]
|
7
23
|
end
|
8
|
-
|
9
|
-
def val
|
10
|
-
read
|
11
|
-
end
|
12
|
-
|
24
|
+
|
13
25
|
def root
|
14
26
|
return self if root?
|
15
|
-
Bigbertha::
|
27
|
+
Bigbertha::Ref.new( @uri.scheme + '://' + @uri.host, @auth_token )
|
16
28
|
end
|
17
29
|
|
18
30
|
def root?
|
@@ -22,11 +34,12 @@ module Bigbertha
|
|
22
34
|
def parent
|
23
35
|
return nil if root?
|
24
36
|
path = parse_path[0..-2].join( "/" )
|
25
|
-
Bigbertha::
|
37
|
+
Bigbertha::Ref.new( root.uri.merge(path).to_s, @auth_token )
|
26
38
|
end
|
27
39
|
|
28
|
-
def child( child_path )
|
29
|
-
|
40
|
+
def child( *child_path )
|
41
|
+
child_path = (child_path.is_a?(Array) ? child_path.join('/') : child_path )
|
42
|
+
Bigbertha::Ref.new( "#{uri.to_s}/#{child_path}", @auth_token )
|
30
43
|
end
|
31
44
|
|
32
45
|
def child?( child_path )
|
@@ -54,7 +67,6 @@ module Bigbertha
|
|
54
67
|
@url
|
55
68
|
end
|
56
69
|
|
57
|
-
|
58
70
|
private
|
59
71
|
|
60
72
|
def parse_path
|
data/lib/bigbertha/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
namespace :token do
|
2
|
+
desc 'Generates firebase auth token'
|
3
|
+
task :generate, :secret, :admin do |t, opts|
|
4
|
+
opts = opts.with_defaults( admin:true, debug:false, simulate:false )
|
5
|
+
gen = Firebase::FirebaseTokenGenerator.new( opts.delete( :secret ) )
|
6
|
+
data = {}
|
7
|
+
puts "Your auth token\n #{gen.create_token( data, opts ) }"
|
8
|
+
end
|
9
|
+
end
|
@@ -8,7 +8,7 @@ describe Map do
|
|
8
8
|
curr = Map(:a,2)
|
9
9
|
evts = prev.diff( curr )
|
10
10
|
evts.should have(1).item
|
11
|
-
evts.first.event_type.should == Bigbertha::
|
11
|
+
evts.first.event_type.should == Bigbertha::Ref.evt_value
|
12
12
|
evts.first.ref.should == 'a'
|
13
13
|
end
|
14
14
|
|
@@ -17,7 +17,7 @@ describe Map do
|
|
17
17
|
curr = Map(:a,2)
|
18
18
|
evts = prev.diff( curr )
|
19
19
|
evts.should have(1).item
|
20
|
-
evts.first.event_type.should == Bigbertha::
|
20
|
+
evts.first.event_type.should == Bigbertha::Ref.evt_child_added
|
21
21
|
evts.first.ref.should == 'a'
|
22
22
|
end
|
23
23
|
|
@@ -26,7 +26,7 @@ describe Map do
|
|
26
26
|
curr = Map.new
|
27
27
|
evts = prev.diff( curr )
|
28
28
|
evts.should have(1).item
|
29
|
-
evts.first.event_type.should == Bigbertha::
|
29
|
+
evts.first.event_type.should == Bigbertha::Ref.evt_child_removed
|
30
30
|
evts.first.ref.should == 'a'
|
31
31
|
end
|
32
32
|
end
|
@@ -37,7 +37,7 @@ describe Map do
|
|
37
37
|
curr = Map({a:{a_1:10, a_2:20}})
|
38
38
|
evts = prev.diff( curr )
|
39
39
|
evts.should have(1).item
|
40
|
-
evts.first.event_type.should == Bigbertha::
|
40
|
+
evts.first.event_type.should == Bigbertha::Ref.evt_value
|
41
41
|
evts.first.ref.should == 'a'
|
42
42
|
end
|
43
43
|
end
|
data/spec/bigbertha/ref_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Bigbertha::Ref do
|
4
4
|
before :all do
|
5
|
-
@ref = Bigbertha::
|
5
|
+
@ref = Bigbertha::Ref.new( ENV['fb_url'] )
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#child?' do
|
@@ -35,7 +35,7 @@ describe Bigbertha::Ref do
|
|
35
35
|
describe '#val' do
|
36
36
|
it "retrieves simple value correctly" do
|
37
37
|
@ref.set( a:1 )
|
38
|
-
@ref.child( :a ).val.
|
38
|
+
@ref.child( :a ).val.should == 1
|
39
39
|
end
|
40
40
|
|
41
41
|
it "retrieves complex values correctly" do
|
@@ -44,9 +44,32 @@ describe Bigbertha::Ref do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
describe '#update' do
|
48
|
+
it "updates a value correctly" do
|
49
|
+
@ref.set( a:{b:{c:1, d:"hello"}} )
|
50
|
+
data = @ref.val
|
51
|
+
data.a.b.c = 2
|
52
|
+
data.a.b.d = "BumbleBee Tuna"
|
53
|
+
@ref.update( data )
|
54
|
+
@ref.val.a.b.c.should == 2
|
55
|
+
@ref.val.a.b.d.should == "BumbleBee Tuna"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "updates the data structure correctly" do
|
59
|
+
@ref.set( a:{b:{c:1, d:"hello"}} )
|
60
|
+
data = @ref.val
|
61
|
+
data.delete( :b )
|
62
|
+
data.a.b = {z:10}
|
63
|
+
@ref.update( data )
|
64
|
+
@ref.val.a.b.z.should == 10
|
65
|
+
lambda { @ref.val.a.b.c }.should raise_error NoMethodError
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
47
70
|
describe '#child' do
|
48
71
|
it "creates a child ref correctly" do
|
49
|
-
child_ref = @ref.child( 'fred')
|
72
|
+
child_ref = @ref.child( 'fred' )
|
50
73
|
child_ref.name.should == 'fred'
|
51
74
|
child_ref.parent.to_s.should == ENV['fb_url']
|
52
75
|
end
|
@@ -56,6 +79,19 @@ describe Bigbertha::Ref do
|
|
56
79
|
child_ref.name.should == 'duh'
|
57
80
|
child_ref.parent.to_s.should == ENV['fb_url'] + '/fred/blee'
|
58
81
|
end
|
82
|
+
|
83
|
+
it "handles array args correctly" do
|
84
|
+
child_ref = @ref.child( %w(fred blee duh) )
|
85
|
+
child_ref.name.should == 'duh'
|
86
|
+
child_ref.parent.to_s.should == ENV['fb_url'] + '/fred/blee'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "handles splat correctly" do
|
90
|
+
child_ref = @ref.child( :fred, :blee, :duh )
|
91
|
+
child_ref.name.should == 'duh'
|
92
|
+
child_ref.parent.to_s.should == ENV['fb_url'] + '/fred/blee'
|
93
|
+
end
|
94
|
+
|
59
95
|
end
|
60
96
|
|
61
97
|
describe '#name' do
|
@@ -64,7 +100,7 @@ describe Bigbertha::Ref do
|
|
64
100
|
end
|
65
101
|
|
66
102
|
it "identifies a url name correctly" do
|
67
|
-
ref = Bigbertha::
|
103
|
+
ref = Bigbertha::Ref.new( ENV['fb_url'] + '/fred/blee' )
|
68
104
|
ref.name.should == 'blee'
|
69
105
|
end
|
70
106
|
end
|
@@ -75,7 +111,7 @@ describe Bigbertha::Ref do
|
|
75
111
|
end
|
76
112
|
|
77
113
|
it "identifies non root url correctly" do
|
78
|
-
ref = Bigbertha::
|
114
|
+
ref = Bigbertha::Ref.new( ENV['fb_url'] + '/fred/blee' )
|
79
115
|
ref.root.to_s.should == ENV['fb_url']
|
80
116
|
end
|
81
117
|
end
|
@@ -86,12 +122,12 @@ describe Bigbertha::Ref do
|
|
86
122
|
end
|
87
123
|
|
88
124
|
it "identifies / as root correctly" do
|
89
|
-
ref = Bigbertha::
|
125
|
+
ref = Bigbertha::Ref.new( ENV['fb_url'] + '/' )
|
90
126
|
ref.should be_root
|
91
127
|
end
|
92
128
|
|
93
129
|
it "identifies non root correctly" do
|
94
|
-
ref = Bigbertha::
|
130
|
+
ref = Bigbertha::Ref.new( ENV['fb_url'] + '/fred' )
|
95
131
|
ref.should_not be_root
|
96
132
|
end
|
97
133
|
end
|
@@ -102,7 +138,7 @@ describe Bigbertha::Ref do
|
|
102
138
|
end
|
103
139
|
|
104
140
|
it "identifies a parent correctly" do
|
105
|
-
ref = Bigbertha::
|
141
|
+
ref = Bigbertha::Ref.new( ENV['fb_url'] + '/fred/blee' )
|
106
142
|
ref.parent.to_s.should == ENV['fb_url'] + '/fred'
|
107
143
|
end
|
108
144
|
end
|
data/spec/bigbertha/root_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Bigbertha::
|
3
|
+
describe Bigbertha::Ref do
|
4
4
|
before :all do
|
5
5
|
@url = ENV['fb_url']
|
6
|
-
@fb = Bigbertha::
|
6
|
+
@fb = Bigbertha::Ref.new( @url )
|
7
7
|
end
|
8
8
|
|
9
9
|
describe '#inc' do
|
@@ -40,7 +40,7 @@ describe Bigbertha::Load do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "fails if the field is non numeric" do
|
43
|
-
lambda { @fb.child( :c ).inc( :c_1 ) }.should raise_error( Bigbertha::
|
43
|
+
lambda { @fb.child( :c ).inc( :c_1 ) }.should raise_error( Bigbertha::Ref::NonNumericFieldError )
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -78,13 +78,13 @@ describe Bigbertha::Load do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "fails if the field is non numeric" do
|
81
|
-
lambda { @fb.child( :c ).dec( :c_1 ) }.should raise_error( Bigbertha::
|
81
|
+
lambda { @fb.child( :c ).dec( :c_1 ) }.should raise_error( Bigbertha::Ref::NonNumericFieldError )
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe '#set_rules' do
|
86
86
|
before :each do
|
87
|
-
@auth_fb = Bigbertha::
|
87
|
+
@auth_fb = Bigbertha::Ref.new( @url, ENV['fb_auth_token'] )
|
88
88
|
end
|
89
89
|
|
90
90
|
after :each do
|
@@ -104,7 +104,7 @@ describe Bigbertha::Load do
|
|
104
104
|
res = @fb.child(:tmp).read
|
105
105
|
res.should == { a: 0, b: 1 }
|
106
106
|
|
107
|
-
lambda { @fb.set( tmp: { d: 0 } ) }.should raise_error Bigbertha::
|
107
|
+
lambda { @fb.set( tmp: { d: 0 } ) }.should raise_error Bigbertha::Ref::PermissionDeniedError
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigbertha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernand Galiana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
prerelease: false
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.2.0
|
20
|
+
name: main
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 5.2.0
|
26
|
+
type: :runtime
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
prerelease: false
|
15
29
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,11 +66,26 @@ dependencies:
|
|
52
66
|
- !ruby/object:Gem::Version
|
53
67
|
version: 1.5.0
|
54
68
|
type: :runtime
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.1
|
76
|
+
name: firebase_token_generator
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.0.1
|
82
|
+
type: :runtime
|
55
83
|
description: Firebase is a real time backend to allow clients to sharedata on the
|
56
84
|
web. This gem provides a ruby API implementation.
|
57
85
|
email:
|
58
86
|
- fernand.galiana@gmail.com
|
59
|
-
executables:
|
87
|
+
executables:
|
88
|
+
- bb_auth_token
|
60
89
|
extensions: []
|
61
90
|
extra_rdoc_files: []
|
62
91
|
files:
|
@@ -65,6 +94,7 @@ files:
|
|
65
94
|
- README.md
|
66
95
|
- Rakefile
|
67
96
|
- bigbertha.gemspec
|
97
|
+
- bin/bb_auth_token
|
68
98
|
- examples/a.rb
|
69
99
|
- examples/b.rb
|
70
100
|
- examples/c.rb
|
@@ -81,10 +111,10 @@ files:
|
|
81
111
|
- lib/bigbertha/core_ext/map.rb
|
82
112
|
- lib/bigbertha/core_ext/string.rb
|
83
113
|
- lib/bigbertha/faults.rb
|
84
|
-
- lib/bigbertha/load.rb
|
85
114
|
- lib/bigbertha/ref.rb
|
86
115
|
- lib/bigbertha/snapshot.rb
|
87
116
|
- lib/bigbertha/version.rb
|
117
|
+
- lib/tasks/auth_token.rake
|
88
118
|
- spec/bigbertha/.firebase_spec.rb.swp
|
89
119
|
- spec/bigbertha/core_ext/map_spec.rb
|
90
120
|
- spec/bigbertha/core_ext/string_spec.rb
|
data/lib/bigbertha/load.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'bigbertha/ref'
|
2
|
-
|
3
|
-
module Bigbertha
|
4
|
-
class Load
|
5
|
-
include Bigbertha::Ref
|
6
|
-
include Bigbertha::Action
|
7
|
-
|
8
|
-
attr_reader :url, :uri
|
9
|
-
|
10
|
-
def self.evt_value; :value; end
|
11
|
-
def self.evt_child_added; :add_child; end
|
12
|
-
def self.evt_child_changed; :mod_child; end
|
13
|
-
def self.evt_child_removed; :rm_child; end
|
14
|
-
def self.evt_child_moved; :mv_child; end
|
15
|
-
|
16
|
-
def initialize( url, auth_token=nil )
|
17
|
-
@url = url
|
18
|
-
@uri = URI.parse( @url )
|
19
|
-
@auth_token = auth_token
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|