firebase 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +13 -9
- data/VERSION +1 -1
- data/firebase.gemspec +4 -4
- data/lib/firebase.rb +31 -70
- data/lib/firebase/request.rb +18 -19
- data/lib/firebase/response.rb +1 -1
- data/spec/firebase_request_spec.rb +0 -8
- data/spec/firebase_spec.rb +14 -6
- metadata +29 -42
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4695f53c5178de66b3d6e41ea5a3a0c5779099cf
|
4
|
+
data.tar.gz: 2e56f83b67bddea9e40470ba74a01467dbd608ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea1883f4e4ba205ac2b81c40a3b576925e9dd2df3d68ee8d3dd25e4f8a043af5ccebb2b158faed2aa2e887935dbfde3b404dd9778a5e90dd28758342e4cc852c
|
7
|
+
data.tar.gz: c456f212241036b86703388137e0b0e153d7f611a41a0b1157fc3ba3a4226f9e1dd3be5a220661bacd410c3c9ebe57df54b0ea45cfaea342c17f580182d912af
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
-
-
|
1
|
+
- 0.2.0
|
2
|
+
|
3
|
+
* You can now pass query options to get/push/set, etc.
|
4
|
+
* The old syntax no longer works. You now need to create instance variables of Firebase::Client.new(...)
|
5
|
+
|
6
|
+
- 0.1.6
|
2
7
|
|
3
8
|
* You can now create instances of Firebase. The old syntax still works but will be removed in version 0,2. - @wannabefro
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ gem install firebase
|
|
17
17
|
```ruby
|
18
18
|
base_uri = 'https://<your-firebase>.firebaseio.com/'
|
19
19
|
|
20
|
-
firebase = Firebase.new(base_uri)
|
20
|
+
firebase = Firebase::Client.new(base_uri)
|
21
21
|
|
22
22
|
response = firebase.push("todos", { :name => 'Pick the milk', :priority => 1 })
|
23
23
|
response.success? # => true
|
@@ -28,22 +28,26 @@ response.raw_body # => '{"name":"-INOQPH-aV_psbk3ZXEX"}'
|
|
28
28
|
|
29
29
|
If you have a read-only namespace, set your secret key as follows:
|
30
30
|
```ruby
|
31
|
-
firebase = Firebase.new(base_uri, secret_key)
|
31
|
+
firebase = Firebase::Client.new(base_uri, secret_key)
|
32
32
|
|
33
33
|
response = firebase.push("todos", { :name => 'Pick the milk', :priority => 1 })
|
34
34
|
```
|
35
35
|
|
36
|
-
|
36
|
+
You can now pass custom query options to firebase:
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
|
40
|
-
get(path)
|
41
|
-
push(path, data)
|
42
|
-
delete(path)
|
43
|
-
update(path, data)
|
39
|
+
response = firebase.push("todos", :limit => 1)
|
44
40
|
```
|
45
41
|
|
46
|
-
|
42
|
+
So far, supported methods are:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
set(path, data, query_options)
|
46
|
+
get(path, query_options)
|
47
|
+
push(path, data, query_options)
|
48
|
+
delete(path, query_options)
|
49
|
+
update(path, data, query_options)
|
50
|
+
```
|
47
51
|
|
48
52
|
More information about Firebase and the Firebase API is available at the
|
49
53
|
[official website](http://www.firebase.com/).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/firebase.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "firebase"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oscar Del Ben"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2014-03-16"
|
13
13
|
s.description = "Firebase wrapper for Ruby"
|
14
14
|
s.email = "info@oscardelben.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -37,11 +37,11 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.homepage = "http://github.com/oscardelben/firebase-ruby"
|
38
38
|
s.licenses = ["MIT"]
|
39
39
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = "
|
40
|
+
s.rubygems_version = "2.0.3"
|
41
41
|
s.summary = "Firebase wrapper for Ruby"
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
44
|
-
s.specification_version =
|
44
|
+
s.specification_version = 4
|
45
45
|
|
46
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
47
|
s.add_runtime_dependency(%q<typhoeus>, [">= 0.6.1"])
|
data/lib/firebase.rb
CHANGED
@@ -1,95 +1,56 @@
|
|
1
|
-
|
1
|
+
module Firebase
|
2
|
+
class Client
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
require 'firebase/request'
|
5
|
+
require 'firebase/response'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
def format_uri(other)
|
7
|
+
def self.format_uri(other)
|
9
8
|
if other
|
10
9
|
other.end_with?("/") ? other : other + '/'
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
deprecate
|
16
|
-
default_instance.request.base_uri = format_uri(other)
|
17
|
-
end
|
13
|
+
attr_reader :auth, :request
|
18
14
|
|
19
|
-
def auth=
|
20
|
-
|
21
|
-
|
15
|
+
def initialize(base_uri, auth=nil)
|
16
|
+
uri = Firebase::Client.format_uri(base_uri)
|
17
|
+
@request = Firebase::Request.new(uri)
|
18
|
+
@auth = auth
|
22
19
|
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
# Writes and returns the data
|
22
|
+
# Firebase.set('users/info', { 'name' => 'Oscar' }) => { 'name' => 'Oscar' }
|
23
|
+
def set(path, data, query={})
|
24
|
+
request.put(path, data, query_options(query))
|
27
25
|
end
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
# Returns the data at path
|
28
|
+
def get(path, query={})
|
29
|
+
request.get(path, query_options(query))
|
32
30
|
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
# Writes the data, returns the key name of the data added
|
33
|
+
# Firebase.push('users', { 'age' => 18}) => {"name":"-INOQPH-aV_psbk3ZXEX"}
|
34
|
+
def push(path, data, query={})
|
35
|
+
request.post(path, data, query_options(query))
|
37
36
|
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
# Deletes the data at path and returs true
|
39
|
+
def delete(path, query={})
|
40
|
+
request.delete(path, query_options(query))
|
42
41
|
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
# Write the data at path but does not delete ommited children. Returns the data
|
44
|
+
# Firebase.update('users/info', { 'name' => 'Oscar' }) => { 'name' => 'Oscar' }
|
45
|
+
def update(path, data, query={})
|
46
|
+
request.patch(path, data, query_options(query))
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
@default_instance ||= Firebase.new(nil, nil)
|
51
|
-
end
|
49
|
+
private
|
52
50
|
|
53
|
-
def
|
54
|
-
|
51
|
+
def query_options(query)
|
52
|
+
{ :auth => auth }.merge(query)
|
55
53
|
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
attr_accessor :request
|
60
|
-
|
61
|
-
def initialize(base_uri, auth=nil)
|
62
|
-
uri = Firebase.format_uri(base_uri)
|
63
|
-
@request = Firebase::Request.new(uri, auth)
|
64
|
-
end
|
65
|
-
|
66
|
-
# Writes and returns the data
|
67
|
-
# Firebase.set('users/info', { 'name' => 'Oscar' }) => { 'name' => 'Oscar' }
|
68
|
-
def set(path, data)
|
69
|
-
request.put(path, data)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns the data at path
|
73
|
-
def get(path)
|
74
|
-
request.get(path)
|
75
|
-
end
|
76
|
-
|
77
|
-
# Writes the data, returns the key name of the data added
|
78
|
-
# Firebase.push('users', { 'age' => 18}) => {"name":"-INOQPH-aV_psbk3ZXEX"}
|
79
|
-
def push(path, data)
|
80
|
-
request.post(path, data)
|
81
54
|
end
|
82
|
-
|
83
|
-
# Deletes the data at path and returs true
|
84
|
-
def delete(path)
|
85
|
-
request.delete(path)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Write the data at path but does not delete ommited children. Returns the data
|
89
|
-
# Firebase.update('users/info', { 'name' => 'Oscar' }) => { 'name' => 'Oscar' }
|
90
|
-
def update(path, data)
|
91
|
-
request.patch(path, data)
|
92
|
-
end
|
93
|
-
|
94
55
|
end
|
95
56
|
|
data/lib/firebase/request.rb
CHANGED
@@ -3,51 +3,50 @@ require 'json'
|
|
3
3
|
require 'open-uri'
|
4
4
|
require 'uri'
|
5
5
|
|
6
|
-
|
6
|
+
module Firebase
|
7
7
|
class Request
|
8
8
|
|
9
|
-
|
9
|
+
attr_reader :base_uri
|
10
10
|
|
11
|
-
def initialize(base_uri
|
11
|
+
def initialize(base_uri)
|
12
12
|
@base_uri = base_uri
|
13
|
-
@auth = auth
|
14
13
|
end
|
15
14
|
|
16
|
-
def get(path)
|
17
|
-
process(:get, path)
|
15
|
+
def get(path, query_options)
|
16
|
+
process(:get, path, nil, query_options)
|
18
17
|
end
|
19
18
|
|
20
|
-
def put(path, value)
|
21
|
-
process(:put, path,
|
19
|
+
def put(path, value, query_options)
|
20
|
+
process(:put, path, value.to_json, query_options)
|
22
21
|
end
|
23
22
|
|
24
|
-
def post(path, value)
|
25
|
-
process(:post, path,
|
23
|
+
def post(path, value, query_options)
|
24
|
+
process(:post, path, value.to_json, query_options)
|
26
25
|
end
|
27
26
|
|
28
|
-
def delete(path)
|
29
|
-
process(:delete, path)
|
27
|
+
def delete(path, query_options)
|
28
|
+
process(:delete, path, nil, query_options)
|
30
29
|
end
|
31
30
|
|
32
|
-
def patch(path, value)
|
33
|
-
process(:patch, path,
|
31
|
+
def patch(path, value, query_options)
|
32
|
+
process(:patch, path, value.to_json, query_options)
|
34
33
|
end
|
35
34
|
|
36
35
|
def build_url(path)
|
37
36
|
path = "#{path}.json"
|
38
|
-
|
39
|
-
url = URI.join(base_uri, path, query_string)
|
37
|
+
url = URI.join(base_uri, path)
|
40
38
|
|
41
39
|
url.to_s
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
45
43
|
|
46
|
-
def process(method, path,
|
44
|
+
def process(method, path, body=nil, query_options={})
|
47
45
|
@@hydra ||= Typhoeus::Hydra.new
|
48
46
|
request = Typhoeus::Request.new(build_url(path),
|
49
|
-
:body =>
|
50
|
-
:method => method
|
47
|
+
:body => body,
|
48
|
+
:method => method,
|
49
|
+
:params => query_options)
|
51
50
|
@@hydra.queue(request)
|
52
51
|
@@hydra.run
|
53
52
|
|
data/lib/firebase/response.rb
CHANGED
@@ -17,12 +17,4 @@ describe "Firebase Request" do
|
|
17
17
|
@req.build_url('users/eugene').should == 'https://test.firebaseio.com/users/eugene.json'
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
describe 'auth' do
|
22
|
-
it "should include a auth in the query string, if configured" do
|
23
|
-
req = Firebase::Request.new('https://test.firebaseio.com', 'secretkey')
|
24
|
-
|
25
|
-
req.build_url('users/eugene').should == 'https://test.firebaseio.com/users/eugene.json?auth=secretkey'
|
26
|
-
end
|
27
|
-
end
|
28
20
|
end
|
data/spec/firebase_spec.rb
CHANGED
@@ -7,20 +7,20 @@ describe "Firebase" do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
|
-
@firebase = Firebase.new('https://test.firebaseio.com')
|
10
|
+
@firebase = Firebase::Client.new('https://test.firebaseio.com')
|
11
11
|
@req = @firebase.request
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "set" do
|
15
15
|
it "writes and returns the data" do
|
16
|
-
@req.should_receive(:put).with('users/info', data)
|
16
|
+
@req.should_receive(:put).with('users/info', data, {:auth => nil})
|
17
17
|
@firebase.set('users/info', data)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "get" do
|
22
22
|
it "returns the data" do
|
23
|
-
@req.should_receive(:get).with('users/info')
|
23
|
+
@req.should_receive(:get).with('users/info', {:auth => nil})
|
24
24
|
@firebase.get('users/info')
|
25
25
|
end
|
26
26
|
|
@@ -51,22 +51,30 @@ describe "Firebase" do
|
|
51
51
|
|
52
52
|
describe "push" do
|
53
53
|
it "writes the data" do
|
54
|
-
@req.should_receive(:post).with('users', data)
|
54
|
+
@req.should_receive(:post).with('users', data, {:auth => nil})
|
55
55
|
@firebase.push('users', data)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "delete" do
|
60
60
|
it "returns true" do
|
61
|
-
@req.should_receive(:delete).with('users/info')
|
61
|
+
@req.should_receive(:delete).with('users/info', {:auth => nil})
|
62
62
|
@firebase.delete('users/info')
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "update" do
|
67
67
|
it "updates and returns the data" do
|
68
|
-
@req.should_receive(:patch).with('users/info', data)
|
68
|
+
@req.should_receive(:patch).with('users/info', data, {:auth => nil})
|
69
69
|
@firebase.update('users/info', data)
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
describe "options" do
|
74
|
+
it "passes custom options" do
|
75
|
+
firebase = Firebase::Client.new('https://test.firebaseio.com', 'secret')
|
76
|
+
firebase.request.should_receive(:get).with('todos', {:auth => 'secret', :foo => 'bar'})
|
77
|
+
firebase.get('todos', :foo => 'bar')
|
78
|
+
end
|
79
|
+
end
|
72
80
|
end
|
metadata
CHANGED
@@ -1,80 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.6
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Oscar Del Ben
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
name: typhoeus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.1
|
20
|
-
none: false
|
21
|
-
prerelease: false
|
22
|
-
name: typhoeus
|
23
20
|
type: :runtime
|
24
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- -
|
24
|
+
- - '>='
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: 0.6.1
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
|
-
- -
|
31
|
+
- - '>='
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: '0'
|
36
|
-
none: false
|
37
|
-
prerelease: false
|
38
|
-
name: json
|
39
34
|
type: :runtime
|
40
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
|
-
- -
|
38
|
+
- - '>='
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: '0'
|
45
|
-
none: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
48
44
|
requirements:
|
49
|
-
- -
|
45
|
+
- - '>='
|
50
46
|
- !ruby/object:Gem::Version
|
51
47
|
version: '0'
|
52
|
-
none: false
|
53
|
-
prerelease: false
|
54
|
-
name: rspec
|
55
48
|
type: :development
|
56
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- -
|
52
|
+
- - '>='
|
59
53
|
- !ruby/object:Gem::Version
|
60
54
|
version: '0'
|
61
|
-
none: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - ~>
|
66
60
|
- !ruby/object:Gem::Version
|
67
61
|
version: 1.8.3
|
68
|
-
none: false
|
69
|
-
prerelease: false
|
70
|
-
name: jeweler
|
71
62
|
type: :development
|
72
|
-
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
65
|
requirements:
|
74
66
|
- - ~>
|
75
67
|
- !ruby/object:Gem::Version
|
76
68
|
version: 1.8.3
|
77
|
-
none: false
|
78
69
|
description: Firebase wrapper for Ruby
|
79
70
|
email: info@oscardelben.com
|
80
71
|
executables: []
|
@@ -102,29 +93,25 @@ files:
|
|
102
93
|
homepage: http://github.com/oscardelben/firebase-ruby
|
103
94
|
licenses:
|
104
95
|
- MIT
|
96
|
+
metadata: {}
|
105
97
|
post_install_message:
|
106
98
|
rdoc_options: []
|
107
99
|
require_paths:
|
108
100
|
- lib
|
109
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
102
|
requirements:
|
111
|
-
- -
|
103
|
+
- - '>='
|
112
104
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
|
-
hash: -3647962587689699515
|
116
105
|
version: '0'
|
117
|
-
none: false
|
118
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
107
|
requirements:
|
120
|
-
- -
|
108
|
+
- - '>='
|
121
109
|
- !ruby/object:Gem::Version
|
122
110
|
version: '0'
|
123
|
-
none: false
|
124
111
|
requirements: []
|
125
112
|
rubyforge_project:
|
126
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.0.3
|
127
114
|
signing_key:
|
128
|
-
specification_version:
|
115
|
+
specification_version: 4
|
129
116
|
summary: Firebase wrapper for Ruby
|
130
117
|
test_files: []
|