avmtrf1-tools 0.17.1 → 0.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31d2d815b6929302e7228217b6de8fd625f4e71b4a0953b9fe7f3fb2e6e9b154
4
- data.tar.gz: 6e9d81271670f7addaeb6b14c658a0551e4681629d53a7ff2e09ed6ad43c3d8b
3
+ metadata.gz: b31e14c6a3b5afe2172bc36829cac5d0e6e05058f28b3349ee9b85a7fdcadd6d
4
+ data.tar.gz: 8741f315a310c7c5b8e19b04c7fb4a51407908063a46616707a27019302025e6
5
5
  SHA512:
6
- metadata.gz: 1f1be42bb48c0d77ee870a9793d325280ee77f0a55e778df33f2ae106f6cb107c394c9478fce515922df2da0ae52749a1e61a5ad4eb4e03552561dbb2dc463fe
7
- data.tar.gz: e9ca28abaf79d9d7330083327e4d5bf10248edc62abb85d0e15c9f1c1158c2d8919c7a7576946bf1c8cdf88387710050b58bcf1b4f02104b3ff8d280cfbacf20
6
+ metadata.gz: 252a6dbb20ba33619f0174c77cf2edf08e4027325716bb2adf57d85855ba4b6a9cf7a830c783ac8f44b4a65dff02da409075caf7d24a2a14a84be137bd2e379b
7
+ data.tar.gz: 22148172bfd1bba6dd6607df23c82fcf7cec22bbea5990dfe076532bfde517d522b2e322f5b6ec8d5e91c6ab7587d0513264a6f09239158e019f400b4079a7fe
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'aranha/parsers/html/item_list'
4
+
5
+ module Avmtrf1
6
+ module Forponto
7
+ module Parsers
8
+ class DayRegisters < ::Aranha::Parsers::Html::ItemList
9
+ field :matricula, :string, './td[1]/font/text()'
10
+ field :nome, :string, './td[2]/font/text()'
11
+ field :hora, :string, './td[3]/font/text()'
12
+
13
+ def items_xpath
14
+ '//tr[@class = "celulatabptodados"]'
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,10 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'aranha/selenium/session'
4
+ require 'eac_ruby_utils/require_sub'
5
+ ::EacRubyUtils.require_sub(__FILE__)
4
6
 
5
7
  module Avmtrf1
6
8
  module Forponto
7
9
  class Session
10
+ include ::Avmtrf1::Forponto::Session::DayRegisters
11
+ include ::Avmtrf1::Forponto::Session::Interval
12
+ include ::Avmtrf1::Forponto::Session::Login
13
+
8
14
  attr_reader :sub, :root_url, :matricula, :codigo
9
15
 
10
16
  def initialize(root_url, matricula, codigo)
@@ -16,51 +22,10 @@ module Avmtrf1
16
22
  )
17
23
  end
18
24
 
19
- def go_to_login_form
20
- sub.navigate.to root_url
21
- sub.wait_for_click(xpath: '//a[text() = "COLABORADOR"]')
22
- end
23
-
24
- def login(start_date, end_date)
25
- go_to_login_form
26
- login_fill_matricula
27
- login_fill_codigo
28
- login_fill_start_date(start_date)
29
- login_fill_end_date(end_date)
30
- sub.wait_for_click(xpath: '//input[@name="ok"]')
31
- end
32
-
33
- def interval_data(start_date, end_date)
25
+ def parser_data(parser_class, source_code)
34
26
  tempfile = '/tmp/forponto.html'
35
- ::File.write(tempfile, interval_source_code(start_date, end_date))
36
- ::Avmtrf1::Forponto::Parsers::Espelho.new("file://#{tempfile}").data
37
- end
38
-
39
- def interval_source_code(start_date, end_date)
40
- login(start_date, end_date)
41
- sub.switch_to.frame(sub.wait_for_element(xpath: '//frame[@name="topFrame"]'))
42
- sub.wait_for_element(xpath: '//form[@name="frmjustificativa"]')
43
- sub.current_source
44
- end
45
-
46
- def login_fill_matricula
47
- sub.wait_for_element(xpath: '//input[@name="deEdtFunCrachaSel"]').send_keys(matricula)
48
- end
49
-
50
- def login_fill_codigo
51
- sub.wait_for_element(xpath: '//input[@name="deEdtFunConsulta"]').send_keys(codigo)
52
- end
53
-
54
- def login_fill_start_date(start_date)
55
- sub.wait_for_element(xpath: '//input[@name="deEdtDataDe"]').send_keys(
56
- start_date.strftime('%d/%m/%Y')
57
- )
58
- end
59
-
60
- def login_fill_end_date(end_date)
61
- sub.wait_for_element(xpath: '//input[@name="deEdtDataAte"]').send_keys(
62
- end_date.strftime('%d/%m/%Y')
63
- )
27
+ ::File.write(tempfile, source_code)
28
+ parser_class.new("file://#{tempfile}").data
64
29
  end
65
30
  end
66
31
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/forponto/parsers/day_registers'
4
+
5
+ module Avmtrf1
6
+ module Forponto
7
+ class Session
8
+ module DayRegisters
9
+ MARCACOES_DO_DIA_VALUE = '1027'
10
+
11
+ def day_registers_data
12
+ parser_data(::Avmtrf1::Forponto::Parsers::DayRegisters, day_registers_source_code)
13
+ end
14
+
15
+ private
16
+
17
+ def day_registers_source_code
18
+ login(::Date.today.at_beginning_of_month, Date.today.at_end_of_month)
19
+ click_on_consultas_on_top_menu
20
+ select_marcacoes_option
21
+ sub.current_source
22
+ end
23
+
24
+ def click_on_consultas_on_top_menu
25
+ sub.switch_to.frame(sub.wait_for_element(xpath: '//frame[@name="topFrame"]'))
26
+ sub.wait_for_click(xpath: '//a[@href="javascript:document.frmconsultas.submit()"]')
27
+ sub.switch_to.default_content
28
+ end
29
+
30
+ def select_marcacoes_option
31
+ Selenium::WebDriver::Support::Select.new(
32
+ sub.wait_for_element(xpath: '//select[@name="deEdtConOpcao"]')
33
+ ).select_by(:value, MARCACOES_DO_DIA_VALUE)
34
+ sub.wait_for_click(xpath: '//input[@name="ok" and @value="ok"]')
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/forponto/parsers/espelho'
4
+
5
+ module Avmtrf1
6
+ module Forponto
7
+ class Session
8
+ module Interval
9
+ def interval_data(start_date, end_date)
10
+ parser_data(
11
+ ::Avmtrf1::Forponto::Parsers::Espelho,
12
+ interval_source_code(start_date, end_date)
13
+ )
14
+ end
15
+
16
+ private
17
+
18
+ def interval_source_code(start_date, end_date)
19
+ login(start_date, end_date)
20
+ sub.switch_to.frame(sub.wait_for_element(xpath: '//frame[@name="topFrame"]'))
21
+ sub.wait_for_element(xpath: '//form[@name="frmjustificativa"]')
22
+ sub.current_source
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avmtrf1
4
+ module Forponto
5
+ class Session
6
+ module Login
7
+ def login(start_date, end_date)
8
+ go_to_login_form
9
+ login_fill_matricula
10
+ login_fill_codigo
11
+ login_fill_start_date(start_date)
12
+ login_fill_end_date(end_date)
13
+ sub.wait_for_click(xpath: '//input[@name="ok"]')
14
+ end
15
+
16
+ private
17
+
18
+ def go_to_login_form
19
+ sub.navigate.to root_url
20
+ sub.wait_for_click(xpath: '//a[text() = "COLABORADOR"]')
21
+ end
22
+
23
+ def login_fill_codigo
24
+ sub.wait_for_element(xpath: '//input[@name="deEdtFunConsulta"]').send_keys(codigo)
25
+ end
26
+
27
+ def login_fill_end_date(end_date)
28
+ sub.wait_for_element(xpath: '//input[@name="deEdtDataAte"]').send_keys(
29
+ end_date.strftime('%d/%m/%Y')
30
+ )
31
+ end
32
+
33
+ def login_fill_matricula
34
+ sub.wait_for_element(xpath: '//input[@name="deEdtFunCrachaSel"]').send_keys(matricula)
35
+ end
36
+
37
+ def login_fill_start_date(start_date)
38
+ sub.wait_for_element(xpath: '//input[@name="deEdtDataDe"]').send_keys(
39
+ start_date.strftime('%d/%m/%Y')
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/simple_cache'
4
+
5
+ module Avmtrf1
6
+ module Forponto
7
+ class User
8
+ class DayRegisters
9
+ enable_simple_cache
10
+ common_constructor :user
11
+
12
+ def date
13
+ fresh_data
14
+ @date
15
+ end
16
+
17
+ def times
18
+ fresh_data.map { |r| r[:hora] }
19
+ end
20
+
21
+ private
22
+
23
+ def fresh_data_uncached
24
+ r = ::Avmtrf1::Forponto::Session.new(user.url, user.matricula, user.codigo)
25
+ .day_registers_data
26
+ @date = ::Date.today
27
+ r
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/forponto/user/day_registers'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avmtrf1
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class Forponto < ::EacRubyUtils::Console::DocoptRunner
11
+ class Marcacoes < ::EacRubyUtils::Console::DocoptRunner
12
+ enable_console_speaker
13
+ enable_simple_cache
14
+
15
+ DOC = <<~DOCOPT
16
+ Mostra marcações Forponto do dia.
17
+
18
+ Usage:
19
+ __PROGRAM__ [options]
20
+ __PROGRAM__ -h | --help
21
+
22
+ Options:
23
+ -h --help Show this screen.
24
+ DOCOPT
25
+
26
+ def run
27
+ infov 'Date', day_registers.date
28
+ infov 'Times', day_registers.times.count
29
+ day_registers.times.each_with_index do |time, index|
30
+ infov " * #{index + 1}º", time
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def day_registers_uncached
37
+ ::Avmtrf1::Forponto::User::DayRegisters.new(context(:user))
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avmtrf1
4
4
  module Tools
5
- VERSION = '0.17.1'
5
+ VERSION = '0.18.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avmtrf1-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.18.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: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -258,6 +258,7 @@ files:
258
258
  - lib/avmtrf1/esosti/session/solicitacao.rb
259
259
  - lib/avmtrf1/esosti/session/solicitacao/main.rb
260
260
  - lib/avmtrf1/executables.rb
261
+ - lib/avmtrf1/forponto/parsers/day_registers.rb
261
262
  - lib/avmtrf1/forponto/parsers/espelho.rb
262
263
  - lib/avmtrf1/forponto/parsers/espelho/day_node.rb
263
264
  - lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb
@@ -267,8 +268,12 @@ files:
267
268
  - lib/avmtrf1/forponto/parsers/espelho/summary_node.rb
268
269
  - lib/avmtrf1/forponto/parsers/espelho/utils.rb
269
270
  - lib/avmtrf1/forponto/session.rb
271
+ - lib/avmtrf1/forponto/session/day_registers.rb
272
+ - lib/avmtrf1/forponto/session/interval.rb
273
+ - lib/avmtrf1/forponto/session/login.rb
270
274
  - lib/avmtrf1/forponto/user.rb
271
275
  - lib/avmtrf1/forponto/user/balance.rb
276
+ - lib/avmtrf1/forponto/user/day_registers.rb
272
277
  - lib/avmtrf1/forponto/user/month.rb
273
278
  - lib/avmtrf1/fs_cache.rb
274
279
  - lib/avmtrf1/git.rb
@@ -328,6 +333,7 @@ files:
328
333
  - lib/avmtrf1/tools/runner/esosti.rb
329
334
  - lib/avmtrf1/tools/runner/forponto.rb
330
335
  - lib/avmtrf1/tools/runner/forponto/espelho.rb
336
+ - lib/avmtrf1/tools/runner/forponto/marcacoes.rb
331
337
  - lib/avmtrf1/tools/runner/forponto/resumos.rb
332
338
  - lib/avmtrf1/tools/runner/forponto/saldo.rb
333
339
  - lib/avmtrf1/tools/runner/git.rb