sapience 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d60ec53bc8d52d27faaa4f781614dc5f054279d
4
- data.tar.gz: 11cddfff56ead42495775d8049404a9e29e0e6ca
3
+ metadata.gz: 712bcdf7d21dacd21c564c2026a0fffafda3330d
4
+ data.tar.gz: 7d0750dea5d0aa3a4c806aec4840149afe98d585
5
5
  SHA512:
6
- metadata.gz: fc47d49144ea1c17f5fc531d2831bd9379a56c35c1cc8bbbbcf349f903e1d102c337a5ff6267c98aa96daf76b469fb09f5187ef1fd28e2f92783af693efe608d
7
- data.tar.gz: 4c86071b9223e830bcf5f9b6981f4caa17733e3e31001f7f10818332b11c2c73ef088b1197779ad7dc17a95e45e4fc4db26c9fec4f3962e2c7635c1ea3cb0d2c
6
+ metadata.gz: 9bed0ad7909f79a32193073372f1f41807bb2ede3c8f0069893b1124239e83349d0518d2c5585c16429ff2814fe24fe411ad3116db04f88307007bf3b3ccd12b
7
+ data.tar.gz: b9e635cf195f309a22db4f3a092d2119a9f70f98e61b1329eb9900b44890db771b9e2079757e5f0e5e7669bbdc6a24fa88b375d253129cd465bfd1c50165e2b1
data/README.md CHANGED
@@ -28,6 +28,25 @@ gem "sapience-rb", require: "sapience/rails"
28
28
  gem "sapience-rb", require: "sapience/grape"
29
29
  ```
30
30
 
31
+ In your Base API class
32
+
33
+ ```ruby
34
+ require "sapience/grape"
35
+
36
+ module Aslan
37
+ module API
38
+ class Base < Grape::API
39
+ use Sapience::Extensions::Grape::Middleware::Logging, logger: Sapience[self]
40
+
41
+ # To log all requests even when no route was found try the following:
42
+ route :any, "*path" do
43
+ error!({ error: "No route found" }, 404)
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ ```
31
50
 
32
51
  ### Configuration
33
52
 
@@ -41,11 +41,9 @@ module Sapience
41
41
  def parameters # rubocop:disable AbcSize
42
42
  {
43
43
  status: (response.nil? ? "fail" : response.status),
44
- time: {
45
- total: total_runtime,
46
- db: db_runtime,
47
- view: view_runtime,
48
- },
44
+ db_runtime: db_runtime,
45
+ view_runtime: view_runtime,
46
+ total_runtime: total_runtime,
49
47
  method: request.request_method,
50
48
  path: request.path,
51
49
  params: request.params,
@@ -62,7 +60,7 @@ module Sapience
62
60
  end
63
61
 
64
62
  def total_runtime
65
- ((stop_time - start_time) * 1000).round(2)
63
+ ((stop_time - start_time) * 1000).round(3)
66
64
  end
67
65
 
68
66
  def view_runtime
@@ -70,7 +68,7 @@ module Sapience
70
68
  end
71
69
 
72
70
  def db_runtime
73
- Grape::Timings.db_runtime.round(2)
71
+ Grape::Timings.db_runtime.round(3)
74
72
  end
75
73
 
76
74
  def reset_db_runtime
@@ -12,8 +12,5 @@ module Sapience
12
12
  class Grape
13
13
  Sapience.configure
14
14
  ::Grape::API.send(:include, Sapience::Loggable)
15
- ::Grape::API.descendants.each do |api|
16
- api.send(:use, Sapience::Extensions::Grape::Middleware::Logging, logger: Sapience[self])
17
- end
18
15
  end
19
16
  end
@@ -1,3 +1,3 @@
1
1
  module Sapience
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapience
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-31 00:00:00.000000000 Z
12
+ date: 2016-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby