eitil 2.0.3 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/lib/eitil/all.rb +0 -1
  4. data/lib/eitil/railtie.rb +1 -1
  5. data/lib/eitil/version.rb +1 -1
  6. data/spec/dummy_app/app/models/user.rb +0 -25
  7. data/spec/spec_helper.rb +0 -2
  8. metadata +2 -30
  9. data/eitil_integrate/README.md +0 -19
  10. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb +0 -63
  11. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +0 -30
  12. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb +0 -22
  13. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb +0 -31
  14. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb +0 -18
  15. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +0 -84
  16. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb +0 -10
  17. data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +0 -44
  18. data/eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb +0 -50
  19. data/eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb +0 -20
  20. data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +0 -32
  21. data/eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb +0 -81
  22. data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +0 -50
  23. data/eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb +0 -58
  24. data/eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb +0 -27
  25. data/eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb +0 -34
  26. data/eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb +0 -104
  27. data/eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb +0 -28
  28. data/eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb +0 -78
  29. data/eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb +0 -18
  30. data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +0 -23
  31. data/eitil_integrate/lib/eitil_integrate/railtie.rb +0 -7
  32. data/eitil_integrate/lib/eitil_integrate.rb +0 -4
  33. data/spec/eitil_wrapper/callbacks/helper_methods_spec.rb +0 -34
  34. data/spec/eitil_wrapper/jobs/single_method_job_spec.rb +0 -72
  35. data/spec/eitil_wrapper/routes/extended_resources_spec.rb +0 -16
  36. data/spec/eitil_wrapper/scopes/default_scopes_spec.rb +0 -154
@@ -1,50 +0,0 @@
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/views/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.to_s.remove("Exporter")}": _c.info || {} } }.inject &:merge
26
- end
27
-
28
- def exporter_info(exporter, info)
29
- exporter_infos[exporter]&.dig(info)
30
- end
31
-
32
- # returns the exporter_infos, without the datatypes – for taxonomy purpuses, the field
33
- # names are often sufficient
34
- def exporter_taxonomy
35
- parameter_fields = exporter_infos.transform_values { |v| v.select { |k,v| k == :required || k == :optional } }
36
-
37
- parameter_fields.transform_values do |setting_collection|
38
- setting_collection.transform_values do |setting|
39
- setting.map { |key| key.is_a?(Hash) ? key.keys : key }.flatten
40
- end
41
- end
42
- end
43
-
44
- def exporter_params
45
- exporter_infos.transform_values { |v| [v[:required], v[:optional]].flatten.compact }
46
- end
47
-
48
- end
49
- end
50
- end
@@ -1,58 +0,0 @@
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
@@ -1,27 +0,0 @@
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
@@ -1,34 +0,0 @@
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
@@ -1,104 +0,0 @@
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
- style_first_column_width
26
- end
27
-
28
- def style_custom
29
- %i[
30
- style_first_x_columns_width
31
- style_x_columns_width
32
- style_first_x_rows_height
33
- style_x_rows_height
34
- ].each { |_method| safe_send _method }
35
- end
36
-
37
- # multi rows
38
-
39
- def style_row_height(height = 15)
40
- base_style_x_rows_height row_indices, height
41
- end
42
-
43
- def style_first_x_rows_height(n_rows, height)
44
- base_style_x_rows_height (0...n_rows), height
45
- end
46
-
47
- def style_x_rows_height(row_indices = [], height)
48
- row_indices.each { |i| @sheet.change_row_height(i, height) }
49
- end
50
-
51
- alias_method :base_style_x_rows_height, :style_x_rows_height
52
-
53
- # multi columns
54
-
55
- def style_column_width(width = 40)
56
- base_style_x_columns_width column_indices, width
57
- end
58
-
59
- def style_first_x_columns_width(n_columns, width)
60
- base_style_x_columns_width (0...n_columns), width
61
- end
62
-
63
- def style_first_column_width(width = 35)
64
- style_first_x_columns_width 1, width
65
- end
66
-
67
- alias_method :base_style_first_x_columns_width, :style_first_x_columns_width
68
-
69
- def style_x_columns_width(column_indices = [], width)
70
- column_indices.each { |i| @sheet.change_column_width(i, width) }
71
- end
72
-
73
- alias_method :base_style_x_columns_width, :style_x_columns_width
74
-
75
- # single row
76
-
77
- def style_first_row_bold
78
- style_row_bold first_row
79
- end
80
-
81
- def style_row_bold(row)
82
- @sheet.change_row_bold(row, true)
83
- end
84
-
85
- def style_row_font_colour(row, colour)
86
- @sheet.change_row_font_color row, COLOURS[colour.to_sym]
87
- end
88
-
89
- def style_row_background_colour(row, colour)
90
- sheet[row].cells.each { |cell| cell.change_fill COLOURS[colour.to_sym] }
91
- end
92
-
93
- # single column
94
-
95
- def style_first_column_bold
96
- style_column_bold first_column
97
- end
98
-
99
- def style_column_bold(column)
100
- @sheet.change_column_bold(column, true)
101
- end
102
-
103
- end
104
- end
@@ -1,28 +0,0 @@
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
@@ -1,78 +0,0 @@
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
@@ -1,18 +0,0 @@
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
@@ -1,23 +0,0 @@
1
- # require "eitil_integrate/application_exporter"
2
-
3
- # base file, which is required by all others
4
- require_relative "application_exporter/initialize"
5
-
6
- # temp file, with methods that should, at some point, moved elsewhere
7
- require_relative "application_exporter/helpers"
8
-
9
- # files split by theme and purpose, feel free to cherry-pick
10
- require_relative "application_exporter/default_export"
11
- require_relative "application_exporter/validations"
12
- require_relative "application_exporter/write_cells"
13
- require_relative "application_exporter/write_messages"
14
- require_relative "application_exporter/style_cells"
15
- require_relative "application_exporter/store_file"
16
- require_relative "application_exporter/setters"
17
- require_relative "application_exporter/selectors"
18
- require_relative "application_exporter/lookups"
19
- require_relative "application_exporter/infos"
20
- require_relative "application_exporter/log_state"
21
-
22
- # the AutoSum module, which is a seperately functioning module (service)
23
- require_relative "application_exporter/auto_sum"
@@ -1,7 +0,0 @@
1
-
2
- module EitilIntegrate
3
-
4
- class Railtie < Rails::Railtie
5
- end
6
-
7
- end
@@ -1,4 +0,0 @@
1
-
2
- # require "eitil_integrate"
3
-
4
- require "eitil_integrate/application_exporter"
@@ -1,34 +0,0 @@
1
-
2
- RSpec.describe "EitilWrapper::Callbacks" do
3
-
4
- let(:callbacks) { User.instance_methods(false) }
5
-
6
- context "for columns of datatype: boolean" do
7
-
8
- it "should create the callback .{column_name}_became_true" do
9
- expect(callbacks).to include(:confirmed_became_true)
10
- end
11
-
12
- it "should create the callback .{column_name}_becomes_true" do
13
- expect(callbacks).to include(:confirmed_becomes_true)
14
- end
15
-
16
- it "should create the callback .{column_name}_to_true (works for both become and became)" do
17
- expect(callbacks).to include(:confirmed_to_true)
18
- end
19
-
20
- it "should create the callback .{column_name}_became_false" do
21
- expect(callbacks).to include(:confirmed_became_false)
22
- end
23
-
24
- it "should create the callback .{column_name}_becomes_false" do
25
- expect(callbacks).to include(:confirmed_becomes_false)
26
- end
27
-
28
- it "should create the callback .{column_name}_to_false (works for both become and became)" do
29
- expect(callbacks).to include(:confirmed_to_false)
30
- end
31
-
32
- end
33
-
34
- end
@@ -1,72 +0,0 @@
1
-
2
- RSpec.describe "EitilWrapper::Jobs" do
3
-
4
- let(:user) { User.create(first_name: "Donald", last_name: "Duck") }
5
-
6
- it "should create a new method, if the new_job (perform_later) is used for a singleton method" do
7
- expect(User.methods).to include(:this_is_a_singleton_method_job)
8
- end
9
-
10
- it "should create a new method, if the new_job (perform_later) is used for an instance method" do
11
- expect(User.instance_methods).to include(:this_is_an_instance_method_job)
12
- end
13
-
14
- it "should create a new method, if the new_job_now (perform_now) is used for a singleton method" do
15
- expect(User.methods).to include(:this_is_a_singleton_method_job_now)
16
- end
17
-
18
- it "should create a new method, if the new_job_now (perform_now) is used for an instance method" do
19
- expect(User.instance_methods).to include(:this_is_an_instance_method_job_now)
20
- end
21
-
22
- it "should allow us to perform the created singleton perform_later method" do
23
- begin
24
- User.this_is_a_singleton_method_job
25
- status = 'passed'
26
- rescue
27
- status = 'failed'
28
- end
29
- expect(status).to eq 'passed'
30
- end
31
-
32
- it "should allow us to perform the created instance perform_later method" do
33
- begin
34
- user.this_is_an_instance_method_job
35
- status = 'passed'
36
- rescue
37
- status = 'failed'
38
- end
39
- expect(status).to eq 'passed'
40
- end
41
-
42
- it "should allow us to perform the created singleton perform_now method" do
43
- begin
44
- User.this_is_a_singleton_method_job_now
45
- status = 'passed'
46
- rescue
47
- status = 'failed'
48
- end
49
- expect(status).to eq 'passed'
50
- end
51
-
52
- it "should allow us to perform the created instance perform_now method" do
53
- begin
54
- user.this_is_an_instance_method_job_now
55
- status = 'passed'
56
- rescue
57
- status = 'failed'
58
- end
59
- expect(status).to eq 'passed'
60
- end
61
-
62
- it "should accept positional arguments" do
63
- return_value = User.this_is_a_singleton_method_job_now("positional_argument")
64
- expect(return_value).to eq "positional_argument"
65
- end
66
-
67
- it "should accept keyword arguments " do
68
- return_value = User.this_is_a_singleton_method_job_now(keyword_value: "keyword_argument")
69
- expect(return_value).to eq "keyword_argument"
70
- end
71
-
72
- end
@@ -1,16 +0,0 @@
1
-
2
- # NOT YET IMPLEMENTED, SINCE THIS PART OF EITIL IS NOT YET IN USE.
3
- # FIRST HOOK UP INTO EITJE_API, SINCE THAT MAY CHANGE THE FUNCTIONALITY.
4
-
5
- # RSpec.describe "EitilWrapper::Routes" do
6
-
7
- # before do
8
- # @pretty_routes = `cd spec/dummy_app && rails routes`
9
- # @routes = @pretty_routes.gsub(/[ \t]+/, ' ')
10
- # end
11
-
12
- # it "should " do
13
- # expect(@routes).to include('POST /users(.:format) users#create')
14
- # end
15
-
16
- # end