eitil 1.1.2 → 1.1.7

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/eitil_core/README.md +100 -1
  3. data/eitil_core/lib/eitil_core.rb +4 -1
  4. data/eitil_core/lib/eitil_core/active_record.rb +2 -0
  5. data/eitil_core/lib/eitil_core/active_record/hash_to_relation.rb +27 -0
  6. data/eitil_core/lib/eitil_core/application_controller.rb +1 -0
  7. data/eitil_core/lib/eitil_core/application_controller/permit_model_atts.rb +27 -0
  8. data/eitil_core/lib/eitil_core/application_record.rb +1 -0
  9. data/eitil_core/lib/eitil_core/application_record/model_atts.rb +19 -0
  10. data/eitil_core/lib/eitil_core/array.rb +2 -0
  11. data/eitil_core/lib/eitil_core/array/slice_hashes.rb +18 -0
  12. data/eitil_core/lib/eitil_core/files.rb +2 -0
  13. data/eitil_core/lib/eitil_core/files/create_file.rb +28 -0
  14. data/eitil_core/lib/eitil_core/formatters.rb +4 -0
  15. data/eitil_core/lib/eitil_core/formatters/sql.rb +72 -0
  16. data/eitil_core/lib/eitil_core/railtie.rb +4 -0
  17. data/eitil_core/lib/eitil_core/safe_executions.rb +2 -1
  18. data/eitil_core/lib/eitil_core/safe_executions/safe_rescue.rb +37 -0
  19. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +7 -4
  20. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +24 -9
  21. data/eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb +59 -23
  22. data/eitil_wrapper/README.md +5 -5
  23. data/eitil_wrapper/lib/eitil_wrapper/jobs.rb +1 -1
  24. data/eitil_wrapper/lib/eitil_wrapper/jobs/{new_job_debugger.rb → new_job_now.rb} +4 -4
  25. data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +14 -1
  26. data/lib/eitil/all.rb +1 -1
  27. data/lib/eitil/version.rb +1 -1
  28. metadata +14 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e3982f2e32bcdb5ed52c9e58a0a811278229b59fd6e2f33aed590f0b7489ca5
4
- data.tar.gz: 2046136ba0059bc70a850744685406629e00571d793668303935451892b03740
3
+ metadata.gz: 533d4d3d52d6d7559bdc922092cfad8ccad7cd525146d6dcf7375a6b2f2a7bf3
4
+ data.tar.gz: fbea7ab7c1ec676116f0b4c4465c8e1c6b89426bcd0b6ccc092e80432d1e7d2b
5
5
  SHA512:
6
- metadata.gz: 938b21d23f8e02911df52706504d1448df1cb9ec4dadbc44ae73075a45d7555b98c8c6b8ff2ac44647fdefe76f70cf7068be3f8ed2a4a73ab1430830460a2334
7
- data.tar.gz: cd61ca8e8d1a2fbc06a40c2af036be4fdd11b4785b34384344c442f454e40f441ee6550e557c1716c1f9671ecfeefb1ad816ba98ee62c34260f2e9e1d08b4980
6
+ metadata.gz: 9ba784b5a5dd993b948e2eecd4cd992f28e43e2d253f90394b60740fc79d947d579b8910ae50c05c3f85367d058ad1d9b78ef6f3d246bc1e161542d836d2324e
7
+ data.tar.gz: db2c1be663f34dedfeb32a08f4c91dbd8f1830188c37977491100715c45c6a4ec259e983e42cb5e13f1563a82e602c302df02ae3ce2da23982a5500c07aed5bd
data/eitil_core/README.md CHANGED
@@ -10,8 +10,24 @@ EitilCore extends the core classes of Ruby and Rails.
10
10
 
11
11
  ```ruby
12
12
 
13
- require "eitil_core/application_controller"
13
+ require "eitil_core/active_record"
14
+
15
+ ```
16
+
17
+ ```ruby
18
+ # require "eitil_core/active_record/hash_to_relation"
19
+
20
+ [].to_relation
21
+ # converts an array of ActiveRecord instances to an ActiveRecord_Relation instance
22
+ # call as: [#<instance1>,<instance2>].to_relation
23
+ ```
14
24
 
25
+ ## ApplicationController
26
+
27
+ ```ruby
28
+
29
+ require "eitil_core/application_controller"
30
+ require "eitil_core/application_controller/permit_model_atts"
15
31
  ```
16
32
 
17
33
  ```ruby
@@ -21,6 +37,11 @@ slice_params(*args)
21
37
  # slices request params, converts them to JSON and symbolizes the keys
22
38
  # call as: slice_params :id, :user
23
39
  # => { id: 1, user: 69 }
40
+
41
+ permit_model_atts(*models, include: nil, except: nil)
42
+ # calls params.permit and automatically permits the columns of all given models (one or more)
43
+ # also accepts additional permits (include: nil) or allows you to reject column values (except: nil)
44
+ # call as: params.permit_model_atts(BillingInfo, BillingIntegration, except: :credit_card)
24
45
  ```
25
46
 
26
47
 
@@ -140,6 +161,23 @@ args_to_ivars!(*local_vars)
140
161
  ```
141
162
 
142
163
 
164
+ ## Concerns
165
+
166
+ ```ruby
167
+
168
+ require "eitil_core/array"
169
+
170
+ ```
171
+
172
+ ```ruby
173
+ # require "eitil_core/array/slice_hashes"
174
+
175
+ slice_hashes(*keys)
176
+ # uses the given keys to slice each hash in the array of hashes
177
+ # call as: [{"a"=>1, "b"=>2, "c"=>3}, {"a"=>1, "b"=>2, "c"=>3}].slice_hashes("a", "b")
178
+ # => [{"a"=>1, "b"=>2}, {"a"=>1, "b"=>2}]
179
+ ```
180
+
143
181
  ## Concerns
144
182
 
145
183
  ```ruby
@@ -196,6 +234,24 @@ raise_error(_class_name, message = nil)
196
234
  ```
197
235
 
198
236
 
237
+ ## Files
238
+
239
+ ```ruby
240
+
241
+ require "eitil_core/files"
242
+
243
+ ```
244
+
245
+ ```ruby
246
+ # require "eitil_core/files/create_file"
247
+
248
+ create_file(file_name, data, directory: nil, suffix: nil, file_type: nil, append: false)
249
+ # writes data to a file (new or existing), with "#{Dir.home}/data" as default directory and with a timestamp as default suffix
250
+ # call as: create_file('test_file', {a: 1, b: {c: 2}}, append: true)
251
+ # => /Users/jurriaanschrofer/data/test_file__2021-06-30.17:30:49.json
252
+ ```
253
+
254
+
199
255
  ## Float
200
256
 
201
257
  ```ruby
@@ -214,6 +270,49 @@ safe_to_i
214
270
  ```
215
271
 
216
272
 
273
+ ## Formatters
274
+
275
+ ```ruby
276
+
277
+ require "eitil_core/formatters"
278
+
279
+ ```
280
+
281
+ ```ruby
282
+ # require "eitil_core/formatters/sql"
283
+
284
+ Date.today.strfsql
285
+ # => "2021-06-23"
286
+
287
+ Date.today.strfsql(:date)
288
+ # => "2021-06-23"
289
+
290
+ DateTime.now.strfsql
291
+ # => "2021-06-23 13:15:37.945083"
292
+
293
+ DateTime.now.strfsql(:datetime)
294
+ # => "2021-06-23 13:15:37.945083"
295
+
296
+ DateTime.now.strfsql(:date)
297
+ # => "2021-06-23"
298
+
299
+ DateTime.now.strfsql(:time)
300
+ # => "13:16:23"
301
+
302
+ Time.now.strfsql
303
+ # => "13:16:23"
304
+
305
+ Time.now.strfsql(:datetime)
306
+ # => "2021-06-23 13:15:37.945083"
307
+
308
+ Time.now.strfsql(:date)
309
+ # => "2021-06-23"
310
+
311
+ Time.now.strfsql(:time)
312
+ # => "13:16:23"
313
+ ```
314
+
315
+
217
316
  ## Hash
218
317
 
219
318
  ```ruby
@@ -2,15 +2,18 @@
2
2
  # require "eitil_core"
3
3
 
4
4
  # core class patches
5
+ require "eitil_core/array"
5
6
  require "eitil_core/hash"
6
7
  require "eitil_core/float"
7
8
  require "eitil_core/datetime"
8
9
 
9
10
  # multi class patches
10
11
  require "eitil_core/type_checkers"
12
+ require "eitil_core/formatters"
11
13
  require "eitil_core/mocks"
12
14
 
13
15
  # rails class patches
16
+ require "eitil_core/active_record"
14
17
  require "eitil_core/application_record"
15
18
  require "eitil_core/application_controller"
16
19
 
@@ -22,4 +25,4 @@ require "eitil_core/setters"
22
25
  require "eitil_core/validations"
23
26
  require "eitil_core/lookups"
24
27
  require "eitil_core/concerns"
25
-
28
+ require "eitil_core/files"
@@ -0,0 +1,2 @@
1
+
2
+ require "eitil_core/active_record/hash_to_relation"
@@ -0,0 +1,27 @@
1
+
2
+ # require "eitil_core/active_record/hash_to_relation"
3
+
4
+ require "eitil_core/errors/raise_error"
5
+
6
+ class Array
7
+
8
+ def to_relation
9
+
10
+ return self unless self.present?
11
+
12
+ unless self.all? { |item| item.class.ancestors.include? ApplicationRecord }
13
+ raise_error "InvalidArrayError", ".to_relation requires that all array items are model instances"
14
+ end
15
+
16
+ unless self.each_cons(2).all? { |el1, el2| el1.class == el2.class }
17
+ raise_error "InvalidArrayError", ".to_relation requires that all array items are instances of the same model"
18
+ end
19
+
20
+ _class = self.first.class
21
+ ids = self.map(&:id)
22
+
23
+ return _class.where(id: ids)
24
+
25
+ end
26
+
27
+ end
@@ -1,2 +1,3 @@
1
1
 
2
2
  require "eitil_core/application_controller/slice_params"
3
+ require "eitil_core/application_controller/permit_model_atts"
@@ -0,0 +1,27 @@
1
+
2
+ # require "eitil_core/application_controller/permit_model_atts"
3
+
4
+ module ActionController
5
+ class Parameters
6
+
7
+ def permit_model_atts(*models, include: nil, except: nil)
8
+
9
+ models = models.is_a?(Array) ? models : [models]
10
+ except = except.is_a?(Array) ? except : [except]
11
+ include = include.is_a?(Array) ? include : [include]
12
+
13
+ columns = models.map do |model|
14
+ model.columns_hash.keys.map &:to_sym
15
+ end.flatten.uniq
16
+
17
+ default_reject = %i( id updated_at created_at )
18
+ given_reject = except.map { |key| key&.to_sym }
19
+ accepted_values = columns + include - default_reject - given_reject
20
+
21
+ return self.permit(*accepted_values)
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+
@@ -2,3 +2,4 @@
2
2
  require "eitil_core/application_record/where_like"
3
3
  require "eitil_core/application_record/find_by_like"
4
4
  require "eitil_core/application_record/all_associations"
5
+ require "eitil_core/application_record/model_atts"
@@ -0,0 +1,19 @@
1
+
2
+ # require "eitil_core/application_record/model_atts"
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 ModelAtts
10
+
11
+ def model_atts
12
+ columns = self.columns_hash.keys.map(&:to_sym)
13
+ reject = %i( id updated_at created_at )
14
+ columns - reject
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,2 @@
1
+
2
+ require "eitil_core/array/slice_hashes"
@@ -0,0 +1,18 @@
1
+
2
+ # require "eitil_core/array/slice_hashes"
3
+
4
+ class Array
5
+
6
+ def slice_hashes(*keys)
7
+
8
+ return self if self.empty?
9
+
10
+ unless self.all? { |item| item.is_a? Hash }
11
+ raise ArgumentError, "Array#slice_hashes requires that all array items are Hash instances"
12
+ end
13
+
14
+ self.map { |item| item.slice(*keys) }
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,2 @@
1
+
2
+ require "eitil_core/files/create_file"
@@ -0,0 +1,28 @@
1
+
2
+ # require "eitil_core/files/create_file"
3
+
4
+ Kernel.module_eval do
5
+
6
+ def create_file(file_name, data, directory: nil, suffix: nil, file_type: nil, append: false)
7
+
8
+ directory = directory || "#{Dir.home}/data"
9
+ suffix = suffix || DateTime.now.prettify
10
+ file_type = file_type || "json"
11
+
12
+ if file_type = "json"
13
+ data = JSON.pretty_generate(data)
14
+ end
15
+
16
+ path = "#{directory}/#{file_name}_#{suffix}.#{file_type}"
17
+
18
+ if append and Dir[path].present?
19
+ File.open(path, "a+") { |f| f << data }
20
+ return path
21
+ end
22
+
23
+ File.write(path, data)
24
+ return path
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,4 @@
1
+
2
+ # require "eitil_core/formatters"
3
+
4
+ require "eitil_core/formatters/sql"
@@ -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
+
@@ -21,6 +21,10 @@ module EitilCore
21
21
  ::ApplicationRecord.send(:extend, EitilCore::ApplicationRecord::AllAssociations)
22
22
  end
23
23
 
24
+ if Object.const_defined?('EitilCore::ApplicationRecord::ModelAtts')
25
+ ::ApplicationRecord.send(:extend, EitilCore::ApplicationRecord::ModelAtts)
26
+ end
27
+
24
28
  # ApplicationController
25
29
 
26
30
  if Object.const_defined?('EitilCore::ApplicationController::SliceParams')
@@ -1,3 +1,4 @@
1
1
 
2
2
  require "eitil_core/safe_executions/safe_send"
3
- require "eitil_core/safe_executions/safe_call"
3
+ require "eitil_core/safe_executions/safe_call"
4
+ require "eitil_core/safe_executions/safe_rescue"
@@ -0,0 +1,37 @@
1
+
2
+ # require "eitil_core/safe_executions/safe_rescue"
3
+
4
+ Kernel.module_eval do
5
+
6
+ # WORK IN PROCESS
7
+ # => accept a second block, prefarabbly not as proc, with code to be exceuted in case of rescue
8
+ # => or would it be possible to patch the 'rescue' keyword itself, so that we don't have to accept
9
+ # blocks as arguments?
10
+
11
+ def safe_rescue(error, &blk)
12
+
13
+ unless blk
14
+ raise ArgumentError, "a block should be passed"
15
+ end
16
+
17
+ unless error.is_a?(Class) or error.is_a?(String)
18
+ raise ArgumentError, "the given 'error' should either be a constant or string"
19
+ end
20
+
21
+ if error.is_a?(Class)
22
+ error_const = error
23
+
24
+ elsif error.is_a?(String) and Object.const_defined?(error)
25
+ error_const = error.constantize
26
+
27
+ elsif error.is_a?(String)
28
+ error_const = Object.const_set(error, Class.new(StandardError))
29
+
30
+ end
31
+
32
+ blk.call
33
+
34
+ rescue error_const
35
+ end
36
+
37
+ end
@@ -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
- def format_time_strings
14
- @hash.transform_values! { |array| array.map { |item| incomplete_time_string?(item) ? "#{item}:00" : item } }
15
- end
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
- sum = array.map { |item| ChronicDuration.parse(item) }.compact.sum
26
- hours = format_time(sum / (60 * 60))
27
- sum = sum % (60 * 60)
28
- minutes = format_time(sum / 60)
29
- seconds = format_time(sum % 60)
30
-
31
- # currently doesn't return seconds, since those will never
32
- # be set (?) and screw the consistency of data formatting
33
- ["#{hours}:#{minutes}"]
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,42 +4,78 @@
4
4
  module EitilIntegrate::RubyXL
5
5
  class ApplicationExporter
6
6
 
7
- private
7
+ private
8
8
 
9
- def log_state
9
+ def log_state
10
10
 
11
- return unless write_log == true
11
+ return unless write_log == true
12
12
 
13
- # create_log_sheet
14
- book.add_worksheet('log')
13
+ # create_log_sheet
14
+ book.add_worksheet('log')
15
15
 
16
- # manage sheets
17
- previous_sheet = @sheet.sheet_name
18
- @sheet = @book["log"]
16
+ # manage sheets
17
+ previous_sheet = @sheet.sheet_name
18
+ @sheet = @book["log"]
19
19
 
20
- # manage coordinates
21
- previous_x = @x
22
- @x = 0
20
+ # manage coordinates
21
+ previous_x = @x
22
+ @x = 0
23
23
 
24
- # log everything we want to log
25
- report_state
24
+ # log everything we want to log
25
+ report_state
26
26
 
27
- # restore what was previously active
28
- @sheet = @book[previous_sheet]
29
- @x = previous_x
27
+ # style logs
28
+ style_first_x_columns_width(1, 40)
29
+ style_first_column_bold
30
30
 
31
- end
31
+ # restore what was previously active
32
+ @sheet = @book[previous_sheet]
33
+ @x = previous_x
32
34
 
33
- def report_state
34
- instance_variables.each do |ivar|
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
35
70
 
36
- variable_name = ivar.to_s
37
- variable_value = instance_variable_get(ivar).to_s
71
+ elsif value_class == RubyXL::Worksheet
72
+ value_class.name
38
73
 
39
- array_to_row [variable_name, variable_value]
74
+ else
75
+ value.to_s
40
76
 
77
+ end
41
78
  end
42
- end
43
79
 
44
80
  end
45
81
  end
@@ -59,7 +59,7 @@ The Eitil jobs wrapper enables you to create perform_now and perform_later jobs
59
59
 
60
60
  The macro new_job accepts a :method as argument and defines a new method :method_job. The newly defined :method_job, when called, performs the orginal :method in the background. The new_job macro accepts both instance methods and singleton methods, which are defined within there own method scope.
61
61
 
62
- In contrast, the new_job_debugger macro defines a new :method_job_debugger method, which performs in the foreground.
62
+ In contrast, the new_job_now macro defines a new :method_job_now method, which performs in the foreground.
63
63
 
64
64
  ```ruby
65
65
  # require "eitil_wrapper/jobs/new_job"
@@ -70,11 +70,11 @@ new_job(_method, *args, **kwargs)
70
70
  ```
71
71
 
72
72
  ```ruby
73
- # require "eitil_wrapper/jobs/new_job_debugger"
73
+ # require "eitil_wrapper/jobs/new_job_now"
74
74
 
75
- new_job_debugger(_method, *args, **kwargs)
76
- # assuming a method :hello_world, call as: new_job_debugger :hello_world
77
- # => defines :hello_world_job_debugger
75
+ new_job_now(_method, *args, **kwargs)
76
+ # assuming a method :hello_world, call as: new_job_now :hello_world
77
+ # => defines :hello_world_job_now
78
78
  ```
79
79
 
80
80
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  require "eitil_wrapper/jobs/new_job"
3
- require "eitil_wrapper/jobs/new_job_debugger"
3
+ require "eitil_wrapper/jobs/new_job_now"
4
4
  require "eitil_wrapper/jobs/single_method_job"
@@ -1,5 +1,5 @@
1
1
 
2
- # require "eitil_wrapper/jobs/new_job_debugger"
2
+ # require "eitil_wrapper/jobs/new_job_now"
3
3
 
4
4
  require "eitil_wrapper/jobs/single_method_job"
5
5
 
@@ -14,10 +14,10 @@ Kernel.module_eval do
14
14
  # being that 'id' works for objects that have a database record, while '_self'
15
15
  # works for non database supported instanes, such as an Exporter instance.
16
16
 
17
- def new_job_debugger(_method, *args, **kwargs)
17
+ def new_job_now(_method, *args, **kwargs)
18
18
 
19
19
  if instance_methods(false).include? _method
20
- define_method "#{_method}_job_debugger" do |_self = nil, *args, **kwargs|
20
+ define_method "#{_method}_job_now" do |_self = nil, *args, **kwargs|
21
21
 
22
22
  EitilWrapper::SingleMethodJob.perform_now(
23
23
  *args, _class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json, **kwargs
@@ -25,7 +25,7 @@ Kernel.module_eval do
25
25
  end
26
26
 
27
27
  elsif singleton_methods(false).include? _method
28
- define_singleton_method "#{_method}_job_debugger" do |*args, **kwargs|
28
+ define_singleton_method "#{_method}_job_now" do |*args, **kwargs|
29
29
 
30
30
  EitilWrapper::SingleMethodJob.perform_now(
31
31
  *args, _class: to_s, _method: _method.to_s, **kwargs
@@ -36,7 +36,20 @@ module EitilWrapper
36
36
  else
37
37
  _class.constantize
38
38
  end
39
- object.send _method, *args, **kwargs
39
+
40
+ if args.present? and kwargs.present?
41
+ object.send _method, *args, **kwargs
42
+
43
+ elsif args.present?
44
+ object.send _method, *args
45
+
46
+ elsif kwargs.present?
47
+ object.send _method, **kwargs
48
+
49
+ else
50
+ object.send _method
51
+ end
52
+
40
53
  end; end; end; end
41
54
 
42
55
 
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/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eitil
2
2
 
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.7'
4
4
 
5
5
  end
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.2
4
+ version: 1.1.7
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-23 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -82,11 +82,15 @@ files:
82
82
  - Rakefile
83
83
  - eitil_core/README.md
84
84
  - eitil_core/lib/eitil_core.rb
85
+ - eitil_core/lib/eitil_core/active_record.rb
86
+ - eitil_core/lib/eitil_core/active_record/hash_to_relation.rb
85
87
  - eitil_core/lib/eitil_core/application_controller.rb
88
+ - eitil_core/lib/eitil_core/application_controller/permit_model_atts.rb
86
89
  - eitil_core/lib/eitil_core/application_controller/slice_params.rb
87
90
  - eitil_core/lib/eitil_core/application_record.rb
88
91
  - eitil_core/lib/eitil_core/application_record/all_associations.rb
89
92
  - eitil_core/lib/eitil_core/application_record/find_by_like.rb
93
+ - eitil_core/lib/eitil_core/application_record/model_atts.rb
90
94
  - eitil_core/lib/eitil_core/application_record/where_like.rb
91
95
  - eitil_core/lib/eitil_core/argument_helpers.rb
92
96
  - eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars.rb
@@ -97,14 +101,20 @@ files:
97
101
  - eitil_core/lib/eitil_core/argument_helpers/args_to_h_bang.rb
98
102
  - eitil_core/lib/eitil_core/argument_helpers/args_to_ivars.rb
99
103
  - eitil_core/lib/eitil_core/argument_helpers/args_to_ivars_bang.rb
104
+ - eitil_core/lib/eitil_core/array.rb
105
+ - eitil_core/lib/eitil_core/array/slice_hashes.rb
100
106
  - eitil_core/lib/eitil_core/concerns.rb
101
107
  - eitil_core/lib/eitil_core/concerns/include_concerns_of.rb
102
108
  - eitil_core/lib/eitil_core/datetime.rb
103
109
  - eitil_core/lib/eitil_core/datetime/prettify.rb
104
110
  - eitil_core/lib/eitil_core/errors.rb
105
111
  - eitil_core/lib/eitil_core/errors/raise_error.rb
112
+ - eitil_core/lib/eitil_core/files.rb
113
+ - eitil_core/lib/eitil_core/files/create_file.rb
106
114
  - eitil_core/lib/eitil_core/float.rb
107
115
  - eitil_core/lib/eitil_core/float/safe_to_i.rb
116
+ - eitil_core/lib/eitil_core/formatters.rb
117
+ - eitil_core/lib/eitil_core/formatters/sql.rb
108
118
  - eitil_core/lib/eitil_core/hash.rb
109
119
  - eitil_core/lib/eitil_core/hash/auto_dig.rb
110
120
  - eitil_core/lib/eitil_core/lookups.rb
@@ -117,6 +127,7 @@ files:
117
127
  - eitil_core/lib/eitil_core/railtie.rb
118
128
  - eitil_core/lib/eitil_core/safe_executions.rb
119
129
  - eitil_core/lib/eitil_core/safe_executions/safe_call.rb
130
+ - eitil_core/lib/eitil_core/safe_executions/safe_rescue.rb
120
131
  - eitil_core/lib/eitil_core/safe_executions/safe_send.rb
121
132
  - eitil_core/lib/eitil_core/setters.rb
122
133
  - eitil_core/lib/eitil_core/setters/set_ivars.rb
@@ -169,7 +180,7 @@ files:
169
180
  - eitil_wrapper/lib/eitil_wrapper/decorators/controller_decorator.rb
170
181
  - eitil_wrapper/lib/eitil_wrapper/jobs.rb
171
182
  - eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb
172
- - eitil_wrapper/lib/eitil_wrapper/jobs/new_job_debugger.rb
183
+ - eitil_wrapper/lib/eitil_wrapper/jobs/new_job_now.rb
173
184
  - eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb
174
185
  - eitil_wrapper/lib/eitil_wrapper/railtie.rb
175
186
  - eitil_wrapper/lib/eitil_wrapper/request_logger.rb