eitil 2.0.3 → 2.0.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.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/eitil/all.rb +0 -1
- data/lib/eitil/railtie.rb +1 -1
- data/lib/eitil/version.rb +1 -1
- data/spec/dummy_app/app/models/user.rb +0 -25
- data/spec/spec_helper.rb +0 -2
- metadata +2 -30
- data/eitil_integrate/README.md +0 -19
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb +0 -63
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb +0 -30
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb +0 -22
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb +0 -31
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb +0 -18
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb +0 -84
- data/eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb +0 -10
- data/eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb +0 -44
- data/eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb +0 -50
- data/eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb +0 -20
- data/eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb +0 -32
- data/eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb +0 -81
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +0 -50
- data/eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb +0 -58
- data/eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb +0 -27
- data/eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb +0 -34
- data/eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb +0 -104
- data/eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb +0 -28
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb +0 -78
- data/eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb +0 -18
- data/eitil_integrate/lib/eitil_integrate/application_exporter.rb +0 -23
- data/eitil_integrate/lib/eitil_integrate/railtie.rb +0 -7
- data/eitil_integrate/lib/eitil_integrate.rb +0 -4
- data/spec/eitil_wrapper/callbacks/helper_methods_spec.rb +0 -34
- data/spec/eitil_wrapper/jobs/single_method_job_spec.rb +0 -72
- data/spec/eitil_wrapper/routes/extended_resources_spec.rb +0 -16
- data/spec/eitil_wrapper/scopes/default_scopes_spec.rb +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4beb8f9bfd939bb2015a9e742271f2f7df0ae8c69a640f243635ff2ad7f25fc9
|
4
|
+
data.tar.gz: 61c9cd613c6a365d62e75c768c6293534ce30deba2f4099d7b003f0d5c97991d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9168dbc018c1f5a50fa3130fe44e8f9c13f2fd235c2148bdfce526439abf1a0e4d70688fbc040d6c5f72207559343b8f5e0f10f4c118cb930d2f27a1f5a4b76a
|
7
|
+
data.tar.gz: 945012264b1d857dfea4f1fc5a923da2d1239f57b4a915700ebfd917f389a6dba7481ba80c8088601927f9361a0bdb3a2a6f1f14300a2a8ee0ab9a59d75f10dc
|
data/README.md
CHANGED
@@ -13,7 +13,6 @@ Our gem currently exists of five seperate layers (Railties), which can be integr
|
|
13
13
|
- EitilCore, [docs](/eitil_core) > extends the core classes of Ruby and rails.
|
14
14
|
- EitilSupport, [docs](/eitil_support) > provides utility through stand-alone classes and modules.
|
15
15
|
- EitilStore, [docs](/eitil_store) > stores data in containers, such as Regexp instances.
|
16
|
-
- EitilIntegrate, [docs](/eitil_integrate) > provides seamless integrations with select gems and API's, through helper methods stored in PORO's.
|
17
16
|
|
18
17
|
|
19
18
|
|
data/lib/eitil/all.rb
CHANGED
data/lib/eitil/railtie.rb
CHANGED
data/lib/eitil/version.rb
CHANGED
@@ -2,29 +2,4 @@ class User < ApplicationRecord
|
|
2
2
|
|
3
3
|
has_one :address
|
4
4
|
|
5
|
-
# ---
|
6
|
-
# below are methods, used for testing EitilWrapper::Jobs
|
7
|
-
|
8
|
-
def self.this_is_a_singleton_method(positional_value = nil, keyword_value: nil)
|
9
|
-
"this is a singleton method"
|
10
|
-
return positional_value if positional_value
|
11
|
-
return keyword_value if keyword_value
|
12
|
-
return nil
|
13
|
-
end
|
14
|
-
|
15
|
-
new_job :this_is_a_singleton_method
|
16
|
-
new_job_now :this_is_a_singleton_method
|
17
|
-
|
18
|
-
def this_is_an_instance_method(positional_value = nil, keyword_value: nil)
|
19
|
-
"this is an instance method"
|
20
|
-
return positional_value if positional_value
|
21
|
-
return keyword_value if keyword_value
|
22
|
-
return nil
|
23
|
-
end
|
24
|
-
|
25
|
-
new_job :this_is_an_instance_method
|
26
|
-
new_job_now :this_is_an_instance_method
|
27
|
-
|
28
|
-
# ---
|
29
|
-
|
30
5
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,12 +7,10 @@ require 'eitil'
|
|
7
7
|
# Eventually implement specs for all layers.
|
8
8
|
|
9
9
|
require "eitil_core/railtie"
|
10
|
-
require "eitil_integrate/railtie"
|
11
10
|
# require "eitil_store/railtie"
|
12
11
|
# require "eitil_support/railtie"
|
13
12
|
|
14
13
|
require "eitil_core"
|
15
|
-
require "eitil_integrate"
|
16
14
|
# require "eitil_store"
|
17
15
|
# require "eitil_support"
|
18
16
|
|
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: 2.0.
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2021-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -231,30 +231,6 @@ files:
|
|
231
231
|
- eitil_core/lib/eitil_core/type_checkers/is_num_or_nan.rb
|
232
232
|
- eitil_core/lib/eitil_core/validations.rb
|
233
233
|
- eitil_core/lib/eitil_core/validations/run_validations.rb
|
234
|
-
- eitil_integrate/README.md
|
235
|
-
- eitil_integrate/lib/eitil_integrate.rb
|
236
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter.rb
|
237
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum.rb
|
238
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/drop_data.rb
|
239
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/format_data.rb
|
240
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/initialize.rb
|
241
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/present_data.rb
|
242
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/reduce_data.rb
|
243
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/auto_sum/sum_data.rb
|
244
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/default_export.rb
|
245
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/helpers.rb
|
246
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/infos.rb
|
247
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/initialize.rb
|
248
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/log_state.rb
|
249
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb
|
250
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/selectors.rb
|
251
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/setters.rb
|
252
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/store_file.rb
|
253
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/style_cells.rb
|
254
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/validations.rb
|
255
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/write_cells.rb
|
256
|
-
- eitil_integrate/lib/eitil_integrate/application_exporter/write_messages.rb
|
257
|
-
- eitil_integrate/lib/eitil_integrate/railtie.rb
|
258
234
|
- eitil_store/README.md
|
259
235
|
- eitil_store/lib/eitil_store.rb
|
260
236
|
- eitil_store/lib/eitil_store/array.rb
|
@@ -419,10 +395,6 @@ files:
|
|
419
395
|
- spec/eitil_core/type_checkers/is_num_or_nan_spec.rb
|
420
396
|
- spec/eitil_integrate/application_exporter/auto_sum_spec.rb
|
421
397
|
- spec/eitil_integrate/application_exporter/initialize_spec.rb
|
422
|
-
- spec/eitil_wrapper/callbacks/helper_methods_spec.rb
|
423
|
-
- spec/eitil_wrapper/jobs/single_method_job_spec.rb
|
424
|
-
- spec/eitil_wrapper/routes/extended_resources_spec.rb
|
425
|
-
- spec/eitil_wrapper/scopes/default_scopes_spec.rb
|
426
398
|
- spec/spec_helper.rb
|
427
399
|
homepage: https://github.com/eitje-app/eitil_engine
|
428
400
|
licenses:
|
data/eitil_integrate/README.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# EitilIntegrate
|
5
|
-
|
6
|
-
EitilIntegrate provides seamless integrations with select gems and API's, through helper methods stored in PORO's.
|
7
|
-
|
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.
|
@@ -1,63 +0,0 @@
|
|
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? ? to_float(item) : 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! do |array|
|
29
|
-
array.reject { |item| item.respond_to?(:empty?) && item.empty? }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def drop_non_accepted_values
|
34
|
-
@hash.transform_values! { |array| array.reject { |item| !accepted_value? item } }
|
35
|
-
end
|
36
|
-
|
37
|
-
def accepted_value?(value)
|
38
|
-
@value = value
|
39
|
-
value_is_a_int || value_is_a_float || value_is_a_time_string
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_float(object)
|
43
|
-
# Implemented a new to_float method, which replaces .to_f, because "7.5".to_f
|
44
|
-
# would correctly return 7.5, but "7,5" would incorrectly return 7.0.
|
45
|
-
object.is_a?(String) ? object.gsub(',','.').to_f : object.to_f
|
46
|
-
end
|
47
|
-
|
48
|
-
def value_is_a_int
|
49
|
-
@value.is_a? Integer
|
50
|
-
end
|
51
|
-
|
52
|
-
def value_is_a_float
|
53
|
-
@value.is_a? Float
|
54
|
-
end
|
55
|
-
|
56
|
-
def value_is_a_time_string
|
57
|
-
( @value.scan(/^[A-Za-z]+/).blank? && @value.scan(/\d{2}:\d{2}:\d{2}/).first ) ||
|
58
|
-
( @value.scan(/^[A-Za-z]+/).blank? && @value.scan(/\d{2}:\d{2}/).first )
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,30 +0,0 @@
|
|
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
|
-
# 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
|
19
|
-
|
20
|
-
def incomplete_time_string?(string)
|
21
|
-
string.is_a?(String) && string.length == 5 && string.scan(/\d{2}:\d{2}/)
|
22
|
-
end
|
23
|
-
|
24
|
-
def format_ints_to_floats
|
25
|
-
@hash.transform_values! { |array| array.map { |item| item.is_a?(Integer) ? item.to_f : item } }
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,84 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/auto_sum/sum_data"
|
3
|
-
|
4
|
-
module EitilIntegrate::RubyXL
|
5
|
-
module AutoSum
|
6
|
-
class << self
|
7
|
-
|
8
|
-
# Reduce values and alter data structure.
|
9
|
-
|
10
|
-
def sum_data
|
11
|
-
sum_floats
|
12
|
-
sum_time_strings
|
13
|
-
unpack_arrays
|
14
|
-
end
|
15
|
-
|
16
|
-
def sum_floats
|
17
|
-
@hash.transform_values! { |array| float_array?(array) ? [array.sum] : array }
|
18
|
-
end
|
19
|
-
|
20
|
-
def sum_time_strings
|
21
|
-
@hash.transform_values! { |array| time_string_array?(array) ? chronic_sum_array(array) : array }
|
22
|
-
end
|
23
|
-
|
24
|
-
def chronic_sum_array(array)
|
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
|
-
# ALERT: the outcomment below is made to skip formatting days at all, so that
|
38
|
-
# – following eitje business logic – we currently only return an hh:mm notation
|
39
|
-
|
40
|
-
# # parsing times into maxes (60 m, 24 h, ∞ days)
|
41
|
-
# th += tm / 60
|
42
|
-
# tm = tm % 60
|
43
|
-
# td += th / 24
|
44
|
-
# th = th % 24
|
45
|
-
|
46
|
-
# # formatting strings
|
47
|
-
# sd = td.to_s
|
48
|
-
|
49
|
-
sh = th.to_s.rjust(2,'0')
|
50
|
-
sm = tm.to_s.rjust(2,'0')
|
51
|
-
|
52
|
-
if sm.to_i >= 60
|
53
|
-
sh = ( sh.to_i + (sm.to_i / 60 )).to_s
|
54
|
-
sm = ( sm.to_i % 60 ).to_s
|
55
|
-
end
|
56
|
-
|
57
|
-
# ALERT: the outcomment below is made to skip formatting days at all, so that
|
58
|
-
# – following eitje business logic – we currently only return an hh:mm notation
|
59
|
-
|
60
|
-
# [[sd, sh, sm].join(':')]
|
61
|
-
[[sh, sm].join(':')]
|
62
|
-
end
|
63
|
-
|
64
|
-
def format_time(time)
|
65
|
-
time.to_s.length == 1 ? "0#{time}" : time.to_s
|
66
|
-
end
|
67
|
-
|
68
|
-
def float_array?(array)
|
69
|
-
return false if array.empty?
|
70
|
-
array.all? { |item| item.is_a?(Float) }
|
71
|
-
end
|
72
|
-
|
73
|
-
def time_string_array?(array)
|
74
|
-
return false if array.empty?
|
75
|
-
array.all? { |item| item.is_a?(String) && item.scan(/\d{2}:\d{2}:\d{2}/) }
|
76
|
-
end
|
77
|
-
|
78
|
-
def unpack_arrays
|
79
|
-
@hash.transform_values! { |array| array.empty? ? nil : array.first }
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,10 +0,0 @@
|
|
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"
|
@@ -1,44 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/default_export"
|
3
|
-
|
4
|
-
require "eitil_integrate/application_exporter/initialize"
|
5
|
-
|
6
|
-
module EitilIntegrate::RubyXL
|
7
|
-
class ApplicationExporter
|
8
|
-
|
9
|
-
# The #create_file method is taken out of #export, to be overwritten by
|
10
|
-
# exports variants that want to loop over objects and call it multiple times.
|
11
|
-
# => e.g. the context of multiple Environment for a single Organisation
|
12
|
-
|
13
|
-
def export
|
14
|
-
prepare_export
|
15
|
-
create_file
|
16
|
-
process_export
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def prepare_export
|
22
|
-
validate_args_presence
|
23
|
-
validate_args_value
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_file
|
27
|
-
name_sheet
|
28
|
-
set_data
|
29
|
-
validate_data
|
30
|
-
fill_messages
|
31
|
-
fill_header
|
32
|
-
fill_file
|
33
|
-
end
|
34
|
-
|
35
|
-
def process_export
|
36
|
-
style_file
|
37
|
-
log_state
|
38
|
-
save_file
|
39
|
-
end
|
40
|
-
|
41
|
-
alias_method :base_create_file, :create_file
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/helpers"
|
3
|
-
|
4
|
-
require "eitil_integrate/application_exporter/initialize"
|
5
|
-
|
6
|
-
module EitilIntegrate::RubyXL
|
7
|
-
class ApplicationExporter
|
8
|
-
|
9
|
-
def array_to_indexed_hash(array)
|
10
|
-
array = array_nils_substituted(array)
|
11
|
-
array = array_values_strf(array)
|
12
|
-
array.flatten.map.with_index { |item, index| { "#{index}": item } }.inject &:merge
|
13
|
-
end
|
14
|
-
|
15
|
-
def array_nils_substituted(array)
|
16
|
-
array.map { |value| value || '' }
|
17
|
-
end
|
18
|
-
|
19
|
-
def array_values_strf(array)
|
20
|
-
array.map &:to_s
|
21
|
-
end
|
22
|
-
|
23
|
-
def sanitize_int(integer)
|
24
|
-
(integer.nan? || integer.infinite?) ? 0 : integer
|
25
|
-
end
|
26
|
-
|
27
|
-
def pretty_date_range
|
28
|
-
date_range.to_s.gsub '..', ' – '
|
29
|
-
end
|
30
|
-
|
31
|
-
def strf_date_range
|
32
|
-
date_range.map &:to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
def double_digit_time(time)
|
36
|
-
time.to_s.length == 1 ? "0#{time}" : time.to_s
|
37
|
-
end
|
38
|
-
|
39
|
-
def format_minutes(minutes)
|
40
|
-
hours = double_digit_time(minutes / 60)
|
41
|
-
minutes = double_digit_time(minutes % 60)
|
42
|
-
"#{hours}:#{minutes}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def name_sheet(name='Worksheet')
|
46
|
-
sheet.sheet_name = name
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/infos"
|
3
|
-
|
4
|
-
require "eitil_integrate/application_exporter/initialize"
|
5
|
-
|
6
|
-
module EitilIntegrate::RubyXL
|
7
|
-
class ApplicationExporter
|
8
|
-
class << self
|
9
|
-
|
10
|
-
attr_accessor :info
|
11
|
-
|
12
|
-
def set_info(_h)
|
13
|
-
@info ||= {}
|
14
|
-
k, v = *_h.first
|
15
|
-
@info[k] = v
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/initialize"
|
3
|
-
|
4
|
-
require "eitil_core/setters/set_ivars"
|
5
|
-
require "eitil_core/argument_helpers/all_kwargs_to_ivars"
|
6
|
-
require "action_view"
|
7
|
-
require "rubyXL"
|
8
|
-
|
9
|
-
module EitilIntegrate
|
10
|
-
module RubyXL
|
11
|
-
class ApplicationExporter
|
12
|
-
|
13
|
-
include ActionView::Helpers::NumberHelper
|
14
|
-
|
15
|
-
attr_accessor :book, :sheet, :x, :y, :start_date, :end_date, :date_range, :write_log
|
16
|
-
|
17
|
-
def initialize(attributes={})
|
18
|
-
|
19
|
-
@start_date ||= attributes[:start_date]
|
20
|
-
@end_date ||= attributes[:end_date]
|
21
|
-
|
22
|
-
set_ivars :start_date, :end_date, :date_range
|
23
|
-
|
24
|
-
@book = ::RubyXL::Workbook.new
|
25
|
-
@sheet = @book.worksheets[0]
|
26
|
-
@x ||= 0
|
27
|
-
@y ||= 0
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
|
2
|
-
# require "eitil_integrate/application_exporter/log_state"
|
3
|
-
|
4
|
-
module EitilIntegrate::RubyXL
|
5
|
-
class ApplicationExporter
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def log_state
|
10
|
-
|
11
|
-
return unless write_log == true
|
12
|
-
|
13
|
-
# create_log_sheet
|
14
|
-
book.add_worksheet('log')
|
15
|
-
|
16
|
-
# manage sheets
|
17
|
-
previous_sheet = @sheet.sheet_name
|
18
|
-
@sheet = @book["log"]
|
19
|
-
|
20
|
-
# manage coordinates
|
21
|
-
previous_x = @x
|
22
|
-
@x = 0
|
23
|
-
|
24
|
-
# log everything we want to log
|
25
|
-
report_state
|
26
|
-
|
27
|
-
# style logs
|
28
|
-
base_style_first_x_columns_width 1, 40
|
29
|
-
style_first_column_bold
|
30
|
-
|
31
|
-
# restore what was previously active
|
32
|
-
@sheet = @book[previous_sheet]
|
33
|
-
@x = previous_x
|
34
|
-
|
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
|
70
|
-
|
71
|
-
elsif value_class == RubyXL::Worksheet
|
72
|
-
value_class.name
|
73
|
-
|
74
|
-
else
|
75
|
-
value.to_s
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|