eco-helpers 2.0.11 → 2.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -71
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/person_entry.rb +5 -0
- data/lib/eco/api/common/people/supervisor_helpers.rb +27 -0
- data/lib/eco/api/common/session/file_manager.rb +2 -2
- data/lib/eco/api/error.rb +5 -3
- data/lib/eco/api/organization/presets_factory.rb +166 -82
- data/lib/eco/api/organization/presets_integrity.json +52 -0
- data/lib/eco/api/session/batch.rb +19 -3
- data/lib/eco/api/session/batch/job.rb +3 -0
- data/lib/eco/api/session/config.rb +16 -5
- data/lib/eco/api/session/config/api.rb +4 -0
- data/lib/eco/api/session/config/apis.rb +14 -0
- data/lib/eco/api/session/config/files.rb +7 -0
- data/lib/eco/api/session/config/people.rb +2 -2
- data/lib/eco/api/usecases.rb +2 -0
- data/lib/eco/api/usecases/default_cases.rb +3 -0
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +161 -0
- data/lib/eco/api/usecases/default_cases/hris_case.rb +14 -8
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +72 -0
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +59 -0
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +41 -21
- data/lib/eco/cli.rb +1 -10
- data/lib/eco/cli/config/default/usecases.rb +20 -2
- data/lib/eco/cli/config/default/workflow.rb +5 -0
- data/lib/eco/data/files/directory.rb +28 -20
- data/lib/eco/version.rb +1 -1
- metadata +5 -1
data/lib/eco/cli.rb
CHANGED
@@ -22,16 +22,7 @@ module Eco
|
|
22
22
|
|
23
23
|
def run(session:)
|
24
24
|
io = Eco::API::UseCases::BaseIO.new(session: session, options: options)
|
25
|
-
|
26
|
-
session.workflow(io: io) do |wf, io|
|
27
|
-
io = wf.run(:options, io: io)
|
28
|
-
io = wf.run(:load, io: io)
|
29
|
-
io = wf.run(:usecases, io: io)
|
30
|
-
io = wf.run(:launch_jobs, io: io)
|
31
|
-
io = wf.run(:post_launch, io: io)
|
32
|
-
io = wf.run(:end, io: io)
|
33
|
-
io = wf.run(:close, io: io)
|
34
|
-
end
|
25
|
+
session.workflow(io: io).run(io: io)
|
35
26
|
end
|
36
27
|
|
37
28
|
end
|
@@ -1,12 +1,30 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
2
|
cnf.usecases do |cases|
|
3
3
|
|
4
|
+
desc = "Draws the Supervisors hiearchy in a file (use option -to file.ext)"
|
5
|
+
cases.add("-supers-hierarchy", :export, desc, case_name: "supers-hierarchy") do |people, session, options|
|
6
|
+
file = (SCR.get_arg("-to") && SCR.get_file("-to", required: true, should_exist: false)) || "supers_hierarchy.txt"
|
7
|
+
options.deep_merge!(output: {file: file})
|
8
|
+
end
|
9
|
+
|
10
|
+
desc = "Draws the Cyclic Supervisors when identified (use option -to file.ext)"
|
11
|
+
cases.add("-identify-cyclic-supers", :export, desc, case_name: "identify-cyclic-supers") do |people, session, options|
|
12
|
+
file = (SCR.get_arg("-to") && SCR.get_file("-to", required: true, should_exist: false)) || "supers_hierarchy.txt"
|
13
|
+
options.deep_merge!(output: {file: file})
|
14
|
+
end
|
15
|
+
|
16
|
+
desc = "Abstracts the Abilities that each Usergroup should probably have (use option -to file.ext)"
|
17
|
+
cases.add("-abstract-policygroup-abilities", :export, desc, case_name: "abstract-policygroup-abilities") do |people, session, options|
|
18
|
+
file = (SCR.get_arg("-to") && SCR.get_file("-to", required: true, should_exist: false)) || "suggested_abilities.txt"
|
19
|
+
options.deep_merge!(output: {file: file})
|
20
|
+
end
|
21
|
+
|
4
22
|
desc = "It exports to a CSV the (filtered) people"
|
5
23
|
cases.add("-people-to-csv", :export, desc) do |people, session, options|
|
6
24
|
file = SCR.get_file("-people-to-csv", required: true, should_exist: false)
|
7
25
|
options.deep_merge!(export: {file: {name: file, format: :csv}})
|
8
26
|
options.deep_merge!(export: {options: {nice_header: true}}) if SCR.get_arg("-nice-header")
|
9
|
-
|
27
|
+
options.deep_merge!(export: {options: {internal_names: true}}) if SCR.get_arg("-internal-names")
|
10
28
|
case_name = SCR.get_arg("-detailed")? "to-csv-detailed" : "to-csv"
|
11
29
|
session.usecases.case(case_name)
|
12
30
|
end
|
@@ -73,7 +91,7 @@ ASSETS.cli.config do |cnf|
|
|
73
91
|
end
|
74
92
|
|
75
93
|
options.deep_merge!(ignore: {missing: {policy_groups: true}}) if SCR.get_arg("-ignore-missing-policy-groups")
|
76
|
-
|
94
|
+
|
77
95
|
end
|
78
96
|
|
79
97
|
desc = "Restores the people manager by using a backup.json file"
|
@@ -2,8 +2,13 @@ ASSETS.cli.config do |config|
|
|
2
2
|
ASSETS.config.workflow do |wf|
|
3
3
|
|
4
4
|
io = nil
|
5
|
+
rescued = false
|
6
|
+
|
5
7
|
# default rescue
|
6
8
|
wf.rescue do |exception, io|
|
9
|
+
next io if rescued
|
10
|
+
rescued = true
|
11
|
+
|
7
12
|
io.session.logger.debug(exception.patch_full_message)
|
8
13
|
wf.run(:close, io: io)
|
9
14
|
io
|
@@ -5,6 +5,29 @@ module Eco
|
|
5
5
|
module Files
|
6
6
|
class Directory
|
7
7
|
|
8
|
+
class << self
|
9
|
+
def create(path, includes_file: false)
|
10
|
+
return true if Files.file_exists?(path)
|
11
|
+
|
12
|
+
parts = Files.split(File.expand_path(path))
|
13
|
+
filename = parts.pop if includes_file
|
14
|
+
|
15
|
+
return true if Files.dir_exists?(File.join(*parts))
|
16
|
+
|
17
|
+
subpath = nil
|
18
|
+
begin
|
19
|
+
parts.each do |curr|
|
20
|
+
subpath = subpath ? File.join(subpath, curr) : curr
|
21
|
+
Dir.mkdir(subpath) unless Files.dir_exists?(subpath)
|
22
|
+
end
|
23
|
+
rescue Exception => e
|
24
|
+
pp e
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
8
31
|
attr_reader :dir_path
|
9
32
|
|
10
33
|
def initialize(dir_path = Dir.pwd)
|
@@ -14,12 +37,14 @@ module Eco
|
|
14
37
|
end
|
15
38
|
|
16
39
|
def exists?
|
17
|
-
Files.dir_exists(@dir_path)
|
40
|
+
Files.dir_exists?(@dir_path)
|
18
41
|
end
|
19
42
|
|
20
43
|
def create
|
21
|
-
|
22
|
-
|
44
|
+
return self.full_path if self.exists?
|
45
|
+
if succeed = Directory.create(File.expand_path(@dir_path))
|
46
|
+
return self.full_path
|
47
|
+
end
|
23
48
|
end
|
24
49
|
|
25
50
|
def full_path
|
@@ -57,23 +82,6 @@ module Eco
|
|
57
82
|
File.join(*args)
|
58
83
|
end
|
59
84
|
|
60
|
-
def self.create(path, includes_file: false)
|
61
|
-
return true if Files.file_exists?(path)
|
62
|
-
parts = Files.split(File.expand_path(path))
|
63
|
-
filename = parts.pop if includes_file
|
64
|
-
return true if Files.dir_exists?(File.join(*parts))
|
65
|
-
subpath = nil
|
66
|
-
begin
|
67
|
-
parts.each do |curr|
|
68
|
-
subpath = subpath ? File.join(subpath, curr) : curr
|
69
|
-
Dir.mkdir(subpath) unless Files.dir_exists?(subpath)
|
70
|
-
end
|
71
|
-
rescue Exception => e
|
72
|
-
pp e
|
73
|
-
end
|
74
|
-
false
|
75
|
-
end
|
76
|
-
|
77
85
|
private
|
78
86
|
|
79
87
|
def file_pattern(value)
|
data/lib/eco/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eco-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -340,6 +340,7 @@ files:
|
|
340
340
|
- lib/eco/api/organization/preferences.rb
|
341
341
|
- lib/eco/api/organization/preferences_reference.json
|
342
342
|
- lib/eco/api/organization/presets_factory.rb
|
343
|
+
- lib/eco/api/organization/presets_integrity.json
|
343
344
|
- lib/eco/api/organization/presets_reference.json
|
344
345
|
- lib/eco/api/organization/presets_values.json
|
345
346
|
- lib/eco/api/organization/tag_tree.rb
|
@@ -374,6 +375,7 @@ files:
|
|
374
375
|
- lib/eco/api/usecases/base_case.rb
|
375
376
|
- lib/eco/api/usecases/base_io.rb
|
376
377
|
- lib/eco/api/usecases/default_cases.rb
|
378
|
+
- lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb
|
377
379
|
- lib/eco/api/usecases/default_cases/append_usergroups_case.rb
|
378
380
|
- lib/eco/api/usecases/default_cases/change_email_case.rb
|
379
381
|
- lib/eco/api/usecases/default_cases/codes_to_tags_case.rb
|
@@ -398,6 +400,8 @@ files:
|
|
398
400
|
- lib/eco/api/usecases/default_cases/restore_db_case.rb
|
399
401
|
- lib/eco/api/usecases/default_cases/set_default_tag_case.rb
|
400
402
|
- lib/eco/api/usecases/default_cases/set_supervisor_case.rb
|
403
|
+
- lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb
|
404
|
+
- lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb
|
401
405
|
- lib/eco/api/usecases/default_cases/switch_supervisor_case.rb
|
402
406
|
- lib/eco/api/usecases/default_cases/to_csv_case.rb
|
403
407
|
- lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb
|