eco-helpers 2.0.18 → 2.0.24

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +80 -1
  3. data/eco-helpers.gemspec +4 -1
  4. data/lib/eco/api/common/base_loader.rb +9 -5
  5. data/lib/eco/api/common/loaders/parser.rb +1 -0
  6. data/lib/eco/api/common/people/default_parsers.rb +1 -0
  7. data/lib/eco/api/common/people/default_parsers/xls_parser.rb +53 -0
  8. data/lib/eco/api/common/people/entries.rb +1 -0
  9. data/lib/eco/api/common/people/entry_factory.rb +88 -23
  10. data/lib/eco/api/common/people/person_entry.rb +1 -0
  11. data/lib/eco/api/common/people/person_parser.rb +1 -1
  12. data/lib/eco/api/common/session.rb +1 -0
  13. data/lib/eco/api/common/session/base_session.rb +2 -0
  14. data/lib/eco/api/common/session/helpers.rb +30 -0
  15. data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
  16. data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
  17. data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
  18. data/lib/eco/api/common/version_patches/exception.rb +5 -2
  19. data/lib/eco/api/microcases/with_each.rb +67 -6
  20. data/lib/eco/api/microcases/with_each_present.rb +4 -2
  21. data/lib/eco/api/microcases/with_each_starter.rb +4 -2
  22. data/lib/eco/api/organization.rb +1 -1
  23. data/lib/eco/api/organization/people.rb +94 -25
  24. data/lib/eco/api/organization/people_similarity.rb +272 -0
  25. data/lib/eco/api/organization/person_schemas.rb +5 -1
  26. data/lib/eco/api/organization/policy_groups.rb +5 -1
  27. data/lib/eco/api/organization/tag_tree.rb +33 -0
  28. data/lib/eco/api/session.rb +19 -8
  29. data/lib/eco/api/session/batch.rb +7 -5
  30. data/lib/eco/api/session/batch/job.rb +34 -9
  31. data/lib/eco/api/usecases.rb +2 -2
  32. data/lib/eco/api/usecases/base_case.rb +2 -2
  33. data/lib/eco/api/usecases/base_io.rb +17 -4
  34. data/lib/eco/api/usecases/default_cases.rb +1 -0
  35. data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +179 -32
  36. data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +37 -0
  37. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +81 -36
  38. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +3 -4
  39. data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
  40. data/lib/eco/cli/config/default/input.rb +61 -8
  41. data/lib/eco/cli/config/default/options.rb +47 -2
  42. data/lib/eco/cli/config/default/people.rb +18 -24
  43. data/lib/eco/cli/config/default/usecases.rb +33 -2
  44. data/lib/eco/cli/config/default/workflow.rb +12 -7
  45. data/lib/eco/cli/scripting/args_helpers.rb +2 -2
  46. data/lib/eco/csv.rb +4 -2
  47. data/lib/eco/csv/table.rb +121 -21
  48. data/lib/eco/data/fuzzy_match.rb +109 -27
  49. data/lib/eco/data/fuzzy_match/chars_position_score.rb +3 -2
  50. data/lib/eco/data/fuzzy_match/ngrams_score.rb +19 -10
  51. data/lib/eco/data/fuzzy_match/pairing.rb +12 -19
  52. data/lib/eco/data/fuzzy_match/result.rb +22 -2
  53. data/lib/eco/data/fuzzy_match/results.rb +30 -6
  54. data/lib/eco/data/fuzzy_match/score.rb +12 -7
  55. data/lib/eco/data/fuzzy_match/string_helpers.rb +14 -1
  56. data/lib/eco/version.rb +1 -1
  57. metadata +67 -3
  58. data/lib/eco/api/organization/people_analytics.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 678fc1c610a5aafd8321a74367a6aaca67aa70bf159f638209b45da0361bb575
4
- data.tar.gz: 280a74a3a3877c5d58bfbe84d0f6a8f8b6f8eda5c68f376fea87522b03a59e42
3
+ metadata.gz: a2d943cd8ff8df507a2285548d7bf0c8fffa4009df45de1c26f38e4c966c747f
4
+ data.tar.gz: 14cdb53085deec51b406000048aa00199478ef9458290061cb47d324957ec1f2
5
5
  SHA512:
6
- metadata.gz: 30c74c7aa8b7f59a4610cb4da804714a165a095d6280b756dcec17df37a81f2b5438a7178cc279750e5f97a43ae6d0041e464d9ed7965af39c39fc71ce4efc99
7
- data.tar.gz: 1abe7f74b0a0452565c1add7778086030372f63912fe2c6279a2d40eb9f908d07746421507241d4905bbdf546e944899fa0f63fa3e3fe086caf1663c83a2624d
6
+ metadata.gz: 8563f5eaac3f8b650b62138fd31252d990467be498f9620bf7276a430ab8470acf1f2a8ab7b3e6ebcb9accedc1af94ac7168e6acdf3eb94de516259069a49c80
7
+ data.tar.gz: 881d6742b555d4b3cf42addef76470b35764684cbca0f903252ae5a39f503dc6a89d9bd7f7f774c587c0b6a23a6f898274af227baf14090d40ae30a16144eecc
data/CHANGELOG.md CHANGED
@@ -1,13 +1,92 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [2.0.24] - 2021-06-xx
5
+
6
+ ### Added
7
+ - `Eco::API::Session::Batch::Job` made **native** `-include-excluded`
8
+ * also added new option `-include-only-excluded` to be able to only target people HRIS excluded
9
+ ### Changed
10
+ ### Fixed
11
+
12
+
13
+ ## [2.0.23] - 2021-06-22
14
+
15
+ ### Added
16
+ - `Eco::API::Session::Batch::Job` **new** option (`-save-requests`) to save requests even if in `dry-run` (`-simulate`)
17
+ ### Changed
18
+ - `Eco::API::Session::Batch::Job` new people won't create updates unless they have either details or account
19
+ * because that entry is not supposed to be created unless has account or details
20
+
21
+ ## [2.0.22] - 2021-06-18
22
+
23
+ ### Added
24
+ - exposed `logger` in `BaseLoader` and
25
+ - support for multiple input files
26
+ * `Eco::API::Common::People::EntryFactory#entries`:
27
+ - refactored to allow multiple input files parsing
28
+ - moreover to `idx`, hash entries will get their `source_file`
29
+ * Input callback at `lib/eco/cli/config/default/input` refactored format detection and enabled folder input
30
+ * `SCR.get_file` language extended to also mention folder (not just file)
31
+ - support for `.xls` and `.xlsx` files
32
+ * `Eco::API::Common::People::DefaultParsers::XLSParser` the Excel files **parser**
33
+ * `Eco::API::Common::People::PersonParser` added `:xls` as an accepted format
34
+ * `Eco::API::Session#fields_mapper` exposed mapper through a method to allow **headers detection**
35
+ - The external names of the fields are the column headers of the input file
36
+ * `Eco::API::UseCases::BaseIO` when arguments validation rails, now it raises with specific `MissingParameter` error
37
+
38
+ ### Changed
39
+ - dry out `BaseLoader` (only session is set as instance variable)
40
+ - removed `creek` **dependency** (it was not used anywhere in the gem)
41
+ * we just kept `roo` and `roo-xls`
42
+ - custom `Error` classes now all inherit from `StandardError` (rather than `Exception`)
43
+
44
+
45
+
46
+ ## [2.0.21] - 2021-06-04
47
+
48
+ ### Added
49
+ - `Eco::CSV::Table`, support to create the table out of an `Array<Hash>`
50
+ - This opens new methods to transform input Excel file to this data structure and unify input data structures.
51
+ - **new** use case `Eco::API::UseCases::DefaultCases::CleanUnknownTags` invokable via `clean-unknown-tags`
52
+
53
+ ### Changed
54
+ - `Eco::API::Common::People::EntryFactory` slight **refactor** to boost better support for multiple input formats
55
+
56
+
57
+ ## [2.0.20] - 2021-05-31
58
+
59
+ ### Added
60
+ - **dependencies** to `creek`, `roo` and `roo-xls`
61
+ - **dependencies** to `hashdiff`
62
+ - `Eco::API::Session#parse_attribute` => added missing parameter `deps:`
63
+ - new option `-stdout [file]` to redirect the output to a file
64
+ - `Eco::CSV::Table`, **added** more helper methods `#group_by`, `#transform_values`, `#slice`, `#slice_columns`, `#delete_column`
65
+ - `Eco::API::Organization::TagTree` **added** more helper methods: `top?`, `tag=`, `as_json`, `dup`, `diff`
66
+
67
+ ### Fixed
68
+ - `Exception` patch: when `SystemStackError` there is not `backtrace` :/
69
+
70
+ ## [2.0.19] - 2021-05-31
71
+
72
+ ### Added
73
+ - Better error message for people searches & **offer** to select among the candidates:
74
+ - `Eco::API::Organization::People::MultipleSearchResults`, triggered from `Eco::API::Organization::People#find`
75
+ - `Eco::API::MicroCases#with_each` will offer the selection of candidates
76
+
77
+ ### Changed
78
+ - **renamed** and repurposed `Eco::API::Organization::PeopleAnalytics` to `PeopleSimilarity`
79
+
80
+ ### Fixed
81
+ - `Eco::Data::FuzzyMatch` adjustments for configuration propagation + some fixes
82
+ - Command option `-entries-from` can still be useful when used to obtain `-get-partial` of people base for `:export` use cases !!
83
+
4
84
  ## [2.0.18] - 2021-05-25
5
85
 
6
86
  ### Added
7
87
  - **`-one-off`** option to not having to type the `-api-key` every time you launch one-off scripts
8
88
  - `-api-key` will store the key to the `./.env_one_off` file (supports update and multi-environment)
9
89
 
10
- ### Changed
11
90
  ### Fixed
12
91
  - patched `Exception#patch_full_message` to do not enter into a cyclic error rescue
13
92
  - also rescue on `workflow.rescue`
data/eco-helpers.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://www.ecoportal.com"
15
15
  spec.licenses = %w[MIT]
16
16
 
17
- spec.required_ruby_version = '>= 2.4.4'
17
+ spec.required_ruby_version = '>= 2.5.0'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
20
  f.match(%r{^(test|spec|features)/})
@@ -36,7 +36,10 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
37
37
  spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
38
38
  spec.add_dependency 'net-sftp', '>= 3.0.0', '< 3.1'
39
+ spec.add_dependency 'hashdiff', '>= 1.0.1', '< 1.1'
39
40
  spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
40
41
  spec.add_dependency 'amatch', '>= 0.4.0', '< 0.5'
41
42
  spec.add_dependency 'jaro_winkler', '>= 1.5.4', '< 1.6'
43
+ spec.add_dependency 'roo', '>= 2.8.3', '< 2.9'
44
+ spec.add_dependency 'roo-xls', '>= 1.2.0', '< 1.3'
42
45
  end
@@ -51,15 +51,19 @@ module Eco
51
51
  private
52
52
 
53
53
  def session
54
- @session ||= ASSETS.session
54
+ ASSETS.session
55
55
  end
56
56
 
57
- def micro
58
- session.micro
57
+ def config
58
+ session.config
59
59
  end
60
60
 
61
- def config
62
- @config ||= ASSETS.config
61
+ def logger
62
+ session.logger
63
+ end
64
+
65
+ def micro
66
+ session.micro
63
67
  end
64
68
 
65
69
  end
@@ -19,6 +19,7 @@ module Eco
19
19
  @attribute = value
20
20
  end
21
21
 
22
+ # TODO: it migh rather merge?
22
23
  # Some parsers require dependencies to do their job.
23
24
  def dependencies(value = nil)
24
25
  @dependencies ||= {}
@@ -44,3 +44,4 @@ require_relative 'default_parsers/freemium_parser'
44
44
  require_relative 'default_parsers/policy_groups_parser'
45
45
  require_relative 'default_parsers/login_providers_parser'
46
46
  require_relative 'default_parsers/csv_parser'
47
+ require_relative 'default_parsers/xls_parser'
@@ -0,0 +1,53 @@
1
+ class Eco::API::Common::People::DefaultParsers::XLSParser < Eco::API::Common::Loaders::Parser
2
+ attribute :xls
3
+
4
+ attr_accessor :already_required
5
+ attr_reader :file
6
+
7
+ def parser(file, deps)
8
+ @file = file
9
+ rows.tap {|r| @file = nil}
10
+ end
11
+
12
+ def serializer(array_hash, deps)
13
+ raise "Not implemented. TODO: using axlsx or rubyXL gems. See: https://spin.atomicobject.com/2017/03/22/parsing-excel-files-ruby/"
14
+ end
15
+
16
+ private
17
+
18
+ def headers
19
+ raise "You should implement this method"
20
+ end
21
+
22
+ def sheet_name
23
+ 0
24
+ end
25
+
26
+ def workbook
27
+ require_reading_libs!
28
+ Roo::Spreadsheet.open(file)
29
+ end
30
+
31
+ def spreadheet(name_or_index = sheet_name)
32
+ workbook.sheet(name_or_index)
33
+ end
34
+
35
+ def rows(target = headers)
36
+ begin
37
+ spreadheet.parse(header_search: target)
38
+ rescue Roo::HeaderRowNotFoundError => e
39
+ missing = JSON.parse(e.message)
40
+ logger.warn("The input file is missing these headers: #{missing}")
41
+ present = target - missing
42
+ rows(present)
43
+ end
44
+ end
45
+
46
+ def require_reading_libs!
47
+ return if already_required
48
+ require 'roo'
49
+ require 'roo-xls'
50
+ already_required = true
51
+ end
52
+
53
+ end
@@ -99,6 +99,7 @@ module Eco
99
99
  newFrom to_a - discarded
100
100
  end
101
101
 
102
+ # TODO: it should rather use the the people-to-csv case somehow
102
103
  # Helper to dump the entries into a CSV
103
104
  # @param filename [String] the destination file
104
105
  def export(filename)
@@ -2,6 +2,10 @@ module Eco
2
2
  module API
3
3
  module Common
4
4
  module People
5
+ # TODO: EntryFactory should suppport multiple schemas itself (rather that being done on `Session`)
6
+ # => currently, it's through session.entry_factory(schema: id), but this is wrong
7
+ # => This way, Entries and PersonEntry will be able to refer to attr_map and person_parser linked to schema_id
8
+ # => "schema_id" should be an optional column in the input file, or parsable via a custom parser to scope the schema
5
9
  # Helper factory class to generate entries (input entries).
6
10
  # @attr_reader schema [Ecoportal::API::V1::PersonSchema] person schema to be used in this entry factory
7
11
  class EntryFactory < Eco::API::Common::Session::BaseSession
@@ -12,7 +16,7 @@ module Eco
12
16
  # @param schema [Ecoportal::API::V1::PersonSchema] schema of person details that the parser will be based upon.
13
17
  # @param person_parser [nil, Eco::API::Common::People::PersonParser] set of attribute, type and format parsers/serializers.
14
18
  # @param attr_map [nil, Eco::Data::Mapper] attribute names mapper to translate external names into internal ones and _vice versa_.
15
- def initialize(e, schema:, person_parser: nil, attr_map: nil)
19
+ def initialize(e, schema:, person_parser: nil, default_parser: nil, attr_map: nil)
16
20
  fatal "Constructor needs a PersonSchema. Given: #{schema}" if !schema.is_a?(Ecoportal::API::V1::PersonSchema)
17
21
  fatal "Expecting PersonParser. Given: #{person_parser}" if person_parser && !person_parser.is_a?(Eco::API::Common::People::PersonParser)
18
22
  fatal "Expecting Mapper object. Given: #{fields_mapper}" if attr_map && !attr_map.is_a?(Eco::Data::Mapper)
@@ -22,14 +26,25 @@ module Eco
22
26
  @source_person_parser = person_parser
23
27
 
24
28
  # load default parser + custom parsers
25
- base_parser = Eco::API::Common::People::DefaultParsers.new(schema: @schema).merge(@source_person_parser)
29
+ @default_parser = default_parser&.new(schema: @schema) || Eco::API::Common::People::DefaultParsers.new(schema: @schema)
30
+ base_parser = @default_parser.merge(@source_person_parser)
26
31
  # new parser with linked schema
27
32
  @person_parser = @source_person_parser.new(schema: @schema).merge(base_parser)
28
33
  @person_parser_patch_version = @source_person_parser.patch_version
29
-
30
34
  @attr_map = attr_map
31
35
  end
32
36
 
37
+ def newFactory(schema: nil)
38
+ self.class.new(
39
+ environment,
40
+ schema: schema,
41
+ person_parser: @source_person_parser,
42
+ default_parser: @default_parser,
43
+ attr_map: @attr_map
44
+ )
45
+ end
46
+
47
+
33
48
  # provides with a Eco::API::Common::People::PersonParser object (collection of attribute parsers)
34
49
  # @note if the custom person parser has changed, it updates the copy of this EntryFactory instance
35
50
  # @return [Eco::API::Common::People::PersonParser] set of attribute, type and format parsers/serializers.
@@ -43,7 +58,7 @@ module Eco
43
58
 
44
59
  # key method to generate objects of `PersonEntry` that share dependencies via this `EntryFactory` environment.
45
60
  # @note this method is necessary to make the factory object work as a if it was a class `PersonEntry` you can call `new` on.
46
- # @param data [Array<Hash>] data to be parsed. The external hashed entry.
61
+ # @param data [Hash, Person] data to be parsed/serialized. Parsed: the external hashed entry. Serialized: a Person object.
47
62
  # @return [Eco::API::Common::People::PersonEntry]
48
63
  def new(data, dependencies: {})
49
64
  PersonEntry.new(
@@ -73,26 +88,63 @@ module Eco
73
88
  fatal("Format should be a Symbol. Given '#{format}'") if format && !format.is_a?(Symbol)
74
89
  fatal("There is no parser/serializer for format ':#{format.to_s}'") unless no_format || @person_parser.defined?(format)
75
90
 
76
- if file
77
- arr_hash = []
78
- if Eco::API::Common::Session::FileManager.file_exists?(file)
79
- encoding ||= Eco::API::Common::Session::FileManager.encoding(file)
80
- encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
81
- file_content = File.read(file, encoding: encoding)
82
- arr_hash = person_parser.parse(format, file_content).map.each_with_index do |entry_hash, i|
83
- j = (format == :csv)? i + 2 : i + 1
84
- entry_hash.tap {|hash| hash["idx"] = j}
85
- end
91
+ kargs = {}
92
+ kargs.merge!(content: data) unless no_data
93
+ kargs.merge!(file: file) unless no_file
94
+ kargs.merge!(format: format) unless no_format
95
+ kargs.merge!(encoding: encoding) if encoding
96
+
97
+ Entries.new(to_array_of_hashes(**kargs), klass: PersonEntry, factory: self)
98
+ end
99
+
100
+ def to_array_of_hashes(**kargs)
101
+ data = []
102
+ content, file, encoding, format = kargs.values_at(:content, :file, :encoding, :format)
103
+
104
+ # Support for multiple file
105
+ if file.is_a?(Array)
106
+ return file.each_with_object([]) do |f, out|
107
+ logger.info("Parsing file '#{f}'")
108
+ curr = to_array_of_hashes(**kargs.merge(file: f))
109
+ out.concat(curr)
110
+ end
111
+ end
112
+ # Get content only when it's not :xls
113
+ # note: even if content was provided, file takes precedence
114
+ content = get_file_content(file, format, encoding) if (format != :xls) && file
115
+
116
+ case content
117
+ when Hash
118
+ logger.error("Input data as 'Hash' not supported. Expecting 'Enumerable' or 'String'")
119
+ exit(1)
120
+ when String
121
+ to_array_of_hashes(content: person_parser.parse(format, content))
122
+ when Enumerable
123
+ sample = content.to_a.first
124
+ case sample
125
+ when Hash, Array, ::CSV::Row
126
+ Eco::CSV::Table.new(content).to_array_of_hashes
86
127
  else
87
- logger.warn("File does not exist: #{file}")
128
+ logger.error("Input content 'Array' of '#{sample.class}' is not supported.")
88
129
  end
89
-
90
- entries(data: arr_hash)
91
130
  else
92
- Entries.new(data, klass: PersonEntry, factory: self)
131
+ if file && format == :xls
132
+ person_parser.parse(format, file)
133
+ else
134
+ logger.error("Could not obtain any data out of these: #{kargs}. Given content: '#{content.class}'")
135
+ exit(1)
136
+ end
137
+ end.tap do |out_array|
138
+ start_from_two = (format == :csv) || format == :xls
139
+ out_array.each_with_index do |entry_hash, i|
140
+ entry_hash["idx"] = start_from_two ? i + 2 : i + 1
141
+ entry_hash["source_file"] = file
142
+ end
93
143
  end
144
+
94
145
  end
95
146
 
147
+
96
148
  # Helper that generates a file out of `data:`.
97
149
  # @raise Exception
98
150
  # - if you try to provide `data:` in the wrong format.
@@ -104,7 +156,7 @@ module Eco
104
156
  # @param format [Symbol] it specifies the format of the output `file:` (i.e. `:xml`, `:csv`). There must be a parser/serializer defined for it.
105
157
  # @param encoding [String] optional parameter to geneate `file:` content by unsing certain encoding.
106
158
  # @return [Void].
107
- def export(data:, file: "export", format: :csv, encoding: "utf-8")
159
+ def export(data:, file: "export", format: :csv, encoding: "utf-8", internal_names: false)
108
160
  fatal("data: Expected Eco::API::Organization::People object. Given: #{data.class}") unless data.is_a?(Eco::API::Organization::People)
109
161
  fatal("A file should be specified.") unless !file.to_s.strip.empty?
110
162
  fatal("Format should be a Symbol. Given '#{format}'") if format && !format.is_a?(Symbol)
@@ -112,16 +164,18 @@ module Eco
112
164
 
113
165
  run = true
114
166
  if Eco::API::Common::Session::FileManager.file_exists?(file)
115
- print "The file '#{file}' already exists. Do you want to overwrite it? (Y/n): "
116
- res = STDIN.gets.strip
117
- run = ["y", "Y", ""].include?(res)
167
+ prompt_user("The file '#{file}' already exists. Do you want to overwrite it? (Y/n):", default: "Y") do |response|
168
+ run = (response == "") || reponse.upcase.start_with?("Y")
169
+ end
118
170
  end
119
171
 
120
172
  if run
121
173
  deps = {"supervisor_id" => {people: data}}
122
174
 
123
175
  data_entries = data.map do |person|
124
- self.new(person, dependencies: deps).external_entry
176
+ self.new(person, dependencies: deps).yield_self do |entry|
177
+ internal_names ? entry.mapped_entry : entry.external_entry
178
+ end
125
179
  end
126
180
 
127
181
  File.open(file, "w", enconding: encoding) do |fd|
@@ -133,6 +187,17 @@ module Eco
133
187
 
134
188
  private
135
189
 
190
+ def get_file_content(file, format, encoding)
191
+ unless Eco::API::Common::Session::FileManager.file_exists?(file)
192
+ logger.error("File does not exist: #{file}")
193
+ exit(1)
194
+ end
195
+ ext = File.extname(file)
196
+ encoding ||= Eco::API::Common::Session::FileManager.encoding(file)
197
+ encoding = (encoding != "utf-8")? "#{encoding}|utf-8": encoding
198
+ content = File.read(file, encoding: encoding)
199
+ end
200
+
136
201
  def fatal(msg)
137
202
  logger.fatal(msg)
138
203
  raise msg
@@ -216,6 +216,7 @@ module Eco
216
216
  end
217
217
  end
218
218
 
219
+ # TO DO: use person.details.schema_id to switch @emap and @person_parser (or just crash if they don't match?)
219
220
  # Setter to fill in all the schema `details` fields of the `Person` that are present in the `Entry`.
220
221
  # @note it only sets those details properties defined in the entry.
221
222
  # Meaning that if an details property is not present in the entry, this will not be set on the target person.
@@ -16,7 +16,7 @@ module Eco
16
16
  CORE_ATTRS = ["id", "external_id", "email", "name", "supervisor_id", "filter_tags", "freemium"]
17
17
  ACCOUNT_ATTRS = ["policy_group_ids", "default_tag", "send_invites", "landing_page_id", "login_provider_ids"]
18
18
  TYPE = [:select, :text, :date, :number, :phone_number, :boolean, :multiple]
19
- FORMAT = [:csv, :xml, :json]
19
+ FORMAT = [:csv, :xml, :json, :xls]
20
20
 
21
21
  attr_reader :schema
22
22
  attr_reader :details_attrs, :all_model_attrs
@@ -13,4 +13,5 @@ require_relative 'session/sftp'
13
13
  require_relative 'session/s3_uploader'
14
14
  require_relative 'session/file_manager'
15
15
  require_relative 'session/environment'
16
+ require_relative 'session/helpers'
16
17
  require_relative 'session/base_session'
@@ -11,6 +11,8 @@ module Eco
11
11
  attr_reader :api, :file_manager, :logger
12
12
  alias_method :fm, :file_manager
13
13
 
14
+ include Session::Helpers
15
+
14
16
  def initialize(e)
15
17
  raise "Expected object Eco::API::Common::Session::Environment. Given: #{e.class}" unless e.is_a?(Environment)
16
18
  self.environment = e