eco-helpers 0.8.3 → 0.8.4

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/eco-helpers.gemspec +0 -2
  3. data/lib/eco-helpers.rb +0 -1
  4. data/lib/eco/api/common/people/person_entry.rb +67 -30
  5. data/lib/eco/api/common/version_patches.rb +2 -1
  6. data/lib/eco/api/common/version_patches/base_model.rb +27 -0
  7. data/lib/eco/api/organization/people.rb +6 -0
  8. data/lib/eco/api/organization/tag_tree.rb +6 -0
  9. data/lib/eco/api/policies/policy.rb +2 -2
  10. data/lib/eco/api/session.rb +23 -30
  11. data/lib/eco/api/session/batch.rb +3 -2
  12. data/lib/eco/api/session/batch_job.rb +18 -10
  13. data/lib/eco/api/session/batch_status.rb +27 -11
  14. data/lib/eco/api/session/config.rb +20 -7
  15. data/lib/eco/api/usecases/default_cases/change_email_case.rb +2 -6
  16. data/lib/eco/api/usecases/default_cases/refresh_presets_case.rb +3 -2
  17. data/lib/eco/api/usecases/use_case.rb +6 -5
  18. data/lib/eco/api/usecases/use_case_chain.rb +3 -3
  19. data/lib/eco/api/usecases/use_case_io.rb +3 -3
  20. data/lib/eco/assets.rb +3 -1
  21. data/lib/eco/{common → assets}/language.rb +2 -2
  22. data/lib/eco/cli.rb +3 -4
  23. data/lib/eco/cli/config.rb +10 -0
  24. data/lib/eco/cli/config/options.rb +11 -0
  25. data/lib/eco/cli/scripting.rb +23 -0
  26. data/lib/eco/cli/scripting/args_helpers.rb +55 -0
  27. data/lib/eco/cli/scripting/argument.rb +31 -0
  28. data/lib/eco/cli/scripting/arguments.rb +70 -0
  29. data/lib/eco/common.rb +1 -3
  30. data/lib/eco/data/crypto/encryption.rb +2 -2
  31. data/lib/eco/language/models/collection.rb +1 -1
  32. data/lib/eco/version.rb +1 -1
  33. metadata +9 -62
  34. data/lib/eco/cli/api.rb +0 -14
  35. data/lib/eco/cli/root.rb +0 -9
  36. data/lib/eco/cli/session.rb +0 -9
  37. data/lib/eco/cli/session/batch.rb +0 -9
  38. data/lib/eco/common/base_cli.rb +0 -23
  39. data/lib/eco/common/base_cli_backup.rb +0 -120
  40. data/lib/eco/common/meta_thor.rb +0 -111
  41. data/lib/eco/common/meta_thor/command_group.rb +0 -36
  42. data/lib/eco/common/meta_thor/command_unit.rb +0 -48
  43. data/lib/eco/common/meta_thor/input_backup.rb +0 -111
  44. data/lib/eco/common/meta_thor/input_multi_backup.rb +0 -139
  45. data/lib/eco/common/meta_thor/pipe.rb +0 -85
  46. data/lib/eco/common/meta_thor/thor.rb +0 -1
  47. data/lib/eco/common/meta_thor/thor/command.rb +0 -36
  48. data/lib/eco/common/meta_thor/value.rb +0 -54
  49. data/lib/eco/scripting.rb +0 -32
  50. data/lib/eco/scripting/README.md +0 -11
  51. data/lib/eco/scripting/args_helpers.rb +0 -53
  52. data/lib/eco/scripting/argument.rb +0 -29
  53. data/lib/eco/scripting/arguments.rb +0 -68
@@ -1,85 +0,0 @@
1
- module Eco
2
- module Common
3
- class MetaThor
4
- class Pipe
5
- SYM = "!"
6
- SYMS = [SYM]
7
-
8
- class << self
9
- #def rex_pipes
10
- # alternatives = Regex.escape(SYMS).join("|")
11
- # /(#{alternatives})/g
12
- #end
13
-
14
- def type(str)
15
- case str
16
- when SYM
17
- :standard
18
- else
19
- :unkown
20
- end
21
- end
22
-
23
- def pipe?(str)
24
- SYMS.include?(str)
25
- end
26
-
27
- def piped?(args)
28
- args.any? do |arg|
29
- pipe?(arg)
30
- end
31
- end
32
-
33
- def split(args, pipe_to_sym: false)
34
- args = (args && [args].flatten) || []
35
- if piped?(args)
36
- args.reduce([[]]) do |groups,arg|
37
- cg = []
38
- cg = pipe?(arg) ? cg : groups.last
39
- cg.push(arg) if arg
40
-
41
- groups.push(cg) if pipe?(arg)
42
- groups
43
- end
44
- else
45
- [].push(args)
46
- end
47
- end
48
- end
49
-
50
- attr_reader :type, :command
51
-
52
- def initialize(command:)
53
- @command = command
54
- args = @command.source_args
55
- @type = self.class.type(args.shift)
56
- end
57
-
58
- def standard?
59
- @type == :standard
60
- end
61
-
62
- def command_group
63
- command.group
64
- end
65
-
66
- def index
67
- command.index
68
- end
69
-
70
- def input_index
71
- return nil unless index > 0
72
- case type
73
- when :standard
74
- index - 1
75
- end
76
- end
77
-
78
- def input
79
- command_group[input_index].output if input_index
80
- end
81
-
82
- end
83
- end
84
- end
85
- end
@@ -1 +0,0 @@
1
- require_relative 'thor/command'
@@ -1,36 +0,0 @@
1
- class Thor
2
- class Command
3
-
4
- # By default, a command invokes a method in the thor class. You can change this
5
- # implementation to create custom commands.
6
- # Source: https://github.com/erikhuda/thor/blob/master/lib/thor/command.rb
7
- # Trace:
8
- # 1. Base_Class.start
9
- # 2. Thor_Class.dispatch
10
- # - (new) Base.initialize -> with options
11
- # 3. Base_Instance.invoke_command (invocation.rb)
12
- # 4. Command_Instance.run
13
- # @note: modified so it integrates input/output for custom Pipe
14
- def run(instance, args = [])
15
- arity = nil
16
-
17
- if private_method?(instance)
18
- result = instance.class.handle_no_command_error(name)
19
- elsif public_method?(instance)
20
- arity = instance.method(name).arity
21
- result = instance.__send__(name, *args)
22
- elsif local_method?(instance, :method_missing)
23
- result = instance.__send__(:method_missing, name.to_sym, *args)
24
- else
25
- result = instance.class.handle_no_command_error(name)
26
- end
27
-
28
- result
29
- rescue ArgumentError => e
30
- handle_argument_error?(instance, e, caller) ? instance.class.handle_argument_error(self, e, args, arity) : (raise e)
31
- rescue NoMethodError => e
32
- handle_no_method_error?(instance, e, caller) ? instance.class.handle_no_command_error(name) : (raise e)
33
- end
34
-
35
- end
36
- end
@@ -1,54 +0,0 @@
1
- module Eco
2
- module Common
3
- class MetaThor
4
- class Value
5
- KEY = "MetaThorValue"
6
- KEY_OPTION = "MetaThorJSON"
7
-
8
- class << self
9
- def to_value(doc)
10
- case
11
- when doc.is_a?(Hash)
12
- case
13
- when doc.key?(KEY_OPTION)
14
- to_value(doc[KEY_OPTION])
15
- when doc.key?(KEY)
16
- doc[KEY]
17
- else
18
- doc
19
- end
20
- when doc.is_a?(String)
21
- to_value(JSON.parse(doc))
22
- when doc.is_a?(Value)
23
- value.value
24
- end
25
- end
26
-
27
- def key?(object)
28
-
29
- end
30
- end
31
-
32
- attr_reader :value
33
-
34
- def initialize(value)
35
- @doc = {"#{KEY}" => value}
36
- end
37
-
38
- def value
39
- @doc[KEY]
40
- end
41
-
42
- def as_input_option
43
- "--#{INPUT_OPTION}=#{KEY_OPTION}:#{@doc.to_json}"
44
- end
45
-
46
- def as_option
47
- {"#{INPUT_SYM}" => self}
48
- end
49
-
50
- end
51
-
52
- end
53
- end
54
- end
data/lib/eco/scripting.rb DELETED
@@ -1,32 +0,0 @@
1
- require_relative 'scripting/args_helpers'
2
- require_relative 'scripting/argument'
3
- require_relative 'scripting/arguments'
4
-
5
- module Eco
6
- #TODO integrate Thor to build the CLI from bottom to top on load
7
- class Scripting
8
- include Scripting::ArgsHelpers
9
-
10
- def args_contain?(*values)
11
- match?(ARGV, patterns, [:any, :or, :insensitive, :pattern])
12
- end
13
-
14
- def modifiers(*values)
15
- values.select { |arg| is_modifier?(arg) }
16
- end
17
-
18
- def args_filter_match(*values)
19
- modifier = Eco::Language::MatchModifier.new.any.or.insensitive
20
- patterns = modifier.to_regex(values)
21
- params = modifiers(*ARGV)
22
- patterns.each_with_index.reduce([]) { |done, (pat, i) |
23
- done.push(values[i]) if Handy.match?(params, pat, modifier)
24
- done
25
- }
26
- end
27
-
28
- end
29
- end
30
-
31
-
32
- SCR = Eco::Scripting.new
@@ -1,11 +0,0 @@
1
- # API Helpers Command Line Interface
2
-
3
- The idea is to use **[Thor](http://whatisthor.com/)**
4
-
5
- `TODO`:
6
-
7
- * check if the unique point access can be feed by the current loading architecture, and make it fit with *Thor*
8
- * analyze if **subcommands** can do the trick there and how
9
- * check of **modifiers / flags** support (is it all *via subcommands*)
10
- * implement the architecture to easily expose specific logics of the helpers
11
- * check if the cli pipe can be used to **thor** between commands
@@ -1,53 +0,0 @@
1
- module Eco
2
- class Scripting
3
- module ArgsHelpers
4
-
5
- def is_modifier?(value)
6
- value&.start_with?("-")
7
- end
8
-
9
- def arguments
10
- @arguments ||= Arguments.new
11
- end
12
-
13
- def stop_on_unknown!(exclude: [])
14
- if arguments.any_unkown?(exclude: exclude)
15
- raise "There are unknown options in your command line arguments: #{arguments.unknown(exclude: exclude)}"
16
- end
17
- end
18
-
19
- def get_arg(key, with_param: false, valid: true)
20
- # track what a known option looks like
21
- arguments.add(key, with_param: with_param)
22
- return nil if !ARGV.include?(key)
23
- value = true
24
- if with_param
25
- next_i = ARGV.index(key) + 1
26
- value = ARGV[next_i]
27
- #puts "modifier argument: #{value}"
28
- value = nil if valid && is_modifier?(value)
29
- end
30
- return value
31
- end
32
-
33
- def get_file(key, required: false, should_exist: true)
34
- filename = get_arg(key, with_param: true)
35
- if !filename
36
- if required
37
- puts "you need to specify a file '#{key} file'"
38
- exit
39
- end
40
- elsif !(File.exists?(filename) || File.exists?(File.expand_path(filename)))
41
- if should_exist && required
42
- puts "file doesn't exist #{filename}"
43
- exit
44
- end
45
- end
46
-
47
- filename = File.expand_path(filename) if filename && should_exist
48
- filename
49
- end
50
-
51
- end
52
- end
53
- end
@@ -1,29 +0,0 @@
1
- module Eco
2
- class Scripting
3
- class Argument
4
-
5
- attr_reader :key
6
-
7
- def initialize(key, with_param: false)
8
- @key = key
9
- @with_param = !!with_param
10
- end
11
-
12
- def args_slice(*args)
13
- #pp "known arg '#{key}' => included? #{args.include?(key)}"
14
- return args unless args.include?(key)
15
- i = args.index(key)
16
- j = with_param?? i+1 : i
17
- args - args.slice(i..j)
18
- end
19
-
20
- def with_param!
21
- @with_param = true
22
- end
23
-
24
- def with_param?
25
- @with_param
26
- end
27
- end
28
- end
29
- end
@@ -1,68 +0,0 @@
1
- module Eco
2
- class Scripting
3
- class Arguments
4
- include Enumerable
5
-
6
- attr_reader :args
7
-
8
- def initialize(args = ARGV)
9
- @args = args
10
- @known = {}
11
- end
12
-
13
- def each(params: {}, &block)
14
- return to_enum(:each) unless block
15
- @known.values.each(&block)
16
- end
17
-
18
- def add(key, with_param: false)
19
- self << Argument.new(key, with_param: with_param)
20
- end
21
-
22
- def <<(arg)
23
- raise "Expected Argument. Given #{arg.class}" unless arg.is_a?(Argument)
24
- if karg = @known[arg.key]
25
- #puts "Found already existent option #{arg.key} (with_param: arg.with_param?)"
26
- karg.with_param! if arg.with_param?
27
- else
28
- #puts "Adding unexistent option #{arg.key}"
29
- @known[arg.key] = arg
30
- end
31
- self
32
- end
33
-
34
- def known?(value)
35
- @known.key?(to_key(value))
36
- end
37
-
38
- def keys
39
- @known.keys
40
- end
41
-
42
- def unknown(exclude: [])
43
- reduce(args.dup - exclude) do |not_known, arg|
44
- arg.args_slice(*not_known)
45
- end
46
- end
47
-
48
- def any_unkown?(exclude: [])
49
- unknown(exclude: exclude).length > 0
50
- end
51
-
52
- private
53
-
54
- def to_key(value)
55
- case value
56
- when String
57
- value
58
- when Argument
59
- value.key
60
- else
61
- "Missuse: only able to transform to key a String or an Argument. Given #{value.class}"
62
- end
63
- end
64
-
65
-
66
- end
67
- end
68
- end