firebase-ruby 0.0.2 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 693b989e038daf52ac6f06a2a978614a3d0fee2b
4
- data.tar.gz: 4c88d12f7167b180dc8cc5b7707a700e1e803f63
3
+ metadata.gz: 71129a24564dba1985fd02873accf5e6d3546d5e
4
+ data.tar.gz: 5e7ce2fcef94d65b4c841baaa19c4d5a504db055
5
5
  SHA512:
6
- metadata.gz: 8a8319b29c0b88f9640d86604fae62bec3a323a243f40caf4a0c32b56db2f5d6914945ed0d3ed80367a5a751cf98565367679cbe55118ffe3680f54c63687b4f
7
- data.tar.gz: 75677e5b82c80ebf6302abf25a995ba7126c3af2f467db9a59f6605b288bb1434fd9e325b1cd68e61ce66a64acda1fed70e879586a2c2f95f46d86a0615ee93d
6
+ metadata.gz: 1ef0c98f6394aaaaf885addb150fa0487c8961180288cef0938f908908797679c34ffa14a5d496e299eaf3f8ef7e3bc499c8c945b285ebb45bd4e163898ee2b8
7
+ data.tar.gz: ec53da00cec351a3b6b7f1ade123a1b2b22cf45712c06d6036c2cbb072e46d1ad4caa2e68ab620fb6cce8474e7f740f7c2d6a302d596fe8db60ba81f991c2f91
data/bin/fbrb CHANGED
@@ -33,7 +33,7 @@ path ||= ARGV.shift
33
33
  Trollop::die :path, "is missing" if path.nil?
34
34
 
35
35
  db = Firebase::Database.new()
36
- db.set_auth_with_keyfile(opts[:key])
36
+ db.set_auth_with_key(path: opts[:key])
37
37
 
38
38
  method = opts[:request].downcase.to_sym
39
39
 
@@ -15,8 +15,13 @@ module Firebase
15
15
  attr_reader :access_token
16
16
  attr_reader :expires
17
17
 
18
- def initialize(path)
19
- load_privatekeyfile(path)
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 path [String] JSON file with private key
44
- def load_privatekeyfile(path)
45
- raise ArgumentError, 'private key file path missing' unless path
46
- Firebase.logger.debug("Loading private key file: #{path}")
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('Auth.load_privatekeyfile done.')
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
@@ -9,8 +9,8 @@ module Firebase
9
9
  def initialize()
10
10
  end
11
11
 
12
- def set_auth_with_keyfile(filepath)
13
- @auth = Auth.new(filepath)
12
+ def set_auth_with_key(json: nil, path: nil)
13
+ @auth = Auth.new(json: json, path: path)
14
14
  end
15
15
 
16
16
  def project_id=(id)
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Firebase
2
2
 
3
- Version = '0.0.2'
3
+ Version = '0.1.0'
4
4
 
5
5
  end
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.2
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-07-17 00:00:00.000000000 Z
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: