eitil 1.0.1.e.3 → 1.0.3
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 +60 -4
- data/eitil_core/lib/eitil_core/argument_helpers.rb +8 -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_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_bang.rb +15 -0
- data/eitil_core/lib/eitil_core/float/safe_to_i.rb +3 -0
- data/eitil_core/lib/eitil_core/lookups.rb +2 -1
- data/eitil_core/lib/eitil_core/lookups/gem_path.rb +10 -0
- data/eitil_integrate/README.md +11 -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_support/lib/eitil_support/directory/lookups.rb +3 -0
- data/lib/eitil.rb +0 -1
- data/lib/eitil/all.rb +2 -3
- data/lib/eitil/railtie.rb +28 -1
- data/lib/eitil/version.rb +1 -1
- metadata +58 -6
- data/lib/eitil/engine.rb +0 -38
- data/lib/tasks/eitil_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb62fad1bf470c019f2d9135d57d1089dcfe66d9d68c615238971bd13de64093
|
4
|
+
data.tar.gz: 23cfaf9d5b62e8eb7ee6b84e30b8eb31443ca8225eabb3273d7f9fe068c73077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21259ffe29a2251548cef05d8732050c46b5553cdba93b1bc71a9558ac4db71f313158e113fa1a69988b2647169dfa5637036bb7baeabe71352ebd7d5bae096c
|
7
|
+
data.tar.gz: 7a4ad7b5b53b8f262070a82342b35caec497be066ed01b3ac929cb078f20e3ef3afbaec85ec2f3ad3db8ede6301e7d9555fa94a41d9bf2c85f8a63f6ee24990a
|
data/Rakefile
CHANGED
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/
|
79
|
+
# require "eitil_core/argument_helpers/all_args_to_ivars_bang"
|
80
80
|
|
81
|
-
|
82
|
-
#
|
83
|
-
#
|
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,16 @@ 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
|
+
|
206
262
|
## SafeExecutions
|
207
263
|
|
208
264
|
```ruby
|
@@ -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
|
data/eitil_integrate/README.md
CHANGED
@@ -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.
|
@@ -0,0 +1,22 @@
|
|
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
|
+
|
21
|
+
# the AutoSum module, which is a seperately functioning module (service)
|
22
|
+
require_relative "application_exporter/auto_sum"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum"
|
3
|
+
|
4
|
+
require_relative "auto_sum/initialize"
|
5
|
+
|
6
|
+
require_relative "auto_sum/drop_data"
|
7
|
+
require_relative "auto_sum/format_data"
|
8
|
+
require_relative "auto_sum/reduce_data"
|
9
|
+
require_relative "auto_sum/sum_data"
|
10
|
+
require_relative "auto_sum/present_data"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum/drop_data"
|
3
|
+
|
4
|
+
module EitilIntegrate::RubyXL
|
5
|
+
module AutoSum
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def drop_data
|
9
|
+
# since excel layout consistency requires stringified values, we first need
|
10
|
+
# to convert strings back to floats.
|
11
|
+
try_float_conversion
|
12
|
+
|
13
|
+
# after the required conversions, drop all values that should not be accepted.
|
14
|
+
drop_nil_values
|
15
|
+
drop_empty_values
|
16
|
+
drop_non_accepted_values
|
17
|
+
end
|
18
|
+
|
19
|
+
def try_float_conversion
|
20
|
+
@hash.transform_values! { |array| array.map { |item| item.is_num? ? item.to_f : item } }
|
21
|
+
end
|
22
|
+
|
23
|
+
def drop_nil_values
|
24
|
+
@hash.transform_values! &:compact
|
25
|
+
end
|
26
|
+
|
27
|
+
def drop_empty_values
|
28
|
+
@hash.transform_values! { |array| array.reject { |item| item.safe_send :empty? } }
|
29
|
+
end
|
30
|
+
|
31
|
+
def drop_non_accepted_values
|
32
|
+
@hash.transform_values! { |array| array.reject { |item| !accepted_value? item } }
|
33
|
+
end
|
34
|
+
|
35
|
+
def accepted_value?(value)
|
36
|
+
@value = value
|
37
|
+
value_is_a_int || value_is_a_float || value_is_a_time_string
|
38
|
+
end
|
39
|
+
|
40
|
+
def value_is_a_int
|
41
|
+
@value.is_a? Integer
|
42
|
+
end
|
43
|
+
|
44
|
+
def value_is_a_float
|
45
|
+
@value.is_a? Float
|
46
|
+
end
|
47
|
+
|
48
|
+
def value_is_a_time_string
|
49
|
+
@value.scan(/\d{2}:\d{2}:\d{2}/).first || @value.scan(/\d{2}:\d{2}/).first
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum/format_data"
|
3
|
+
|
4
|
+
module EitilIntegrate::RubyXL
|
5
|
+
module AutoSum
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def format_data
|
9
|
+
format_time_strings
|
10
|
+
format_ints_to_floats
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_time_strings
|
14
|
+
@hash.transform_values! { |array| array.map { |item| incomplete_time_string?(item) ? "#{item}:00" : item } }
|
15
|
+
end
|
16
|
+
|
17
|
+
def incomplete_time_string?(string)
|
18
|
+
string.is_a?(String) && string.length == 5 && string.scan(/\d{2}:\d{2}/)
|
19
|
+
end
|
20
|
+
|
21
|
+
def format_ints_to_floats
|
22
|
+
@hash.transform_values! { |array| array.map { |item| item.is_a?(Integer) ? item.to_f : item } }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum/initialize"
|
3
|
+
|
4
|
+
module EitilIntegrate::RubyXL
|
5
|
+
module AutoSum
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def perform(hashed_excel)
|
9
|
+
@hash = hashed_excel
|
10
|
+
|
11
|
+
drop_data
|
12
|
+
format_data
|
13
|
+
reduce_data
|
14
|
+
sum_data
|
15
|
+
present_data
|
16
|
+
|
17
|
+
@hash
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum/present_data"
|
3
|
+
|
4
|
+
module EitilIntegrate::RubyXL
|
5
|
+
module AutoSum
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# As final step, prepare the data for the excel file, according to formatting requirements.
|
9
|
+
|
10
|
+
def present_data
|
11
|
+
transform_floats_to_integers
|
12
|
+
transform_values_to_strings
|
13
|
+
set_title
|
14
|
+
end
|
15
|
+
|
16
|
+
def transform_floats_to_integers
|
17
|
+
@hash.transform_values! { |value| value.is_a?(Float) ? value.safe_to_i.round(3) : value }
|
18
|
+
end
|
19
|
+
|
20
|
+
def transform_values_to_strings
|
21
|
+
@hash.transform_values! { |value| value&.to_s }
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_title
|
25
|
+
# @hash[0] = 'Totaal' unless @hash[0]
|
26
|
+
@hash[0] = 'Totaal'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
# require "eitil_integrate/application_exporter/auto_sum/reduce_data"
|
3
|
+
|
4
|
+
module EitilIntegrate::RubyXL
|
5
|
+
module AutoSum
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def reduce_data
|
9
|
+
drop_multi_class_arrays
|
10
|
+
end
|
11
|
+
|
12
|
+
def drop_multi_class_arrays
|
13
|
+
@hash.transform_values! { |array| array.map(&:class).uniq.length == 1 ? array : [] }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|