eitil 1.0.1.e.4 → 1.0.4
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 +93 -4
- data/eitil_core/lib/eitil_core.rb +1 -0
- 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_core/lib/eitil_core/mocks.rb +6 -0
- data/eitil_core/lib/eitil_core/mocks/array.rb +39 -0
- data/eitil_core/lib/eitil_core/mocks/hash.rb +36 -0
- data/eitil_core/lib/eitil_core/mocks/string.rb +11 -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 +62 -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: 2bf167d056adee32eeba94ac5282d6a9890575a309c775bd53da822f4817501e
|
4
|
+
data.tar.gz: '08bbebecb6e9d84567d522d9c7b62e23ff8b3a6e3b3b1fee5639a58aa9f6bc68'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cab736bd8a72ba50468f017d91f12fabe1a8a8887bb892797c7466296227fb763e413a5ae372c535ef134963181414ac8ef3d7cae497d708b178f05a93c03ce1
|
7
|
+
data.tar.gz: dc057b62c574bea1b96e4074c9af724cf3ad59d957f9a62790cbe63ec998503c1ae1a1b5f253388d293ab1bfb5eeeb41b7f247dc61e1b635dacadc7bf644ddd0
|
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,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
|
@@ -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
|
@@ -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
|
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
|