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,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class Parser
8
+ module Body
9
+ def body_rows_uncached
10
+ index = 0
11
+ r = []
12
+ loop do
13
+ raw_row_i = BODY_OFFSET + index
14
+ return r if raw_row_i > sheet.last_row
15
+
16
+ r << sheet.row(raw_row_i).map { |v| v.to_s.strip }
17
+ index += 1
18
+ end
19
+ end
20
+
21
+ def body_rows_offset
22
+ Header::HEADER_ROW_OFFSET + Header::HEADER_ROWS_SIZE
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class Parser
8
+ class BodyRow # rubocop:disable Lint/EmptyClass
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class Parser
8
+ module Header
9
+ HEADER_ROW_OFFSET = 3
10
+ HEADER_ROWS_SIZE = 2
11
+
12
+ private
13
+
14
+ def header_columns_uncached
15
+ r = []
16
+ last_main = nil
17
+ main_row.each_with_index do |main, index|
18
+ sub = sub_row[index]
19
+ main ||= last_main
20
+ raise "[main] is blank (Index: #{index}, Sub: #{sub})" if main.blank?
21
+
22
+ r << HeaderColumn.new(index, main, sub)
23
+ last_main = main if main.present?
24
+ end
25
+ r
26
+ end
27
+
28
+ def main_row_uncached
29
+ sheet.row(HEADER_ROW_OFFSET)
30
+ end
31
+
32
+ def sub_row_uncached
33
+ sheet.row(HEADER_ROW_OFFSET + 1)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class Parser
8
+ class HeaderColumn
9
+ class << self
10
+ def build_id(main, sub)
11
+ "#{main}_#{sub || 'nil'}".downcase.parameterize
12
+ end
13
+ end
14
+
15
+ common_constructor :index, :main, :sub
16
+
17
+ def id
18
+ self.class.build_id(main, sub)
19
+ end
20
+
21
+ def key
22
+ main + sub.if_present('') { |v| "/#{v}" }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'roo'
5
+
6
+ module Avmtrf1
7
+ class InventarioSistemas
8
+ class Parser
9
+ require_sub __FILE__, include_modules: true
10
+
11
+ SHEET_NAME = 'TRF1'
12
+ UNUSED_OFFSET = 1
13
+ UNUSED_SIZE = 2
14
+ HEADER_OFFSET = UNUSED_OFFSET + UNUSED_SIZE
15
+ HEADER_SIZE = 2
16
+ BODY_OFFSET = HEADER_OFFSET + HEADER_SIZE
17
+
18
+ enable_simple_cache
19
+ common_constructor :path do
20
+ self.path = path.to_pathname
21
+ end
22
+
23
+ delegate :to_s, to: :path
24
+
25
+ private
26
+
27
+ def roo_uncached
28
+ ::Roo::Spreadsheet.open(path.to_path)
29
+ end
30
+
31
+ def sheet_uncached
32
+ roo.sheet(SHEET_NAME) || raise("Sheet not found: \"#{SHEET_NAME}\"")
33
+ end
34
+
35
+ def sheet_row_count
36
+ sheet.last_row
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class SiteBuild
8
+ class HtmlPageBase
9
+ module Elements
10
+ def html_link(link_text, link_href)
11
+ "<a href=#{link_href}>#{link_text}</a>"
12
+ end
13
+
14
+ def html_linkfy(input)
15
+ output = url_or_text(input)
16
+ if output.is_a?(::Addressable::URI)
17
+ html_link(output, output)
18
+ else
19
+ output
20
+ end
21
+ end
22
+
23
+ def html_table(columns, rows)
24
+ b = '<table><theader>'
25
+ b += html_table_row(columns, 'th', '')
26
+ b += '</theader><tbody>'
27
+ rows.each_with_index do |row, index|
28
+ b += html_table_row(row, 'td', (index % 2).zero? ? 'even' : 'odd')
29
+ end
30
+ b + '</tbody></theader>' # rubocop:disable Style/StringConcatenation
31
+ end
32
+
33
+ def html_table_row(values, tag, css_class)
34
+ begin_tag = "<#{tag} class='#{css_class}'>"
35
+ end_tag = "</#{tag}>"
36
+ '<tr>' + values.map { |v| begin_tag + v + end_tag }.join + "</tr>\n" # rubocop:disable Style/StringConcatenation
37
+ end
38
+
39
+ def self_html_link
40
+ html_link(title, href)
41
+ end
42
+
43
+ def url_or_text(input)
44
+ converted_input = input.gsub('\\', '/').gsub(%r{\A//}, 'smb://')
45
+ uri = ::Addressable::URI.parse(converted_input)
46
+ uri.scheme.present? && uri.host.present? ? uri : input
47
+ rescue Addressable::URI::InvalidURIError
48
+ input
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ class InventarioSistemas
5
+ class SiteBuild
6
+ class HtmlPageBase
7
+ module Layout
8
+ def metadata_info
9
+ "<div class='input_metadata'>" \
10
+ "Extraído de <strong>#{site.input_file.basename}</strong>." \
11
+ '</div>'
12
+ end
13
+
14
+ def output_body
15
+ <<~HTML
16
+ <body><div id="top">
17
+ #{output_navbar}
18
+ <h1>#{site_title}</h1>
19
+ #{metadata_info}
20
+ </div><div id="inner">
21
+ <h2>#{title}</h2>
22
+ #{output_inner_content}
23
+ </div></body>
24
+ HTML
25
+ end
26
+
27
+ def output_content
28
+ "<html>\n" + output_header + output_body + '</html>' # rubocop:disable Style/StringConcatenation
29
+ end
30
+
31
+ def output_header
32
+ <<~HTML
33
+ <head>
34
+ <meta charset="UTF-8">
35
+ <title>#{site_title} - #{title}</title>
36
+ <style>
37
+ #{::File.read(::File.join(__dir__, 'stylesheet.css'))}
38
+ </style>
39
+ </head>
40
+ HTML
41
+ end
42
+
43
+ def output_navbar
44
+ '<nav>' + output_navbar_path(false) + '</nav>' # rubocop:disable Style/StringConcatenation
45
+ end
46
+
47
+ def output_navbar_path(links)
48
+ (parent.present? ? parent.output_navbar_path(true) + NAVBAR_SEPARATOR : '') +
49
+ (links ? self_html_link : title)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,57 @@
1
+ body, #top, #top * {
2
+ padding: 0;
3
+ margin: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ #top * {
8
+ padding: 0.3em;
9
+ }
10
+
11
+ #inner {
12
+ margin: 0.3em;
13
+ }
14
+
15
+ nav {
16
+ padding: 0.2em;
17
+ }
18
+
19
+ a {
20
+ color: blue;
21
+ }
22
+
23
+ a:visited {
24
+ color: darkblue;
25
+ }
26
+
27
+ h1 {
28
+ text-align: right;
29
+ background-color: lightyellow;
30
+ }
31
+
32
+ .input_metadata {
33
+ text-align: right;
34
+ background-color: lightblue;
35
+ }
36
+
37
+ table {
38
+ border: thin solid black;
39
+ border-collapse: collapse;
40
+ }
41
+
42
+ .odd {
43
+ background-color: lightgray;
44
+ }
45
+
46
+ td, th {
47
+ border-left: thin solid black;
48
+ }
49
+
50
+ th {
51
+ border-bottom: thin solid black;
52
+ }
53
+
54
+ nav, nav a, nav a:visited, th {
55
+ background-color: black;
56
+ color: white;
57
+ }
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class SiteBuild
8
+ class HtmlPageBase
9
+ require_sub __FILE__, include_modules: true
10
+ enable_speaker
11
+ common_constructor :site, :parent
12
+
13
+ SITE_TITLE = 'Inventário de Sistemas'
14
+ NAVBAR_SEPARATOR = ' > '
15
+
16
+ def build
17
+ infom "Building #{href}..."
18
+ output_path.write(output_content)
19
+ end
20
+
21
+ def href
22
+ "#{uid}.html"
23
+ end
24
+
25
+ def output_path
26
+ site.output_directory.join(href)
27
+ end
28
+
29
+ def uid
30
+ r = self.class.name.demodulize
31
+ r += "_#{id}" if respond_to?(:id)
32
+ r.parameterize
33
+ end
34
+
35
+ def site_title
36
+ SITE_TITLE.to_s
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avmtrf1/inventario_sistemas/site_build/html_page_base'
5
+
6
+ module Avmtrf1
7
+ class InventarioSistemas
8
+ class SiteBuild
9
+ class Index < ::Avmtrf1::InventarioSistemas::SiteBuild::HtmlPageBase
10
+ def output_inner_content
11
+ ['<ul>', "<li>#{site.sistemas_index.self_html_link}</li>", '</ul>'].join("\n")
12
+ end
13
+
14
+ def title
15
+ 'Índice'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avmtrf1/inventario_sistemas/parser/header_column'
5
+ require 'avmtrf1/inventario_sistemas/site_build/html_page_base'
6
+
7
+ module Avmtrf1
8
+ class InventarioSistemas
9
+ class SiteBuild
10
+ class Sistema < ::Avmtrf1::InventarioSistemas::SiteBuild::HtmlPageBase
11
+ attr_reader :raw_row
12
+
13
+ def initialize(site, parent, raw_row)
14
+ super(site, parent)
15
+ @raw_row = raw_row
16
+ end
17
+
18
+ def id
19
+ nome.parameterize
20
+ end
21
+
22
+ def gestor
23
+ column_value('gestor na jf1', 'unidade')
24
+ end
25
+
26
+ def nome
27
+ column_value('sistema', 'sigla')
28
+ end
29
+
30
+ def producao
31
+ html_linkfy(column_value('ambientes', 'produção – serv. ap'))
32
+ end
33
+
34
+ def responsavel
35
+ %w[unidade seção nome]
36
+ .map { |sub| column_value('responsável pelo desenvolvimento', sub) }
37
+ .reject(&:blank?).join(' » ')
38
+ end
39
+
40
+ def output_inner_content
41
+ column_values = site.parser.header_columns.map { |c| [c.key, column_value(c)] }
42
+ '<h3>Detalhes</h3>' + html_table(%w[Campo Valor], column_values) # rubocop:disable Style/StringConcatenation
43
+ end
44
+
45
+ def title
46
+ nome
47
+ end
48
+
49
+ def column_value(main, sub = nil)
50
+ column = if main.is_a?(::Avmtrf1::InventarioSistemas::Parser::HeaderColumn)
51
+ main
52
+ else
53
+ site.column(main, sub)
54
+ end
55
+ raise 'Out of bound' if column.index >= raw_row.count
56
+
57
+ raw_row[column.index]
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avmtrf1/inventario_sistemas/site_build/html_page_base'
5
+
6
+ module Avmtrf1
7
+ class InventarioSistemas
8
+ class SiteBuild
9
+ class SistemasIndex < ::Avmtrf1::InventarioSistemas::SiteBuild::HtmlPageBase
10
+ def output_inner_content
11
+ output_count + output_list
12
+ end
13
+
14
+ def title
15
+ 'Sistemas'
16
+ end
17
+
18
+ def output_count
19
+ "<p>Quantidade: #{site.sistemas.count}</p>"
20
+ end
21
+
22
+ def output_list
23
+ html_table(
24
+ %w[Nome Produção Responsável Gestor],
25
+ site.sistemas.map { |s| [s.self_html_link, s.producao, s.responsavel, s.gestor] }
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ class InventarioSistemas
7
+ class SiteBuild
8
+ require_sub __FILE__
9
+ enable_simple_cache
10
+ common_constructor :input_file, :output_directory
11
+
12
+ UNIQUES = %w[index sistemas_index].freeze
13
+
14
+ def run
15
+ create_output_directory
16
+ build_uniques
17
+ build_sistemas
18
+ end
19
+
20
+ def column(main, sub)
21
+ indexed_columns.fetch(
22
+ ::Avmtrf1::InventarioSistemas::Parser::HeaderColumn.build_id(main, sub)
23
+ )
24
+ end
25
+
26
+ private
27
+
28
+ def build_uniques
29
+ UNIQUES.each { |unique| send(unique).build }
30
+ end
31
+
32
+ def build_sistemas
33
+ sistemas.each(&:build)
34
+ end
35
+
36
+ def create_output_directory
37
+ output_directory.mkpath
38
+ end
39
+
40
+ def parser_uncached
41
+ ::Avmtrf1::InventarioSistemas::Parser.new(input_file)
42
+ end
43
+
44
+ def sistemas_uncached
45
+ parser.body_rows
46
+ .map { |body_row| new_sistema(body_row) }
47
+ .sort_by { |sistema| [sistema.title.downcase] }
48
+ end
49
+
50
+ def indexed_columns_uncached
51
+ parser.header_columns.index_by do |c| # rubocop:disable Style/SymbolProc
52
+ c.id
53
+ end
54
+ end
55
+
56
+ def index_uncached
57
+ ::Avmtrf1::InventarioSistemas::SiteBuild::Index.new(self, nil)
58
+ end
59
+
60
+ def sistemas_index_uncached
61
+ ::Avmtrf1::InventarioSistemas::SiteBuild::SistemasIndex.new(self, index)
62
+ end
63
+
64
+ def new_sistema(body_row)
65
+ ::Avmtrf1::InventarioSistemas::SiteBuild::Sistema.new(
66
+ self, sistemas_index, body_row
67
+ )
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'roo'
5
+
6
+ module Avmtrf1
7
+ class InventarioSistemas
8
+ require_sub __FILE__, include_modules: true
9
+
10
+ SHEET_NAME = 'TRF1'
11
+ UNUSED_OFFSET = 1
12
+ UNUSED_SIZE = 2
13
+ HEADER_OFFSET = UNUSED_OFFSET + UNUSED_SIZE
14
+ HEADER_SIZE = 2
15
+ BODY_OFFSET = HEADER_OFFSET + HEADER_SIZE
16
+
17
+ enable_simple_cache
18
+ common_constructor :path do
19
+ self.path = path.to_pathname
20
+ end
21
+
22
+ delegate :to_s, to: :path
23
+
24
+ private
25
+
26
+ def roo_uncached
27
+ ::Roo::Spreadsheet.open(path.to_path)
28
+ end
29
+
30
+ def sheet_uncached
31
+ roo.sheet(SHEET_NAME) || raise("Sheet not found: \"#{SHEET_NAME}\"")
32
+ end
33
+
34
+ def sheet_row_count
35
+ sheet.last_row
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/default_jira'
4
+ require 'avmtrf1/default_redmine'
5
+
6
+ module Avmtrf1
7
+ class IssueFactory
8
+ class << self
9
+ def find(issue_id)
10
+ factories.each do |factory|
11
+ issue = factory.find_issue(issue_id)
12
+ return issue if issue
13
+ end
14
+ nil
15
+ end
16
+
17
+ def factories
18
+ [::Avmtrf1.default_jira, ::Avmtrf1.default_redmine]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Issues
5
+ require 'avmtrf1/issues/factory'
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/rest_provider/entity'
4
+
5
+ module Avmtrf1
6
+ module Jira
7
+ module Entities
8
+ class Issue < ::Avmtrf1::RestProvider::Entity
9
+ CATEGORY_CLOSED_STATUSES = %w[Pendências Concluído].freeze
10
+ CATEGORY_OPEN_STATUSES = ['Em andamento'].freeze
11
+
12
+ def status_name
13
+ data.fetch('fields').fetch('status').fetch('name')
14
+ end
15
+
16
+ def status_category_name
17
+ data.fetch('fields').fetch('status').fetch('statusCategory').fetch('name')
18
+ end
19
+
20
+ def closed?
21
+ return true if CATEGORY_CLOSED_STATUSES.include?(status_category_name)
22
+ return false if CATEGORY_OPEN_STATUSES.include?(status_category_name)
23
+
24
+ raise "Unknown category status \"#{status_category_name}\" " \
25
+ "(Status: \"#{status_name}\")"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Jira
5
+ module Entities
6
+ require 'avmtrf1/jira/entities/issue'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/rest_provider/instance'
4
+
5
+ module Avmtrf1
6
+ module Jira
7
+ class Instance < ::Avmtrf1::RestProvider::Instance
8
+ ISSUE_ID_PATTERN = /\A([a-z][a-z0-9]+)-(\d+)\z/i.freeze
9
+
10
+ class << self
11
+ def parse_issue_id(global_issue_id)
12
+ m = ISSUE_ID_PATTERN.match(global_issue_id)
13
+ return nil unless m
14
+
15
+ ::OpenStruct.new(provider_issue_id: m[0], project_id: m[1], project_issue_id: m[2]) # rubocop:disable Style/OpenStructUse
16
+ end
17
+ end
18
+
19
+ def build_service_url(service_url_suffix)
20
+ "#{root_url}/rest/api/latest#{service_url_suffix}"
21
+ end
22
+
23
+ def issue_get_url_suffix(provider_issue_id)
24
+ "/issue/#{provider_issue_id}"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Jira
5
+ require 'avmtrf1/jira/entities'
6
+ require 'avmtrf1/jira/instance'
7
+ end
8
+ end