bigbertha 0.0.1

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.
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ describe Bigbertha::Snapshot do
5
+
6
+ describe '#to_map' do
7
+ it "sorts a simple hierarchy correctly" do
8
+ snap = Bigbertha::Snapshot.new( {a:{b:1} } )
9
+ snap.to_map.a.should == {b:1}
10
+ end
11
+
12
+ it "sorts a priority hierarchy correctly" do
13
+ snap = Bigbertha::Snapshot.new({
14
+ a: {
15
+ '.priority' => 1000,
16
+ a_1: {
17
+ '.priority' => 20,
18
+ a_1_1: 1
19
+ },
20
+ a_2: {
21
+ '.priority' => 10,
22
+ a_2_1: 1
23
+ }
24
+ },
25
+ b: {
26
+ '.priority' => 0,
27
+ b_1: {
28
+ '.priority' => 50,
29
+ b_1_1: 1
30
+ },
31
+ b_2: {
32
+ '.priority' => 10,
33
+ b_2_1: 1
34
+ }
35
+ }
36
+ })
37
+ map = snap.to_map
38
+ map.keys.should == %w(b a)
39
+ map.b.keys.should == %w(b_2 b_1)
40
+ map.a.keys.should == %w(a_2 a_1)
41
+ end
42
+
43
+ it "sorts a mixed priority hierarchy correctly" do
44
+ snap = Bigbertha::Snapshot.new({
45
+ a: {
46
+ a_1: {
47
+ '.priority' => 20,
48
+ a_1_1: 1
49
+ },
50
+ a_2: {
51
+ '.priority' => 10,
52
+ a_2_1: 1
53
+ }
54
+ },
55
+ b: {
56
+ b_1: {
57
+ '.priority' => "10",
58
+ b_1_1: 1
59
+ },
60
+ b_2: {
61
+ '.priority' => "10",
62
+ b_2_1: 1
63
+ }
64
+ }
65
+ })
66
+ map = snap.to_map
67
+ map.keys.should == %w(a b)
68
+ map.b.keys.should == %w(b_1 b_2)
69
+ map.a.keys.should == %w(a_2 a_1)
70
+ end
71
+
72
+ it "sorts a firebase hierarchy correctly" do
73
+ map = Map( JSON.parse( '{
74
+ "-IrIRswPWIABbNj1q045" : {
75
+ ".priority" : 10.0,
76
+ "-IrIRt0-K0Ae0VkYGzPz" : {
77
+ "c" : 1,
78
+ ".priority" : 50.0
79
+ },
80
+ "-IrIRt4bNTVPk7bILOqR" : {
81
+ ".priority" : 30.0,
82
+ "d" : 1
83
+ }
84
+ },
85
+ "-IrIRsiaW32Hp5xUOyMZ" : {
86
+ ".priority" : 20.0,
87
+ "-IrIRsnD1QRcgMU4lgH1" : {
88
+ ".priority" : 50.0,
89
+ "a" : 1
90
+ },
91
+ "-IrIRsrpWvE7ykm4tRBT" : {
92
+ ".priority" : 30.0,
93
+ "b" : 1
94
+ }
95
+ }
96
+ }'))
97
+ snap = Bigbertha::Snapshot.new( map )
98
+ map = snap.to_map
99
+ map.keys.should == %w(-IrIRswPWIABbNj1q045 -IrIRsiaW32Hp5xUOyMZ)
100
+ map['-IrIRsiaW32Hp5xUOyMZ'].keys.should == %w(-IrIRsrpWvE7ykm4tRBT -IrIRsnD1QRcgMU4lgH1)
101
+ end
102
+
103
+ it "sorts a complex hierarchy correctly" do
104
+ map = Map( JSON.parse( '{
105
+ "-IrIRswPWIABbNj1q045" : {
106
+ ".priority" : 10.0,
107
+ "-IrIRt0-K0Ae0VkYGzPz" : {
108
+ "c" : 1,
109
+ ".priority" : 50.0
110
+ },
111
+ "-IrIRt4bNTVPk7bILOqR" : {
112
+ ".priority" : 30.0,
113
+ "d" : 1
114
+ }
115
+ },
116
+ "-IrIRsiaW32Hp5xUOyMZ" : {
117
+ "-IrIRsnD1QRcgMU4lgH1" : {
118
+ ".priority" : 50.0,
119
+ "a" : 1
120
+ },
121
+ "-IrIRsrpWvE7ykm4tRBT" : {
122
+ ".priority" : 30.0,
123
+ "b" : 1
124
+ }
125
+ }
126
+ }'))
127
+ snap = Bigbertha::Snapshot.new( map )
128
+ map = snap.to_map
129
+ map.keys.should == %w(-IrIRsiaW32Hp5xUOyMZ -IrIRswPWIABbNj1q045)
130
+ map['-IrIRsiaW32Hp5xUOyMZ'].keys.should == %w(-IrIRsrpWvE7ykm4tRBT -IrIRsnD1QRcgMU4lgH1)
131
+ end
132
+
133
+ it "sorts a complex hierarchy correctly" do
134
+ map = Map( JSON.parse( '{
135
+ "-IrIRswPWIABbNj1q045" : {
136
+ ".priority" : "10.0",
137
+ "-IrIRt0-K0Ae0VkYGzPz" : {
138
+ "c" : 1,
139
+ ".priority" : 50.0
140
+ },
141
+ "-IrIRt4bNTVPk7bILOqR" : {
142
+ ".priority" : 30.0,
143
+ "d" : 1
144
+ }
145
+ },
146
+ "-IrIRsiaW32Hp5xUOyMZ" : {
147
+ ".priority" : 10.0,
148
+ "-IrIRsnD1QRcgMU4lgH1" : {
149
+ ".priority" : 50.0,
150
+ "a" : 1
151
+ },
152
+ "-IrIRsrpWvE7ykm4tRBT" : {
153
+ ".priority" : 30.0,
154
+ "b" : 1
155
+ }
156
+ },
157
+ "-IrIRsiaW32Hp5xUOyMA" : {
158
+ "-IrIRsnD1QRcgMU4lgH1" : {
159
+ ".priority" : 50.0,
160
+ "a" : 1
161
+ },
162
+ "-IrIRsrpWvE7ykm4tRBT" : {
163
+ ".priority" : 30.0,
164
+ "b" : 1
165
+ }
166
+ }
167
+ }'))
168
+ snap = Bigbertha::Snapshot.new( map )
169
+ map = snap.to_map
170
+ map.keys.should == %w(-IrIRsiaW32Hp5xUOyMA -IrIRsiaW32Hp5xUOyMZ -IrIRswPWIABbNj1q045)
171
+ map['-IrIRsiaW32Hp5xUOyMZ'].keys.should == %w(-IrIRsrpWvE7ykm4tRBT -IrIRsnD1QRcgMU4lgH1)
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,10 @@
1
+ require 'bigbertha'
2
+ require 'simplecov'
3
+
4
+ if ENV['COV']
5
+ SimpleCov.start do
6
+ end
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigbertha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fernand Galiana
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-07 00:00:00.000000000 Z
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: 6.3.0
20
+ name: map
21
+ requirement: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: 6.3.0
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ prerelease: false
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.6.2
34
+ name: typhoeus
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: 0.6.2
40
+ type: :runtime
41
+ description: Firebase is a real time backend to allow clients to sharedata on the
42
+ web. This gem provides a ruby API implementation.
43
+ email:
44
+ - fernand.galiana@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - README.md
52
+ - Rakefile
53
+ - bigbertha.gemspec
54
+ - examples/a.rb
55
+ - examples/b.rb
56
+ - examples/c.rb
57
+ - examples/d.rb
58
+ - examples/e.rb
59
+ - examples/f.rb
60
+ - examples/g.rb
61
+ - examples/h.rb
62
+ - examples/i.rb
63
+ - examples/j.rb
64
+ - lib/bigbertha.rb
65
+ - lib/bigbertha/action.rb
66
+ - lib/bigbertha/core.rb
67
+ - lib/bigbertha/core_ext/map.rb
68
+ - lib/bigbertha/core_ext/string.rb
69
+ - lib/bigbertha/faults.rb
70
+ - lib/bigbertha/load.rb
71
+ - lib/bigbertha/ref.rb
72
+ - lib/bigbertha/snapshot.rb
73
+ - lib/bigbertha/version.rb
74
+ - spec/bigbertha/.firebase_spec.rb.swp
75
+ - spec/bigbertha/core_ext/map_spec.rb
76
+ - spec/bigbertha/core_ext/string_spec.rb
77
+ - spec/bigbertha/ref_spec.rb
78
+ - spec/bigbertha/root_spec.rb
79
+ - spec/bigbertha/snapshot_spec.rb
80
+ - spec/spec_helper.rb
81
+ homepage: http://derailed.github.io/bigbertha
82
+ licenses: []
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project: bigbertha
100
+ rubygems_version: 2.0.3
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Ruby implementation for your Firebase battery
104
+ test_files: []