avmtrf1-tools 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/avmtrf1/esosti/parsers/solicitacao/main.rb +22 -0
- data/lib/avmtrf1/esosti/session.rb +36 -0
- data/lib/avmtrf1/esosti/session/action_base.rb +34 -0
- data/lib/avmtrf1/esosti/session/atividades.rb +35 -0
- data/lib/avmtrf1/esosti/session/login.rb +47 -0
- data/lib/avmtrf1/esosti/session/solicitacao.rb +83 -0
- data/lib/avmtrf1/esosti/session/solicitacao/main.rb +49 -0
- data/lib/avmtrf1/tools/runner.rb +1 -0
- data/lib/avmtrf1/tools/runner/esosti.rb +61 -0
- data/lib/avmtrf1/tools/version.rb +1 -1
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 879271ccb45b493fc594260cda3c71e3adac3445bd9995980a49db870770bb7c
|
4
|
+
data.tar.gz: 6ca633eab04f267bb43a47c4d932bbe0a554dd2cd87319d87acf4be1bfaadbbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ce1e5e0be56a8f4eb43df74aa4e04f796a049abf3470171e42b743238a0042e706b1551de79e200e77b2e33889b41d2e7815775c50fa9bf681184a913eeae3
|
7
|
+
data.tar.gz: 8e60cb085c76ed1ee50d094389b443dbfd2079221f3ef4166a0776233e48bad9d91f26865e357772111ede2fb83d9ebb100d69d5f330631604e44fd391afacc1
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object' # To-to: declare in gem "aranha"
|
4
|
+
require 'active_support/core_ext/string' # To-to: declare in gem "aranha"
|
5
|
+
require 'aranha/parsers/html/item'
|
6
|
+
require 'nokogiri' # To-to: declare in gem "aranha"
|
7
|
+
|
8
|
+
module Avmtrf1
|
9
|
+
module Esosti
|
10
|
+
module Parsers
|
11
|
+
module Solicitacao
|
12
|
+
class Main < ::Aranha::Parsers::Html::Item
|
13
|
+
field :pessoa_afetada_email, :string,
|
14
|
+
'//input[@type="text" and ' \
|
15
|
+
'following-sibling::img[contains(@aria-label, "Pessoa Afetada")]]/@value'
|
16
|
+
|
17
|
+
def item_xpath; end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/json' # To-to: declare in gem "aranha"
|
4
|
+
require 'aranha/selenium/session'
|
5
|
+
Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
|
6
|
+
require path
|
7
|
+
end
|
8
|
+
|
9
|
+
module Avmtrf1
|
10
|
+
module Esosti
|
11
|
+
class Session
|
12
|
+
attr_reader :session, :url, :user, :password, :uf
|
13
|
+
|
14
|
+
def initialize(url, user, password, user_uf)
|
15
|
+
raise 'Argument "url" is blank' if url.blank?
|
16
|
+
raise 'Argument "user" is blank' if user.blank?
|
17
|
+
raise 'Argument "password" is blank' if password.blank?
|
18
|
+
raise 'Argument "user_uf" is blank' if user_uf.blank?
|
19
|
+
|
20
|
+
@url = url
|
21
|
+
@user = user
|
22
|
+
@password = password
|
23
|
+
@uf = user_uf
|
24
|
+
@session = ::Aranha::Selenium::Session.new
|
25
|
+
end
|
26
|
+
|
27
|
+
def login
|
28
|
+
::Avmtrf1::Esosti::Session::Login.new(self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def solicitacao_get_data(solitacao_id)
|
32
|
+
::Avmtrf1::Esosti::Session::Solicitacao.new(self, solitacao_id).data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Esosti
|
7
|
+
class Session
|
8
|
+
class ActionBase
|
9
|
+
attr_reader :data
|
10
|
+
|
11
|
+
def initialize(parent)
|
12
|
+
@parent = parent
|
13
|
+
run
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
attr_reader :parent
|
19
|
+
|
20
|
+
def session
|
21
|
+
parent.session
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_data
|
25
|
+
@data = {}.with_indifferent_access
|
26
|
+
data_keys.each do |key|
|
27
|
+
@data[key] = send("#{key}_data")
|
28
|
+
end
|
29
|
+
@data.freeze
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Esosti
|
5
|
+
class Session
|
6
|
+
module Atividades
|
7
|
+
def go_to_activities # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
8
|
+
session.wait_for_click(id: 'titlebar-tb_gotoButton')
|
9
|
+
el = session.find_element(
|
10
|
+
xpath: "//*[@id = 'menuholder']//*[contains(text(), 'Central de Serv')]"
|
11
|
+
)
|
12
|
+
session.action.move_to(el).perform
|
13
|
+
el = session.find_element(
|
14
|
+
xpath: "//*[@id = 'menuholder']//*[contains(text(), 'Atividades')]"
|
15
|
+
)
|
16
|
+
session.action.move_to(el).perform
|
17
|
+
el.click
|
18
|
+
session.wait_for_element(id: 'SystemNavAppContent-chld')
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh_activities
|
22
|
+
session.wait_for_click(xpath: "//img[contains(@title, 'Recarregar para atualizar')]")
|
23
|
+
end
|
24
|
+
|
25
|
+
def route_activity_and_back
|
26
|
+
session.wait_for_click(
|
27
|
+
xpath: "//a[@id = 'ROUTEWF__-tbb_anchor' and contains(@class, 'on')]"
|
28
|
+
)
|
29
|
+
session.wait_for_click(xpath: "//table[@id = 'completewf-mesh']//button[text() = 'OK']")
|
30
|
+
session.wait_for_click(xpath: "//*[text() = 'Visualizar Lista']")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'action_base'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Esosti
|
7
|
+
class Session
|
8
|
+
class Login < ::Avmtrf1::Esosti::Session::ActionBase
|
9
|
+
private
|
10
|
+
|
11
|
+
def run
|
12
|
+
try_go_to_root_url
|
13
|
+
fill_username
|
14
|
+
fill_password
|
15
|
+
fill_uf
|
16
|
+
click_on_login
|
17
|
+
wait_for_home_page
|
18
|
+
end
|
19
|
+
|
20
|
+
def try_go_to_root_url
|
21
|
+
session.navigate.to parent.url
|
22
|
+
end
|
23
|
+
|
24
|
+
def fill_username
|
25
|
+
session.wait_for_element(id: 'j_username').send_keys(parent.user)
|
26
|
+
end
|
27
|
+
|
28
|
+
def fill_password
|
29
|
+
session.wait_for_element(id: 'j_password').send_keys(parent.password)
|
30
|
+
end
|
31
|
+
|
32
|
+
def fill_uf
|
33
|
+
session.wait_for_element(id: 'uf')
|
34
|
+
.find_element(xpath: "//option[text()='#{parent.uf}']").click
|
35
|
+
end
|
36
|
+
|
37
|
+
def click_on_login
|
38
|
+
session.wait_for_element(id: 'loginbutton').click
|
39
|
+
end
|
40
|
+
|
41
|
+
def wait_for_home_page
|
42
|
+
session.wait_for_element(id: 'titlebar-tb_username')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'action_base'
|
4
|
+
Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].each do |path|
|
5
|
+
require path
|
6
|
+
end
|
7
|
+
|
8
|
+
module Avmtrf1
|
9
|
+
module Esosti
|
10
|
+
class Session
|
11
|
+
class Solicitacao < ::Avmtrf1::Esosti::Session::ActionBase
|
12
|
+
def initialize(parent, solicitacao_id)
|
13
|
+
@solicitacao_id = solicitacao_id.to_s.upcase
|
14
|
+
super parent
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :solicitacao_id
|
20
|
+
|
21
|
+
def run
|
22
|
+
raise 'Argument "solicitacao_id" is blank' if solicitacao_id.blank?
|
23
|
+
|
24
|
+
go_to_solicitacao
|
25
|
+
build_data
|
26
|
+
end
|
27
|
+
|
28
|
+
def data_keys
|
29
|
+
%w[main]
|
30
|
+
end
|
31
|
+
|
32
|
+
def main_data
|
33
|
+
Main.new(parent).data
|
34
|
+
end
|
35
|
+
|
36
|
+
def go_to_solicitacao
|
37
|
+
go_to_solicitacoes
|
38
|
+
search_by_id
|
39
|
+
click_on_first_result
|
40
|
+
wait_for_solicitacao_page
|
41
|
+
end
|
42
|
+
|
43
|
+
def go_to_solicitacoes
|
44
|
+
session.action.move_to(session.find_element(
|
45
|
+
xpath: '//.[contains(text(), "Central de Serviços")]'
|
46
|
+
)).perform
|
47
|
+
session.wait_for_element(xpath: '//.[contains(text(), "Solicitações de Serviço")]').click
|
48
|
+
end
|
49
|
+
|
50
|
+
def search_by_id
|
51
|
+
session.wait_for_element(
|
52
|
+
xpath: '//.[@id = "SystemNavAppContent-sc_div"]' \
|
53
|
+
'//input[@type = "text" and contains(@class, "queryField")]'
|
54
|
+
).send_keys(solicitacao_id)
|
55
|
+
session.action.send_keys("\n").perform
|
56
|
+
end
|
57
|
+
|
58
|
+
def click_on_first_result
|
59
|
+
session.wait.until do
|
60
|
+
begin
|
61
|
+
first_result.click
|
62
|
+
true
|
63
|
+
rescue Selenium::WebDriver::Error::ElementClickInterceptedError
|
64
|
+
false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def first_result
|
70
|
+
session.find_element(xpath: '//*[@id="SystemNavAppContent-chld"]' \
|
71
|
+
'//span[contains(@id, "tdrow_[C:1]_ttxt-lb[R:0]")]')
|
72
|
+
end
|
73
|
+
|
74
|
+
def wait_for_solicitacao_page
|
75
|
+
id_text = session.wait_for_element(xpath: '//.[contains(@class, "ticketidtext2")]')
|
76
|
+
return if id_text.text == solicitacao_id
|
77
|
+
|
78
|
+
raise "Wrong ID found (Found: \"#{id_text.text}\", Should be: \"#{solicitacao_id}\")"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
require 'avmtrf1/esosti/parsers/solicitacao/main'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Esosti
|
8
|
+
class Session
|
9
|
+
class Solicitacao < ::Avmtrf1::Esosti::Session::ActionBase
|
10
|
+
class Main < ::Avmtrf1::Esosti::Session::ActionBase
|
11
|
+
attr_reader :data
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def run
|
16
|
+
build_data
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_data
|
20
|
+
file = Tempfile.new('foo')
|
21
|
+
begin
|
22
|
+
file.write(session.current_source)
|
23
|
+
@data = ::Avmtrf1::Esosti::Parsers::Solicitacao::Main.new(file.path).data
|
24
|
+
ensure
|
25
|
+
file.close
|
26
|
+
file.unlink
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def data_keys
|
31
|
+
%w[source pessoa_afetada]
|
32
|
+
end
|
33
|
+
|
34
|
+
def pessoa_afetada_data
|
35
|
+
by_aria_label('Pessoa Afetada Mais Informações')
|
36
|
+
end
|
37
|
+
|
38
|
+
def detalhes_data
|
39
|
+
session.find_element(id: 'dijitEditorBody').text
|
40
|
+
end
|
41
|
+
|
42
|
+
def by_aria_label(aria_label)
|
43
|
+
session.find_element(xpath: "//.[@aria-label = '#{aria_label}']").text
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/avmtrf1/tools/runner.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
4
|
+
require 'eac_ruby_utils/console/speaker'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
6
|
+
require 'avmtrf1/ini'
|
7
|
+
require 'avmtrf1/red/profile'
|
8
|
+
require 'avmtrf1/esosti/session'
|
9
|
+
|
10
|
+
module Avmtrf1
|
11
|
+
module Tools
|
12
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
class Esosti < ::EacRubyUtils::Console::DocoptRunner
|
14
|
+
include ::EacRubyUtils::Console::Speaker
|
15
|
+
include ::EacRubyUtils::SimpleCache
|
16
|
+
|
17
|
+
DOC = <<~DOCOPT
|
18
|
+
Utilidades para e-Sosti (Control Desk).
|
19
|
+
|
20
|
+
Usage:
|
21
|
+
__PROGRAM__ [options] fetch <solicitacao_id>
|
22
|
+
__PROGRAM__ -h | --help
|
23
|
+
|
24
|
+
Options:
|
25
|
+
-h --help Mostra esta ajuda.
|
26
|
+
-u --user Usuário no e-Sosti.
|
27
|
+
DOCOPT
|
28
|
+
|
29
|
+
def run
|
30
|
+
if options.fetch('fetch')
|
31
|
+
fetch
|
32
|
+
else
|
33
|
+
fatal_error('Subcomando não mapeado (Isto é um defeito do software)')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def login
|
40
|
+
infom "Logando em #{session.url} com #{session.uf}\\#{session.user}..."
|
41
|
+
session.login
|
42
|
+
end
|
43
|
+
|
44
|
+
def fetch
|
45
|
+
login
|
46
|
+
infom "Recuperando informações de #{options.fetch('<solicitacao_id>')}..."
|
47
|
+
pp session.solicitacao_get_data(options.fetch('<solicitacao_id>'))
|
48
|
+
end
|
49
|
+
|
50
|
+
def session_uncached
|
51
|
+
::Avmtrf1::Esosti::Session.new(
|
52
|
+
'https://esosti.trf1.jus.br',
|
53
|
+
ENV.fetch('ESOSTI_USER'),
|
54
|
+
ENV.fetch('ESOSTI_PASSWORD'),
|
55
|
+
ENV.fetch('ESOSTI_UF')
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avmtrf1-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo H. Bogoni
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aranha
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: eac_ruby_utils
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +134,13 @@ files:
|
|
120
134
|
- exe/avmtrf1
|
121
135
|
- init.rb
|
122
136
|
- lib/avmtrf1.rb
|
137
|
+
- lib/avmtrf1/esosti/parsers/solicitacao/main.rb
|
138
|
+
- lib/avmtrf1/esosti/session.rb
|
139
|
+
- lib/avmtrf1/esosti/session/action_base.rb
|
140
|
+
- lib/avmtrf1/esosti/session/atividades.rb
|
141
|
+
- lib/avmtrf1/esosti/session/login.rb
|
142
|
+
- lib/avmtrf1/esosti/session/solicitacao.rb
|
143
|
+
- lib/avmtrf1/esosti/session/solicitacao/main.rb
|
123
144
|
- lib/avmtrf1/ini.rb
|
124
145
|
- lib/avmtrf1/ini/profile.rb
|
125
146
|
- lib/avmtrf1/patches.rb
|
@@ -133,6 +154,7 @@ files:
|
|
133
154
|
- lib/avmtrf1/red/server.rb
|
134
155
|
- lib/avmtrf1/tools.rb
|
135
156
|
- lib/avmtrf1/tools/runner.rb
|
157
|
+
- lib/avmtrf1/tools/runner/esosti.rb
|
136
158
|
- lib/avmtrf1/tools/runner/red.rb
|
137
159
|
- lib/avmtrf1/tools/version.rb
|
138
160
|
- lib/oracle/commands/base.rb
|