pd1_tools 0.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +12 -0
  3. data/exe/pd1 +8 -0
  4. data/lib/avmtrf1/active_directory/user.rb +28 -0
  5. data/lib/avmtrf1/active_directory.rb +8 -0
  6. data/lib/avmtrf1/ad_user.rb +11 -0
  7. data/lib/avmtrf1/check_point/session/login.rb +57 -0
  8. data/lib/avmtrf1/check_point/session.rb +60 -0
  9. data/lib/avmtrf1/check_point.rb +3 -0
  10. data/lib/avmtrf1/default_esosti.rb +20 -0
  11. data/lib/avmtrf1/default_jira.rb +18 -0
  12. data/lib/avmtrf1/default_redmine.rb +16 -0
  13. data/lib/avmtrf1/docker/image.rb +49 -0
  14. data/lib/avmtrf1/docker/image_runner.rb +83 -0
  15. data/lib/avmtrf1/docker.rb +9 -0
  16. data/lib/avmtrf1/esosti/entities/issue.rb +24 -0
  17. data/lib/avmtrf1/esosti/entities.rb +9 -0
  18. data/lib/avmtrf1/esosti/instance/changed.rb +33 -0
  19. data/lib/avmtrf1/esosti/instance.rb +22 -0
  20. data/lib/avmtrf1/esosti/raw_data_sanitizer.rb +47 -0
  21. data/lib/avmtrf1/esosti/session/action_base.rb +34 -0
  22. data/lib/avmtrf1/esosti/session/atividades.rb +35 -0
  23. data/lib/avmtrf1/esosti/session/login.rb +47 -0
  24. data/lib/avmtrf1/esosti/session/solicitacao/main.rb +49 -0
  25. data/lib/avmtrf1/esosti/session/solicitacao.rb +81 -0
  26. data/lib/avmtrf1/esosti/session.rb +36 -0
  27. data/lib/avmtrf1/esosti.rb +8 -0
  28. data/lib/avmtrf1/executables.rb +23 -0
  29. data/lib/avmtrf1/forponto/parsers/day_registers.rb +19 -0
  30. data/lib/avmtrf1/forponto/parsers/espelho/day_node.rb +50 -0
  31. data/lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb +21 -0
  32. data/lib/avmtrf1/forponto/parsers/espelho/row_node.rb +34 -0
  33. data/lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb +71 -0
  34. data/lib/avmtrf1/forponto/parsers/espelho/sub_node.rb +20 -0
  35. data/lib/avmtrf1/forponto/parsers/espelho/summary_node.rb +55 -0
  36. data/lib/avmtrf1/forponto/parsers/espelho/utils.rb +32 -0
  37. data/lib/avmtrf1/forponto/parsers/espelho.rb +26 -0
  38. data/lib/avmtrf1/forponto/session/day_registers.rb +39 -0
  39. data/lib/avmtrf1/forponto/session/interval.rb +27 -0
  40. data/lib/avmtrf1/forponto/session/login.rb +45 -0
  41. data/lib/avmtrf1/forponto/session.rb +32 -0
  42. data/lib/avmtrf1/forponto/user/balance.rb +155 -0
  43. data/lib/avmtrf1/forponto/user/day_registers.rb +32 -0
  44. data/lib/avmtrf1/forponto/user/month.rb +141 -0
  45. data/lib/avmtrf1/forponto/user.rb +22 -0
  46. data/lib/avmtrf1/git/cached_repository.rb +27 -0
  47. data/lib/avmtrf1/git/gitlab.rb +11 -0
  48. data/lib/avmtrf1/git/issue_on_repository.rb +100 -0
  49. data/lib/avmtrf1/git/push_large/_utils.rb +16 -0
  50. data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +21 -0
  51. data/lib/avmtrf1/git/push_large/lfs_commit/checkout_previous_revision.rb +35 -0
  52. data/lib/avmtrf1/git/push_large/lfs_commit/commit_changes.rb +48 -0
  53. data/lib/avmtrf1/git/push_large/lfs_commit/helpers.rb +29 -0
  54. data/lib/avmtrf1/git/push_large/lfs_commit/pick_source_revision.rb +103 -0
  55. data/lib/avmtrf1/git/push_large/lfs_commit/push.rb +90 -0
  56. data/lib/avmtrf1/git/push_large/lfs_commit/track_large_files.rb +53 -0
  57. data/lib/avmtrf1/git/push_large/lfs_commit.rb +47 -0
  58. data/lib/avmtrf1/git/push_large/source_commit/push.rb +42 -0
  59. data/lib/avmtrf1/git/push_large/source_commit.rb +58 -0
  60. data/lib/avmtrf1/git/push_large.rb +69 -0
  61. data/lib/avmtrf1/git/reference.rb +34 -0
  62. data/lib/avmtrf1/git.rb +10 -0
  63. data/lib/avmtrf1/gitlab/commit.rb +37 -0
  64. data/lib/avmtrf1/gitlab/repository.rb +41 -0
  65. data/lib/avmtrf1/ini/profile.rb +42 -0
  66. data/lib/avmtrf1/ini.rb +55 -0
  67. data/lib/avmtrf1/inventario_sistemas/parser/body.rb +27 -0
  68. data/lib/avmtrf1/inventario_sistemas/parser/body_row.rb +12 -0
  69. data/lib/avmtrf1/inventario_sistemas/parser/header.rb +38 -0
  70. data/lib/avmtrf1/inventario_sistemas/parser/header_column.rb +27 -0
  71. data/lib/avmtrf1/inventario_sistemas/parser.rb +40 -0
  72. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/elements.rb +54 -0
  73. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/layout.rb +55 -0
  74. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/stylesheet.css +57 -0
  75. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +41 -0
  76. data/lib/avmtrf1/inventario_sistemas/site_build/index.rb +20 -0
  77. data/lib/avmtrf1/inventario_sistemas/site_build/sistema.rb +62 -0
  78. data/lib/avmtrf1/inventario_sistemas/site_build/sistemas_index.rb +31 -0
  79. data/lib/avmtrf1/inventario_sistemas/site_build.rb +71 -0
  80. data/lib/avmtrf1/inventario_sistemas.rb +38 -0
  81. data/lib/avmtrf1/issues/factory.rb +22 -0
  82. data/lib/avmtrf1/issues.rb +7 -0
  83. data/lib/avmtrf1/jira/entities/issue.rb +30 -0
  84. data/lib/avmtrf1/jira/entities.rb +9 -0
  85. data/lib/avmtrf1/jira/instance.rb +28 -0
  86. data/lib/avmtrf1/jira.rb +8 -0
  87. data/lib/avmtrf1/node_js/docker_image.rb +14 -0
  88. data/lib/avmtrf1/node_js.rb +9 -0
  89. data/lib/avmtrf1/openvpn/config/builder.rb +59 -0
  90. data/lib/avmtrf1/openvpn/config/parser/builder.rb +62 -0
  91. data/lib/avmtrf1/openvpn/config/parser/line.rb +47 -0
  92. data/lib/avmtrf1/openvpn/config/parser/simple.rb +27 -0
  93. data/lib/avmtrf1/openvpn/config/parser/tag.rb +39 -0
  94. data/lib/avmtrf1/openvpn/config/parser.rb +20 -0
  95. data/lib/avmtrf1/oracle/connection/base.rb +66 -0
  96. data/lib/avmtrf1/oracle/connection/string_builder.rb +44 -0
  97. data/lib/avmtrf1/oracle/connection.rb +12 -0
  98. data/lib/avmtrf1/oracle/object/base.rb +39 -0
  99. data/lib/avmtrf1/oracle/object/table.rb +15 -0
  100. data/lib/avmtrf1/oracle/object/user.rb +15 -0
  101. data/lib/avmtrf1/oracle/object/view.rb +15 -0
  102. data/lib/avmtrf1/oracle/object.rb +25 -0
  103. data/lib/avmtrf1/oracle/objects/relation.rb +23 -0
  104. data/lib/avmtrf1/oracle/objects/sql_builder.rb +64 -0
  105. data/lib/avmtrf1/oracle/objects.rb +53 -0
  106. data/lib/avmtrf1/oracle/oci8.rb +29 -0
  107. data/lib/avmtrf1/oracle.rb +10 -0
  108. data/lib/avmtrf1/patches/avm/git/issue/complete.rb +50 -0
  109. data/lib/avmtrf1/patches/avm/git/issue.rb +4 -0
  110. data/lib/avmtrf1/patches/avm/git/launcher/base.rb +46 -0
  111. data/lib/avmtrf1/patches/avm/git/launcher.rb +4 -0
  112. data/lib/avmtrf1/patches/avm/git.rb +4 -0
  113. data/lib/avmtrf1/patches/avm.rb +4 -0
  114. data/lib/avmtrf1/patches/inifile.rb +13 -0
  115. data/lib/avmtrf1/patches.rb +4 -0
  116. data/lib/avmtrf1/php/docker_images/base.rb +49 -0
  117. data/lib/avmtrf1/php/docker_images/factory.rb +37 -0
  118. data/lib/avmtrf1/php/docker_images/v5.rb +47 -0
  119. data/lib/avmtrf1/php/docker_images/v7.rb +27 -0
  120. data/lib/avmtrf1/php/docker_images/v7_v4.rb +30 -0
  121. data/lib/avmtrf1/php/docker_images/v8.rb +19 -0
  122. data/lib/avmtrf1/php/docker_images.rb +11 -0
  123. data/lib/avmtrf1/php.rb +9 -0
  124. data/lib/avmtrf1/red/client/authorization.xml.erb +4 -0
  125. data/lib/avmtrf1/red/client.rb +38 -0
  126. data/lib/avmtrf1/red/helper.rb +35 -0
  127. data/lib/avmtrf1/red/profile/put_file.xml.erb +19 -0
  128. data/lib/avmtrf1/red/profile.rb +58 -0
  129. data/lib/avmtrf1/red/server.rb +33 -0
  130. data/lib/avmtrf1/red.rb +5 -0
  131. data/lib/avmtrf1/redmine/entities/issue.rb +29 -0
  132. data/lib/avmtrf1/redmine/entities/issue_status.rb +23 -0
  133. data/lib/avmtrf1/redmine/entities.rb +10 -0
  134. data/lib/avmtrf1/redmine/instance.rb +41 -0
  135. data/lib/avmtrf1/redmine.rb +7 -0
  136. data/lib/avmtrf1/rest_provider/entity.rb +18 -0
  137. data/lib/avmtrf1/rest_provider/instance/issues.rb +30 -0
  138. data/lib/avmtrf1/rest_provider/instance.rb +30 -0
  139. data/lib/avmtrf1/rest_provider/request.rb +44 -0
  140. data/lib/avmtrf1/rest_provider/response.rb +73 -0
  141. data/lib/avmtrf1/rest_provider.rb +7 -0
  142. data/lib/avmtrf1/result.rb +44 -0
  143. data/lib/avmtrf1/ruby.rb +9 -0
  144. data/lib/avmtrf1/tools/application.rb +13 -0
  145. data/lib/avmtrf1/tools/core_ext.rb +4 -0
  146. data/lib/avmtrf1/tools/msgraph/api/entity.rb +35 -0
  147. data/lib/avmtrf1/tools/msgraph/api/member.rb +31 -0
  148. data/lib/avmtrf1/tools/msgraph/api/root.rb +27 -0
  149. data/lib/avmtrf1/tools/msgraph/api/team/member_add.rb +36 -0
  150. data/lib/avmtrf1/tools/msgraph/api/team.rb +40 -0
  151. data/lib/avmtrf1/tools/msgraph/api.rb +55 -0
  152. data/lib/avmtrf1/tools/msgraph/error.rb +31 -0
  153. data/lib/avmtrf1/tools/msgraph/request_mixin.rb +18 -0
  154. data/lib/avmtrf1/tools/msgraph/response_mixin.rb +23 -0
  155. data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
  156. data/lib/avmtrf1/tools/msgraph.rb +11 -0
  157. data/lib/avmtrf1/tools/rubygems/dependency.rb +20 -0
  158. data/lib/avmtrf1/tools/rubygems/not_found_error.rb +17 -0
  159. data/lib/avmtrf1/tools/rubygems.rb +11 -0
  160. data/lib/avmtrf1/tools/runner/check_point/login.rb +33 -0
  161. data/lib/avmtrf1/tools/runner/check_point.rb +17 -0
  162. data/lib/avmtrf1/tools/runner/esosti/changed.rb +39 -0
  163. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +39 -0
  164. data/lib/avmtrf1/tools/runner/esosti/request.rb +76 -0
  165. data/lib/avmtrf1/tools/runner/esosti.rb +27 -0
  166. data/lib/avmtrf1/tools/runner/forponto/espelho.rb +47 -0
  167. data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +32 -0
  168. data/lib/avmtrf1/tools/runner/forponto/resumos.rb +87 -0
  169. data/lib/avmtrf1/tools/runner/forponto/saldo.rb +91 -0
  170. data/lib/avmtrf1/tools/runner/forponto.rb +70 -0
  171. data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +81 -0
  172. data/lib/avmtrf1/tools/runner/git/gitlab.rb +20 -0
  173. data/lib/avmtrf1/tools/runner/git/issues_check.rb +59 -0
  174. data/lib/avmtrf1/tools/runner/git/push_large.rb +46 -0
  175. data/lib/avmtrf1/tools/runner/git.rb +14 -0
  176. data/lib/avmtrf1/tools/runner/inventario_sistemas.rb +71 -0
  177. data/lib/avmtrf1/tools/runner/msgraph/joined_teams.rb +39 -0
  178. data/lib/avmtrf1/tools/runner/msgraph/request.rb +45 -0
  179. data/lib/avmtrf1/tools/runner/msgraph/team/member/add.rb +48 -0
  180. data/lib/avmtrf1/tools/runner/msgraph/team/member.rb +25 -0
  181. data/lib/avmtrf1/tools/runner/msgraph/team/members.rb +38 -0
  182. data/lib/avmtrf1/tools/runner/msgraph/team.rb +27 -0
  183. data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
  184. data/lib/avmtrf1/tools/runner/msgraph.rb +43 -0
  185. data/lib/avmtrf1/tools/runner/node_js/docker.rb +15 -0
  186. data/lib/avmtrf1/tools/runner/node_js.rb +18 -0
  187. data/lib/avmtrf1/tools/runner/openvpn.rb +91 -0
  188. data/lib/avmtrf1/tools/runner/oracle/query.rb +71 -0
  189. data/lib/avmtrf1/tools/runner/oracle/source_get.rb +51 -0
  190. data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +59 -0
  191. data/lib/avmtrf1/tools/runner/oracle.rb +37 -0
  192. data/lib/avmtrf1/tools/runner/php/docker.rb +20 -0
  193. data/lib/avmtrf1/tools/runner/php.rb +18 -0
  194. data/lib/avmtrf1/tools/runner/red.rb +83 -0
  195. data/lib/avmtrf1/tools/runner/source.rb +14 -0
  196. data/lib/avmtrf1/tools/runner.rb +43 -0
  197. data/lib/avmtrf1/tools.rb +4 -0
  198. data/lib/pd1_tools/version.rb +5 -0
  199. data/lib/pd1_tools.rb +7 -0
  200. data/template/avmtrf1/node_js/docker_image/Dockerfile.template +25 -0
  201. data/template/avmtrf1/node_js/docker_image/auxiliary/config_banner.sh +15 -0
  202. data/template/avmtrf1/node_js/docker_image/auxiliary/init.sh +18 -0
  203. data/template/avmtrf1/node_js/docker_image/auxiliary/lib.sh +30 -0
  204. data/template/avmtrf1/node_js/docker_image/auxiliary/ng_serve.sh +16 -0
  205. data/template/avmtrf1/node_js/docker_image/auxiliary/npm_install.sh +21 -0
  206. data/template/avmtrf1/node_js/docker_image/auxiliary/start.sh +17 -0
  207. data/template/avmtrf1/php/docker_images/base/Dockerfile.template +104 -0
  208. data/template/avmtrf1/php/docker_images/base/aux/apache_foreground.sh +16 -0
  209. data/template/avmtrf1/php/docker_images/base/aux/apache_user.sh +54 -0
  210. data/template/avmtrf1/php/docker_images/base/aux/app_user_run.sh +17 -0
  211. data/template/avmtrf1/php/docker_images/base/aux/config_banner.sh +20 -0
  212. data/template/avmtrf1/php/docker_images/base/aux/init.sh +39 -0
  213. data/template/avmtrf1/php/docker_images/base/aux/laravel.sh +58 -0
  214. data/template/avmtrf1/php/docker_images/base/aux/lib.sh +70 -0
  215. data/template/avmtrf1/php/docker_images/base/aux/pear.sh +35 -0
  216. data/template/avmtrf1/php/docker_images/base/aux/php_composer.sh +31 -0
  217. data/template/avmtrf1/php/docker_images/base/aux/php_values.sh +41 -0
  218. data/template/avmtrf1/php/docker_images/base/aux/setup_apache_site.sh +16 -0
  219. data/template/avmtrf1/php/docker_images/base/aux/start.sh +26 -0
  220. data/template/avmtrf1/php/docker_images/base/aux/templates/apache_site.conf +12 -0
  221. data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
  222. metadata +460 -0
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/#{File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
+ require path
5
+ end
6
+
7
+ module Avmtrf1
8
+ module Oracle
9
+ end
10
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/issue/complete'
4
+ require 'eac_ruby_utils/patch'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avmtrf1
8
+ module Patches
9
+ module Avm
10
+ module Git
11
+ module Issue
12
+ module Complete
13
+ extend ::ActiveSupport::Concern
14
+
15
+ REDMINE_ISSUE_ID_PATTERN = /\Aredmine_(\d+)\z/.freeze
16
+ JIRA_ISSUE_ID_PATTERN = /\A([a-z][a-z0-9]*-\d+)\z/.freeze
17
+ ESOSTI_ISSUE_ID_PATTERN = /\A((?:ss|in)\d+)\z/.freeze
18
+
19
+ included do
20
+ prepend InstanceMethods
21
+ end
22
+
23
+ module InstanceMethods
24
+ def issue_id
25
+ %w[redmine esosti jira].find do |provider|
26
+ issue_id_by_provider(provider)
27
+ end
28
+ end
29
+
30
+ def issue_id_by_provider(provider)
31
+ issue_id_pattern_by_provider(provider).match(branch_name).if_present do |m|
32
+ [provider, m[1]]
33
+ end
34
+ end
35
+
36
+ def issue_id_pattern_by_provider(provider)
37
+ self.class.const_get("#{provider}_issue_id_pattern".upcase)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ EacRubyUtils.patch(
48
+ Avm::Git::Issue::Complete,
49
+ Avmtrf1::Patches::Avm::Git::Issue::Complete
50
+ )
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/git/launcher/base'
4
+ require 'eac_ruby_utils/patch'
5
+ require 'active_support/concern'
6
+
7
+ module Avmtrf1
8
+ module Patches
9
+ module Avm
10
+ module Git
11
+ module Launcher
12
+ module Base
13
+ extend ActiveSupport::Concern
14
+
15
+ included do
16
+ include InstanceMethods
17
+ end
18
+
19
+ module InstanceMethods
20
+ def status_files
21
+ execute!('-c', 'core.quotepath=off', 'status', '--porcelain')
22
+ .each_line.map do |line|
23
+ parse_status_file(line)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def parse_status_file(line)
30
+ m = /\A(.)(.)\s*(\S.*)\z/.match(line.strip)
31
+ return ::OpenStruct.new(stage: m[1], dirty: m[2], path: m[3]) if m # rubocop:disable Style/OpenStructUse
32
+
33
+ raise "\"#{line.strip}\" did not match pattern"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ EacRubyUtils.patch(
44
+ Avm::Git::Launcher::Base,
45
+ Avmtrf1::Patches::Avm::Git::Launcher::Base
46
+ )
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'inifile'
4
+
5
+ class IniFile
6
+ class Parser
7
+ alias original_typecast typecast
8
+
9
+ def typecast(value)
10
+ value.to_s
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'rubygems'
5
+ require 'avmtrf1/docker/image'
6
+
7
+ module Avmtrf1
8
+ module Php
9
+ module DockerImages
10
+ class Base < ::Avmtrf1::Docker::Image
11
+ enable_abstract_methods
12
+ abstract_methods :mcrypt_install, :xdebug_pecl_package
13
+
14
+ GD_OPTIONS = %w[--with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-zlib-dir
15
+ --with-xpm-dir --with-freetype-dir].freeze
16
+ PLATFORM_STEREOTYPE_TAG = 'php'
17
+
18
+ class << self
19
+ # @return [Gem::Version]
20
+ def php_version
21
+ const_get('PHP_VERSION')
22
+ end
23
+ end
24
+
25
+ # @return [String]
26
+ def php_dist_curl_args
27
+ '-sS "https://www.php.net/distributions/php-$PHP_VERSION.tar.gz"'
28
+ end
29
+
30
+ def platform_stereotype_tag
31
+ PLATFORM_STEREOTYPE_TAG
32
+ end
33
+
34
+ def write_in_provide_dir
35
+ ::Avmtrf1::Php::DockerImages::Base.template.apply(self, provide_dir)
36
+ end
37
+
38
+ def gd_options
39
+ GD_OPTIONS.join(' ')
40
+ end
41
+
42
+ # @return [String]
43
+ def xdebug_install
44
+ "RUN pecl install #{xdebug_pecl_package}"
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/v5'
4
+ require 'avmtrf1/php/docker_images/v7'
5
+ require 'avmtrf1/php/docker_images/v7_v4'
6
+ require 'avmtrf1/php/docker_images/v8'
7
+ require 'eac_ruby_utils/core_ext'
8
+ require 'rubygems'
9
+
10
+ module Avmtrf1
11
+ module Php
12
+ module DockerImages
13
+ class Factory
14
+ VERSIONS = [
15
+ ::Avmtrf1::Php::DockerImages::V8,
16
+ ::Avmtrf1::Php::DockerImages::V7V4,
17
+ ::Avmtrf1::Php::DockerImages::V7,
18
+ ::Avmtrf1::Php::DockerImages::V5
19
+ ].freeze
20
+
21
+ common_constructor :platform_version do
22
+ self.platform_version = ::Gem::Version.new(platform_version)
23
+ end
24
+
25
+ def result
26
+ versions = VERSIONS.dup
27
+ lesser_version = versions.pop
28
+ versions.each do |version|
29
+ return version if platform_version >= version.php_version
30
+ end
31
+
32
+ lesser_version
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Php
8
+ module DockerImages
9
+ class V5 < ::Avmtrf1::Php::DockerImages::Base
10
+ MCRYPT_INSTALL = <<~CODE
11
+ RUN docker-php-ext-install mcrypt
12
+ CODE
13
+ XDEBUG_INSTALL = <<~CODE
14
+ RUN apt-get install -y git
15
+ RUN cd /tmp && \
16
+ git clone https://github.com/xdebug/xdebug.git && \
17
+ cd xdebug && \
18
+ git checkout XDEBUG_2_5_5 && \
19
+ phpize && \
20
+ ./configure --enable-xdebug && \
21
+ make && \
22
+ make install && \
23
+ rm -rf /tmp/xdebug
24
+ CODE
25
+
26
+ # @return [String]
27
+ def apt_setup
28
+ debian_stretch_apt_setup
29
+ end
30
+
31
+ # @return [String]
32
+ def php_dist_curl_args
33
+ "--insecure #{super}"
34
+ end
35
+
36
+ def mcrypt_install
37
+ MCRYPT_INSTALL
38
+ end
39
+
40
+ # @return [String]
41
+ def xdebug_install
42
+ XDEBUG_INSTALL
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Php
8
+ module DockerImages
9
+ class V7 < ::Avmtrf1::Php::DockerImages::Base
10
+ MCRYPT_INSTALL = <<~CODE
11
+ RUN pecl install mcrypt
12
+ RUN echo extension=mcrypt.so > "$PHP_INI_DIR/conf.d/mcrypt.ini"
13
+ CODE
14
+ PHP_VERSION = ::Gem::Version.new('7')
15
+ XDEBUG_PECL_PACKAGE = 'xdebug-3.1.6'
16
+
17
+ def mcrypt_install
18
+ MCRYPT_INSTALL
19
+ end
20
+
21
+ def xdebug_pecl_package
22
+ XDEBUG_PECL_PACKAGE
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/v7'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Php
8
+ module DockerImages
9
+ class V7V4 < ::Avmtrf1::Php::DockerImages::V7
10
+ GD_OPTION_PARSER = /\A(.+)-dir\z/.to_parser do |m|
11
+ m[1]
12
+ end
13
+ GD_OPTION_REJECT = %w[--with-gd --with-png --with-zlib].freeze
14
+ PHP_VERSION = ::Gem::Version.new('7.4')
15
+
16
+ # Referência: https://github.com/docker-library/php/issues/912
17
+ def gd_options
18
+ GD_OPTIONS
19
+ .map { |option| gd_option_replace(option) }
20
+ .reject { |option| GD_OPTION_REJECT.include?(option) }
21
+ .join(' ')
22
+ end
23
+
24
+ def gd_option_replace(option)
25
+ GD_OPTION_PARSER.parse(option).if_present(option)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/v7_v4'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Php
8
+ module DockerImages
9
+ class V8 < ::Avmtrf1::Php::DockerImages::V7V4
10
+ PHP_VERSION = ::Gem::Version.new('8')
11
+ XDEBUG_PECL_PACKAGE = 'xdebug'
12
+
13
+ def xdebug_pecl_package
14
+ XDEBUG_PECL_PACKAGE
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Php
7
+ module DockerImages
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+
5
+ module Avmtrf1
6
+ module Php
7
+ ::EacRubyUtils.require_sub(__FILE__)
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0"?>
2
+ <root>
3
+ <Solicitante login="<%= login %>" ip="<%= ip %>" sistema="<%= sistema %>" nomeMaquina="<%= nome_maquina %>"/>
4
+ </root>
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/red/server'
4
+ require 'avmtrf1/red/helper'
5
+ require 'pp' # rubocop:disable Lint/RedundantRequireStatement
6
+ require 'tempfile'
7
+
8
+ module Avmtrf1
9
+ module Red
10
+ class Client
11
+ include ::Avmtrf1::Red::Helper
12
+
13
+ class << self
14
+ def by_ini_profile(ini_profile)
15
+ ::Avmtrf1::Red::Client.new(
16
+ ::Avmtrf1::Red::Server.by_ini_profile(ini_profile),
17
+ ini_profile.to_h('parametros.')
18
+ )
19
+ end
20
+ end
21
+
22
+ attr_reader :server, :login, :ip, :sistema, :nome_maquina
23
+
24
+ def initialize(server, parametros)
25
+ @server = server
26
+ @login = parametros.fetch('login')
27
+ @ip = parametros.fetch('ip')
28
+ @sistema = parametros.fetch('sistema')
29
+ @nome_maquina = parametros.fetch('nomeMaquina')
30
+ end
31
+
32
+ def authorization_url
33
+ xml = post_xml('/REDCentral/autorizacaoinclusao', xml_content('authorization'))
34
+ xml.at_xpath('/root/retornoSolicitacaoInclusao/@url')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_envs/http/request'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'erb'
6
+ require 'nokogiri'
7
+
8
+ module Avmtrf1
9
+ module Red
10
+ module Helper
11
+ common_concern do
12
+ enable_speaker
13
+ end
14
+
15
+ def post(url, *post_args)
16
+ infom "Requesting \"#{url}\""
17
+ ::EacEnvs::Http::Request.new.url(url.to_s).verb(:post).body_data(post_args.first).response
18
+ .body_str_or_raise
19
+ end
20
+
21
+ def post_xml(url_suffix, xml_body)
22
+ url = server.resource_url(url_suffix)
23
+ ::Nokogiri::XML(post(url, xml_body))
24
+ end
25
+
26
+ def xml_content(name)
27
+ ::ERB.new(::File.read(xml_path(name))).result(binding)
28
+ end
29
+
30
+ def xml_path(name)
31
+ ::File.join(__dir__, self.class.name.demodulize.underscore, "#{name}.xml.erb")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ <root>
2
+ <MetadadosInclusao
3
+ dataHoraProducaoConteudo="<%= Time.now.strftime('%d/%m/%Y %H:%I:%S') %>"
4
+ numeroPasta="<%= metadados.fetch('numeroPasta') %>"
5
+ descricaoTituloDocumento="<%= metadados.fetch('descricaoTituloDocumento') %>"
6
+ numeroTipoSigilo="<%= metadados.fetch('numeroSigiloPublico') %>"
7
+ nomeSistemaIntrodutor="<%= client.sistema %>"
8
+ ipMaquinaResponsavelIntervencao = "<%= client.ip %>"
9
+ secaoOrigemDocumento ="<%= metadados.fetch('secaoOrigemDocumento') %>"
10
+ prioridadeReplicacao="<%= metadados.fetch('prioridadeReplicacaoNormal') %>"
11
+ espacoDocumento="<%= metadados.fetch('espacoDocumento') %>"
12
+ indicadorAnotacao="<%= metadados.fetch('indicadorAnotacaoMinutaTemporario') %>"
13
+ nomeMaquinaResponsavelIntervensao="<%= metadados.fetch('nomeMaquinaResponsavelIntervensao') %>"
14
+ >
15
+
16
+ <SecaoDestino idSecao = "<%= metadados.fetch('secaoDestinoIdSecao') %>"/>
17
+
18
+ </MetadadosInclusao>
19
+ </root>
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/red/client'
4
+ require 'avmtrf1/red/helper'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avmtrf1
8
+ module Red
9
+ class Profile
10
+ include ::Avmtrf1::Red::Helper
11
+ enable_simple_cache
12
+
13
+ class << self
14
+ def by_ini_profile(ini_profile)
15
+ new(
16
+ ::Avmtrf1::Red::Client.by_ini_profile(ini_profile),
17
+ ini_profile.to_h('metadados.')
18
+ )
19
+ end
20
+ end
21
+
22
+ # @!method initialize(client, metadados)
23
+ # @param client [Avmtrf1::Red::Client]
24
+ # @param metadados [Hash]
25
+ common_constructor :client, :metadados
26
+
27
+ def put_file(file_path)
28
+ auth_url = client.authorization_url
29
+ infov 'Authorization URL', auth_url
30
+ put_file_request(auth_url, file_path)
31
+ end
32
+
33
+ delegate :server, to: :client
34
+
35
+ private
36
+
37
+ def put_file_request(auth_url, file_path)
38
+ post(auth_url, put_file_body(file_path))
39
+ end
40
+
41
+ def metadados_file_path_uncached
42
+ file = Tempfile.new(['red_metadados', '.xml'])
43
+ ::File.write(file.path, xml_content('put_file'))
44
+ file.path
45
+ end
46
+
47
+ def put_file_body(file_path)
48
+ infov 'Metadados', ::File.read(metadados_file_path)
49
+ {
50
+ 'ip' => client.ip,
51
+ 'login' => client.login,
52
+ 'metadado' => ::File.open(metadados_file_path, 'r'),
53
+ 'conteudo' => ::File.open(file_path, 'r')
54
+ }
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/red/client'
4
+
5
+ module Avmtrf1
6
+ module Red
7
+ class Server
8
+ class << self
9
+ def by_ini_profile(ini_profile)
10
+ new(ini_profile.fetch('red.server'))
11
+ end
12
+ end
13
+
14
+ attr_reader :host
15
+
16
+ def initialize(host)
17
+ @host = host
18
+ end
19
+
20
+ def client(login, ip, sistema, nome_maquina)
21
+ ::Avmtrf1::Red::Client.new(self, login, ip, sistema, nome_maquina)
22
+ end
23
+
24
+ def root_url
25
+ "http://#{host}"
26
+ end
27
+
28
+ def resource_url(url_suffix)
29
+ "#{root_url}#{url_suffix}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/red/client'
4
+ require 'avmtrf1/red/profile'
5
+ require 'avmtrf1/red/server'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/rest_provider/entity'
4
+
5
+ module Avmtrf1
6
+ module Redmine
7
+ module Entities
8
+ class Issue < ::Avmtrf1::RestProvider::Entity
9
+ delegate :closed?, to: :status
10
+
11
+ def data
12
+ super.fetch('issue')
13
+ end
14
+
15
+ def status
16
+ @status ||= instance.issue_status(status_id)
17
+ end
18
+
19
+ def status_name
20
+ data.fetch('status').fetch('name')
21
+ end
22
+
23
+ def status_id
24
+ data.fetch('status').fetch('id')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/rest_provider/entity'
4
+
5
+ module Avmtrf1
6
+ module Redmine
7
+ module Entities
8
+ class IssueStatus < ::Avmtrf1::RestProvider::Entity
9
+ def id
10
+ data.fetch('id')
11
+ end
12
+
13
+ def name
14
+ data.fetch('name')
15
+ end
16
+
17
+ def closed?
18
+ data.fetch('is_closed')
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Redmine
5
+ module Entities
6
+ require 'avmtrf1/redmine/entities/issue'
7
+ require 'avmtrf1/redmine/entities/issue_status'
8
+ end
9
+ end
10
+ end