eitil 1.0.1.e.2 → 1.0.3.e.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/eitil_core/README.md +344 -0
- data/eitil_core/lib/eitil_core.rb +24 -0
- data/eitil_core/lib/eitil_core/application_controller.rb +2 -0
- data/eitil_core/lib/eitil_core/application_controller/slice_params.rb +14 -0
- data/eitil_core/lib/eitil_core/application_record.rb +4 -0
- data/eitil_core/lib/eitil_core/application_record/all_associations.rb +16 -0
- data/eitil_core/lib/eitil_core/application_record/find_by_like.rb +15 -0
- data/eitil_core/lib/eitil_core/application_record/where_like.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers.rb +13 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_kwargs_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/all_kwargs_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_h.rb +15 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_h_bang.rb +17 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/argument_helpers/args_to_ivars_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/concerns.rb +2 -0
- data/eitil_core/lib/eitil_core/concerns/include_concerns_of.rb +15 -0
- data/eitil_core/lib/eitil_core/datetime.rb +2 -0
- data/eitil_core/lib/eitil_core/datetime/prettify.rb +10 -0
- data/eitil_core/lib/eitil_core/errors.rb +2 -0
- data/eitil_core/lib/eitil_core/errors/raise_error.rb +11 -0
- data/eitil_core/lib/eitil_core/float.rb +2 -0
- data/eitil_core/lib/eitil_core/float/safe_to_i.rb +12 -0
- data/eitil_core/lib/eitil_core/hash.rb +2 -0
- data/eitil_core/lib/eitil_core/hash/auto_dig.rb +17 -0
- data/eitil_core/lib/eitil_core/lookups.rb +3 -0
- data/eitil_core/lib/eitil_core/lookups/all_methods.rb +32 -0
- data/eitil_core/lib/eitil_core/lookups/gem_path.rb +10 -0
- data/eitil_core/lib/eitil_core/railtie.rb +37 -0
- data/eitil_core/lib/eitil_core/safe_executions.rb +3 -0
- data/eitil_core/lib/eitil_core/safe_executions/safe_call.rb +12 -0
- data/eitil_core/lib/eitil_core/safe_executions/safe_send.rb +12 -0
- data/eitil_core/lib/eitil_core/setters.rb +2 -0
- data/eitil_core/lib/eitil_core/setters/set_ivars.rb +12 -0
- data/eitil_core/lib/eitil_core/type_checkers.rb +2 -0
- data/eitil_core/lib/eitil_core/type_checkers/is_num_or_nan.rb +96 -0
- data/eitil_core/lib/eitil_core/validations.rb +2 -0
- data/eitil_core/lib/eitil_core/validations/run_validations.rb +10 -0
- data/eitil_integrate/README.md +19 -0
- data/eitil_integrate/lib/eitil_integrate.rb +4 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +22 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb +10 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb +54 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +27 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb +22 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb +31 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb +18 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +56 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +43 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb +50 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb +20 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +28 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +40 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb +58 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb +27 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb +34 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb +97 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb +28 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb +78 -0
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb +18 -0
- data/eitil_integrate/lib/eitil_integrate/railtie.rb +10 -0
- data/eitil_store/README.md +16 -0
- data/eitil_store/lib/eitil_store.rb +4 -0
- data/eitil_store/lib/eitil_store/railtie.rb +10 -0
- data/eitil_store/lib/eitil_store/regex.rb +4 -0
- data/eitil_store/lib/eitil_store/regex/regex.rb +41 -0
- data/eitil_support/README.md +78 -0
- data/eitil_support/lib/eitil_support.rb +5 -0
- data/eitil_support/lib/eitil_support/directory.rb +2 -0
- data/eitil_support/lib/eitil_support/directory/lookups.rb +26 -0
- data/eitil_support/lib/eitil_support/railtie.rb +10 -0
- data/eitil_support/lib/eitil_support/stacktrace.rb +4 -0
- data/eitil_support/lib/eitil_support/stacktrace/audit.rb +15 -0
- data/eitil_support/lib/eitil_support/stacktrace/call.rb +17 -0
- data/eitil_support/lib/eitil_support/stacktrace/stack.rb +28 -0
- data/eitil_wrapper/README.md +181 -0
- data/eitil_wrapper/lib/eitil_wrapper.rb +7 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators.rb +3 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators/application_decorator.rb +19 -0
- data/eitil_wrapper/lib/eitil_wrapper/decorators/controller_decorator.rb +60 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs.rb +4 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb +34 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job_debugger.rb +37 -0
- data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +8 -0
- data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +49 -0
- data/eitil_wrapper/lib/eitil_wrapper/routes.rb +2 -0
- data/eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb +40 -0
- data/eitil_wrapper/lib/eitil_wrapper/scopes.rb +2 -0
- data/eitil_wrapper/lib/eitil_wrapper/scopes/default_scopes.rb +80 -0
- data/lib/eitil.rb +5 -0
- data/lib/eitil/all.rb +17 -0
- data/lib/eitil/railtie.rb +37 -0
- data/lib/eitil/version.rb +5 -0
- metadata +125 -2
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/lookups"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
require "eitil_support/directory"
|
6
|
+
|
7
|
+
module EitilIntegrate::RubyXL
|
8
|
+
class ApplicationExporter
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def exporter_paths
|
13
|
+
EitilSupport::Directory.files('app/exporters/exporters').select { |path| path.end_with? '_exporter.rb' }
|
14
|
+
end
|
15
|
+
|
16
|
+
def exporter_names
|
17
|
+
exporter_paths.map { |path| path.split('/').last.remove('.rb').camelcase }
|
18
|
+
end
|
19
|
+
|
20
|
+
def exporter_constants
|
21
|
+
exporter_names.map &:constantize
|
22
|
+
end
|
23
|
+
|
24
|
+
def exporter_infos
|
25
|
+
exporter_constants.map { |_c| { "#{_c}": _c.info || {} } }.inject &:merge
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method :taxonomy, :exporter_infos
|
29
|
+
|
30
|
+
def exporter_info(exporter, info)
|
31
|
+
exporter_infos[exporter]&.dig(info)
|
32
|
+
end
|
33
|
+
|
34
|
+
def exporter_params
|
35
|
+
exporter_infos.transform_values { |v| [v[:required], v[:optional]].flatten.compact }
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/selectors"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
|
6
|
+
module EitilIntegrate::RubyXL
|
7
|
+
class ApplicationExporter
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
# rows
|
12
|
+
|
13
|
+
def current_row
|
14
|
+
x
|
15
|
+
end
|
16
|
+
|
17
|
+
def previous_row
|
18
|
+
x - 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def next_row
|
22
|
+
x + 1
|
23
|
+
end
|
24
|
+
|
25
|
+
def first_row
|
26
|
+
0
|
27
|
+
end
|
28
|
+
|
29
|
+
# columns
|
30
|
+
|
31
|
+
def current_column
|
32
|
+
y
|
33
|
+
end
|
34
|
+
|
35
|
+
def previous_column
|
36
|
+
y - 1
|
37
|
+
end
|
38
|
+
|
39
|
+
def next_column
|
40
|
+
y + 1
|
41
|
+
end
|
42
|
+
|
43
|
+
def first_column
|
44
|
+
0
|
45
|
+
end
|
46
|
+
|
47
|
+
# RubyXL object selectors for rows. For columns I have not found a RubyXL object,
|
48
|
+
# or a practical way of accessing the cells of a column, yet.
|
49
|
+
|
50
|
+
def method_missing(_method, *args, &block)
|
51
|
+
m = _method.to_s
|
52
|
+
super _method unless m.include?('row') and m.ends_with?('_object')
|
53
|
+
super _method unless respond_to? m.delete_suffix!('_object'), true
|
54
|
+
sheet[send(m)]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/setters"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
|
6
|
+
module EitilIntegrate::RubyXL
|
7
|
+
class ApplicationExporter
|
8
|
+
|
9
|
+
# The date setter methods allow Exporters to receive dates as strings, which are
|
10
|
+
# required to prevent serialization errors in perform_later background jobs.
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def set_start_date
|
15
|
+
@start_date.is_a?(Date) ? @start_date : Date.parse(@start_date) if @start_date
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_end_date
|
19
|
+
@end_date.is_a?(Date) ? @end_date : Date.parse(@end_date) if @end_date
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_date_range
|
23
|
+
@start_date..@end_date if @start_date && @end_date
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/store_file"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
require "eitil_core/setters/set_ivars"
|
6
|
+
|
7
|
+
module EitilIntegrate::RubyXL
|
8
|
+
class ApplicationExporter
|
9
|
+
|
10
|
+
attr_accessor :storage_path
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def save_file
|
15
|
+
set_ivars :storage_path
|
16
|
+
save_book
|
17
|
+
run_after_save_effects
|
18
|
+
@storage_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_storage_path
|
22
|
+
"#{Rails.root}/data/#{self.class.name.snakecase}_#{DateTime.now.prettify}.xlsx"
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_book
|
26
|
+
book.write @storage_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_after_save_effects
|
30
|
+
# nil fallback for if the application class (which inherits from ApplicationExporter) has no method #run_after_save_effects
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/style_cells"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
|
6
|
+
module EitilIntegrate::RubyXL
|
7
|
+
class ApplicationExporter
|
8
|
+
|
9
|
+
COLOURS = { white: 'ffffff', black: '000000', red: 'FF0000', blue: '0000FF', green: '00FF00', yellow: 'FFFF00',
|
10
|
+
cyan: '00FFFF', magenta: 'FF00FF', dark_grey: '464646', grey: '7E7E7E', light_grey: 'C1C1C1',
|
11
|
+
eitje_blue: '0496FF' }
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def style_file
|
16
|
+
style_general
|
17
|
+
style_custom
|
18
|
+
end
|
19
|
+
|
20
|
+
def style_general
|
21
|
+
style_row_height
|
22
|
+
style_column_width
|
23
|
+
style_first_row_bold
|
24
|
+
style_first_column_bold
|
25
|
+
end
|
26
|
+
|
27
|
+
def style_custom
|
28
|
+
%i[
|
29
|
+
style_first_x_columns_width
|
30
|
+
style_x_columns_width
|
31
|
+
style_first_x_rows_height
|
32
|
+
style_x_rows_height
|
33
|
+
].each { |_method| safe_send _method }
|
34
|
+
end
|
35
|
+
|
36
|
+
# multi rows
|
37
|
+
|
38
|
+
def style_row_height(height = 15)
|
39
|
+
base_style_x_rows_height row_indices, height
|
40
|
+
end
|
41
|
+
|
42
|
+
def style_first_x_rows_height(n_rows, height)
|
43
|
+
base_style_x_rows_height (0...n_rows), height
|
44
|
+
end
|
45
|
+
|
46
|
+
def style_x_rows_height(row_indices = [], height)
|
47
|
+
row_indices.each { |i| @sheet.change_row_height(i, height) }
|
48
|
+
end
|
49
|
+
|
50
|
+
alias_method :base_style_x_rows_height, :style_x_rows_height
|
51
|
+
|
52
|
+
# multi columns
|
53
|
+
|
54
|
+
def style_column_width(width = 40)
|
55
|
+
base_style_x_columns_width column_indices, width
|
56
|
+
end
|
57
|
+
|
58
|
+
def style_first_x_columns_width(n_columns, width)
|
59
|
+
base_style_x_columns_width (0...n_columns), width
|
60
|
+
end
|
61
|
+
|
62
|
+
def style_x_columns_width(column_indices = [], width)
|
63
|
+
column_indices.each { |i| @sheet.change_column_width(i, width) }
|
64
|
+
end
|
65
|
+
|
66
|
+
alias_method :base_style_x_columns_width, :style_x_columns_width
|
67
|
+
|
68
|
+
# single row
|
69
|
+
|
70
|
+
def style_first_row_bold
|
71
|
+
style_row_bold first_row
|
72
|
+
end
|
73
|
+
|
74
|
+
def style_row_bold(row)
|
75
|
+
@sheet.change_row_bold(row, true)
|
76
|
+
end
|
77
|
+
|
78
|
+
def style_row_font_colour(row, colour)
|
79
|
+
@sheet.change_row_font_color row, COLOURS[colour.to_sym]
|
80
|
+
end
|
81
|
+
|
82
|
+
def style_row_background_colour(row, colour)
|
83
|
+
sheet[row].cells.each { |cell| cell.change_fill COLOURS[colour.to_sym] }
|
84
|
+
end
|
85
|
+
|
86
|
+
# single column
|
87
|
+
|
88
|
+
def style_first_column_bold
|
89
|
+
style_column_bold first_column
|
90
|
+
end
|
91
|
+
|
92
|
+
def style_column_bold(column)
|
93
|
+
@sheet.change_column_bold(column, true)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/validations"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
require "eitil_core/errors/raise_error"
|
6
|
+
|
7
|
+
module EitilIntegrate::RubyXL
|
8
|
+
class ApplicationExporter
|
9
|
+
|
10
|
+
def validate_args_presence(*args)
|
11
|
+
args.each do |arg|
|
12
|
+
unless instance_variable_get "@#{arg}"
|
13
|
+
raise_error 'ExportArgumentsNotSetError', 'Set all required arguments. (Be aware that nil values will fail the test.)'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_args_value
|
20
|
+
# Empty holder to prevent NoMethodError in DefaultExporter#export.
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate_data
|
24
|
+
# Empty holder to prevent NoMethodError in DefaultExporter#export.
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/write_cells"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
|
6
|
+
module EitilIntegrate::RubyXL
|
7
|
+
class ApplicationExporter
|
8
|
+
|
9
|
+
def new_row(row_hash)
|
10
|
+
row_hash.each { |x_axis, title| @sheet.add_cell(x, x_axis.to_s.to_i, title) }
|
11
|
+
@x += 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def empty_row
|
15
|
+
@x += 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty_rows(n_rows)
|
19
|
+
@x += n_rows
|
20
|
+
end
|
21
|
+
|
22
|
+
def new_column(column_hash)
|
23
|
+
column_hash.each { |y_axis, title| @sheet.add_cell(y_axis.to_s.to_i, y, title) }
|
24
|
+
@y += 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def empty_column
|
28
|
+
@y += 1
|
29
|
+
end
|
30
|
+
|
31
|
+
def empty_columns(n_columns)
|
32
|
+
@y += n_columns
|
33
|
+
end
|
34
|
+
|
35
|
+
def rows
|
36
|
+
@sheet.sheet_data.rows
|
37
|
+
end
|
38
|
+
|
39
|
+
def row_indices
|
40
|
+
(0...rows.count).to_a
|
41
|
+
end
|
42
|
+
|
43
|
+
def columns
|
44
|
+
# RubyXl does not seem to be purposed around columns, but merely handle rows properly.
|
45
|
+
end
|
46
|
+
|
47
|
+
def column_indices
|
48
|
+
n_rows = rows.map { |r| r&.cells&.count }.compact.max #temporary hack
|
49
|
+
(0...n_rows).to_a
|
50
|
+
end
|
51
|
+
|
52
|
+
def array_to_row(array)
|
53
|
+
new_row array_to_indexed_hash(array)
|
54
|
+
end
|
55
|
+
|
56
|
+
def row_values(row_index)
|
57
|
+
rows.dig(row_index).cells.map &:value
|
58
|
+
end
|
59
|
+
|
60
|
+
def column_values(column_index)
|
61
|
+
rows.map { |row| row&.cells&.dig(column_index)&.value }
|
62
|
+
end
|
63
|
+
|
64
|
+
def all_column_values
|
65
|
+
column_indices.map { |i| { i => column_values(i) } }.inject &:merge
|
66
|
+
end
|
67
|
+
|
68
|
+
def all_row_values
|
69
|
+
row_indices.map { |i| { i => row_values(i) } }.inject &:merge
|
70
|
+
end
|
71
|
+
|
72
|
+
def sum_row
|
73
|
+
new_row EitilIntegrate::RubyXL::AutoSum.perform(all_column_values)
|
74
|
+
style_row_bold previous_row
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/write_messages"
|
3
|
+
|
4
|
+
require "eitil_integrate/application_exporter/initialize"
|
5
|
+
|
6
|
+
module EitilIntegrate::RubyXL
|
7
|
+
class ApplicationExporter
|
8
|
+
|
9
|
+
def fill_messages
|
10
|
+
# nil fallback for if the exporter class has no method #fill_messages
|
11
|
+
end
|
12
|
+
|
13
|
+
def write_message(message)
|
14
|
+
new_row({ '0': message })
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
# EitilStore
|
5
|
+
|
6
|
+
EitilStore stores data in containers, such as Regexp instances.
|
7
|
+
|
8
|
+
|
9
|
+
## EitilSupport::Regex
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
|
13
|
+
require "eitil_store/regex"
|
14
|
+
|
15
|
+
```
|
16
|
+
Provides regular expressions which are of general use. To see which general expressions are available, see /eitil_store/regex/regex.rb
|