avmtrf1-tools 0.28.0 → 0.31.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avmtrf1/check_point/session.rb +10 -9
  3. data/lib/avmtrf1/esosti/entities/issue.rb +2 -29
  4. data/lib/avmtrf1/esosti/instance.rb +4 -0
  5. data/lib/avmtrf1/esosti/instance/changed.rb +33 -0
  6. data/lib/avmtrf1/esosti/raw_data_sanitizer.rb +47 -0
  7. data/lib/avmtrf1/forponto/user/month.rb +1 -1
  8. data/lib/avmtrf1/inventario_sistemas.rb +40 -0
  9. data/lib/avmtrf1/inventario_sistemas/parser.rb +42 -0
  10. data/lib/avmtrf1/inventario_sistemas/parser/body.rb +27 -0
  11. data/lib/avmtrf1/inventario_sistemas/parser/body_row.rb +12 -0
  12. data/lib/avmtrf1/inventario_sistemas/parser/header.rb +38 -0
  13. data/lib/avmtrf1/inventario_sistemas/parser/header_column.rb +27 -0
  14. data/lib/avmtrf1/inventario_sistemas/site_build.rb +71 -0
  15. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +41 -0
  16. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/elements.rb +54 -0
  17. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/layout.rb +55 -0
  18. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/stylesheet.css +57 -0
  19. data/lib/avmtrf1/inventario_sistemas/site_build/index.rb +20 -0
  20. data/lib/avmtrf1/inventario_sistemas/site_build/sistema.rb +62 -0
  21. data/lib/avmtrf1/inventario_sistemas/site_build/sistemas_index.rb +31 -0
  22. data/lib/avmtrf1/patches/eac_launcher/git/base.rb +0 -15
  23. data/lib/avmtrf1/redmine/instance.rb +2 -1
  24. data/lib/avmtrf1/rest_provider/instance.rb +13 -55
  25. data/lib/avmtrf1/rest_provider/instance/issues.rb +30 -0
  26. data/lib/avmtrf1/rest_provider/request.rb +44 -0
  27. data/lib/avmtrf1/rest_provider/response.rb +77 -0
  28. data/lib/avmtrf1/tools/runner/esosti.rb +2 -21
  29. data/lib/avmtrf1/tools/runner/esosti/changed.rb +52 -0
  30. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +52 -0
  31. data/lib/avmtrf1/tools/runner/esosti/request.rb +88 -0
  32. data/lib/avmtrf1/tools/runner/inventario_sistemas.rb +73 -0
  33. data/lib/avmtrf1/tools/runner/trf1_dspace_base0/deploy.rb +2 -2
  34. data/lib/avmtrf1/tools/version.rb +1 -1
  35. data/lib/avmtrf1/trf1_dspace_base0/deploy.rb +3 -3
  36. metadata +77 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74d89accf83c82b82c4cabc7ae771fd0cf7977e6b3a18c1c94e5a7b6d035a7e8
4
- data.tar.gz: 729168d22da5b1f2418712687afd767cdc1365b70f2ae2cc7bcd138a592c3803
3
+ metadata.gz: 15b0f6e21f65419282e6935854bf52b8a2cb66df48b0ec5d3514b22f63998a46
4
+ data.tar.gz: 3719e0002280f131142e156889f28bb876376cfedf9ae1d94b6f0c285813c026
5
5
  SHA512:
6
- metadata.gz: 16ac680b2e78a38f944afb194892e8655dfbcbc377107a37edfb760b2a17704746972a0f2344c88ee20e3088ed505913b51f07743086e692817ce194d82632b5
7
- data.tar.gz: 7df63a50a530c9f466f9be161d1e5699abe48e0d29c39d1710e6dc693d165bb9171f18a1c530df3405536ff93202ca3790f1a9190c7f14ef1bae0eac92bc71d6
6
+ metadata.gz: 37002181a2dcc8e46eb145596133b4052b3db605e37cf8a4ad3b92cbd5081d226a2781ba91cf8e6eebe033f6d3db5dd044ba1c00eeaf9d7e9fad7ec8d9792592
7
+ data.tar.gz: 30192eca0adf53cd4e89e89541402c8a0475ad3c7e5e1afdab159cd2e18726505166c072be7a6860952d60c8954b5aba6471471fe8e4d23d9107b1efea6355c6
@@ -2,10 +2,13 @@
2
2
 
3
3
  require 'avmtrf1/ad_user'
4
4
  require 'avmtrf1/check_point/session/login'
5
+ require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avmtrf1
7
8
  module CheckPoint
8
9
  class Session
10
+ enable_simple_cache
11
+
9
12
  ROOT_URL = 'https://cp.trf1.jus.br'
10
13
  LOGIN_URL = "#{ROOT_URL}/connect/PortalMain"
11
14
  LOGGED_TITLE_TEXT = 'Network Access Granted'
@@ -24,15 +27,7 @@ module Avmtrf1
24
27
  end
25
28
  end
26
29
 
27
- attr_reader :username, :password, :session
28
-
29
- def initialize(username, password, driver_options = {})
30
- @username = username
31
- @password = password
32
- @session = ::Aranha::Selenium::Session.new(
33
- driver_options.merge(accept_insecure_certs: true)
34
- )
35
- end
30
+ common_constructor :username, :password, :driver_options, default: [{}]
36
31
 
37
32
  def logged?
38
33
  session.navigate.to LOGIN_URL
@@ -54,6 +49,12 @@ module Avmtrf1
54
49
  end
55
50
  result_text
56
51
  end
52
+
53
+ private
54
+
55
+ def session_uncached
56
+ ::Aranha::Selenium::Session.new(driver_options.merge(accept_insecure_certs: true))
57
+ end
57
58
  end
58
59
  end
59
60
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avmtrf1/esosti/raw_data_sanitizer'
3
4
  require 'avmtrf1/rest_provider/entity'
4
5
 
5
6
  module Avmtrf1
@@ -9,37 +10,9 @@ module Avmtrf1
9
10
  class << self
10
11
  def parse_data(data)
11
12
  data.fetch('QueryMS_RMTICKETResponse')['MS_RMTICKETSet'].if_present(nil) do |v|
12
- sanitize_data(v.fetch('TICKET'))
13
+ ::Avmtrf1::Esosti::RawDataSanitizer.sanitize(v.fetch('TICKET'))
13
14
  end
14
15
  end
15
-
16
- def sanitize_data(data)
17
- if data.is_a?(Array)
18
- sanitize_array_data(data)
19
- elsif data.is_a?(Hash)
20
- sanitize_hash_data(data)
21
- else
22
- data
23
- end
24
- end
25
-
26
- private
27
-
28
- def sanitize_array_data(data)
29
- data.map { |v| sanitize_data(v) }
30
- end
31
-
32
- def sanitize_hash_data(data)
33
- if content_hash?(data)
34
- sanitize_data(data.fetch('content'))
35
- else
36
- data.transform_values { |v| sanitize_data(v) }
37
- end
38
- end
39
-
40
- def content_hash?(data)
41
- data.is_a?(Hash) && data.count == 1 && data.key?('content')
42
- end
43
16
  end
44
17
 
45
18
  def initialize(instance, data)
@@ -1,11 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
3
4
  require 'avmtrf1/esosti/entities/issue'
4
5
  require 'avmtrf1/rest_provider/instance'
5
6
 
6
7
  module Avmtrf1
7
8
  module Esosti
8
9
  class Instance < ::Avmtrf1::RestProvider::Instance
10
+ require_sub __FILE__
11
+ include ::Avmtrf1::Esosti::Instance::Changed
12
+
9
13
  def build_service_url(service_url_suffix)
10
14
  "#{root_url}/maxrest/rest#{service_url_suffix}"
11
15
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/esosti/raw_data_sanitizer'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Esosti
8
+ class Instance < ::Avmtrf1::RestProvider::Instance
9
+ module Changed
10
+ def changed(since)
11
+ changed_request(since).response.body_data_or_raise
12
+ end
13
+
14
+ def changed_request(since)
15
+ request_json(changed_url_suffix(since)) do |data|
16
+ ::Avmtrf1::Esosti::RawDataSanitizer.sanitize(
17
+ data.fetch('TICKETMboSet').fetch('TICKET')
18
+ ).map { |ticket| ticket.fetch('Attributes').fetch('TICKETID').downcase }
19
+ end
20
+ end
21
+
22
+ def changed_url_suffix(since)
23
+ '/mbo/ticket?_includecols=ticketid&changedate=~gt~' +
24
+ ::CGI.escape(formatted_time(since))
25
+ end
26
+
27
+ def formatted_time(time)
28
+ time.strftime('%FT%T%:z')
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Esosti
7
+ class RawDataSanitizer
8
+ class << self
9
+ def sanitize(raw_data)
10
+ new(raw_data).sanitized
11
+ end
12
+ end
13
+
14
+ CONTENT_KEY = 'content'
15
+
16
+ common_constructor :raw_data
17
+
18
+ def sanitized
19
+ if raw_data.is_a?(Array)
20
+ array_sanitized
21
+ elsif raw_data.is_a?(Hash)
22
+ hash_sanitized
23
+ else
24
+ raw_data
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def array_sanitized
31
+ raw_data.map { |v| self.class.sanitize(v) }
32
+ end
33
+
34
+ def hash_sanitized
35
+ if content_hash?
36
+ self.class.sanitize(raw_data.fetch(CONTENT_KEY))
37
+ else
38
+ raw_data.transform_values { |v| self.class.sanitize(v) }
39
+ end
40
+ end
41
+
42
+ def content_hash?
43
+ raw_data.is_a?(Hash) && raw_data.count == 1 && raw_data.key?(CONTENT_KEY)
44
+ end
45
+ end
46
+ end
47
+ end
@@ -117,7 +117,7 @@ module Avmtrf1
117
117
  def cached_data
118
118
  raise 'There is no data cached' unless data_cache.cached?
119
119
 
120
- ::EacRubyUtils::Yaml.load_common(data_cache.read)
120
+ ::EacRubyUtils::Yaml.load(data_cache.read)
121
121
  end
122
122
 
123
123
  def fresh_data
@@ -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
+ 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
+ def to_s
23
+ path.to_s
24
+ end
25
+
26
+ private
27
+
28
+ def roo_uncached
29
+ ::Roo::Spreadsheet.open(path.to_path)
30
+ end
31
+
32
+ def sheet_uncached
33
+ roo.sheet(SHEET_NAME) || raise("Sheet not found: \"#{SHEET_NAME}\"")
34
+ end
35
+
36
+ def sheet_row_count
37
+ sheet.last_row
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,42 @@
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
+ def to_s
24
+ path.to_s
25
+ end
26
+
27
+ private
28
+
29
+ def roo_uncached
30
+ ::Roo::Spreadsheet.open(path.to_path)
31
+ end
32
+
33
+ def sheet_uncached
34
+ roo.sheet(SHEET_NAME) || raise("Sheet not found: \"#{SHEET_NAME}\"")
35
+ end
36
+
37
+ def sheet_row_count
38
+ sheet.last_row
39
+ end
40
+ end
41
+ end
42
+ 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
+ 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
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,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.map do |c|
52
+ [c.id, c]
53
+ end.to_h
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