fire-model 0.0.16 → 0.0.17
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 +4 -4
- data/VERSION +1 -1
- data/fire-model.gemspec +4 -3
- data/lib/connection/request.rb +4 -3
- data/lib/connection/response.rb +6 -4
- data/lib/fire-model.rb +25 -7
- data/lib/support/fire_logger.rb +27 -0
- data/spec/spec_helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0292578dac18393a6a381aaa09db5f799fa291b
|
4
|
+
data.tar.gz: c92f90f64fe030d036289762b53c871d52b113dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf81a452c2bd1fa34a6a7728e6ad5ecb858f976c4b7d32d5356c298cbeb6f036fe97c5472cb4fc927e7cc00a39c1e2a99511f4ae66d65898fc67e564b4475714
|
7
|
+
data.tar.gz: c6cfad687bd93a24e2943d4a9f397d7bd0ff2fab761d7165847fec792dd10a830311328bd930fdde5ad243081cbcbe1ac883d308408a233cc12504a7c270992c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
data/fire-model.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: fire-model 0.0.
|
5
|
+
# stub: fire-model 0.0.17 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "fire-model"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.17"
|
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 = ["Vitaly Tarasenko"]
|
14
|
-
s.date = "2015-06-
|
14
|
+
s.date = "2015-06-28"
|
15
15
|
s.description = "You can define your Firebase models, set collection names, CRUD your data. "
|
16
16
|
s.email = "vetal.tarasenko@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
"lib/model/nested/parent.rb",
|
35
35
|
"lib/model/nested/single.rb",
|
36
36
|
"lib/model/querying/querying.rb",
|
37
|
+
"lib/support/fire_logger.rb",
|
37
38
|
"spec/models/main_spec.rb",
|
38
39
|
"spec/models/nested_models_spec.rb",
|
39
40
|
"spec/spec_helper.rb"
|
data/lib/connection/request.rb
CHANGED
@@ -35,10 +35,11 @@ METHOD
|
|
35
35
|
def process(method, path, query={}, body=nil, tries=5)
|
36
36
|
raise 'Firebase Connection Failed' if tries.zero?
|
37
37
|
begin
|
38
|
-
|
39
|
-
|
38
|
+
Fire.logger.request(method, path)
|
39
|
+
raw_response = @client.request(method, "#{path}.json", body: body, query: prepare_options(query), follow_redirect: true)
|
40
|
+
Fire::Connection::Response.new(raw_response, path)
|
40
41
|
rescue HTTPClient::ConnectTimeoutError
|
41
|
-
|
42
|
+
Fire.logger.timed_out(method, path)
|
42
43
|
return process(method, path, query, body, tries-1)
|
43
44
|
end
|
44
45
|
end
|
data/lib/connection/response.rb
CHANGED
@@ -3,15 +3,17 @@ module Fire
|
|
3
3
|
require 'active_support/all'
|
4
4
|
|
5
5
|
class Response
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :raw_response, :path
|
7
7
|
delegate :status, to: :response
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
9
|
+
def initialize(raw_response, path)
|
10
|
+
@raw_response = raw_response
|
11
|
+
@path = path
|
12
|
+
Fire.logger.response(@raw_response, path)
|
11
13
|
end
|
12
14
|
|
13
15
|
def body
|
14
|
-
JSON.parse(
|
16
|
+
JSON.parse(raw_response.body, :quirks_mode => true)
|
15
17
|
end
|
16
18
|
|
17
19
|
end
|
data/lib/fire-model.rb
CHANGED
@@ -3,22 +3,34 @@ module Fire
|
|
3
3
|
require 'connection/request'
|
4
4
|
require 'model/base'
|
5
5
|
|
6
|
+
require 'support/fire_logger'
|
7
|
+
|
6
8
|
require 'ostruct'
|
7
9
|
ROOT = ?/
|
8
10
|
|
9
|
-
def self.setup(options)
|
10
|
-
configuration = {}
|
11
|
-
configuration[:base_uri] = base_uri(options[:firebase_path])
|
12
|
-
configuration[:auth] = (options[:firebase_auth] || {})
|
13
|
-
@config = OpenStruct.new(configuration)
|
14
|
-
end
|
15
|
-
|
16
11
|
class << self
|
17
12
|
|
13
|
+
def setup(options)
|
14
|
+
configuration = {}
|
15
|
+
configuration[:base_uri] = base_uri(options[:firebase_path])
|
16
|
+
configuration[:auth] = (options[:firebase_auth] || {})
|
17
|
+
setup_logger(options)
|
18
|
+
@config = OpenStruct.new(configuration)
|
19
|
+
end
|
20
|
+
|
18
21
|
def config
|
19
22
|
@config
|
20
23
|
end
|
21
24
|
|
25
|
+
def logger
|
26
|
+
@logger
|
27
|
+
end
|
28
|
+
|
29
|
+
def logger=(logger)
|
30
|
+
logger.extend(FireLogger::Ext)
|
31
|
+
@logger = logger
|
32
|
+
end
|
33
|
+
|
22
34
|
def connection
|
23
35
|
Fire::Connection::Request.new
|
24
36
|
end
|
@@ -35,6 +47,12 @@ module Fire
|
|
35
47
|
connection.set(ROOT, data)
|
36
48
|
end
|
37
49
|
|
50
|
+
private
|
51
|
+
|
52
|
+
def setup_logger(options)
|
53
|
+
@logger = FireLogger.create(options)
|
54
|
+
end
|
55
|
+
|
38
56
|
end
|
39
57
|
|
40
58
|
private
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class FireLogger < ::Logger
|
2
|
+
|
3
|
+
module Ext
|
4
|
+
|
5
|
+
def request(method, path)
|
6
|
+
debug "[REQUEST] #{method}: #{path}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def timed_out(method, path)
|
10
|
+
error "[TIMED OUT] #{method}: #{path}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def response(response_value, path)
|
14
|
+
debug "[RESPONSE] #{response_value.status}: #{ path } }"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
include Ext
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def create(options)
|
23
|
+
new(STDOUT)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fire-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Tarasenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tarvit-helpers
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/model/nested/parent.rb
|
161
161
|
- lib/model/nested/single.rb
|
162
162
|
- lib/model/querying/querying.rb
|
163
|
+
- lib/support/fire_logger.rb
|
163
164
|
- spec/models/main_spec.rb
|
164
165
|
- spec/models/nested_models_spec.rb
|
165
166
|
- spec/spec_helper.rb
|