abank 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/abank.rb +11 -2
- data/lib/abank/bigquery.rb +13 -5
- data/lib/abank/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab432e51be128ae3bf7ba50a5dadcacad1e940b0d36fa0cf04cdf15e255be19
|
4
|
+
data.tar.gz: 968c78583abbff5c4dc5a0286e31c6d9278270af322ec2f86a045f8b776356fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f25e773fc986695bd318c8938168bd01ff27dd44c2799afd653428886fbe6c08b0dde2e8a520fe63d386caf9ad730a67979faf677512c9e03404a161448020
|
7
|
+
data.tar.gz: 8dee5c630c47155bb4478b5f0f7d2c6963e716a186db8ec31f11d86c194693e8167c09b09054f22f66910519e7d3fabd53d093ad71efaa5567fc4816cb448d34
|
data/Gemfile.lock
CHANGED
data/lib/abank.rb
CHANGED
@@ -18,6 +18,8 @@ module Abank
|
|
18
18
|
desc: 'Onde procurar folhas calculo'
|
19
19
|
option :x, banner: 'EXT', default: '.xlsx',
|
20
20
|
desc: 'Extensao das folhas calculo'
|
21
|
+
option :n, banner: 'NUM', type: :numeric, default: 0,
|
22
|
+
desc: 'Correcao dias para data valor'
|
21
23
|
option :s, type: :boolean, default: false,
|
22
24
|
desc: 'apaga linha similar no bigquery'
|
23
25
|
option :e, type: :boolean, default: false,
|
@@ -27,8 +29,7 @@ module Abank
|
|
27
29
|
# processa folha calculo
|
28
30
|
def load
|
29
31
|
Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
|
30
|
-
Bigquery.new(f,
|
31
|
-
m: options[:m], i: true }).processa
|
32
|
+
Bigquery.new(f, load_ops).processa
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
@@ -50,6 +51,14 @@ module Abank
|
|
50
51
|
Bigquery.new.classifica
|
51
52
|
end
|
52
53
|
|
54
|
+
no_commands do
|
55
|
+
# @return [Hash] ops opcoes trabalho com linhas para load
|
56
|
+
def load_ops
|
57
|
+
{ s: options[:s], e: options[:e],
|
58
|
+
m: options[:m], i: true, n: options[:n] }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
53
62
|
default_task :mostra
|
54
63
|
end
|
55
64
|
end
|
data/lib/abank/bigquery.rb
CHANGED
@@ -12,7 +12,7 @@ module Abank
|
|
12
12
|
attr_reader :apibq
|
13
13
|
# @return [Roo::Excelx] folha calculo a processar
|
14
14
|
attr_reader :folha
|
15
|
-
# @return [Hash
|
15
|
+
# @return [Hash] opcoes trabalho com linhas
|
16
16
|
attr_reader :linha
|
17
17
|
# @return [Integer] numero conta
|
18
18
|
attr_reader :conta
|
@@ -25,14 +25,16 @@ module Abank
|
|
25
25
|
attr_reader :sql
|
26
26
|
|
27
27
|
# @param [String] xls folha calculo para processar
|
28
|
-
# @param [Hash
|
28
|
+
# @param [Hash] ops opcoes trabalho com linhas
|
29
29
|
# @option ops [Boolean] :s (false) apaga linha similar?
|
30
30
|
# @option ops [Boolean] :e (false) apaga linha igual?
|
31
31
|
# @option ops [Boolean] :m (false) apaga linhas existencia multipla?
|
32
32
|
# @option ops [Boolean] :i (false) insere linha nova?
|
33
|
+
# @option ops [Numeric] :n (0) numero dias correcao para data valor
|
33
34
|
# @return [Bigquery] acesso folhas calculo activobank
|
34
35
|
# & correspondente bigquery dataset
|
35
|
-
def initialize(xls = '', ops = { s: false, e: false, m: false,
|
36
|
+
def initialize(xls = '', ops = { s: false, e: false, m: false,
|
37
|
+
i: false, n: 0 })
|
36
38
|
# usa env GOOGLE_APPLICATION_CREDENTIALS para obter credentials
|
37
39
|
# @see https://cloud.google.com/bigquery/docs/authentication/getting-started
|
38
40
|
@apibq = Google::Cloud::Bigquery.new
|
@@ -93,10 +95,15 @@ module Abank
|
|
93
95
|
return 1 unless linha[:i]
|
94
96
|
|
95
97
|
dml('insert hernanilr.ab.mv(dl,dv,ds,vl,nc,ano,mes,ct,tp) VALUES(' \
|
96
|
-
|
98
|
+
"'#{row[0].strftime(DF)}','#{data_valor.strftime(DF)}','#{row[2]}'" +
|
97
99
|
str_insert1)
|
98
100
|
end
|
99
101
|
|
102
|
+
# @return [Date] data valor corrigida
|
103
|
+
def data_valor
|
104
|
+
row[1] + linha[:n].to_i
|
105
|
+
end
|
106
|
+
|
100
107
|
# @return [String] campos extra da linha bigquery
|
101
108
|
def str_insert1
|
102
109
|
",#{row[3]},#{conta}" + str_insert2
|
@@ -104,7 +111,8 @@ module Abank
|
|
104
111
|
|
105
112
|
# @return [String] campos calculados da linha bigquery
|
106
113
|
def str_insert2
|
107
|
-
",#{
|
114
|
+
",#{data_valor.year},#{data_valor.month},null," \
|
115
|
+
"'#{row[3].positive? ? 'c' : 'd'}')"
|
108
116
|
end
|
109
117
|
|
110
118
|
# @return [Integer] numero linhas apagadas
|
data/lib/abank/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.1
|
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-05-
|
11
|
+
date: 2020-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|