firebase 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +7 -2
- data/Gemfile.lock +37 -32
- data/README.md +1 -1
- data/Rakefile +15 -12
- data/VERSION +1 -1
- data/firebase.gemspec +10 -6
- data/lib/firebase.rb +3 -3
- data/spec/firebase_spec.rb +51 -11
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e864ba62615c80fdea3df462d52ff16f0a05581b
|
4
|
+
data.tar.gz: f92180ed3c2af45cdec10d0c0342a05079727b58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63f404aa8ed4b8f69baebeb5dc3043fd3f7bec1916dd9c1bb51e4690225e7908dad5807a732da525b8b365d2c43467079ff9626e658eb645f911b2e566dcf769
|
7
|
+
data.tar.gz: 7bdbd22fffb2c1ebb2362db13f2b7e01d13303c56d365e806f8073c8422699024a03fc2da4c2f9c6d283f4242aaca4478eefecc6b9db82d18a1fb3d7aeed32c9
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -9,6 +9,11 @@ gem 'json'
|
|
9
9
|
# Add dependencies to develop your gem here.
|
10
10
|
# Include everything needed to run rake, tests, features, etc.
|
11
11
|
group :development do
|
12
|
-
gem
|
13
|
-
gem
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rdoc'
|
14
|
+
gem 'rspec'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :utility do
|
18
|
+
gem 'jeweler'
|
14
19
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.8)
|
5
5
|
builder (3.2.2)
|
6
6
|
descendants_tracker (0.0.4)
|
7
7
|
thread_safe (~> 0.3, >= 0.3.1)
|
8
8
|
diff-lcs (1.2.5)
|
9
|
-
faraday (0.9.
|
9
|
+
faraday (0.9.2)
|
10
10
|
multipart-post (>= 1.2, < 3)
|
11
|
-
git (1.2.
|
12
|
-
github_api (0.
|
11
|
+
git (1.2.9.1)
|
12
|
+
github_api (0.13.0)
|
13
13
|
addressable (~> 2.3)
|
14
|
-
descendants_tracker (~> 0.0.
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
15
|
faraday (~> 0.8, < 0.10)
|
16
|
-
hashie (>=
|
16
|
+
hashie (>= 3.4)
|
17
17
|
multi_json (>= 1.7.5, < 2.0)
|
18
|
-
nokogiri (~> 1.6.
|
18
|
+
nokogiri (~> 1.6.6)
|
19
19
|
oauth2
|
20
|
-
hashie (
|
21
|
-
highline (1.
|
22
|
-
httpclient (2.
|
20
|
+
hashie (3.4.3)
|
21
|
+
highline (1.7.8)
|
22
|
+
httpclient (2.7.0.1)
|
23
23
|
jeweler (2.0.1)
|
24
24
|
builder
|
25
25
|
bundler (>= 1.0)
|
@@ -29,34 +29,37 @@ GEM
|
|
29
29
|
nokogiri (>= 1.5.10)
|
30
30
|
rake
|
31
31
|
rdoc
|
32
|
-
json (1.8.
|
33
|
-
jwt (
|
34
|
-
|
35
|
-
|
36
|
-
multi_json (1.9.3)
|
32
|
+
json (1.8.3)
|
33
|
+
jwt (1.5.2)
|
34
|
+
mini_portile (0.6.2)
|
35
|
+
multi_json (1.11.2)
|
37
36
|
multi_xml (0.5.5)
|
38
37
|
multipart-post (2.0.0)
|
39
|
-
nokogiri (1.6.
|
40
|
-
mini_portile (~> 0.
|
41
|
-
oauth2 (0.
|
38
|
+
nokogiri (1.6.6.4)
|
39
|
+
mini_portile (~> 0.6.0)
|
40
|
+
oauth2 (1.0.0)
|
42
41
|
faraday (>= 0.8, < 0.10)
|
43
|
-
jwt (~>
|
42
|
+
jwt (~> 1.0)
|
44
43
|
multi_json (~> 1.3)
|
45
44
|
multi_xml (~> 0.5)
|
46
45
|
rack (~> 1.2)
|
47
|
-
rack (1.
|
48
|
-
rake (10.
|
49
|
-
rdoc (4.
|
50
|
-
|
51
|
-
|
52
|
-
rspec-
|
53
|
-
rspec-
|
54
|
-
|
55
|
-
|
56
|
-
rspec-expectations (
|
57
|
-
diff-lcs (>= 1.
|
58
|
-
|
59
|
-
|
46
|
+
rack (1.6.4)
|
47
|
+
rake (10.4.2)
|
48
|
+
rdoc (4.2.0)
|
49
|
+
rspec (3.4.0)
|
50
|
+
rspec-core (~> 3.4.0)
|
51
|
+
rspec-expectations (~> 3.4.0)
|
52
|
+
rspec-mocks (~> 3.4.0)
|
53
|
+
rspec-core (3.4.1)
|
54
|
+
rspec-support (~> 3.4.0)
|
55
|
+
rspec-expectations (3.4.0)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.4.0)
|
58
|
+
rspec-mocks (3.4.0)
|
59
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
+
rspec-support (~> 3.4.0)
|
61
|
+
rspec-support (3.4.1)
|
62
|
+
thread_safe (0.3.5)
|
60
63
|
|
61
64
|
PLATFORMS
|
62
65
|
ruby
|
@@ -65,4 +68,6 @@ DEPENDENCIES
|
|
65
68
|
httpclient
|
66
69
|
jeweler
|
67
70
|
json
|
71
|
+
rake
|
72
|
+
rdoc
|
68
73
|
rspec
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -11,19 +11,22 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
begin
|
15
|
+
require 'jeweler'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "firebase"
|
19
|
+
gem.homepage = "http://github.com/oscardelben/firebase-ruby"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Firebase wrapper for Ruby}
|
22
|
+
gem.description = %Q{Firebase wrapper for Ruby}
|
23
|
+
gem.email = "info@oscardelben.com"
|
24
|
+
gem.authors = ["Oscar Del Ben"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
rescue LoadError
|
25
29
|
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
30
|
|
28
31
|
require 'rspec/core'
|
29
32
|
require 'rspec/core/rake_task'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/firebase.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: firebase 0.2.
|
5
|
+
# stub: firebase 0.2.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "firebase"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Oscar Del Ben"]
|
14
|
-
s.date = "2015-11-
|
14
|
+
s.date = "2015-11-26"
|
15
15
|
s.description = "Firebase wrapper for Ruby"
|
16
16
|
s.email = "info@oscardelben.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.files = [
|
23
23
|
".document",
|
24
24
|
".rspec",
|
25
|
+
".travis.yml",
|
25
26
|
"CHANGELOG.md",
|
26
27
|
"Gemfile",
|
27
28
|
"Gemfile.lock",
|
@@ -47,19 +48,22 @@ Gem::Specification.new do |s|
|
|
47
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
48
49
|
s.add_runtime_dependency(%q<httpclient>, [">= 0"])
|
49
50
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
50
53
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
52
54
|
else
|
53
55
|
s.add_dependency(%q<httpclient>, [">= 0"])
|
54
56
|
s.add_dependency(%q<json>, [">= 0"])
|
57
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
55
59
|
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
57
60
|
end
|
58
61
|
else
|
59
62
|
s.add_dependency(%q<httpclient>, [">= 0"])
|
60
63
|
s.add_dependency(%q<json>, [">= 0"])
|
64
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
61
66
|
s.add_dependency(%q<rspec>, [">= 0"])
|
62
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
data/lib/firebase.rb
CHANGED
@@ -30,7 +30,7 @@ module Firebase
|
|
30
30
|
|
31
31
|
# Returns the data at path
|
32
32
|
def get(path, query={})
|
33
|
-
process :get, path, query
|
33
|
+
process :get, path, nil, query
|
34
34
|
end
|
35
35
|
|
36
36
|
# Writes the data, returns the key name of the data added
|
@@ -41,7 +41,7 @@ module Firebase
|
|
41
41
|
|
42
42
|
# Deletes the data at path and returs true
|
43
43
|
def delete(path, query={})
|
44
|
-
process :delete, path, query
|
44
|
+
process :delete, path, nil, query
|
45
45
|
end
|
46
46
|
|
47
47
|
# Write the data at path but does not delete ommited children. Returns the data
|
@@ -55,7 +55,7 @@ module Firebase
|
|
55
55
|
def process(verb, path, data=nil, query={})
|
56
56
|
Firebase::Response.new @request.request(verb, "#{path}.json", {
|
57
57
|
:body => (data && data.to_json),
|
58
|
-
:query => (auth ? { :auth => auth }.merge(query) : query),
|
58
|
+
:query => (@auth ? { :auth => @auth }.merge(query) : query),
|
59
59
|
:follow_redirect => true
|
60
60
|
})
|
61
61
|
end
|
data/spec/firebase_spec.rb
CHANGED
@@ -21,17 +21,57 @@ describe "Firebase" do
|
|
21
21
|
|
22
22
|
describe "set" do
|
23
23
|
it "writes and returns the data" do
|
24
|
-
@firebase.
|
24
|
+
expect(@firebase).to receive(:process).with(:put, 'users/info', data, {})
|
25
25
|
@firebase.set('users/info', data)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "get" do
|
30
30
|
it "returns the data" do
|
31
|
-
@firebase.
|
31
|
+
expect(@firebase).to receive(:process).with(:get, 'users/info', nil, {})
|
32
32
|
@firebase.get('users/info')
|
33
33
|
end
|
34
34
|
|
35
|
+
it "correctly passes custom ordering params" do
|
36
|
+
params = {
|
37
|
+
:orderBy => '"$key"',
|
38
|
+
:startAt => '"A1"'
|
39
|
+
}
|
40
|
+
expect(@firebase).to receive(:process).with(:get, 'users/info', nil, params)
|
41
|
+
@firebase.get('users/info', params)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "works when run against real Firebase dataset" do
|
45
|
+
firebase = Firebase::Client.new 'https://dinosaur-facts.firebaseio.com'
|
46
|
+
response = firebase.get 'dinosaurs', :orderBy => '"$key"', :startAt => '"a"', :endAt => '"m"'
|
47
|
+
expect(response.body).to eq({
|
48
|
+
"bruhathkayosaurus" => {
|
49
|
+
"appeared" => -70000000,
|
50
|
+
"height" => 25,
|
51
|
+
"length" => 44,
|
52
|
+
"order" => "saurischia",
|
53
|
+
"vanished" => -70000000,
|
54
|
+
"weight" => 135000
|
55
|
+
},
|
56
|
+
"lambeosaurus" => {
|
57
|
+
"appeared" => -76000000,
|
58
|
+
"height" => 2.1,
|
59
|
+
"length" => 12.5,
|
60
|
+
"order" => "ornithischia",
|
61
|
+
"vanished" => -75000000,
|
62
|
+
"weight" => 5000
|
63
|
+
},
|
64
|
+
"linhenykus" => {
|
65
|
+
"appeared" => -85000000,
|
66
|
+
"height" => 0.6,
|
67
|
+
"length" => 1,
|
68
|
+
"order" => "theropoda",
|
69
|
+
"vanished" => -75000000,
|
70
|
+
"weight" => 3
|
71
|
+
}
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
35
75
|
it "return nil if response body contains 'null'" do
|
36
76
|
mock_response = double(:body => 'null')
|
37
77
|
response = Firebase::Response.new(mock_response)
|
@@ -41,39 +81,39 @@ describe "Firebase" do
|
|
41
81
|
it "return true if response body contains 'true'" do
|
42
82
|
mock_response = double(:body => 'true')
|
43
83
|
response = Firebase::Response.new(mock_response)
|
44
|
-
response.body.
|
84
|
+
expect(response.body).to eq(true)
|
45
85
|
end
|
46
86
|
|
47
87
|
it "return false if response body contains 'false'" do
|
48
88
|
mock_response = double(:body => 'false')
|
49
89
|
response = Firebase::Response.new(mock_response)
|
50
|
-
response.body.
|
90
|
+
expect(response.body).to eq(false)
|
51
91
|
end
|
52
92
|
|
53
93
|
it "raises JSON::ParserError if response body contains invalid JSON" do
|
54
94
|
mock_response = double(:body => '{"this is wrong"')
|
55
95
|
response = Firebase::Response.new(mock_response)
|
56
|
-
expect { response.body }.to raise_error
|
96
|
+
expect { response.body }.to raise_error(JSON::ParserError)
|
57
97
|
end
|
58
98
|
end
|
59
99
|
|
60
100
|
describe "push" do
|
61
101
|
it "writes the data" do
|
62
|
-
@firebase.
|
102
|
+
expect(@firebase).to receive(:process).with(:post, 'users', data, {})
|
63
103
|
@firebase.push('users', data)
|
64
104
|
end
|
65
105
|
end
|
66
106
|
|
67
107
|
describe "delete" do
|
68
108
|
it "returns true" do
|
69
|
-
@firebase.
|
109
|
+
expect(@firebase).to receive(:process).with(:delete, 'users/info', nil, {})
|
70
110
|
@firebase.delete('users/info')
|
71
111
|
end
|
72
112
|
end
|
73
113
|
|
74
114
|
describe "update" do
|
75
115
|
it "updates and returns the data" do
|
76
|
-
@firebase.
|
116
|
+
expect(@firebase).to receive(:process).with(:patch, 'users/info', data, {})
|
77
117
|
@firebase.update('users/info', data)
|
78
118
|
end
|
79
119
|
end
|
@@ -81,9 +121,9 @@ describe "Firebase" do
|
|
81
121
|
describe "http processing" do
|
82
122
|
it "sends custom auth" do
|
83
123
|
firebase = Firebase::Client.new('https://test.firebaseio.com', 'secret')
|
84
|
-
firebase.request.
|
85
|
-
:body =>
|
86
|
-
:query => {:auth => "secret"},
|
124
|
+
expect(firebase.request).to receive(:request).with(:get, "todos.json", {
|
125
|
+
:body => nil,
|
126
|
+
:query => {:auth => "secret", :foo => 'bar'},
|
87
127
|
:follow_redirect => true
|
88
128
|
})
|
89
129
|
firebase.get('todos', :foo => 'bar')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Del Ben
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -77,6 +91,7 @@ extra_rdoc_files:
|
|
77
91
|
files:
|
78
92
|
- ".document"
|
79
93
|
- ".rspec"
|
94
|
+
- ".travis.yml"
|
80
95
|
- CHANGELOG.md
|
81
96
|
- Gemfile
|
82
97
|
- Gemfile.lock
|