firebase 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/firebase.gemspec +2 -2
- data/lib/firebase/request.rb +5 -3
- data/spec/firebase_spec.rb +25 -0
- metadata +30 -30
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
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.1.
|
8
|
+
s.version = "0.1.5"
|
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 = "2013-
|
12
|
+
s.date = "2013-11-10"
|
13
13
|
s.description = "Firebase wrapper for Ruby"
|
14
14
|
s.email = "info@oscardelben.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/firebase/request.rb
CHANGED
@@ -42,7 +42,7 @@ module Firebase
|
|
42
42
|
def process(method, path, options={})
|
43
43
|
raise "Please set Firebase.base_uri before making requests" unless Firebase.base_uri
|
44
44
|
|
45
|
-
|
45
|
+
@@hydra ||= Typhoeus::Hydra.new
|
46
46
|
request = Typhoeus::Request.new(build_url(path),
|
47
47
|
:body => options[:body],
|
48
48
|
:method => method)
|
@@ -61,7 +61,9 @@ module Firebase
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def body
|
64
|
-
JSON.parse(response.body)
|
64
|
+
JSON.parse(response.body, :quirks_mode => true)
|
65
|
+
rescue JSON::ParserError => e
|
66
|
+
response.body == 'null' ? nil : raise
|
65
67
|
end
|
66
68
|
|
67
69
|
def raw_body
|
@@ -69,7 +71,7 @@ module Firebase
|
|
69
71
|
end
|
70
72
|
|
71
73
|
def success?
|
72
|
-
|
74
|
+
[200, 204].include? response.code
|
73
75
|
end
|
74
76
|
|
75
77
|
def code
|
data/spec/firebase_spec.rb
CHANGED
@@ -24,6 +24,31 @@ describe "Firebase" do
|
|
24
24
|
Firebase::Request.should_receive(:get).with('users/info')
|
25
25
|
Firebase.get('users/info')
|
26
26
|
end
|
27
|
+
|
28
|
+
it "return nil if response body contains 'null'" do
|
29
|
+
mock_response = mock(:body => 'null')
|
30
|
+
@request = Firebase::Request.new(mock_response)
|
31
|
+
expect { @request.body }.to_not raise_error(JSON::ParserError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "return true if response body contains 'true'" do
|
35
|
+
mock_response = mock(:body => 'true')
|
36
|
+
@request = Firebase::Request.new(mock_response)
|
37
|
+
@request.body.should eq(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "return false if response body contains 'false'" do
|
41
|
+
mock_response = mock(:body => 'false')
|
42
|
+
@request = Firebase::Request.new(mock_response)
|
43
|
+
@request.body.should eq(false)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "raises JSON::ParserError if response body contains invalid JSON" do
|
47
|
+
mock_response = mock(:body => '{"this is wrong"')
|
48
|
+
@request = Firebase::Request.new(mock_response)
|
49
|
+
expect { @request.body }.to raise_error(JSON::ParserError)
|
50
|
+
end
|
51
|
+
|
27
52
|
end
|
28
53
|
|
29
54
|
describe "push" do
|
metadata
CHANGED
@@ -1,80 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4
|
5
4
|
prerelease:
|
5
|
+
version: 0.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Oscar Del Ben
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.6.1
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
20
|
none: false
|
21
|
+
prerelease: false
|
22
|
+
name: typhoeus
|
23
|
+
type: :runtime
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
26
25
|
requirements:
|
27
26
|
- - ! '>='
|
28
27
|
- !ruby/object:Gem::Version
|
29
28
|
version: 0.6.1
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: json
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
29
|
none: false
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
32
|
requirements:
|
35
33
|
- - ! '>='
|
36
34
|
- !ruby/object:Gem::Version
|
37
35
|
version: '0'
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
36
|
none: false
|
37
|
+
prerelease: false
|
38
|
+
name: json
|
39
|
+
type: :runtime
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
44
43
|
- !ruby/object:Gem::Version
|
45
44
|
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
45
|
none: false
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
48
|
requirements:
|
51
49
|
- - ! '>='
|
52
50
|
- !ruby/object:Gem::Version
|
53
51
|
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
52
|
none: false
|
53
|
+
prerelease: false
|
54
|
+
name: rspec
|
55
|
+
type: :development
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - ! '>='
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: jeweler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
61
|
none: false
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
64
|
requirements:
|
67
65
|
- - ~>
|
68
66
|
- !ruby/object:Gem::Version
|
69
67
|
version: 1.8.3
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
68
|
none: false
|
69
|
+
prerelease: false
|
70
|
+
name: jeweler
|
71
|
+
type: :development
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
74
73
|
requirements:
|
75
74
|
- - ~>
|
76
75
|
- !ruby/object:Gem::Version
|
77
76
|
version: 1.8.3
|
77
|
+
none: false
|
78
78
|
description: Firebase wrapper for Ruby
|
79
79
|
email: info@oscardelben.com
|
80
80
|
executables: []
|
@@ -105,20 +105,20 @@ rdoc_options: []
|
|
105
105
|
require_paths:
|
106
106
|
- lib
|
107
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
108
|
requirements:
|
110
109
|
- - ! '>='
|
111
110
|
- !ruby/object:Gem::Version
|
112
|
-
version: '0'
|
113
111
|
segments:
|
114
112
|
- 0
|
115
|
-
hash:
|
116
|
-
|
113
|
+
hash: 675265491536299218
|
114
|
+
version: '0'
|
117
115
|
none: false
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
117
|
requirements:
|
119
118
|
- - ! '>='
|
120
119
|
- !ruby/object:Gem::Version
|
121
120
|
version: '0'
|
121
|
+
none: false
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
124
|
rubygems_version: 1.8.23
|