abank 0.2.7 → 0.2.9

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: cc1db6b7872fbccb5da608191caea95a6c79e598b40dc86f64b4c64597a57a2a
4
- data.tar.gz: c021d951d7cfb4c83413a72c097bdf7958e75ae4c886277da3848a3e88b97242
3
+ metadata.gz: 36171477026334dbce5da50183c84e693047db8fb387c1306308f254590793fc
4
+ data.tar.gz: da568eeb037c6deb414981abed805596ae1034f94eee103948bfdec5da958734
5
5
  SHA512:
6
- metadata.gz: 859152f519b2517cfbbbe36635f92b66ff648e8ebf24fe9bb041d40e2d1f953094d75d94cca4f198ee90df68ad40abd9ceeb24d10b06ebafc2eb7a00ee00da69
7
- data.tar.gz: 8f2fdb535d5edd44e6c3a8a959475de72bb8760685509317a2194d6e2e4f56833ecfd0891d850ad6647c1db2fd46d7b90b405f5975a4a29a7cdc7b16eb2d12bc
6
+ metadata.gz: a9fbda092cf84a6ee8a2552fbd0ff363d482fd599a243d263d03374978e6ab819cfcd270dc3d0c67456c4b54ddcc126d161e45180888a38922d1a4d468dbfe35
7
+ data.tar.gz: 69365abb9979d7ca48369451c8496708cee0d15a3f4a0ef73521daa608c0c9c94a67ce2e5a00c4f2656c40ed4b1386d3224ea26b2094a6879bb87f03b6a14b1f
@@ -1,30 +1,15 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 2.7
3
3
  EnabledByDefault: true
4
4
 
5
5
  Style/Copyright:
6
- Enabled: false
6
+ Enabled: false
7
7
 
8
- Style/DocumentationMethod:
9
- Enabled: false
10
-
11
- Style/MethodCallWithArgsParentheses:
12
- Enabled: false
8
+ Lint/ConstantResolution:
9
+ Enabled: false
13
10
 
14
11
  Style/ConstantVisibility:
15
- Enabled: false
16
-
17
- Layout/MultilineMethodArgumentLineBreaks:
18
- Enabled: false
19
-
20
- Layout/MultilineHashKeyLineBreaks:
21
- Enabled: false
22
-
23
- Layout/FirstMethodParameterLineBreak:
24
- Enabled: false
25
-
26
- Layout/FirstHashElementLineBreak:
27
- Enabled: false
12
+ Enabled: false
28
13
 
29
- Style/MissingElse:
30
- Enabled: false
14
+ Style/EmptyElse:
15
+ EnforcedStyle: nil
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abank (0.2.7)
4
+ abank (0.2.9)
5
5
  google-cloud-bigquery
6
6
  roo
7
7
  thor
@@ -12,12 +12,12 @@ GEM
12
12
  specs:
13
13
  addressable (2.7.0)
14
14
  public_suffix (>= 2.0.2, < 5.0)
15
- concurrent-ruby (1.1.6)
16
- declarative (0.0.10)
15
+ concurrent-ruby (1.1.7)
16
+ declarative (0.0.20)
17
17
  declarative-option (0.1.0)
18
18
  faraday (1.0.1)
19
19
  multipart-post (>= 1.2, < 3)
20
- google-api-client (0.40.1)
20
+ google-api-client (0.43.0)
21
21
  addressable (~> 2.5, >= 2.5.1)
22
22
  googleauth (~> 0.9)
23
23
  httpclient (>= 2.8.1, < 3.0)
@@ -25,7 +25,7 @@ GEM
25
25
  representable (~> 3.0)
26
26
  retriable (>= 2.0, < 4.0)
27
27
  signet (~> 0.12)
28
- google-cloud-bigquery (1.21.1)
28
+ google-cloud-bigquery (1.21.2)
29
29
  concurrent-ruby (~> 1.0)
30
30
  google-api-client (~> 0.33)
31
31
  google-cloud-core (~> 1.2)
@@ -34,10 +34,10 @@ GEM
34
34
  google-cloud-core (1.5.0)
35
35
  google-cloud-env (~> 1.0)
36
36
  google-cloud-errors (~> 1.0)
37
- google-cloud-env (1.3.2)
37
+ google-cloud-env (1.3.3)
38
38
  faraday (>= 0.17.3, < 2.0)
39
39
  google-cloud-errors (1.0.1)
40
- googleauth (0.12.0)
40
+ googleauth (0.13.1)
41
41
  faraday (>= 0.17.3, < 2.0)
42
42
  jwt (>= 1.4, < 3.0)
43
43
  memoist (~> 0.16)
@@ -45,15 +45,15 @@ GEM
45
45
  os (>= 0.9, < 2.0)
46
46
  signet (~> 0.14)
47
47
  httpclient (2.8.3)
48
- jwt (2.2.1)
48
+ jwt (2.2.2)
49
49
  memoist (0.16.2)
50
50
  mini_mime (1.0.2)
51
51
  mini_portile2 (2.4.0)
52
- multi_json (1.14.1)
52
+ multi_json (1.15.0)
53
53
  multipart-post (2.1.1)
54
- nokogiri (1.10.9)
54
+ nokogiri (1.10.10)
55
55
  mini_portile2 (~> 2.4.0)
56
- os (1.1.0)
56
+ os (1.1.1)
57
57
  public_suffix (4.0.5)
58
58
  rake (12.3.3)
59
59
  representable (3.0.4)
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
4
- require 'abank/big'
5
- require 'abank/contrato'
6
- require 'abank/rendas'
7
- require 'abank/folha'
8
- require 'abank/version'
3
+ require('thor')
4
+ require('abank/big')
5
+ require('abank/contrato')
6
+ require('abank/rendas')
7
+ require('abank/folha')
8
+ require('abank/version')
9
9
 
10
10
  # @author Hernani Rodrigues Vaz
11
11
  module Abank
12
12
  DR = "/home/#{`whoami`.chomp}/Downloads"
13
+ BD = 'hernanilr.ab'
13
14
 
14
15
  class Error < StandardError; end
15
16
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'google/cloud/bigquery'
3
+ require('google/cloud/bigquery')
4
4
 
5
5
  module Abank
6
6
  # @see Big
@@ -42,16 +42,13 @@ module Abank
42
42
  @mvvls = ''
43
43
  @mvkys = opc.fetch(:k, '')
44
44
  @ctide = opc.fetch(:c, '')
45
- # p ['B', opcao]
46
45
  opcao
47
46
  end
48
47
 
49
48
  # (see CLI#tag)
50
49
  def mv_classifica
51
- dml('update hernanilr.ab.mv set mv.ct=tt.nct ' \
52
- 'from (select * from hernanilr.ab.cl) as tt ' \
53
- "where #{ky_mv}=tt.ky")
54
- puts 'MOVIMENTOS CLASSIFICADOS ' + bqnrs.to_s
50
+ dml("update #{BD}.mv set mv.ct=tt.nct from (select * from #{BD}.cl) as tt where #{ky_mv}=tt.ky")
51
+ puts("MOVIMENTOS CLASSIFICADOS #{bqnrs}")
55
52
  end
56
53
 
57
54
  # apaga movimentos & suas rendas associadas no bigquery
@@ -61,7 +58,7 @@ module Abank
61
58
  vars_mv_work
62
59
  if mvkys.size.positive?
63
60
  # obtem lista contratos arrendamento associados aos movimentos a apagar
64
- @ctlct = sel("select ct from hernanilr.ab.mv where #{ky_mv} in(#{mvkys}) and substr(ct,1,1)='r' group by 1")
61
+ @ctlct = sql("select ct from #{BD}.mv where #{ky_mv} in(#{mvkys}) and substr(ct,1,1)='r' group by 1")
65
62
 
66
63
  # apaga rendas associadas e depois movimentos
67
64
  @opcao[:t] = true
@@ -69,6 +66,7 @@ module Abank
69
66
 
70
67
  # para obrigar re_work a trabalhar com lista contratos (ctlct)
71
68
  @bqnrs = 0
69
+ else
72
70
  end
73
71
  self
74
72
  end
@@ -78,9 +76,10 @@ module Abank
78
76
  # @return [Big] acesso a base dados abank no bigquery
79
77
  def mv_insert
80
78
  if mvvls.size.positive?
81
- dml('insert hernanilr.ab.mv VALUES' + mvvls)
82
- puts 'MOVIMENTOS INSERIDOS ' + bqnrs.to_s
79
+ dml("insert #{BD}.mv VALUES#{mvvls}")
80
+ puts("MOVIMENTOS INSERIDOS #{bqnrs}")
83
81
  mv_classifica if bqnrs.positive?
82
+ else
84
83
  end
85
84
  self
86
85
  end
@@ -95,8 +94,8 @@ module Abank
95
94
 
96
95
  # apaga movimentos no bigquery
97
96
  def mv_delete_dml
98
- dml("delete from hernanilr.ab.mv where #{ky_mv} in(#{mvkys})")
99
- puts 'MOVIMENTOS APAGADOS ' + bqnrs.to_s
97
+ dml("delete from #{BD}.mv where #{ky_mv} in(#{mvkys})")
98
+ puts("MOVIMENTOS APAGADOS #{bqnrs}")
100
99
  end
101
100
 
102
101
  # @return [String] expressao sql da chave de movimentos
@@ -106,13 +105,13 @@ module Abank
106
105
 
107
106
  # cria job bigquery & verifica execucao
108
107
  #
109
- # @param [String] sql comando a executar
108
+ # @param [String] cmd comando a executar
110
109
  # @return [Boolean] job ok?
111
- def job?(sql)
112
- # p sql
113
- @bqjob = bqapi.query_job(sql)
110
+ def job?(cmd)
111
+ # p cmd
112
+ @bqjob = bqapi.query_job(cmd)
114
113
  @bqjob.wait_until_done!
115
- puts @bqjob.error['message'] if @bqjob.failed?
114
+ puts(@bqjob.error['message']) if @bqjob.failed?
116
115
  @bqjob.failed?
117
116
  end
118
117
 
@@ -121,16 +120,16 @@ module Abank
121
120
  # @param (see job?)
122
121
  # @param [Array] erro quando da erro no bigquery
123
122
  # @return [Google::Cloud::Bigquery::Data] resultado do sql
124
- def sel(sql, erro = [])
125
- @bqres = job?(sql) ? erro : bqjob.data
123
+ def sql(cmd, erro = [])
124
+ @bqres = job?(cmd) ? erro : bqjob.data
126
125
  end
127
126
 
128
127
  # executa Data Manipulation Language (DML) no bigquery
129
128
  #
130
129
  # @param (see job?)
131
130
  # @return [Integer] numero rows afetadas pelo dml
132
- def dml(sql)
133
- @bqnrs = job?(sql) ? 0 : bqjob.num_dml_affected_rows
131
+ def dml(cmd)
132
+ @bqnrs = job?(cmd) ? 0 : bqjob.num_dml_affected_rows
134
133
  end
135
134
  end
136
135
  end
@@ -20,10 +20,10 @@ module Abank
20
20
  def ct_cria
21
21
  if existe_contrato?
22
22
  @bqnrs = 1
23
- puts 'CONTRATO JA EXISTE'
23
+ puts('CONTRATO JA EXISTE')
24
24
  else
25
- dml('insert into hernanilr.ab.re ' + sql_contrato_mv)
26
- puts "CONTRATO #{ctide} " + (bqnrs.zero? ? 'NAO EXISTE' : 'INSERIDO')
25
+ dml("insert into #{BD}.re #{sql_contrato_mv}")
26
+ puts("CONTRATO #{ctide} " + (bqnrs.zero? ? 'NAO EXISTE' : 'INSERIDO'))
27
27
  end
28
28
  return unless existem_rendas?
29
29
 
@@ -52,8 +52,8 @@ module Abank
52
52
 
53
53
  # apaga rendas da lista de contratos arrendamento
54
54
  def lc_apaga
55
- dml("delete from hernanilr.ab.re where ct in(#{str_lc})#{opcao[:t] ? '' : ' and cnt>0'}")
56
- puts "RENDAS #{str_lc('')} APAGADAS " + bqnrs.to_s
55
+ dml("delete from #{BD}.re where ct in(#{str_lc})#{opcao[:t] ? '' : ' and cnt>0'}")
56
+ puts("RENDAS #{str_lc('')} APAGADAS " + bqnrs.to_s)
57
57
  end
58
58
 
59
59
  # @return [String] texto formatado que representa lista de contratos arrendamento
@@ -68,8 +68,8 @@ module Abank
68
68
  @ctlcm = []
69
69
  ctlct.each do |c|
70
70
  @ctide = c[:ct]
71
- sel(sql_last_re)
72
- @ctlcm << bqres[0].merge({ mv: sel(sql_novo_mv(bqres[0][:dl])) })
71
+ sql(sql_last_re)
72
+ @ctlcm << bqres[0].merge({ mv: sql(sql_novo_mv(bqres[0][:dl])) })
73
73
  end
74
74
  self
75
75
  end
@@ -82,25 +82,25 @@ module Abank
82
82
 
83
83
  # @return [Boolean] contrato arrendamento ja existe sim/nao?
84
84
  def existe_contrato?
85
- sel("select ct from hernanilr.ab.re where ct='#{ctide}' and cnt=0").count.positive?
85
+ sql("select ct from #{BD}.re where ct='#{ctide}' and cnt=0").count.positive?
86
86
  end
87
87
 
88
88
  # @return [String] sql para obter ultima renda do contrato arrendamento
89
89
  def sql_last_re
90
90
  'select ct,DATE_SUB(DATE_SUB(dl,INTERVAL dias DAY),INTERVAL IF(cnt=0,0,cnt-1) MONTH) as dc,ano,cnt,dl ' \
91
- "from hernanilr.ab.re where ct='#{ctide}' order by ano desc,cnt desc limit 1"
91
+ "from #{BD}.re where ct='#{ctide}' order by ano desc,cnt desc limit 1"
92
92
  end
93
93
 
94
94
  # @return [String] sql para obter movimentos novos (depois da ultima renda do contrato arrendamento)
95
95
  def sql_novo_mv(mdl)
96
- "select dl,vl from hernanilr.ab.mv where ct='#{ctide}' and dl>='#{(mdl + 1).strftime(DF)}' order by dl,dv"
96
+ "select dl,vl from #{BD}.mv where ct='#{ctide}' and dl>='#{(mdl + 1).strftime(DF)}' order by dl,dv"
97
97
  end
98
98
 
99
99
  # @return [String] sql para obter dados do inicio contrato arrendamento
100
100
  def sql_contrato_mv
101
101
  if opcao[:d].size.zero?
102
102
  'select ct,EXTRACT(YEAR FROM DATE_TRUNC(dl,MONTH)) as ano,0 as cnt,DATE_TRUNC(dl,MONTH) as dl,0 dias ' \
103
- "from hernanilr.ab.mv where ct='#{ctide}' order by dl limit 1"
103
+ "from #{BD}.mv where ct='#{ctide}' order by dl limit 1"
104
104
  else
105
105
  "select '#{ctide}' as ct,EXTRACT(YEAR FROM DATE '#{opcao[:d]}') as ano" \
106
106
  ",0 as cnt,DATE '#{opcao[:d]}' as dl,0 dias"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'roo'
3
+ require('roo')
4
4
 
5
5
  module Abank
6
6
  # acesso a folha calculo & base dados abank no bigquery
@@ -42,7 +42,7 @@ module Abank
42
42
  n = 0
43
43
  folha.sheet(0).parse(header_search: ['Data Lanc.', 'Data Valor', 'Descrição', 'Valor']) do |r|
44
44
  n += 1
45
- puts n == 1 ? "\n" + folha.info : processa_linha(r)
45
+ puts n == 1 ? "\n#{folha.info}" : processa_linha(r)
46
46
  end
47
47
  return unless opcao[:i]
48
48
 
@@ -60,7 +60,7 @@ module Abank
60
60
  # array.count = 0 ==> pode carregar esta linha
61
61
  # array.count = 1 ==> mais testes necessarios
62
62
  # array.count > 1 ==> nao pode carregar esta linha
63
- sel(sql_existe_mv, [{}, {}])
63
+ sql(sql_existe_mv, [{}, {}])
64
64
  if linha_naoexiste? then linha_base + values_mv
65
65
  elsif linha_existe? then linha_existe
66
66
  elsif linha_simila? then linha_similar
@@ -85,18 +85,18 @@ module Abank
85
85
  # @return [String] texto linha existente formatada para display
86
86
  def linha_existe
87
87
  add_kys if opcao[:e]
88
- linha_base + ' EXIS ' + format('%<v1>20d', v1: bqres.first[:ky])
88
+ "#{linha_base} EXIS #{format('%<v1>20d', v1: bqres.first[:ky])}"
89
89
  end
90
90
 
91
91
  # @return [String] texto linha similar formatada para display
92
92
  def linha_similar
93
93
  add_kys if opcao[:s]
94
- linha_base + ' SIMI ' + format('%<v1>-20.20s', v1: bqres.first[:ds].strip)
94
+ "#{linha_base} SIMI #{format('%<v1>-20.20s', v1: bqres.first[:ds].strip)}"
95
95
  end
96
96
 
97
97
  # @return [String] texto linha existencia multipla formatada para display
98
98
  def linha_multiplas
99
- linha_base + ' MULT(' + bqres.count.to_s + ')'
99
+ "#{linha_base} MULT(#{bqres.count})"
100
100
  end
101
101
 
102
102
  # obtem chaves movimento (keysin.mv) para apagar
@@ -121,7 +121,7 @@ module Abank
121
121
 
122
122
  # @return [String] sql para movimentos no bigquery
123
123
  def sql_existe_mv
124
- "select *,#{ky_mv} as ky from hernanilr.ab.mv " \
124
+ "select *,#{ky_mv} as ky from #{BD}.mv " \
125
125
  "where nc=#{conta} and dl='#{rowfc[0].strftime(DF)}' and vl=#{rowfc[3]}"
126
126
  end
127
127
 
@@ -145,7 +145,7 @@ module Abank
145
145
 
146
146
  # @return [String] classificacao do movimento (null --> classificacao automatica)
147
147
  def ctc
148
- opcao[:g].size.zero? ? 'null' : ("'" + opcao[:g] + "'")
148
+ opcao[:g].size.zero? ? 'null' : "'#{opcao[:g]}'"
149
149
  end
150
150
 
151
151
  # @return [String] tipo movimento c[redito] ou d[ebito]
@@ -27,7 +27,7 @@ module Abank
27
27
  # (see CLI#recriare)
28
28
  def re_atualiza
29
29
  # obtem contratos ativos
30
- @ctlct = sel('SELECT ct from hernanilr.ab.re group by 1')
30
+ @ctlct = sql("SELECT ct from #{BD}.re group by 1")
31
31
 
32
32
  # [re]cria rendas [novas|todas]
33
33
  lr_apaga.cm_cria.vr_cria.re_insert
@@ -49,10 +49,10 @@ module Abank
49
49
  # insere rendas no bigquery
50
50
  def re_insert
51
51
  if revls.size.zero?
52
- puts 'NAO EXISTEM RENDAS NOVAS'
52
+ puts('NAO EXISTEM RENDAS NOVAS')
53
53
  else
54
- dml('insert hernanilr.ab.re VALUES' + revls)
55
- puts "RENDAS #{str_lc('')} CRIADAS " + bqnrs.to_s
54
+ dml("insert #{BD}.re VALUES#{revls}")
55
+ puts("RENDAS #{str_lc('')} CRIADAS " + bqnrs.to_s)
56
56
  end
57
57
  end
58
58
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abank
4
- VERSION = '0.2.7'
4
+ VERSION = '0.2.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-11 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.8
146
+ rubygems_version: 3.1.2
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Arquiva movimentos conta-corrente, conta-cartao do activobank no bigquery.