eitil 1.0.3 → 1.1.3
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 +76 -0
- data/eitil_core/lib/eitil_core.rb +2 -0
- data/eitil_core/lib/eitil_core/application_controller/slice_params.rb +3 -0
- data/eitil_core/lib/eitil_core/application_record/all_associations.rb +3 -0
- data/eitil_core/lib/eitil_core/application_record/find_by_like.rb +3 -0
- data/eitil_core/lib/eitil_core/application_record/where_like.rb +3 -0
- data/eitil_core/lib/eitil_core/formatters.rb +4 -0
- data/eitil_core/lib/eitil_core/formatters/sql.rb +72 -0
- data/eitil_core/lib/eitil_core/mocks.rb +6 -0
- data/eitil_core/lib/eitil_core/mocks/array.rb +39 -0
- data/eitil_core/lib/eitil_core/mocks/hash.rb +36 -0
- data/eitil_core/lib/eitil_core/mocks/string.rb +11 -0
- data/eitil_core/lib/eitil_core/railtie.rb +0 -3
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +1 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +1 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +1 -3
- data/eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb +81 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +9 -3
- data/eitil_integrate/lib/eitil_integrate/railtie.rb +0 -3
- data/eitil_store/lib/eitil_store/railtie.rb +0 -3
- data/eitil_support/lib/eitil_support/railtie.rb +0 -3
- data/eitil_wrapper/README.md +24 -0
- data/eitil_wrapper/lib/eitil_wrapper.rb +2 -1
- data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +3 -0
- data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +24 -7
- data/eitil_wrapper/lib/eitil_wrapper/request_logger.rb +5 -0
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb +48 -0
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb +17 -0
- data/eitil_wrapper/lib/eitil_wrapper/scopes/default_scopes.rb +6 -0
- data/lib/eitil/all.rb +3 -2
- data/lib/eitil/railtie.rb +6 -4
- data/lib/eitil/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1d078f5e3e79e4849d54692fcbfa418bec803333e69dcc6f4df72b09941ff31
|
|
4
|
+
data.tar.gz: 9e1232d63ae999afbbb5d0df2405fdb1ca038269096a73a8f8b82dc29de9ab1e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d80703adbc3faf1be7faf8ffdbed5d70b7e04f9edbd7f88dba9baef9b5e3b7b79cf8091732d0e03aaa28fa0ec8efe66260da9d64ca595fd31b64f667e742160
|
|
7
|
+
data.tar.gz: cf450d841ca4f1a528ba3aa2d7be7a018b9a4ae08f2a16e491cec44ce69245e8f7a3193ce00824a3b7fda959917c0127d1528c979bce14a4b5c221a79b4bfdec
|
data/eitil_core/README.md
CHANGED
|
@@ -214,6 +214,49 @@ safe_to_i
|
|
|
214
214
|
```
|
|
215
215
|
|
|
216
216
|
|
|
217
|
+
## Formatters
|
|
218
|
+
|
|
219
|
+
```ruby
|
|
220
|
+
|
|
221
|
+
require "eitil_core/formatters"
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```ruby
|
|
226
|
+
# require "eitil_core/formatters/sql"
|
|
227
|
+
|
|
228
|
+
Date.today.strfsql
|
|
229
|
+
# => "2021-06-23"
|
|
230
|
+
|
|
231
|
+
Date.today.strfsql(:date)
|
|
232
|
+
# => "2021-06-23"
|
|
233
|
+
|
|
234
|
+
DateTime.now.strfsql
|
|
235
|
+
# => "2021-06-23 13:15:37.945083"
|
|
236
|
+
|
|
237
|
+
DateTime.now.strfsql(:datetime)
|
|
238
|
+
# => "2021-06-23 13:15:37.945083"
|
|
239
|
+
|
|
240
|
+
DateTime.now.strfsql(:date)
|
|
241
|
+
# => "2021-06-23"
|
|
242
|
+
|
|
243
|
+
DateTime.now.strfsql(:time)
|
|
244
|
+
# => "13:16:23"
|
|
245
|
+
|
|
246
|
+
Time.now.strfsql
|
|
247
|
+
# => "13:16:23"
|
|
248
|
+
|
|
249
|
+
Time.now.strfsql(:datetime)
|
|
250
|
+
# => "2021-06-23 13:15:37.945083"
|
|
251
|
+
|
|
252
|
+
Time.now.strfsql(:date)
|
|
253
|
+
# => "2021-06-23"
|
|
254
|
+
|
|
255
|
+
Time.now.strfsql(:time)
|
|
256
|
+
# => "13:16:23"
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
|
|
217
260
|
## Hash
|
|
218
261
|
|
|
219
262
|
```ruby
|
|
@@ -259,6 +302,39 @@ Find.gem_path(gem_name)
|
|
|
259
302
|
```
|
|
260
303
|
|
|
261
304
|
|
|
305
|
+
## Mocks
|
|
306
|
+
|
|
307
|
+
```ruby
|
|
308
|
+
|
|
309
|
+
require "eitil_core/mocks"
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```ruby
|
|
314
|
+
# require "eitil_core/mocks/string"
|
|
315
|
+
|
|
316
|
+
String.mock(n=25)
|
|
317
|
+
# String.mock(10) # ==> "oooooo c nnnnnnnnnn ttttttttt p kkk r ppppp rrrrrrr uuu"
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
```ruby
|
|
321
|
+
# require "eitil_core/mocks/array"
|
|
322
|
+
|
|
323
|
+
Array.mock(n=10, type=Integer, &block)
|
|
324
|
+
# Array.mock # ==> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
325
|
+
# Array.mock(10, Float) #==> [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
|
|
326
|
+
# Built-in methods are provided for classes Integer, Float, String, Date, Time
|
|
327
|
+
# But any other class is accepted as well, also your own classes such as User, Shift and Environment
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
```ruby
|
|
331
|
+
# require "eitil_core/mocks/hash"
|
|
332
|
+
|
|
333
|
+
Hash.mock(n=10)
|
|
334
|
+
# Hash.mock(10) #==> {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5, "f"=>6, "g"=>7, "h"=>8, "i"=>9, "j"=>10}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
|
|
262
338
|
## SafeExecutions
|
|
263
339
|
|
|
264
340
|
```ruby
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_core/formatters/sql"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Date
|
|
6
|
+
|
|
7
|
+
def strfsql(type = :date)
|
|
8
|
+
|
|
9
|
+
type = type.kind_of?(String) ? type.to_sym : type
|
|
10
|
+
|
|
11
|
+
case type
|
|
12
|
+
|
|
13
|
+
when :date
|
|
14
|
+
return self.strftime "%Y-%m-%d"
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
return
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class DateTime
|
|
25
|
+
|
|
26
|
+
def strfsql(type = :datetime)
|
|
27
|
+
|
|
28
|
+
type = type.kind_of?(String) ? type.to_sym : type
|
|
29
|
+
|
|
30
|
+
case type
|
|
31
|
+
|
|
32
|
+
when :datetime
|
|
33
|
+
return self.strftime "%Y-%m-%d %H:%M:%S.%6N"
|
|
34
|
+
|
|
35
|
+
when :date
|
|
36
|
+
return self.strftime "%Y-%m-%d"
|
|
37
|
+
|
|
38
|
+
when :time
|
|
39
|
+
return self.strftime "%H:%M:%S"
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Time
|
|
50
|
+
|
|
51
|
+
def strfsql(type = :time)
|
|
52
|
+
|
|
53
|
+
type = type.kind_of?(String) ? type.to_sym : type
|
|
54
|
+
|
|
55
|
+
case type
|
|
56
|
+
|
|
57
|
+
when :datetime
|
|
58
|
+
return self.strftime "%Y-%m-%d %H:%M:%S.%6N"
|
|
59
|
+
|
|
60
|
+
when :date
|
|
61
|
+
return self.strftime "%Y-%m-%d"
|
|
62
|
+
|
|
63
|
+
when :time
|
|
64
|
+
return self.strftime "%H:%M:%S"
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
return
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_core/mocks/array"
|
|
3
|
+
|
|
4
|
+
class Array
|
|
5
|
+
|
|
6
|
+
def self.mock(n=10, type=Integer, &block)
|
|
7
|
+
|
|
8
|
+
return Array.new(n,&block) if block_given?
|
|
9
|
+
|
|
10
|
+
case type.to_s
|
|
11
|
+
|
|
12
|
+
when 'Integer'
|
|
13
|
+
Array.new(n) {|i| i+1}
|
|
14
|
+
|
|
15
|
+
when 'Float'
|
|
16
|
+
Array.new(n) {|i| i+1.0}
|
|
17
|
+
|
|
18
|
+
when 'String'
|
|
19
|
+
words = String.mock(n).split
|
|
20
|
+
Array.new(n) {|i| words[i]}
|
|
21
|
+
|
|
22
|
+
when 'Time'
|
|
23
|
+
time_now = Time.now
|
|
24
|
+
Array.new(n) {|i| time_now + (i * (60 * 60 * 24)) }
|
|
25
|
+
|
|
26
|
+
when 'Date'
|
|
27
|
+
date_now = Date.today
|
|
28
|
+
Array.new(n) {|i| date_now + (i * 1) }
|
|
29
|
+
|
|
30
|
+
else
|
|
31
|
+
Array.new(n) do
|
|
32
|
+
type.send(:new) rescue
|
|
33
|
+
raise NoNewMethodError, 'Please provide Object that responds to `new` call'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_core/mocks/hash"
|
|
3
|
+
|
|
4
|
+
class Hash
|
|
5
|
+
|
|
6
|
+
def self.mock(n=10)
|
|
7
|
+
range = mock_size(n).to_a
|
|
8
|
+
Hash[Array.mock(n) {|m| range[m] }.zip(Array.mock(n))]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def self.mock_size(n)
|
|
14
|
+
EitilCore::Mock.hash_range_for(n)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
module EitilCore
|
|
21
|
+
module Mock
|
|
22
|
+
|
|
23
|
+
def self.hash_range_for(n)
|
|
24
|
+
range = nil
|
|
25
|
+
i = 0
|
|
26
|
+
|
|
27
|
+
until range != nil do
|
|
28
|
+
range = ('a'..'z') if n <= 26
|
|
29
|
+
range = ('a'.."z#{'z'*i}") if n < (26 + (26 ** (i+1) )) && !range
|
|
30
|
+
i += 1
|
|
31
|
+
end
|
|
32
|
+
range
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -17,6 +17,7 @@ require_relative "application_exporter/setters"
|
|
|
17
17
|
require_relative "application_exporter/selectors"
|
|
18
18
|
require_relative "application_exporter/lookups"
|
|
19
19
|
require_relative "application_exporter/infos"
|
|
20
|
+
require_relative "application_exporter/log_state"
|
|
20
21
|
|
|
21
22
|
# the AutoSum module, which is a seperately functioning module (service)
|
|
22
23
|
require_relative "application_exporter/auto_sum"
|
|
@@ -4,15 +4,13 @@
|
|
|
4
4
|
require "eitil_core/setters/set_ivars"
|
|
5
5
|
require "eitil_core/argument_helpers/all_kwargs_to_ivars"
|
|
6
6
|
|
|
7
|
-
# EitilIntegrate::RubyXL::ApplicationExporter
|
|
8
|
-
|
|
9
7
|
module EitilIntegrate
|
|
10
8
|
module RubyXL
|
|
11
9
|
class ApplicationExporter
|
|
12
10
|
|
|
13
11
|
include ActionView::Helpers::NumberHelper
|
|
14
12
|
|
|
15
|
-
attr_accessor :book, :sheet, :x, :y, :start_date, :end_date, :date_range
|
|
13
|
+
attr_accessor :book, :sheet, :x, :y, :start_date, :end_date, :date_range, :write_log
|
|
16
14
|
|
|
17
15
|
def initialize(attributes={})
|
|
18
16
|
all_kwargs_to_ivars binding, :attributes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_integrate/application_exporter/log_state"
|
|
3
|
+
|
|
4
|
+
module EitilIntegrate::RubyXL
|
|
5
|
+
class ApplicationExporter
|
|
6
|
+
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
def log_state
|
|
10
|
+
|
|
11
|
+
return unless write_log == true
|
|
12
|
+
|
|
13
|
+
# create_log_sheet
|
|
14
|
+
book.add_worksheet('log')
|
|
15
|
+
|
|
16
|
+
# manage sheets
|
|
17
|
+
previous_sheet = @sheet.sheet_name
|
|
18
|
+
@sheet = @book["log"]
|
|
19
|
+
|
|
20
|
+
# manage coordinates
|
|
21
|
+
previous_x = @x
|
|
22
|
+
@x = 0
|
|
23
|
+
|
|
24
|
+
# log everything we want to log
|
|
25
|
+
report_state
|
|
26
|
+
|
|
27
|
+
# style logs
|
|
28
|
+
style_first_x_columns_width(1, 40)
|
|
29
|
+
style_first_column_bold
|
|
30
|
+
|
|
31
|
+
# restore what was previously active
|
|
32
|
+
@sheet = @book[previous_sheet]
|
|
33
|
+
@x = previous_x
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def report_state
|
|
38
|
+
instance_variables.each do |ivar|
|
|
39
|
+
|
|
40
|
+
variable_name = ivar.to_s
|
|
41
|
+
variable_value = format_value(instance_variable_get(ivar))
|
|
42
|
+
|
|
43
|
+
array_to_row [variable_name, variable_value]
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# formatting the values to a human readably format is important, because otherwise Excel warns
|
|
49
|
+
# users on safety when opening the file.
|
|
50
|
+
def format_value(value)
|
|
51
|
+
value_class = value.class
|
|
52
|
+
|
|
53
|
+
if value_class == Hash
|
|
54
|
+
value.map {|k,v| "#{k.to_s.split('_').map(&:capitalize).join(' ')}: #{v}"}.join(' // ')
|
|
55
|
+
|
|
56
|
+
elsif value_class == Array && value.all? { |item| item.class.superclass == ApplicationRecord }
|
|
57
|
+
"#{value.class} #{value.map(&:id).join(', ')}"
|
|
58
|
+
|
|
59
|
+
elsif value_class.superclass == ApplicationRecord
|
|
60
|
+
"#{value.class} ##{value.id}"
|
|
61
|
+
|
|
62
|
+
elsif value_class.superclass == ActiveRecord::Relation
|
|
63
|
+
"#{value.class.to_s.split('::').first} #{value.ids.to_s.delete('[]')}"
|
|
64
|
+
|
|
65
|
+
elsif value_class.superclass == ActiveRecord::Associations::CollectionProxy
|
|
66
|
+
"#{value.class.to_s.split('::').first} #{value.ids.to_s.delete('[]')}"
|
|
67
|
+
|
|
68
|
+
elsif value_class == RubyXL::Workbook
|
|
69
|
+
value_class.name
|
|
70
|
+
|
|
71
|
+
elsif value_class == RubyXL::Worksheet
|
|
72
|
+
value_class.name
|
|
73
|
+
|
|
74
|
+
else
|
|
75
|
+
value.to_s
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -22,15 +22,21 @@ module EitilIntegrate::RubyXL
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def exporter_infos
|
|
25
|
-
exporter_constants.map { |_c| { "#{_c}": _c.info || {} } }.inject &:merge
|
|
25
|
+
exporter_constants.map { |_c| { "#{_c.to_s.remove("Exporter")}": _c.info || {} } }.inject &:merge
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
alias_method :taxonomy, :exporter_infos
|
|
29
|
-
|
|
30
28
|
def exporter_info(exporter, info)
|
|
31
29
|
exporter_infos[exporter]&.dig(info)
|
|
32
30
|
end
|
|
33
31
|
|
|
32
|
+
# returns the exporter_infos, without the datatypes – for taxonomy purpuses, the field
|
|
33
|
+
# names are often sufficient
|
|
34
|
+
def exporter_taxonomy
|
|
35
|
+
exporter_infos.transform_values do |settings|
|
|
36
|
+
settings.transform_values { |info| info.first.is_a?(Hash) ? info.first.keys : info }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
34
40
|
def exporter_params
|
|
35
41
|
exporter_infos.transform_values { |v| [v[:required], v[:optional]].flatten.compact }
|
|
36
42
|
end
|
data/eitil_wrapper/README.md
CHANGED
|
@@ -179,3 +179,27 @@ Scopes are generated through the columns of your model's database table. Which s
|
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## EitilWrapper::RequestLogger
|
|
186
|
+
|
|
187
|
+
```ruby
|
|
188
|
+
|
|
189
|
+
require "eitil_wrapper/request_logger"
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The RequestLogger wrapper logs request params in /log/request_logger.log, which offers the opportunity to pry into webhooks while developing. In order to track a controller, simply add the following. This calls a background job which writes to the file.
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
|
|
197
|
+
include EitilWrapper::RequestLogger::ControllerMixin
|
|
198
|
+
before_action :log_request
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# somehow leads to errors in the initialization process. Ideally, this code would be
|
|
3
3
|
# defined in eitil_wrapper/jobs/single_method_job.rb and dispatched in eitil_wrapper/railtie.rb
|
|
4
4
|
|
|
5
|
+
# require "eitil_wrapper/railtie" to run the dynamic dispatch as an init hook during boot
|
|
6
|
+
require "eitil_wrapper/railtie"
|
|
7
|
+
|
|
5
8
|
module EitilWrapper
|
|
6
9
|
module CreateSingleMethodJob
|
|
7
10
|
end
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
require "rails"
|
|
3
|
-
require "eitil_wrapper"
|
|
4
|
-
|
|
5
2
|
module EitilWrapper
|
|
6
3
|
|
|
7
4
|
class Railtie < Rails::Railtie
|
|
8
5
|
|
|
6
|
+
# Dynamic dispatching after initialization of Rails classes.
|
|
7
|
+
|
|
9
8
|
initializer "my_railtie.configure_rails_initialization", options: :after do |app|
|
|
10
9
|
|
|
11
|
-
# Dynamic dispatching after initialization of Rails classes.
|
|
12
10
|
|
|
13
|
-
# Scopes
|
|
14
|
-
|
|
15
11
|
if Object.const_defined?('EitilWrapper::Scopes::DefaultScopes')
|
|
16
12
|
::ApplicationRecord.send(:extend, EitilWrapper::Scopes::DefaultScopes)
|
|
17
13
|
end
|
|
18
14
|
|
|
19
|
-
# Jobs
|
|
20
15
|
|
|
21
16
|
if Object.const_defined?('EitilWrapper::CreateSingleMethodJob')
|
|
22
17
|
|
|
@@ -44,6 +39,28 @@ module EitilWrapper
|
|
|
44
39
|
object.send _method, *args, **kwargs
|
|
45
40
|
end; end; end; end
|
|
46
41
|
|
|
42
|
+
|
|
43
|
+
if Object.const_defined?('EitilWrapper::RequestLogger::CreateLoggerJob')
|
|
44
|
+
|
|
45
|
+
module ::EitilWrapper
|
|
46
|
+
module RequestLogger
|
|
47
|
+
class LoggerJob < ::ApplicationJob
|
|
48
|
+
|
|
49
|
+
def perform(logger_object)
|
|
50
|
+
|
|
51
|
+
# set path for logger
|
|
52
|
+
$request_logger_path ||= "#{Rails.root}/log/request_logger.log"
|
|
53
|
+
|
|
54
|
+
# create logger, if not present
|
|
55
|
+
if Dir[$request_logger_path].blank? || $request_logger.blank?
|
|
56
|
+
$request_logger = Logger.new($request_logger_path)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# add logger_object to logger
|
|
60
|
+
$request_logger.info(logger_object)
|
|
61
|
+
|
|
62
|
+
end; end; end; end; end
|
|
63
|
+
|
|
47
64
|
end
|
|
48
65
|
end
|
|
49
66
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_wrapper/request_logger/controller_mixin"
|
|
3
|
+
|
|
4
|
+
require_relative "logger_job"
|
|
5
|
+
|
|
6
|
+
module EitilWrapper
|
|
7
|
+
module RequestLogger
|
|
8
|
+
module ControllerMixin
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def log_request
|
|
13
|
+
$request_logger_path ||= "#{Rails.root}/log/request_logger.log"
|
|
14
|
+
EitilWrapper::RequestLogger::LoggerJob.perform_later(request_logger_object)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def request_logger_object
|
|
18
|
+
|
|
19
|
+
log_request = {
|
|
20
|
+
path: request.env["REQUEST_PATH"],
|
|
21
|
+
method: request.env["REQUEST_METHOD"],
|
|
22
|
+
query_str: request.env["QUERY_STRING"],
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
log_params = {
|
|
26
|
+
params: params.as_json
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
log_attributes = {
|
|
30
|
+
time: Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
log = {
|
|
34
|
+
request: log_request,
|
|
35
|
+
params: log_params,
|
|
36
|
+
attributes: log_attributes
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
log_time = log_attributes[:time]
|
|
40
|
+
log_strf = log.deep_symbolize_keys.to_s
|
|
41
|
+
# log_strf may be hashed through eval(log_strf)
|
|
42
|
+
|
|
43
|
+
return log_strf
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
# require "eitil_wrapper/request_logger/logger_job"
|
|
3
|
+
|
|
4
|
+
# require "eitil_wrapper/railtie" to run the dynamic dispatch as an init hook during boot
|
|
5
|
+
require "eitil_wrapper/railtie"
|
|
6
|
+
|
|
7
|
+
# ISSUE: this code is currently defined eitil_wrapper/railtie.rb, since module inclusion
|
|
8
|
+
# somehow leads to errors in the initialization process. Ideally, this code would be
|
|
9
|
+
# defined in eitil_wrapper/request_logger/logger_job.rb and dispatched in eitil_wrapper/railtie.rb
|
|
10
|
+
|
|
11
|
+
module EitilWrapper
|
|
12
|
+
module RequestLogger
|
|
13
|
+
module CreateLoggerJob
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/eitil/all.rb
CHANGED
|
@@ -6,10 +6,11 @@ Eitil::Layers.each do |layer|
|
|
|
6
6
|
|
|
7
7
|
begin
|
|
8
8
|
require "#{layer}/railtie"
|
|
9
|
-
|
|
9
|
+
require "#{layer}"
|
|
10
|
+
puts "succesfully required #{layer} and #{layer}/railtie" if Rails.env.development?
|
|
10
11
|
|
|
11
12
|
rescue LoadError => e
|
|
12
|
-
puts "failed to require #{layer}/railtie"
|
|
13
|
+
puts "failed to require #{layer} and #{layer}/railtie"
|
|
13
14
|
puts "message: #{e.message}"
|
|
14
15
|
# binding.pry
|
|
15
16
|
|
data/lib/eitil/railtie.rb
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
require 'eitil/railtie'
|
|
3
|
-
|
|
4
2
|
# Constants
|
|
5
3
|
|
|
6
4
|
module Eitil
|
|
@@ -10,16 +8,20 @@ module Eitil
|
|
|
10
8
|
|
|
11
9
|
end
|
|
12
10
|
|
|
13
|
-
|
|
14
11
|
# Configuration
|
|
15
12
|
|
|
16
13
|
module Eitil
|
|
17
14
|
|
|
18
15
|
class Railtie < ::Rails::Railtie
|
|
19
16
|
|
|
20
|
-
# Add lib dirs to $LOAD_PATH, making them available in your main app.
|
|
21
17
|
Eitil::Layers.each do |layer|
|
|
18
|
+
|
|
19
|
+
# Add lib dirs to $LOAD_PATH, making them available in your main app.
|
|
22
20
|
$LOAD_PATH << "#{Eitil::Root}/#{layer}/lib"
|
|
21
|
+
|
|
22
|
+
# Load railtie into main app, enabling on the fly inclusion of dispatches.
|
|
23
|
+
require "#{layer}/railtie"
|
|
24
|
+
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
end
|
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.
|
|
4
|
+
version: 1.1.3
|
|
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-06-
|
|
11
|
+
date: 2021-06-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -105,11 +105,17 @@ files:
|
|
|
105
105
|
- eitil_core/lib/eitil_core/errors/raise_error.rb
|
|
106
106
|
- eitil_core/lib/eitil_core/float.rb
|
|
107
107
|
- eitil_core/lib/eitil_core/float/safe_to_i.rb
|
|
108
|
+
- eitil_core/lib/eitil_core/formatters.rb
|
|
109
|
+
- eitil_core/lib/eitil_core/formatters/sql.rb
|
|
108
110
|
- eitil_core/lib/eitil_core/hash.rb
|
|
109
111
|
- eitil_core/lib/eitil_core/hash/auto_dig.rb
|
|
110
112
|
- eitil_core/lib/eitil_core/lookups.rb
|
|
111
113
|
- eitil_core/lib/eitil_core/lookups/all_methods.rb
|
|
112
114
|
- eitil_core/lib/eitil_core/lookups/gem_path.rb
|
|
115
|
+
- eitil_core/lib/eitil_core/mocks.rb
|
|
116
|
+
- eitil_core/lib/eitil_core/mocks/array.rb
|
|
117
|
+
- eitil_core/lib/eitil_core/mocks/hash.rb
|
|
118
|
+
- eitil_core/lib/eitil_core/mocks/string.rb
|
|
113
119
|
- eitil_core/lib/eitil_core/railtie.rb
|
|
114
120
|
- eitil_core/lib/eitil_core/safe_executions.rb
|
|
115
121
|
- eitil_core/lib/eitil_core/safe_executions/safe_call.rb
|
|
@@ -134,6 +140,7 @@ files:
|
|
|
134
140
|
- eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
|
|
135
141
|
- eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb
|
|
136
142
|
- eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb
|
|
143
|
+
- eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb
|
|
137
144
|
- eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb
|
|
138
145
|
- eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb
|
|
139
146
|
- eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb
|
|
@@ -167,6 +174,9 @@ files:
|
|
|
167
174
|
- eitil_wrapper/lib/eitil_wrapper/jobs/new_job_debugger.rb
|
|
168
175
|
- eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb
|
|
169
176
|
- eitil_wrapper/lib/eitil_wrapper/railtie.rb
|
|
177
|
+
- eitil_wrapper/lib/eitil_wrapper/request_logger.rb
|
|
178
|
+
- eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb
|
|
179
|
+
- eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb
|
|
170
180
|
- eitil_wrapper/lib/eitil_wrapper/routes.rb
|
|
171
181
|
- eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb
|
|
172
182
|
- eitil_wrapper/lib/eitil_wrapper/scopes.rb
|