eitil 1.0.1 → 1.1.0

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -1
  3. data/eitil_core/README.md +93 -4
  4. data/eitil_core/lib/eitil_core.rb +1 -0
  5. data/eitil_core/lib/eitil_core/application_controller/slice_params.rb +3 -0
  6. data/eitil_core/lib/eitil_core/application_record/all_associations.rb +3 -0
  7. data/eitil_core/lib/eitil_core/application_record/find_by_like.rb +3 -0
  8. data/eitil_core/lib/eitil_core/application_record/where_like.rb +3 -0
  9. data/eitil_core/lib/eitil_core/argument_helpers.rb +8 -0
  10. data/eitil_core/lib/eitil_core/argument_helpers/all_args_to_ivars_bang.rb +15 -0
  11. data/eitil_core/lib/eitil_core/argument_helpers/all_kwargs_to_ivars_bang.rb +15 -0
  12. data/eitil_core/lib/eitil_core/argument_helpers/args_to_h.rb +15 -0
  13. data/eitil_core/lib/eitil_core/argument_helpers/args_to_h_bang.rb +17 -0
  14. data/eitil_core/lib/eitil_core/argument_helpers/args_to_ivars_bang.rb +15 -0
  15. data/eitil_core/lib/eitil_core/float/safe_to_i.rb +3 -0
  16. data/eitil_core/lib/eitil_core/lookups.rb +2 -1
  17. data/eitil_core/lib/eitil_core/lookups/gem_path.rb +10 -0
  18. data/eitil_core/lib/eitil_core/mocks.rb +6 -0
  19. data/eitil_core/lib/eitil_core/mocks/array.rb +39 -0
  20. data/eitil_core/lib/eitil_core/mocks/hash.rb +36 -0
  21. data/eitil_core/lib/eitil_core/mocks/string.rb +11 -0
  22. data/eitil_core/lib/eitil_core/railtie.rb +0 -3
  23. data/eitil_integrate/README.md +11 -0
  24. data/eitil_integrate/lib/eitil_integrate.rb +4 -0
  25. data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +22 -0
  26. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb +10 -0
  27. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb +54 -0
  28. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +27 -0
  29. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb +22 -0
  30. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb +31 -0
  31. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb +18 -0
  32. data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +56 -0
  33. data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +43 -0
  34. data/eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb +50 -0
  35. data/eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb +20 -0
  36. data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +28 -0
  37. data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +40 -0
  38. data/eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb +58 -0
  39. data/eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb +27 -0
  40. data/eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb +34 -0
  41. data/eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb +97 -0
  42. data/eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb +28 -0
  43. data/eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb +78 -0
  44. data/eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb +18 -0
  45. data/eitil_integrate/lib/eitil_integrate/railtie.rb +0 -3
  46. data/eitil_store/lib/eitil_store/railtie.rb +0 -3
  47. data/eitil_support/lib/eitil_support/directory/lookups.rb +3 -0
  48. data/eitil_support/lib/eitil_support/railtie.rb +0 -3
  49. data/eitil_wrapper/README.md +16 -0
  50. data/eitil_wrapper/lib/eitil_wrapper.rb +2 -1
  51. data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +3 -0
  52. data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +24 -7
  53. data/eitil_wrapper/lib/eitil_wrapper/request_logger.rb +5 -0
  54. data/eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb +48 -0
  55. data/eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb +17 -0
  56. data/eitil_wrapper/lib/eitil_wrapper/scopes/default_scopes.rb +6 -0
  57. data/lib/eitil.rb +0 -1
  58. data/lib/eitil/all.rb +5 -5
  59. data/lib/eitil/railtie.rb +28 -1
  60. data/lib/eitil/version.rb +1 -1
  61. metadata +63 -4
  62. data/lib/eitil/engine.rb +0 -38
  63. data/lib/tasks/eitil_tasks.rake +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc43b6cd9707424c178a28ad387d5cd144da66c9b4c213b767681c7e4d2b2d2a
4
- data.tar.gz: b0b29f5ee309257e820b53406e8e8285e7107ea89f9519d018c30b2e4ca7e411
3
+ metadata.gz: da8ee05892ab05d923342f6ed43e13665bba39fb04cf896bb74f1914892252fd
4
+ data.tar.gz: 372286a8ac0c7c01d0c33e7f37b6335a8045834e31e31e0a93a4ddbc1656d882
5
5
  SHA512:
6
- metadata.gz: 360ce038ad78851c9a3f20f798bbc6dacd3a30a2dd9be73f097b3b08f72f1d513c4b3154f79842ece02ae872147be6ec9a8594641e209471827579dbed802d86
7
- data.tar.gz: c823a9649a75e6db7bc31b5d91d60a2497d34ebf171c104e5fb2dcdda9926b70543cdd7be4d5a38c63cfa366ae9e3f679017aee1897834797e330817034aabe9
6
+ metadata.gz: 5c1dddb52e1efcb4eb8272050792fd81ec9f4281b46bafb444bece9ba0c54c1407d5f78c6ea8354760093680c3a7546c76bd7591185f4628394b4974df0e4634
7
+ data.tar.gz: 0d69428c5db0e7aea257d0a85fb8a658bae7789672718bbcadea24b11b9089faa2979d3fee67fb02176663685e17c2c1e124aa4bcf63bbe867e124ffe7cf5343
data/Rakefile CHANGED
@@ -1,7 +1,6 @@
1
1
  require "bundler/setup"
2
2
 
3
3
  APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
- load "rails/tasks/engine.rake"
5
4
 
6
5
  load "rails/tasks/statistics.rake"
7
6
 
data/eitil_core/README.md CHANGED
@@ -76,11 +76,11 @@ all_args_to_ivars(binding)
76
76
 
77
77
 
78
78
  ```ruby
79
- # require "eitil_core/argument_helpers/args_to_ivars"
79
+ # require "eitil_core/argument_helpers/all_args_to_ivars_bang"
80
80
 
81
- args_to_ivars(binding, *local_vars)
82
- # sets specified keywords arguments of the method's local binding to instance variables
83
- # call as: all_args_to_ivars binding :user_id, :user_name
81
+ all_args_to_ivars!
82
+ # works the same as .all_args_to_ivars, except that passing the binding is no longer required
83
+ # production usage is discouraged by the creator of the supporting gem
84
84
  ```
85
85
 
86
86
 
@@ -94,6 +94,52 @@ all_kwargs_to_ivars(local_binding, namespace= :kwargs)
94
94
  ```
95
95
 
96
96
 
97
+ ```ruby
98
+ # require "eitil_core/argument_helpers/all_kwargs_to_ivars_bang"
99
+
100
+ all_kwargs_to_ivars!(namespace= :kwargs)
101
+ # works the same as .all_kwargs_to_ivars, except that passing the binding is no longer required
102
+ # production usage is discouraged by the creator of the supporting gem
103
+ ```
104
+
105
+
106
+ ```ruby
107
+ # require "eitil_core/argument_helpers/args_to_h"
108
+
109
+ args_to_h(binding, *local_vars)
110
+ # creates a hash, with a given local_var as keys and its value as value
111
+ # call as: args_to_h(binding, :username, :password)
112
+ # => { username: 'jurriaan', password: 'matz_is_nice' }
113
+ ```
114
+
115
+
116
+ ```ruby
117
+ # require "eitil_core/argument_helpers/args_to_h_bang"
118
+
119
+ args_to_h!(*local_vars)
120
+ # works the same as .args_to_h, except that passing the binding is no longer required
121
+ # production usage is discouraged by the creator of the supporting gem
122
+ ```
123
+
124
+
125
+ ```ruby
126
+ # require "eitil_core/argument_helpers/args_to_ivars"
127
+
128
+ args_to_ivars(binding, *local_vars)
129
+ # sets specified keywords arguments of the method's local binding to instance variables
130
+ # call as: all_args_to_ivars binding :user_id, :user_name
131
+ ```
132
+
133
+
134
+ ```ruby
135
+ # require "eitil_core/argument_helpers/args_to_ivars_bang"
136
+
137
+ args_to_ivars!(*local_vars)
138
+ # works the same as .args_to_ivars, except that passing the binding is no longer required
139
+ # production usage is discouraged by the creator of the supporting gem
140
+ ```
141
+
142
+
97
143
  ## Concerns
98
144
 
99
145
  ```ruby
@@ -203,6 +249,49 @@ all_methods(include_ancestors = true, grep: nil)
203
249
  ```
204
250
 
205
251
 
252
+ ```ruby
253
+ # require "eitil_core/lookups/gem_path"
254
+
255
+ Find.gem_path(gem_name)
256
+ # finds the root of an installed gem, allowing you to traverse its paths from there.
257
+ # call as: Find.gem_path("rails")
258
+ # => "/Users/jurriaanschrofer/.rvm/gems/ruby-2.6.5/gems/rails-5.2.3"
259
+ ```
260
+
261
+
262
+ ## Mocks
263
+
264
+ ```ruby
265
+
266
+ require "eitil_core/mocks"
267
+
268
+ ```
269
+
270
+ ```ruby
271
+ # require "eitil_core/mocks/string"
272
+
273
+ String.mock(n=25)
274
+ # String.mock(10) # ==> "oooooo c nnnnnnnnnn ttttttttt p kkk r ppppp rrrrrrr uuu"
275
+ ```
276
+
277
+ ```ruby
278
+ # require "eitil_core/mocks/array"
279
+
280
+ Array.mock(n=10, type=Integer, &block)
281
+ # Array.mock # ==> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
282
+ # Array.mock(10, Float) #==> [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
283
+ # Built-in methods are provided for classes Integer, Float, String, Date, Time
284
+ # But any other class is accepted as well, also your own classes such as User, Shift and Environment
285
+ ```
286
+
287
+ ```ruby
288
+ # require "eitil_core/mocks/hash"
289
+
290
+ Hash.mock(n=10)
291
+ # Hash.mock(10) #==> {"a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5, "f"=>6, "g"=>7, "h"=>8, "i"=>9, "j"=>10}
292
+ ```
293
+
294
+
206
295
  ## SafeExecutions
207
296
 
208
297
  ```ruby
@@ -8,6 +8,7 @@ require "eitil_core/datetime"
8
8
 
9
9
  # multi class patches
10
10
  require "eitil_core/type_checkers"
11
+ require "eitil_core/mocks"
11
12
 
12
13
  # rails class patches
13
14
  require "eitil_core/application_record"
@@ -1,6 +1,9 @@
1
1
 
2
2
  # require "eitil_core/application_controller/slice_params"
3
3
 
4
+ # require "eitil_core/railtie" to run the dynamic dispatch as an init hook during boot
5
+ require "eitil_core/railtie"
6
+
4
7
  module EitilCore
5
8
  module ApplicationController
6
9
  module SliceParams
@@ -1,6 +1,9 @@
1
1
 
2
2
  # require "eitil_core/application_record/all_associations"
3
3
 
4
+ # require "eitil_core/railtie" to run the dynamic dispatch as an init hook during boot
5
+ require "eitil_core/railtie"
6
+
4
7
  module EitilCore
5
8
  module ApplicationRecord
6
9
  module AllAssociations
@@ -1,6 +1,9 @@
1
1
 
2
2
  # require "eitil_core/application_record/find_by_like"
3
3
 
4
+ # require "eitil_core/railtie" to run the dynamic dispatch as an init hook during boot
5
+ require "eitil_core/railtie"
6
+
4
7
  module EitilCore
5
8
  module ApplicationRecord
6
9
  module FindByLike
@@ -1,6 +1,9 @@
1
1
 
2
2
  # require "eitil_core/application_record/where_like"
3
3
 
4
+ # require "eitil_core/railtie" to run the dynamic dispatch as an init hook during boot
5
+ require "eitil_core/railtie"
6
+
4
7
  module EitilCore
5
8
  module ApplicationRecord
6
9
  module WhereLike
@@ -1,5 +1,13 @@
1
1
  # require "eitil_core/arugment_helpers"
2
2
 
3
3
  require "eitil_core/argument_helpers/all_args_to_ivars"
4
+ require "eitil_core/argument_helpers/all_args_to_ivars_bang"
5
+
4
6
  require "eitil_core/argument_helpers/args_to_ivars"
7
+ require "eitil_core/argument_helpers/args_to_ivars_bang"
8
+
9
+ require "eitil_core/argument_helpers/args_to_h"
10
+ require "eitil_core/argument_helpers/args_to_h_bang"
11
+
5
12
  require "eitil_core/argument_helpers/all_kwargs_to_ivars"
13
+ require "eitil_core/argument_helpers/all_kwargs_to_ivars_bang"
@@ -0,0 +1,15 @@
1
+
2
+ # require "eitil_core/argument_helpers/all_args_to_ivars_bang"
3
+
4
+ require "eitil_core/lookups/gem_path"
5
+ require "#{Find.gem_path('binding_of_caller')}/lib/binding_of_caller/mri.rb"
6
+
7
+ Kernel.module_eval do
8
+
9
+ def all_args_to_ivars!
10
+ binding.of_caller(1).local_variables.each do |lvar|
11
+ instance_variable_set("@#{lvar}", binding.of_caller(2).local_variable_get(lvar))
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+
2
+ # require "eitil_core/argument_helpers/all_kwargs_to_ivars_bang"
3
+
4
+ require "eitil_core/lookups/gem_path"
5
+ require "#{Find.gem_path('binding_of_caller')}/lib/binding_of_caller/mri.rb"
6
+
7
+ Kernel.module_eval do
8
+
9
+ def all_kwargs_to_ivars!(namespace=:kwargs)
10
+ binding.of_caller(1).local_variable_get(namespace).each do |name, value|
11
+ instance_variable_set "@#{name}", value
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+
2
+ # require "eitil_core/argument_helpers/args_to_h"
3
+
4
+ Kernel.module_eval do
5
+
6
+ def args_to_h(local_binding, *local_vars)
7
+
8
+ local_vars.reject { |lvar| lvar == local_binding }
9
+ .reject { |lvar| lvar.to_s.starts_with?('_') }
10
+ .map { |lvar| { "#{lvar}": local_binding.local_variable_get(lvar) } }
11
+ .inject &:merge
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,17 @@
1
+
2
+ # require "eitil_core/argument_helpers/args_to_h_bang"
3
+
4
+ require "eitil_core/lookups/gem_path"
5
+ require "#{Find.gem_path('binding_of_caller')}/lib/binding_of_caller/mri.rb"
6
+
7
+ Kernel.module_eval do
8
+
9
+ def args_to_h!(*local_vars)
10
+
11
+ local_vars.reject { |lvar| lvar.to_s.starts_with?('_') }
12
+ .map { |lvar| { "#{lvar}": binding.of_caller(2).local_variable_get(lvar) } }
13
+ .inject &:merge
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+
2
+ # require "eitil_core/argument_helpers/args_to_ivars_bang"
3
+
4
+ require "eitil_core/lookups/gem_path"
5
+ require "#{Find.gem_path('binding_of_caller')}/lib/binding_of_caller/mri.rb"
6
+
7
+ Kernel.module_eval do
8
+
9
+ def args_to_ivars!(*local_vars)
10
+ local_vars.each do |lvar|
11
+ instance_variable_set("@#{lvar}", binding.of_caller(2).local_variable_get(lvar))
12
+ end
13
+ end
14
+
15
+ end
@@ -1,3 +1,6 @@
1
+
2
+ # require "eitil_core/float/safe_to_i"
3
+
1
4
  class Float
2
5
 
3
6
  # converts a float to an integer, only when no decimal values are lost.
@@ -1,2 +1,3 @@
1
1
 
2
- require "eitil_core/lookups/all_methods"
2
+ require "eitil_core/lookups/all_methods"
3
+ require "eitil_core/lookups/gem_path"
@@ -0,0 +1,10 @@
1
+
2
+ # require "eitil_core/lookups/gem_path"
3
+
4
+ module Find
5
+
6
+ def self.gem_path(gem_name)
7
+ Gem.loaded_specs[gem_name].full_gem_path
8
+ end
9
+
10
+ end
@@ -0,0 +1,6 @@
1
+
2
+ # require "eitil_core/mocks"
3
+
4
+ require "eitil_core/mocks/array"
5
+ require "eitil_core/mocks/hash"
6
+ require "eitil_core/mocks/string"
@@ -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
@@ -0,0 +1,11 @@
1
+
2
+ # require "eitil_core/mocks/string"
3
+
4
+ class String
5
+
6
+ def self.mock(n=25)
7
+ alphabet = ('a'..'z').to_a
8
+ n.times.map { alphabet.sample * rand(1..10) } * ' '
9
+ end
10
+
11
+ end
@@ -1,7 +1,4 @@
1
1
 
2
- require "rails"
3
- require "eitil_core"
4
-
5
2
  module EitilCore
6
3
 
7
4
  class Railtie < Rails::Railtie
@@ -6,3 +6,14 @@
6
6
  EitilIntegrate provides seamless integrations with select gems and API's, through helper methods stored in PORO's.
7
7
 
8
8
 
9
+ ## EitilIntegrate::RubyXL::ApplicationExporter
10
+
11
+ ```ruby
12
+
13
+ require "eitil_integrate/application_exporter"
14
+
15
+ ```
16
+
17
+ EitilIntegrate::RubyXL::ApplicationExporter provides an extensive wrapper around the RubyXL gem, and can be used by setting it as the superclass of your application's exporter classes.
18
+
19
+ Since the functionality is diverse and changing, you can best look at the source code files for the options and methods.