eitil 1.1.16 → 1.1.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/eitil_core/README.md +9 -0
- data/eitil_core/lib/eitil_core/application_record.rb +1 -0
- data/eitil_core/lib/eitil_core/application_record/duck_find.rb +35 -0
- data/eitil_core/lib/eitil_core/railtie.rb +4 -0
- data/eitil_support/lib/eitil_support/stacktrace/audit.rb +3 -1
- data/eitil_support/lib/eitil_support/stacktrace/stack.rb +9 -1
- data/lib/eitil/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a8caa773c7a08c53830b261d9007a4fe49fbd7329465288793b2f63e07290c
|
4
|
+
data.tar.gz: c3fb3a87ed76aded03530af4ebf4df552a59135f8d14b673fd53f4e2915fd02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25a16fd8b38c62c66b16360bb29f53a5fce31507c03199530adbd51324fb3b7504055b69e3e65b92896920af5eb09a8098168347c20ea4aa258d2e75ba111e7
|
7
|
+
data.tar.gz: f7ffffb04e9b5d45ac9f725ce8e643ce2676fddc30703e536608ac3279fd49b93fd18de95dd100e1ce194ee97238650bf709002a91e176d2ab587a6d01c7d1d2
|
data/eitil_core/README.md
CHANGED
@@ -53,6 +53,15 @@ require "eitil_core/application_controller"
|
|
53
53
|
|
54
54
|
```
|
55
55
|
|
56
|
+
```ruby
|
57
|
+
# require "eitil_core/application_record/duck_find"
|
58
|
+
|
59
|
+
self.duck_find(identifier)
|
60
|
+
# tries to find a record for the model through a wide accepting parameter, which may either be:
|
61
|
+
# 1) an instance of the model, 2) an Integer, 3) a Float or 4) a stringified number
|
62
|
+
# call as: User.duck_find("11")
|
63
|
+
```
|
64
|
+
|
56
65
|
```ruby
|
57
66
|
# require "eitil_core/application_record/find_by_like"
|
58
67
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
|
2
2
|
require "eitil_core/application_record/where_like"
|
3
3
|
require "eitil_core/application_record/find_by_like"
|
4
|
+
require "eitil_core/application_record/duck_find"
|
4
5
|
require "eitil_core/application_record/all_associations"
|
5
6
|
require "eitil_core/application_record/model_atts"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
# require "eitil_core/application_record/find_by_like"
|
3
|
+
|
4
|
+
# require "eitil_core/railtie" to run the dynamic dispatch as an init hook during boot
|
5
|
+
require "eitil_core/railtie"
|
6
|
+
|
7
|
+
module EitilCore
|
8
|
+
module ApplicationRecord
|
9
|
+
module DuckFind
|
10
|
+
|
11
|
+
def duck_find(identifier)
|
12
|
+
|
13
|
+
case identifier
|
14
|
+
|
15
|
+
when self
|
16
|
+
return identifier
|
17
|
+
|
18
|
+
when Integer
|
19
|
+
return find identifier
|
20
|
+
|
21
|
+
when Float
|
22
|
+
return find identifier
|
23
|
+
|
24
|
+
when String
|
25
|
+
return find identifier if identifier.is_num?
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
raise ArgumentError, "#{name}#duck_find only accepts a #{name} instance, integer, float or stringified integer as argument."
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -17,6 +17,10 @@ module EitilCore
|
|
17
17
|
::ApplicationRecord.send(:extend, EitilCore::ApplicationRecord::FindByLike)
|
18
18
|
end
|
19
19
|
|
20
|
+
if Object.const_defined?('EitilCore::ApplicationRecord::DuckFind')
|
21
|
+
::ApplicationRecord.send(:extend, EitilCore::ApplicationRecord::DuckFind)
|
22
|
+
end
|
23
|
+
|
20
24
|
if Object.const_defined?('EitilCore::ApplicationRecord::AllAssociations')
|
21
25
|
::ApplicationRecord.send(:extend, EitilCore::ApplicationRecord::AllAssociations)
|
22
26
|
end
|
@@ -7,7 +7,9 @@ module EitilSupport::Stack::Audit
|
|
7
7
|
after_update :add_stacktrace_to_audit
|
8
8
|
|
9
9
|
def add_stacktrace_to_audit
|
10
|
-
|
10
|
+
# .report_app_calls filters the stack on calls whose path include "/app/", since
|
11
|
+
# audits otherwise tend to grow very big, which might endanger the database.
|
12
|
+
stacktrace = EitilSupport::Stack.new.report_app_calls
|
11
13
|
self.audits.last.update(stacktrace: stacktrace)
|
12
14
|
end
|
13
15
|
|
@@ -9,7 +9,15 @@ module EitilSupport
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def report
|
12
|
-
backtrace.map
|
12
|
+
backtrace.map.with_index { |call, call_nr| "#{call_nr}. #{call}" }
|
13
|
+
end
|
14
|
+
|
15
|
+
def report_app_calls
|
16
|
+
filter_report '/app/'
|
17
|
+
end
|
18
|
+
|
19
|
+
def filter_report(path_shard)
|
20
|
+
report.select { |call| call.include? path_shard }
|
13
21
|
end
|
14
22
|
|
15
23
|
def show
|
data/lib/eitil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eitil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Schrofer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- eitil_core/lib/eitil_core/application_controller/slice_params.rb
|
90
90
|
- eitil_core/lib/eitil_core/application_record.rb
|
91
91
|
- eitil_core/lib/eitil_core/application_record/all_associations.rb
|
92
|
+
- eitil_core/lib/eitil_core/application_record/duck_find.rb
|
92
93
|
- eitil_core/lib/eitil_core/application_record/find_by_like.rb
|
93
94
|
- eitil_core/lib/eitil_core/application_record/model_atts.rb
|
94
95
|
- eitil_core/lib/eitil_core/application_record/where_like.rb
|