emasser 1.0.6 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +8 -8
  3. data/.env-example +12 -12
  4. data/.github/release-drafter.yml +15 -15
  5. data/.github/workflows/codeql-analysis.yml +70 -70
  6. data/.github/workflows/draft-release.yml +15 -15
  7. data/.github/workflows/gh-pages.yml +32 -32
  8. data/.github/workflows/push-to-docker-mail.yml +28 -28
  9. data/.github/workflows/push-to-docker.yml +35 -35
  10. data/.github/workflows/release.yml +42 -42
  11. data/.github/workflows/rubocop.yml +23 -23
  12. data/.github/workflows/test-cli.yml +72 -72
  13. data/.gitignore +19 -19
  14. data/.mergify.yml +25 -25
  15. data/.rubocop.yml +80 -80
  16. data/.rubocop_todo.yml +27 -27
  17. data/CHANGELOG.md +16 -16
  18. data/Dockerfile +44 -44
  19. data/Gemfile +8 -8
  20. data/Gemfile.lock +104 -104
  21. data/LICENSE.md +15 -15
  22. data/README.md +178 -178
  23. data/Rakefile +18 -18
  24. data/_config.yml +1 -1
  25. data/docs/features.md +1436 -1330
  26. data/docs/redoc/index.html +1230 -1230
  27. data/emasser.gemspec +44 -44
  28. data/exe/emasser +5 -5
  29. data/lib/emasser/cli.rb +37 -37
  30. data/lib/emasser/configuration.rb +49 -49
  31. data/lib/emasser/constants.rb +26 -26
  32. data/lib/emasser/delete.rb +148 -148
  33. data/lib/emasser/errors.rb +14 -14
  34. data/lib/emasser/get.rb +949 -670
  35. data/lib/emasser/help/approvalCac_post_mapper.md +20 -20
  36. data/lib/emasser/help/approvalPac_post_mapper.md +20 -20
  37. data/lib/emasser/help/artifacts_del_mapper.md +9 -9
  38. data/lib/emasser/help/artifacts_post_mapper.md +59 -59
  39. data/lib/emasser/help/artifacts_put_mapper.md +34 -34
  40. data/lib/emasser/help/cloudresource_post_mapper.md +62 -62
  41. data/lib/emasser/help/cmmc_get_mapper.md +4 -4
  42. data/lib/emasser/help/container_post_mapper.md +44 -44
  43. data/lib/emasser/help/controls_put_mapper.md +74 -74
  44. data/lib/emasser/help/milestone_del_mapper.md +11 -11
  45. data/lib/emasser/help/milestone_post_mapper.md +14 -14
  46. data/lib/emasser/help/milestone_put_mapper.md +23 -23
  47. data/lib/emasser/help/poam_del_mapper.md +5 -5
  48. data/lib/emasser/help/poam_post_mapper.md +93 -93
  49. data/lib/emasser/help/poam_put_mapper.md +107 -107
  50. data/lib/emasser/help/staticcode_clear_mapper.md +16 -16
  51. data/lib/emasser/help/staticcode_post_mapper.md +21 -21
  52. data/lib/emasser/help/testresults_post_mapper.md +21 -21
  53. data/lib/emasser/help.rb +11 -11
  54. data/lib/emasser/input_converters.rb +21 -21
  55. data/lib/emasser/options_parser.rb +20 -20
  56. data/lib/emasser/output_converters.rb +111 -111
  57. data/lib/emasser/post.rb +830 -802
  58. data/lib/emasser/put.rb +588 -588
  59. data/lib/emasser/version.rb +5 -5
  60. data/lib/emasser.rb +19 -19
  61. metadata +10 -16
@@ -1,111 +1,111 @@
1
- # frozen_string_literal: true
2
-
3
- module OutputConverters
4
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
5
- # rubocop:disable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
6
- def to_output_hash(obj)
7
- diplay_nulls = (ENV.fetch('EMASSER_CLI_DISPLAY_NULL', 'true').eql? 'true') ? true : false
8
- diplay_datetime = (ENV.fetch('EMASSER_EPOCH_TO_DATETIME', 'false').eql? 'true') ? true : false
9
-
10
- if obj.to_s.include? 'Error message'
11
- begin
12
- index = obj.to_s.index('Response body')+14
13
- arr_obj = obj.to_s[index, obj.to_s.size - index]
14
- JSON.pretty_generate(JSON.parse(arr_obj))
15
- rescue
16
- obj
17
- end
18
- else
19
- obj = obj.to_body if obj.respond_to?(:to_body)
20
- if !diplay_nulls
21
- clean_obj = {}
22
- data_obj = {}
23
- obj.each do |key, value|
24
- if key.to_s.include?('meta')
25
- obj_entry = {}
26
- obj_entry[:meta] = value
27
- clean_obj.merge!(obj_entry)
28
- elsif key.to_s.include?('data')
29
- if value.is_a?(Array)
30
- hash_array = []
31
- value.each do |elements|
32
- hash_array << elements.compact
33
- end
34
- data_obj['data'] = hash_array
35
- else
36
- data_obj['data'] = value.nil? ? value : value.compact
37
- end
38
- elsif key.to_s.include?('pagination')
39
- pg_obj = {}
40
- pg_obj[:pagination] = value
41
- data_obj.merge!(pg_obj)
42
- end
43
- clean_obj.merge!(data_obj)
44
- end
45
- obj = clean_obj
46
- end
47
-
48
- if diplay_datetime
49
- clean_obj = {}
50
- data_obj = {}
51
- obj.each do |key, value|
52
- if key.to_s.include?('meta')
53
- obj_entry = {}
54
- obj_entry[:meta] = value
55
- clean_obj.merge!(obj_entry)
56
- elsif key.to_s.include?('data')
57
- if value.is_a?(Array)
58
- hash_array = []
59
- value.each do |element|
60
- datetime_obj = change_to_datetime(element)
61
- hash_array << datetime_obj
62
- end
63
- data_obj['data'] = hash_array
64
- else
65
- data_obj['data'] = change_to_datetime(value)
66
- end
67
- elsif key.to_s.include?('pagination')
68
- pg_obj = {}
69
- pg_obj[:pagination] = value
70
- data_obj.merge!(pg_obj)
71
- end
72
- clean_obj.merge!(data_obj)
73
- end
74
- obj = clean_obj
75
- end
76
- JSON.pretty_generate(obj)
77
- end
78
- end
79
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
80
- # rubocop:enable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
81
-
82
- # rubocop:disable Style/IdenticalConditionalBranches, Performance/RedundantMatch, Performance/RegexpMatch
83
- def change_to_datetime(obj)
84
- if obj.nil?
85
- return obj
86
- end
87
-
88
- data_obj = {}
89
- obj.each do |key, value|
90
- obj_entry = {}
91
- if value.is_a?(Array)
92
- hash_array = []
93
- value.each do |element|
94
- hash_array << change_to_datetime(element)
95
- end
96
- obj_entry[key] = hash_array
97
- data_obj.merge!(obj_entry)
98
- else
99
- if /\w(date|Date)/.match(key.to_s)
100
- value = value.nil? ? value : Time.at(value)
101
- end
102
- obj_entry[key] = value
103
- data_obj.merge!(obj_entry)
104
- end
105
- end
106
- # rubocop:disable Style/RedundantReturn
107
- return data_obj
108
- # rubocop:enable Style/RedundantReturn
109
- end
110
- # rubocop:enable Style/IdenticalConditionalBranches, Performance/RedundantMatch, Performance/RegexpMatch
111
- end
1
+ # frozen_string_literal: true
2
+
3
+ module OutputConverters
4
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
5
+ # rubocop:disable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
6
+ def to_output_hash(obj)
7
+ diplay_nulls = (ENV.fetch('EMASSER_CLI_DISPLAY_NULL', 'true').eql? 'true') ? true : false
8
+ diplay_datetime = (ENV.fetch('EMASSER_EPOCH_TO_DATETIME', 'false').eql? 'true') ? true : false
9
+
10
+ if obj.to_s.include? 'Error message'
11
+ begin
12
+ index = obj.to_s.index('Response body')+14
13
+ arr_obj = obj.to_s[index, obj.to_s.size - index]
14
+ JSON.pretty_generate(JSON.parse(arr_obj))
15
+ rescue
16
+ obj
17
+ end
18
+ else
19
+ obj = obj.to_body if obj.respond_to?(:to_body)
20
+ if !diplay_nulls
21
+ clean_obj = {}
22
+ data_obj = {}
23
+ obj.each do |key, value|
24
+ if key.to_s.include?('meta')
25
+ obj_entry = {}
26
+ obj_entry[:meta] = value
27
+ clean_obj.merge!(obj_entry)
28
+ elsif key.to_s.include?('data')
29
+ if value.is_a?(Array)
30
+ hash_array = []
31
+ value.each do |elements|
32
+ hash_array << elements.compact
33
+ end
34
+ data_obj['data'] = hash_array
35
+ else
36
+ data_obj['data'] = value.nil? ? value : value.compact
37
+ end
38
+ elsif key.to_s.include?('pagination')
39
+ pg_obj = {}
40
+ pg_obj[:pagination] = value
41
+ data_obj.merge!(pg_obj)
42
+ end
43
+ clean_obj.merge!(data_obj)
44
+ end
45
+ obj = clean_obj
46
+ end
47
+
48
+ if diplay_datetime
49
+ clean_obj = {}
50
+ data_obj = {}
51
+ obj.each do |key, value|
52
+ if key.to_s.include?('meta')
53
+ obj_entry = {}
54
+ obj_entry[:meta] = value
55
+ clean_obj.merge!(obj_entry)
56
+ elsif key.to_s.include?('data')
57
+ if value.is_a?(Array)
58
+ hash_array = []
59
+ value.each do |element|
60
+ datetime_obj = change_to_datetime(element)
61
+ hash_array << datetime_obj
62
+ end
63
+ data_obj['data'] = hash_array
64
+ else
65
+ data_obj['data'] = change_to_datetime(value)
66
+ end
67
+ elsif key.to_s.include?('pagination')
68
+ pg_obj = {}
69
+ pg_obj[:pagination] = value
70
+ data_obj.merge!(pg_obj)
71
+ end
72
+ clean_obj.merge!(data_obj)
73
+ end
74
+ obj = clean_obj
75
+ end
76
+ JSON.pretty_generate(obj)
77
+ end
78
+ end
79
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
80
+ # rubocop:enable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
81
+
82
+ # rubocop:disable Style/IdenticalConditionalBranches
83
+ def change_to_datetime(obj)
84
+ if obj.nil?
85
+ return obj
86
+ end
87
+
88
+ data_obj = {}
89
+ obj.each do |key, value|
90
+ obj_entry = {}
91
+ if value.is_a?(Array)
92
+ hash_array = []
93
+ value.each do |element|
94
+ hash_array << change_to_datetime(element)
95
+ end
96
+ obj_entry[key] = hash_array
97
+ data_obj.merge!(obj_entry)
98
+ else
99
+ if /(date|Date)/.match?(key.to_s)
100
+ value = value.nil? ? value : Time.at(value.to_i)
101
+ end
102
+ obj_entry[key] = value
103
+ data_obj.merge!(obj_entry)
104
+ end
105
+ end
106
+ # rubocop:disable Style/RedundantReturn
107
+ return data_obj
108
+ # rubocop:enable Style/RedundantReturn
109
+ end
110
+ # rubocop:enable Style/IdenticalConditionalBranches
111
+ end