avmtrf1-tools 0.9.0 → 0.10.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.rb +0 -1
- data/lib/avmtrf1/forponto/parsers/espelho.rb +26 -0
- data/lib/avmtrf1/forponto/parsers/espelho/day_node.rb +50 -0
- data/lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb +21 -0
- data/lib/avmtrf1/forponto/parsers/espelho/row_node.rb +34 -0
- data/lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb +71 -0
- data/lib/avmtrf1/forponto/parsers/espelho/sub_node.rb +20 -0
- data/lib/avmtrf1/forponto/parsers/espelho/summary_node.rb +57 -0
- data/lib/avmtrf1/forponto/parsers/espelho/utils.rb +32 -0
- data/lib/avmtrf1/forponto/session.rb +67 -0
- data/lib/avmtrf1/forponto/user.rb +22 -0
- data/lib/avmtrf1/forponto/user/month.rb +127 -0
- data/lib/avmtrf1/fs_cache.rb +2 -2
- data/lib/avmtrf1/git/push_large.rb +1 -1
- data/lib/avmtrf1/git/push_large/lfs_commit/_cache.rb +2 -2
- data/lib/avmtrf1/git/push_large/source_commit.rb +1 -1
- data/lib/avmtrf1/git/push_large/source_commit/_push.rb +1 -1
- data/lib/avmtrf1/tools/runner.rb +1 -0
- data/lib/avmtrf1/tools/runner/forponto.rb +79 -0
- data/lib/avmtrf1/tools/runner/forponto/espelho.rb +53 -0
- data/lib/avmtrf1/tools/version.rb +1 -1
- metadata +31 -7
- data/lib/avmtrf1/filesystem_cache.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67446ce01961d10946a8fc937e4b915f3c05f5ed677de2ae96eeec9326973fa5
|
4
|
+
data.tar.gz: 351e637a0c371bd1d4d5186cbd0c38fae2972701053ac2b2489adc1288d3d8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1bf19d47042636ad7edaa9d0828003493e31d118492f77ceb03fa8f23042a04c6b1cbdf2fefdece9ebb2030d6fda7568d3b8eff08aaa7a954491287a958661d
|
7
|
+
data.tar.gz: 67a212a7482ef95aff8d91a7b3c16c703d9e9d3f8c94810456e72cee74580e6b2e20271904b689d6ea4608a405b249c38ac3e41a5ceae17a065c69cf092c1184
|
data/lib/avmtrf1.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/item'
|
4
|
+
require 'eac_ruby_utils/require_sub'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
module Parsers
|
9
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
10
|
+
::EacRubyUtils.require_sub(__FILE__)
|
11
|
+
|
12
|
+
def item_xpath
|
13
|
+
'//table[@class="fiotabelaponto"]//table//table'
|
14
|
+
end
|
15
|
+
|
16
|
+
def data
|
17
|
+
consumer = RowsConsumer.new
|
18
|
+
item_node.xpath('./tbody/tr').map do |row_node|
|
19
|
+
consumer.add_row(row_node)
|
20
|
+
end
|
21
|
+
consumer.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'sub_node'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Forponto
|
7
|
+
module Parsers
|
8
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
9
|
+
class DayNode < SubNode
|
10
|
+
include MethodsAsFields
|
11
|
+
|
12
|
+
FIELDS = %w[date marcacoes summaries].freeze
|
13
|
+
SUMMARIES_XPATH = './following-sibling::tr[1]//font[@class="fontetabptodados"]/p/text()'
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
super(*args)
|
17
|
+
@summaries = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_summary(summary)
|
21
|
+
@summaries << summary
|
22
|
+
end
|
23
|
+
|
24
|
+
def date_string
|
25
|
+
node.at_xpath('.//font[@class="fontetabptodata"]/text()').to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def date
|
29
|
+
m = %r{(\d{2})/(\d{2})/(\d{4})}.match(date_string)
|
30
|
+
return Date.new(m[3].to_i, m[2].to_i, m[1].to_i) if m
|
31
|
+
|
32
|
+
raise "Date not found at \"#{date_string}\""
|
33
|
+
end
|
34
|
+
|
35
|
+
def marcacoes_string
|
36
|
+
node.at_xpath('.//font[@class="fontetabptomarc"]/text()').to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def marcacoes
|
40
|
+
marcacoes_string.scan(/\d{2}:\d{2}/)
|
41
|
+
end
|
42
|
+
|
43
|
+
def summaries
|
44
|
+
@summaries.map(&:data)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/item'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Forponto
|
7
|
+
module Parsers
|
8
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
9
|
+
module MethodsAsFields
|
10
|
+
def methods_as_fields(fields)
|
11
|
+
fields.map { |field| [field, send(field)] }.to_h
|
12
|
+
end
|
13
|
+
|
14
|
+
def data
|
15
|
+
methods_as_fields(self.class.const_get('FIELDS'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'sub_node'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Forponto
|
7
|
+
module Parsers
|
8
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
9
|
+
class RowNode < SubNode
|
10
|
+
def empty?
|
11
|
+
Utils.string_recursive(node).blank?
|
12
|
+
end
|
13
|
+
|
14
|
+
def css_class
|
15
|
+
node['class']
|
16
|
+
end
|
17
|
+
|
18
|
+
def day?
|
19
|
+
css_class == 'celulatabptomarc'
|
20
|
+
end
|
21
|
+
|
22
|
+
def summary?
|
23
|
+
css_class == 'celulatabptodados'
|
24
|
+
end
|
25
|
+
|
26
|
+
def days_area_end?
|
27
|
+
font = node.at_xpath('.//font[@class="fontetopotabelaponto"]')
|
28
|
+
font && font.text.to_s.include?('Total das Ocorr')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Forponto
|
5
|
+
module Parsers
|
6
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
7
|
+
class RowsConsumer
|
8
|
+
include MethodsAsFields
|
9
|
+
|
10
|
+
FIELDS = %w[days summaries].freeze
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@days = []
|
14
|
+
@summaries = []
|
15
|
+
@days_area = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_row(row_node)
|
19
|
+
row_node = RowNode.new(row_node)
|
20
|
+
return if row_node.empty?
|
21
|
+
|
22
|
+
if @days_area
|
23
|
+
add_row_from_days_area(row_node)
|
24
|
+
else
|
25
|
+
add_row_from_summaries_area(row_node)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def days
|
30
|
+
@days.map(&:data)
|
31
|
+
end
|
32
|
+
|
33
|
+
def summaries
|
34
|
+
@summaries.map(&:data)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def add_row_from_days_area(row_node)
|
40
|
+
if row_node.days_area_end?
|
41
|
+
@days_area = false
|
42
|
+
elsif row_node.day?
|
43
|
+
add_day(row_node)
|
44
|
+
elsif row_node.summary?
|
45
|
+
add_summary_on_day(row_node)
|
46
|
+
else
|
47
|
+
"Unmapped class: \"#{row_node.css_class}\""
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_row_from_summaries_area(row_node)
|
52
|
+
raise "Not a summary node found on summaries area: #{row_node.node}" unless
|
53
|
+
row_node.summary?
|
54
|
+
|
55
|
+
row_node.node.xpath('.//table').each do |table_node|
|
56
|
+
@summaries << SummaryNode.new(table_node)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_day(row_node)
|
61
|
+
@days << DayNode.new(row_node.node)
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_summary_on_day(row_node)
|
65
|
+
@days.last.add_summary(SummaryNode.new(row_node.node))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/item'
|
4
|
+
require_relative 'methods_as_fields'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
module Parsers
|
9
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
10
|
+
class SubNode
|
11
|
+
attr_reader :node
|
12
|
+
|
13
|
+
def initialize(node)
|
14
|
+
@node = node
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
4
|
+
require_relative 'sub_node'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
module Parsers
|
9
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
10
|
+
class SummaryNode < SubNode
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
include MethodsAsFields
|
13
|
+
|
14
|
+
FIELDS = %w[code description time minutes].freeze
|
15
|
+
|
16
|
+
def code
|
17
|
+
code_description_parsed.code
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
code_description_parsed.description
|
22
|
+
end
|
23
|
+
|
24
|
+
def time
|
25
|
+
column_text('20%')
|
26
|
+
end
|
27
|
+
|
28
|
+
def minutes
|
29
|
+
m = /\A(\d+):(\d+)\z/.match(time)
|
30
|
+
raise "\"#{time}\" does not match time pattern" unless m
|
31
|
+
|
32
|
+
m[1].to_i * 60 + m[2].to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def column_text(width)
|
38
|
+
Utils.string_recursive(node.at_xpath(".//td[@width='#{width}']"))
|
39
|
+
end
|
40
|
+
|
41
|
+
def code_description
|
42
|
+
column_text('80%')
|
43
|
+
end
|
44
|
+
|
45
|
+
def code_description_parsed_uncached
|
46
|
+
return ::OpenStruct.new(code: nil, description: nil) if code_description.blank?
|
47
|
+
|
48
|
+
m = /\A(\d+)\s*-\s*(\S.+)\z/.match(code_description)
|
49
|
+
raise "Code/description pattern not match: \"#{code_description}\"" unless m
|
50
|
+
|
51
|
+
::OpenStruct.new(code: m[1].to_i, description: m[2].strip)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
4
|
+
require_relative 'sub_node'
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
module Parsers
|
9
|
+
class Espelho < ::Aranha::Parsers::Html::Item
|
10
|
+
class Utils
|
11
|
+
class << self
|
12
|
+
def string_recursive(node)
|
13
|
+
return nil unless node.present?
|
14
|
+
return sanitize_string(node.text) if node.is_a?(::Nokogiri::XML::Text)
|
15
|
+
|
16
|
+
s = ''
|
17
|
+
node.children.each do |child|
|
18
|
+
child_s = string_recursive(child)
|
19
|
+
s += ' ' + child_s if child_s.present?
|
20
|
+
end
|
21
|
+
sanitize_string(s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def sanitize_string(obj)
|
25
|
+
obj.to_s.tr("\u00A0", ' ').strip
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/selenium/session'
|
4
|
+
|
5
|
+
module Avmtrf1
|
6
|
+
module Forponto
|
7
|
+
class Session
|
8
|
+
attr_reader :sub, :root_url, :matricula, :codigo
|
9
|
+
|
10
|
+
def initialize(root_url, matricula, codigo)
|
11
|
+
@root_url = root_url
|
12
|
+
@matricula = matricula
|
13
|
+
@codigo = codigo
|
14
|
+
@sub = ::Aranha::Selenium::Session.new(
|
15
|
+
user_agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko'
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
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)
|
34
|
+
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
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
::EacRubyUtils.require_sub(__FILE__)
|
5
|
+
|
6
|
+
module Avmtrf1
|
7
|
+
module Forponto
|
8
|
+
class User
|
9
|
+
attr_reader :url, :matricula, :codigo
|
10
|
+
|
11
|
+
def initialize(url, matricula, codigo)
|
12
|
+
@url = url
|
13
|
+
@matricula = matricula
|
14
|
+
@codigo = codigo
|
15
|
+
end
|
16
|
+
|
17
|
+
def month(year, month)
|
18
|
+
::Avmtrf1::Forponto::User::Month.new(self, year, month)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/json'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/yaml'
|
6
|
+
require 'avmtrf1/forponto/parsers/espelho'
|
7
|
+
require 'avmtrf1/forponto/session'
|
8
|
+
require 'avmtrf1/fs_cache'
|
9
|
+
|
10
|
+
module Avmtrf1
|
11
|
+
module Forponto
|
12
|
+
class User
|
13
|
+
class Month
|
14
|
+
enable_simple_cache
|
15
|
+
|
16
|
+
DEBITO_CODE = 66
|
17
|
+
CREDITO_CODE = 72
|
18
|
+
|
19
|
+
attr_reader :user, :year, :month
|
20
|
+
|
21
|
+
def initialize(user, year, month)
|
22
|
+
@user = user
|
23
|
+
@year = year
|
24
|
+
@month = month
|
25
|
+
end
|
26
|
+
|
27
|
+
def data_uncached
|
28
|
+
if recache?
|
29
|
+
r = fresh_data
|
30
|
+
data_cache.write(r.to_yaml)
|
31
|
+
r
|
32
|
+
else
|
33
|
+
::EacRubyUtils::Yaml.load_common(data_cache.read)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
month.to_s.rjust(2, '0') + '/' + year.to_s
|
39
|
+
end
|
40
|
+
|
41
|
+
def empty?
|
42
|
+
os_data.summaries.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def debito_acumulado; end
|
46
|
+
|
47
|
+
def debito
|
48
|
+
summary_minutes(DEBITO_CODE)
|
49
|
+
end
|
50
|
+
|
51
|
+
def debito_acum
|
52
|
+
debito + (parent_month ? parent_month.debito_acum : 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
def credito_acum
|
56
|
+
credito + (parent_month ? parent_month.credito_acum : 0)
|
57
|
+
end
|
58
|
+
|
59
|
+
def saldo
|
60
|
+
credito - debito
|
61
|
+
end
|
62
|
+
|
63
|
+
def saldo_acum
|
64
|
+
credito_acum - debito_acum
|
65
|
+
end
|
66
|
+
|
67
|
+
def credito
|
68
|
+
summary_minutes(CREDITO_CODE)
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def summary_minutes(code)
|
74
|
+
summary = os_data.summaries.find { |s| s.code == code }
|
75
|
+
summary ? summary.minutes : 0
|
76
|
+
end
|
77
|
+
|
78
|
+
def parent_month_uncached
|
79
|
+
date = Date.civil(year, month, 1) - 1.month
|
80
|
+
r = user.month(date.year, date.month)
|
81
|
+
r.empty? ? nil : r
|
82
|
+
end
|
83
|
+
|
84
|
+
def os_data_uncached
|
85
|
+
::RecursiveOpenStruct.new(data, recurse_over_arrays: true)
|
86
|
+
end
|
87
|
+
|
88
|
+
def recache?
|
89
|
+
!data_cache.cached?
|
90
|
+
end
|
91
|
+
|
92
|
+
def data_cache_uncached
|
93
|
+
::Avmtrf1.fs_cache.child('forponto', user.matricula, month.to_s.rjust(2, '0'))
|
94
|
+
end
|
95
|
+
|
96
|
+
def date(day)
|
97
|
+
::Date.civil(year, month, day)
|
98
|
+
end
|
99
|
+
|
100
|
+
def start_date_uncached
|
101
|
+
date(1)
|
102
|
+
end
|
103
|
+
|
104
|
+
def end_date_uncached
|
105
|
+
date(-1)
|
106
|
+
end
|
107
|
+
|
108
|
+
def fresh_data
|
109
|
+
session = new_session
|
110
|
+
begin
|
111
|
+
session.interval_data(start_date, end_date).merge(fetch_data)
|
112
|
+
ensure
|
113
|
+
session.sub.close
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def fetch_data
|
118
|
+
{ year: year, month: month, url: user.url, matricula: user.matricula }
|
119
|
+
end
|
120
|
+
|
121
|
+
def new_session
|
122
|
+
::Avmtrf1::Forponto::Session.new(user.url, user.matricula, user.codigo)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
data/lib/avmtrf1/fs_cache.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'eac_ruby_utils/filesystem_cache'
|
4
4
|
|
5
5
|
module Avmtrf1
|
6
6
|
class << self
|
7
7
|
def fs_cache
|
8
|
-
@fs_cache ||= ::
|
8
|
+
@fs_cache ||= ::EacRubyUtils::FilesystemCache.new(ENV['HOME'], '.cache', 'avmtrf1-tools')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -5,11 +5,11 @@ module Avmtrf1
|
|
5
5
|
class PushLarge
|
6
6
|
class LfsCommit
|
7
7
|
def fs_cache_uncached
|
8
|
-
source_commit.fs_cache.
|
8
|
+
source_commit.fs_cache.child(lfs_file_min_size.present? ? lfs_file_min_size : 'nil')
|
9
9
|
end
|
10
10
|
|
11
11
|
%w[sha1 files_size push_pack_error].each do |attr|
|
12
|
-
define_method("#{attr}_cache_uncached") { fs_cache.
|
12
|
+
define_method("#{attr}_cache_uncached") { fs_cache.child(attr) }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/avmtrf1/tools/runner.rb
CHANGED
@@ -4,6 +4,7 @@ require 'aranha/selenium/driver_factory/base'
|
|
4
4
|
require 'eac_ruby_utils/console/docopt_runner'
|
5
5
|
require 'avmtrf1/tools/runner/check_point'
|
6
6
|
require 'avmtrf1/tools/runner/esosti'
|
7
|
+
require 'avmtrf1/tools/runner/forponto'
|
7
8
|
require 'avmtrf1/tools/runner/git'
|
8
9
|
require 'avmtrf1/tools/runner/oracle'
|
9
10
|
require 'avmtrf1/tools/runner/red'
|
@@ -0,0 +1,79 @@
|
|
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/require_sub'
|
6
|
+
::EacRubyUtils.require_sub(__FILE__)
|
7
|
+
require 'avmtrf1/configs'
|
8
|
+
require 'avmtrf1/forponto/user'
|
9
|
+
|
10
|
+
module Avmtrf1
|
11
|
+
module Tools
|
12
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
class Forponto < ::EacRubyUtils::Console::DocoptRunner
|
14
|
+
include ::EacRubyUtils::SimpleCache
|
15
|
+
include ::EacRubyUtils::Console::Speaker
|
16
|
+
|
17
|
+
DEFAULT_VALUES = {
|
18
|
+
url: 'http://pontoeletronico.trf1.jus.br/forponto/fptoweb.exe'
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
DOC = <<~DOCOPT
|
22
|
+
Operações para Forponto.
|
23
|
+
|
24
|
+
Usage:
|
25
|
+
__PROGRAM__ [options] __SUBCOMMANDS__
|
26
|
+
__PROGRAM__ -h | --help
|
27
|
+
|
28
|
+
Options:
|
29
|
+
-h --help Show this screen.
|
30
|
+
-u --url=<url> URL inicial.
|
31
|
+
-m --matricula=<matricula> Matrícula.
|
32
|
+
-c --codigo=<codigo> Código.
|
33
|
+
DOCOPT
|
34
|
+
|
35
|
+
def run
|
36
|
+
start_banner
|
37
|
+
run_with_subcommand
|
38
|
+
end
|
39
|
+
|
40
|
+
def start_banner
|
41
|
+
infov 'URL', user.url
|
42
|
+
infov 'Matrícula', user.matricula
|
43
|
+
end
|
44
|
+
|
45
|
+
def attr_value(name, read_options = {})
|
46
|
+
value_by_option(name) || value_by_default(name) || value_by_entry(name, read_options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def value_by_option(name)
|
50
|
+
options.fetch("--#{name}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def value_by_default(name)
|
54
|
+
DEFAULT_VALUES[name.to_sym]
|
55
|
+
end
|
56
|
+
|
57
|
+
def value_by_entry(name, read_options)
|
58
|
+
::Avmtrf1.configs.read_entry("trf1.forponto.#{name}", read_options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def user_uncached
|
62
|
+
::Avmtrf1::Forponto::User.new(url, matricula, codigo)
|
63
|
+
end
|
64
|
+
|
65
|
+
def url
|
66
|
+
attr_value(__method__)
|
67
|
+
end
|
68
|
+
|
69
|
+
def matricula
|
70
|
+
attr_value(__method__)
|
71
|
+
end
|
72
|
+
|
73
|
+
def codigo
|
74
|
+
attr_value(__method__, noecho: true)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Avmtrf1
|
4
|
+
module Tools
|
5
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
6
|
+
class Forponto < ::EacRubyUtils::Console::DocoptRunner
|
7
|
+
class Espelho < ::EacRubyUtils::Console::DocoptRunner
|
8
|
+
include ::EacRubyUtils::SimpleCache
|
9
|
+
include ::EacRubyUtils::Console::Speaker
|
10
|
+
|
11
|
+
DOC = <<~DOCOPT
|
12
|
+
Recupera e trata dados do Forponto.
|
13
|
+
|
14
|
+
Usage:
|
15
|
+
__PROGRAM__ [options] <year> <month>
|
16
|
+
__PROGRAM__ -h | --help
|
17
|
+
|
18
|
+
Options:
|
19
|
+
-h --help Show this screen.
|
20
|
+
DOCOPT
|
21
|
+
|
22
|
+
def run
|
23
|
+
infov 'Start date', user_month.start_date
|
24
|
+
infov 'End date', user_month.end_date
|
25
|
+
out(fetched_data.to_yaml)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def fetched_data
|
31
|
+
user_month.data
|
32
|
+
end
|
33
|
+
|
34
|
+
def user_month_uncached
|
35
|
+
context(:user).month(year, month)
|
36
|
+
end
|
37
|
+
|
38
|
+
def year
|
39
|
+
options.fetch('<year>').to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
def month
|
43
|
+
options.fetch('<month>').to_i
|
44
|
+
end
|
45
|
+
|
46
|
+
def date(day)
|
47
|
+
::Date.civil(year, month, day)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
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.
|
4
|
+
version: 0.10.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-10-
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -50,14 +50,20 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.15'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.15.1
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
61
|
- - "~>"
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
63
|
+
version: '0.15'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.15.1
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: curb
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,6 +85,9 @@ dependencies:
|
|
79
85
|
- - "~>"
|
80
86
|
- !ruby/object:Gem::Version
|
81
87
|
version: '0.6'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.6.2
|
82
91
|
type: :runtime
|
83
92
|
prerelease: false
|
84
93
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -86,20 +95,23 @@ dependencies:
|
|
86
95
|
- - "~>"
|
87
96
|
- !ruby/object:Gem::Version
|
88
97
|
version: '0.6'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.6.2
|
89
101
|
- !ruby/object:Gem::Dependency
|
90
102
|
name: eac_ruby_utils
|
91
103
|
requirement: !ruby/object:Gem::Requirement
|
92
104
|
requirements:
|
93
105
|
- - "~>"
|
94
106
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0.
|
107
|
+
version: '0.15'
|
96
108
|
type: :runtime
|
97
109
|
prerelease: false
|
98
110
|
version_requirements: !ruby/object:Gem::Requirement
|
99
111
|
requirements:
|
100
112
|
- - "~>"
|
101
113
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0.
|
114
|
+
version: '0.15'
|
103
115
|
- !ruby/object:Gem::Dependency
|
104
116
|
name: filesize
|
105
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,7 +241,17 @@ files:
|
|
229
241
|
- lib/avmtrf1/esosti/session/login.rb
|
230
242
|
- lib/avmtrf1/esosti/session/solicitacao.rb
|
231
243
|
- lib/avmtrf1/esosti/session/solicitacao/main.rb
|
232
|
-
- lib/avmtrf1/
|
244
|
+
- lib/avmtrf1/forponto/parsers/espelho.rb
|
245
|
+
- lib/avmtrf1/forponto/parsers/espelho/day_node.rb
|
246
|
+
- lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb
|
247
|
+
- lib/avmtrf1/forponto/parsers/espelho/row_node.rb
|
248
|
+
- lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb
|
249
|
+
- lib/avmtrf1/forponto/parsers/espelho/sub_node.rb
|
250
|
+
- lib/avmtrf1/forponto/parsers/espelho/summary_node.rb
|
251
|
+
- lib/avmtrf1/forponto/parsers/espelho/utils.rb
|
252
|
+
- lib/avmtrf1/forponto/session.rb
|
253
|
+
- lib/avmtrf1/forponto/user.rb
|
254
|
+
- lib/avmtrf1/forponto/user/month.rb
|
233
255
|
- lib/avmtrf1/fs_cache.rb
|
234
256
|
- lib/avmtrf1/git.rb
|
235
257
|
- lib/avmtrf1/git/cached_repository.rb
|
@@ -283,6 +305,8 @@ files:
|
|
283
305
|
- lib/avmtrf1/tools/runner/check_point.rb
|
284
306
|
- lib/avmtrf1/tools/runner/check_point/login.rb
|
285
307
|
- lib/avmtrf1/tools/runner/esosti.rb
|
308
|
+
- lib/avmtrf1/tools/runner/forponto.rb
|
309
|
+
- lib/avmtrf1/tools/runner/forponto/espelho.rb
|
286
310
|
- lib/avmtrf1/tools/runner/git.rb
|
287
311
|
- lib/avmtrf1/tools/runner/git/issues_check.rb
|
288
312
|
- lib/avmtrf1/tools/runner/git/push_large.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Avmtrf1
|
4
|
-
class FilesystemCache
|
5
|
-
attr_reader :path
|
6
|
-
|
7
|
-
def initialize(*path_parts)
|
8
|
-
raise ArgumentError, "\"#{path_parts}\" is empty" if path_parts.empty?
|
9
|
-
|
10
|
-
@path = ::File.join(*path_parts.map(&:to_s))
|
11
|
-
end
|
12
|
-
|
13
|
-
def read
|
14
|
-
check_file
|
15
|
-
return nil unless ::File.exist?(path)
|
16
|
-
|
17
|
-
::File.read(path)
|
18
|
-
end
|
19
|
-
|
20
|
-
def write(value)
|
21
|
-
raise "\"#{value}\" is blank" if value.blank?
|
22
|
-
|
23
|
-
check_file
|
24
|
-
::File.write(path, value)
|
25
|
-
value
|
26
|
-
end
|
27
|
-
|
28
|
-
def sub(*path_parts)
|
29
|
-
self.class.new(absolute_path, *path_parts)
|
30
|
-
end
|
31
|
-
|
32
|
-
def absolute_path
|
33
|
-
::File.expand_path(path)
|
34
|
-
end
|
35
|
-
|
36
|
-
def dirname
|
37
|
-
::File.dirname
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def check_file
|
43
|
-
dirname = ::File.dirname(absolute_path)
|
44
|
-
raise "#{dirname}|#{dirname.class}" unless dirname.is_a?(String)
|
45
|
-
|
46
|
-
::FileUtils.mkdir_p(dirname)
|
47
|
-
return unless ::File.exist?(absolute_path)
|
48
|
-
return if ::File.file?(absolute_path)
|
49
|
-
|
50
|
-
raise "\"#{absolute_path}\" exist and is not a path"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|