eitil 1.1.0 → 1.1.5
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 +43 -0
- data/eitil_core/lib/eitil_core.rb +1 -0
- data/eitil_core/lib/eitil_core/formatters.rb +4 -0
- data/eitil_core/lib/eitil_core/formatters/sql.rb +72 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +1 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +7 -4
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +24 -9
- 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_wrapper/README.md +9 -1
- data/lib/eitil/all.rb +1 -1
- data/lib/eitil/railtie.rb +6 -4
- data/lib/eitil/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2aa00902c0c436b26613f26555b6d583907285491dac4178b03ad0916be42d
|
4
|
+
data.tar.gz: ccb82971dcdeaa31c03716f942ace584d40183bded78c25a92b9df0800b97998
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6502c6a8df10c45af6234c1f49e7fcc4f8960c27693d09d797bfa5bb2a217dd576297fb0be5afc3c02a30a6556da1e2ff139741a69f91fccd2c595cee8a7be4c
|
7
|
+
data.tar.gz: 686b771909c542bc6ef2a5d6657161353af8535754f23a2396c91ce6ede9590b0c6d4033c7acf1a80d1090f084ca57c90d97d97f8b4d7d2f07ae8b675dbdba28
|
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
|
@@ -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
|
+
|
@@ -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"
|
@@ -6,13 +6,16 @@ module EitilIntegrate::RubyXL
|
|
6
6
|
class << self
|
7
7
|
|
8
8
|
def format_data
|
9
|
-
format_time_strings
|
9
|
+
# format_time_strings
|
10
10
|
format_ints_to_floats
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
# outcommented method in favour of AutoSum#chronic_sum_array: no longer accept days, since the method excepts
|
14
|
+
# either hh:mm or hh:mm:ss
|
15
|
+
|
16
|
+
# def format_time_strings
|
17
|
+
# @hash.transform_values! { |array| array.map { |item| incomplete_time_string?(item) ? "#{item}:00" : item } }
|
18
|
+
# end
|
16
19
|
|
17
20
|
def incomplete_time_string?(string)
|
18
21
|
string.is_a?(String) && string.length == 5 && string.scan(/\d{2}:\d{2}/)
|
@@ -22,15 +22,30 @@ module EitilIntegrate::RubyXL
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def chronic_sum_array(array)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
|
26
|
+
#total minutes, hours and days
|
27
|
+
tm, th, td = [0]*3
|
28
|
+
|
29
|
+
array.each do |time_string|
|
30
|
+
|
31
|
+
# add empty 0's, to avoid defining nil values when time values are absent
|
32
|
+
h, m, s = *time_string.split(':').map(&:to_i), *[0]*3
|
33
|
+
tm += m; th += h
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
# parsing times into maxes (60 m, 24 h, ∞ days)
|
38
|
+
th += tm / 60
|
39
|
+
tm = tm % 60
|
40
|
+
td += th / 24
|
41
|
+
th = th % 24
|
42
|
+
|
43
|
+
# formatting strings
|
44
|
+
sd = td.to_s
|
45
|
+
sh = th.to_s.rjust(2,'0')
|
46
|
+
sm = tm.to_s.rjust(2,'0')
|
47
|
+
|
48
|
+
[[sd, sh, sm].join(':')]
|
34
49
|
end
|
35
50
|
|
36
51
|
def format_time(time)
|
@@ -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
@@ -190,7 +190,15 @@ require "eitil_wrapper/request_logger"
|
|
190
190
|
|
191
191
|
```
|
192
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
|
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
|
+
|
194
202
|
|
195
203
|
|
196
204
|
|
data/lib/eitil/all.rb
CHANGED
@@ -7,7 +7,7 @@ Eitil::Layers.each do |layer|
|
|
7
7
|
begin
|
8
8
|
require "#{layer}/railtie"
|
9
9
|
require "#{layer}"
|
10
|
-
puts "succesfully required #{layer} and #{layer}/railtie"
|
10
|
+
puts "succesfully required #{layer} and #{layer}/railtie" if Rails.env.development?
|
11
11
|
|
12
12
|
rescue LoadError => e
|
13
13
|
puts "failed to require #{layer} and #{layer}/railtie"
|
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.1.
|
4
|
+
version: 1.1.5
|
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,6 +105,8 @@ 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
|
@@ -138,6 +140,7 @@ files:
|
|
138
140
|
- eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
|
139
141
|
- eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb
|
140
142
|
- eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb
|
143
|
+
- eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb
|
141
144
|
- eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb
|
142
145
|
- eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb
|
143
146
|
- eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb
|