firebase-ruby 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/fbrb +1 -1
- data/lib/firebase-ruby/auth.rb +19 -8
- data/lib/firebase-ruby/database.rb +2 -2
- data/lib/firebase-ruby/http.rb +1 -2
- data/lib/firebase-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71129a24564dba1985fd02873accf5e6d3546d5e
|
4
|
+
data.tar.gz: 5e7ce2fcef94d65b4c841baaa19c4d5a504db055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ef0c98f6394aaaaf885addb150fa0487c8961180288cef0938f908908797679c34ffa14a5d496e299eaf3f8ef7e3bc499c8c945b285ebb45bd4e163898ee2b8
|
7
|
+
data.tar.gz: ec53da00cec351a3b6b7f1ade123a1b2b22cf45712c06d6036c2cbb072e46d1ad4caa2e68ab620fb6cce8474e7f740f7c2d6a302d596fe8db60ba81f991c2f91
|
data/bin/fbrb
CHANGED
data/lib/firebase-ruby/auth.rb
CHANGED
@@ -15,8 +15,13 @@ module Firebase
|
|
15
15
|
attr_reader :access_token
|
16
16
|
attr_reader :expires
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
# Creates Firebase OAuth based auth object; one argument must be specified
|
19
|
+
def initialize(json: nil, path: nil)
|
20
|
+
if json
|
21
|
+
load_privatekeyjson(json)
|
22
|
+
elsif path
|
23
|
+
load_privatekeyfile(path)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
# Return a valid access token; it will retrieve a new token if necessary
|
@@ -40,15 +45,21 @@ module Firebase
|
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
|
-
# @param
|
44
|
-
def
|
45
|
-
raise ArgumentError, 'private key
|
46
|
-
|
47
|
-
cred = JSON.parse(IO.read(path), {symbolize_names: true})
|
48
|
+
# @param json [String] JSON with private key
|
49
|
+
def load_privatekeyjson(json)
|
50
|
+
raise ArgumentError, 'private key JSON missing' unless json
|
51
|
+
cred = JSON.parse(json, {symbolize_names: true})
|
48
52
|
@private_key = cred[:private_key]
|
49
53
|
@project_id = cred[:project_id]
|
50
54
|
@client_email = cred[:client_email]
|
51
|
-
Firebase.logger.info('
|
55
|
+
Firebase.logger.info('Private key loaded from JSON')
|
56
|
+
end
|
57
|
+
|
58
|
+
# @param path [String] path to JSON file with private key
|
59
|
+
def load_privatekeyfile(path)
|
60
|
+
raise ArgumentError, 'private key file path missing' unless path
|
61
|
+
Firebase.logger.debug("Loading private key file: #{path}")
|
62
|
+
load_privatekeyjson(IO.read(path))
|
52
63
|
end
|
53
64
|
|
54
65
|
# Request new token from Google
|
data/lib/firebase-ruby/http.rb
CHANGED
@@ -73,9 +73,8 @@ module Firebase
|
|
73
73
|
if params
|
74
74
|
query = URI.encode_www_form(params)
|
75
75
|
Firebase.logger.info('Created urlencoded query from params')
|
76
|
-
else
|
77
|
-
uri.query = query
|
78
76
|
end
|
77
|
+
uri.query = query
|
79
78
|
req = METHOD_HTTP_CLASS[method].new(uri)
|
80
79
|
when :put, :patch, :post
|
81
80
|
uri.query = query if query
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebase-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken J.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Firebase REST library written in pure Ruby without external dependancy.
|
14
14
|
email:
|