abank 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/abank.gemspec +40 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/abank +6 -0
- data/lib/abank.rb +46 -0
- data/lib/abank/bigquery.rb +88 -0
- data/lib/abank/folhacalculo.rb +90 -0
- data/lib/abank/version.rb +5 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fbdcefc1907b8fd455d8689ad69f29a9736d997757b1f39732699a1ac6e61c11
|
4
|
+
data.tar.gz: db9dfec60431152eac112aaec03c7f35f3f57566d82da359a336f0366684e506
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4762f3760ce278b7ddb723e8207d1c9f9b0f57369fb66a0f496e02d1c21a7c53c30bc66a7b914a970575f0298c1a8c1aeead80c862e979f2eddf334ca56897b
|
7
|
+
data.tar.gz: b366c60e3ffe669a1dc5cd3f05cf29dbca315ae8d32366da0e0d32ee58494504fa12ce79eaad9b51fdff22369f6865b84e72b1f2ea81eb6895a38222e2ea6d9a
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at hernanirvaz@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
abank (0.1.1)
|
5
|
+
google-cloud-bigquery
|
6
|
+
roo
|
7
|
+
thor
|
8
|
+
yard
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
addressable (2.7.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
|
+
concurrent-ruby (1.1.6)
|
16
|
+
declarative (0.0.10)
|
17
|
+
declarative-option (0.1.0)
|
18
|
+
faraday (1.0.1)
|
19
|
+
multipart-post (>= 1.2, < 3)
|
20
|
+
google-api-client (0.38.0)
|
21
|
+
addressable (~> 2.5, >= 2.5.1)
|
22
|
+
googleauth (~> 0.9)
|
23
|
+
httpclient (>= 2.8.1, < 3.0)
|
24
|
+
mini_mime (~> 1.0)
|
25
|
+
representable (~> 3.0)
|
26
|
+
retriable (>= 2.0, < 4.0)
|
27
|
+
signet (~> 0.12)
|
28
|
+
google-cloud-bigquery (1.21.0)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
google-api-client (~> 0.33)
|
31
|
+
google-cloud-core (~> 1.2)
|
32
|
+
googleauth (~> 0.9)
|
33
|
+
mini_mime (~> 1.0)
|
34
|
+
google-cloud-core (1.5.0)
|
35
|
+
google-cloud-env (~> 1.0)
|
36
|
+
google-cloud-errors (~> 1.0)
|
37
|
+
google-cloud-env (1.3.1)
|
38
|
+
faraday (>= 0.17.3, < 2.0)
|
39
|
+
google-cloud-errors (1.0.0)
|
40
|
+
googleauth (0.12.0)
|
41
|
+
faraday (>= 0.17.3, < 2.0)
|
42
|
+
jwt (>= 1.4, < 3.0)
|
43
|
+
memoist (~> 0.16)
|
44
|
+
multi_json (~> 1.11)
|
45
|
+
os (>= 0.9, < 2.0)
|
46
|
+
signet (~> 0.14)
|
47
|
+
httpclient (2.8.3)
|
48
|
+
jwt (2.2.1)
|
49
|
+
memoist (0.16.2)
|
50
|
+
mini_mime (1.0.2)
|
51
|
+
mini_portile2 (2.4.0)
|
52
|
+
multi_json (1.14.1)
|
53
|
+
multipart-post (2.1.1)
|
54
|
+
nokogiri (1.10.9)
|
55
|
+
mini_portile2 (~> 2.4.0)
|
56
|
+
os (1.1.0)
|
57
|
+
public_suffix (4.0.4)
|
58
|
+
rake (12.3.3)
|
59
|
+
representable (3.0.4)
|
60
|
+
declarative (< 0.1.0)
|
61
|
+
declarative-option (< 0.2.0)
|
62
|
+
uber (< 0.2.0)
|
63
|
+
retriable (3.1.2)
|
64
|
+
roo (2.8.3)
|
65
|
+
nokogiri (~> 1)
|
66
|
+
rubyzip (>= 1.3.0, < 3.0.0)
|
67
|
+
rubyzip (2.3.0)
|
68
|
+
signet (0.14.0)
|
69
|
+
addressable (~> 2.3)
|
70
|
+
faraday (>= 0.17.3, < 2.0)
|
71
|
+
jwt (>= 1.5, < 3.0)
|
72
|
+
multi_json (~> 1.10)
|
73
|
+
thor (1.0.1)
|
74
|
+
uber (0.1.0)
|
75
|
+
yard (0.9.24)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
abank!
|
82
|
+
bundler
|
83
|
+
rake (~> 12.0)
|
84
|
+
|
85
|
+
BUNDLED WITH
|
86
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Hernâni Rodrigues Vaz
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Abank
|
2
|
+
|
3
|
+
Arquiva activobank.xlsx no bigquery. Pode arquivar movimentos conta corrente e cartoes. Pode ainda classificar dados ja no bigquery.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'abank'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install abank
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/abank. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/abank/blob/master/CODE_OF_CONDUCT.md).
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
39
|
+
|
40
|
+
## Code of Conduct
|
41
|
+
|
42
|
+
Everyone interacting in the Abank project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/abank/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/abank.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/abank/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'abank'
|
7
|
+
spec.version = Abank::VERSION
|
8
|
+
spec.authors = ['Hernâni Rodrigues Vaz']
|
9
|
+
spec.email = ['hernanirvaz@gmail.com']
|
10
|
+
spec.homepage = 'https://github.com/hernanirvaz/abank'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.summary = 'Arquiva activobank.xlsx no bigquery.'
|
14
|
+
spec.description = spec.summary +
|
15
|
+
' Pode arquivar movimentos conta corrente e cartoes.' \
|
16
|
+
' Pode ainda classificar dados ja no bigquery.'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['yard.run'] = 'yard'
|
20
|
+
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads files in RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0")
|
27
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = 'exe'
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler'
|
34
|
+
spec.add_development_dependency 'rake'
|
35
|
+
|
36
|
+
spec.add_dependency 'google-cloud-bigquery'
|
37
|
+
spec.add_dependency 'roo'
|
38
|
+
spec.add_dependency 'thor'
|
39
|
+
spec.add_dependency 'yard'
|
40
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "abank"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/abank
ADDED
data/lib/abank.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'abank/version'
|
5
|
+
require 'abank/bigquery'
|
6
|
+
require 'abank/folhacalculo'
|
7
|
+
|
8
|
+
module Abank
|
9
|
+
ID = `whoami`.chomp
|
10
|
+
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
# CLI para carregar folhas calculo comuns no bigquery
|
14
|
+
class CLI < Thor
|
15
|
+
class_option :d, banner: 'DIR',
|
16
|
+
default: "/home/#{ID}/Downloads",
|
17
|
+
desc: 'Onde procurar folhas calculo'
|
18
|
+
class_option :x, banner: 'EXT',
|
19
|
+
default: '.xlsx',
|
20
|
+
desc: 'Extensao das folhas calculo'
|
21
|
+
|
22
|
+
desc 'load', 'carrega dados xlsx no bigquery'
|
23
|
+
# processa xlsx
|
24
|
+
def load
|
25
|
+
Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
|
26
|
+
Bigquery.new(f).processa
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'mostra', 'mostra dados do xlsx'
|
31
|
+
# mostra xlsx
|
32
|
+
def mostra
|
33
|
+
Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
|
34
|
+
Bigquery.new(f).show
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'classifica', 'classifica arquivo no bigquery'
|
39
|
+
# classifica bigquery
|
40
|
+
def classifica
|
41
|
+
Bigquery.new('').sql_update
|
42
|
+
end
|
43
|
+
|
44
|
+
default_task :mostra
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'roo'
|
4
|
+
require 'google/cloud/bigquery'
|
5
|
+
|
6
|
+
module Abank
|
7
|
+
DF = '%Y-%m-%d'
|
8
|
+
|
9
|
+
# folhas calculo comuns no bigquery
|
10
|
+
class Bigquery
|
11
|
+
# @return [Roo::Excelx] folha calculo a processar
|
12
|
+
attr_reader :book
|
13
|
+
# @return [Array] row folha calculo em processamento
|
14
|
+
attr_reader :row
|
15
|
+
# @return [Google::Cloud::Bigquery] API bigquery
|
16
|
+
attr_reader :api
|
17
|
+
# @return [Google::Cloud::Bigquery::QueryJob] job bigquery
|
18
|
+
attr_reader :job
|
19
|
+
# @return (see sql_select)
|
20
|
+
attr_reader :sql
|
21
|
+
# @return [Integer] numero conta
|
22
|
+
attr_reader :num
|
23
|
+
|
24
|
+
# permite processa folhas calculo comuns no bigquery
|
25
|
+
#
|
26
|
+
# @param [String] xls folha calculo para processar
|
27
|
+
# @return [Bigquery] acesso folha calculo & bigquery
|
28
|
+
def initialize(xls)
|
29
|
+
@book = Roo::Spreadsheet.open(xls) if xls.size.positive?
|
30
|
+
@num = xls.match?(/card/i) ? 2 : 1
|
31
|
+
# usa env GOOGLE_APPLICATION_CREDENTIALS para obter credentials
|
32
|
+
# @see https://cloud.google.com/bigquery/docs/authentication/getting-started
|
33
|
+
@api = Google::Cloud::Bigquery.new
|
34
|
+
end
|
35
|
+
|
36
|
+
# cria job bigquery & verifica execucao
|
37
|
+
#
|
38
|
+
# @param [String] sql para executar
|
39
|
+
# @return [Boolean] job ok?
|
40
|
+
def job_bigquery?(sql)
|
41
|
+
@job = api.query_job(sql)
|
42
|
+
@job.wait_until_done!
|
43
|
+
puts @job.error['message'] if @job.failed?
|
44
|
+
@job.failed?
|
45
|
+
end
|
46
|
+
|
47
|
+
# cria Data Manipulation Language (DML) job bigquery
|
48
|
+
#
|
49
|
+
# @param (see job_bigquery?)
|
50
|
+
# @return [Integer] numero linhas afetadas
|
51
|
+
def dml(sql)
|
52
|
+
job_bigquery?(sql) ? 0 : job.num_dml_affected_rows
|
53
|
+
end
|
54
|
+
|
55
|
+
# cria sql job bigquery com resultados
|
56
|
+
#
|
57
|
+
# @return [Array<Hash>] resultado sql
|
58
|
+
def sql_select
|
59
|
+
s = "select * from ab.mv where nc=#{num}" \
|
60
|
+
" and dl='#{row[0].strftime(DF)}'" \
|
61
|
+
" and vl=#{row[3]}"
|
62
|
+
|
63
|
+
# se array.count > 1 => nao fazer nada
|
64
|
+
@sql = job_bigquery?(s) ? [{}, {}] : job.data
|
65
|
+
end
|
66
|
+
|
67
|
+
# classifica linhas
|
68
|
+
def sql_update
|
69
|
+
puts 'LINHAS CLASSIFICADAS ' +
|
70
|
+
dml('update ab.mv set mv.ct=tt.nct' \
|
71
|
+
' from (select * from ab.cl) as tt ' \
|
72
|
+
'where mv.dl=tt.dl and mv.dv=tt.dv' \
|
73
|
+
' and mv.ds=tt.ds and mv.vl=tt.vl').to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
# @return [Integer] numero linhas inseridas
|
77
|
+
def sql_insert
|
78
|
+
dml('insert ab.mv(dl,dv,ds,vl,nc,ano,mes,ct,tp) VALUES(' \
|
79
|
+
"'#{row[0].strftime(DF)}','#{row[1].strftime(DF)}','#{row[2]}'," \
|
80
|
+
"#{row[3]},#{num}" + sql_insert_calculado)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [String] campos calculados da linha bigquery
|
84
|
+
def sql_insert_calculado
|
85
|
+
",#{row[1].year},#{row[1].month},null,'#{row[3].positive? ? 'c' : 'd'}')"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Abank
|
4
|
+
HT = ['Data Lanc.', 'Data Valor', 'Descrição', 'Valor'].freeze
|
5
|
+
RF = '%<v3>-50.50s %<v4>8.2f'
|
6
|
+
|
7
|
+
# folhas calculo comuns no bigquery
|
8
|
+
class Bigquery
|
9
|
+
# prepara linha folha calculo para processamento
|
10
|
+
#
|
11
|
+
# @param [Hash] has da linha em processamento
|
12
|
+
def corrige_dados(has)
|
13
|
+
@row = has.values
|
14
|
+
@row[2] = row[2].strip
|
15
|
+
@row[3] = -1 * row[3] if num > 1
|
16
|
+
end
|
17
|
+
|
18
|
+
# processa linhas folha calculo
|
19
|
+
def processa
|
20
|
+
n = 0
|
21
|
+
book.sheet(0).parse(header_search: HT) do |r|
|
22
|
+
n += 1
|
23
|
+
puts n == 1 ? "\n" + book.info : processa_row(r)
|
24
|
+
end
|
25
|
+
sql_update
|
26
|
+
end
|
27
|
+
|
28
|
+
# mostra linhas folha calculo
|
29
|
+
def show
|
30
|
+
n = 0
|
31
|
+
book.sheet(0).parse(header_search: HT) do |r|
|
32
|
+
n += 1
|
33
|
+
puts n == 1 ? "\n" + book.info : show_row(r)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# processa linha folha calculo para arquivo
|
38
|
+
#
|
39
|
+
# @param (see corrige_dados)
|
40
|
+
# @return [String] linha folha calculo processada
|
41
|
+
def processa_row(has)
|
42
|
+
corrige_dados(has)
|
43
|
+
sql_select
|
44
|
+
if rnaoexiste? then row_str + (sql_insert == 1 ? ' NOVA' : ' ERRO')
|
45
|
+
elsif rexiste? then row_existente
|
46
|
+
elsif rsimila? then row_similar
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# obtem linha folha calculo para apresentacao
|
51
|
+
#
|
52
|
+
# @param (see corrige_dados)
|
53
|
+
# @return (see row_str)
|
54
|
+
def show_row(has)
|
55
|
+
corrige_dados(has)
|
56
|
+
row_str
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [String] linha folha calculo formatada
|
60
|
+
def row_str
|
61
|
+
"#{row[0].strftime(DF)} #{row[1].strftime(DF)} " \
|
62
|
+
"#{format(RF, v3: row[2], v4: row[3])}"
|
63
|
+
end
|
64
|
+
|
65
|
+
# @return [String] linha folha calculo similar
|
66
|
+
def row_similar
|
67
|
+
row_str + " PARECIDA #{sql.first[:ds].strip}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [String] linha folha calculo existente
|
71
|
+
def row_existente
|
72
|
+
row_str + ' EXISTE'
|
73
|
+
end
|
74
|
+
|
75
|
+
# @return [Boolean] linha folha calculo nao existe no bigquery?
|
76
|
+
def rnaoexiste?
|
77
|
+
sql.count.zero?
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Boolean] linha folha calculo existe no bigquery?
|
81
|
+
def rexiste?
|
82
|
+
sql.count == 1 && sql.first[:ds].strip == row[2]
|
83
|
+
end
|
84
|
+
|
85
|
+
# @return [Boolean] linha folha calculo parecida no bigquery?
|
86
|
+
def rsimila?
|
87
|
+
sql.count == 1 && sql.first[:ds].strip != row[2]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: abank
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hernâni Rodrigues Vaz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: google-cloud-bigquery
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: roo
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Arquiva activobank.xlsx no bigquery. Pode arquivar movimentos conta corrente
|
98
|
+
e cartoes. Pode ainda classificar dados ja no bigquery.
|
99
|
+
email:
|
100
|
+
- hernanirvaz@gmail.com
|
101
|
+
executables:
|
102
|
+
- abank
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- abank.gemspec
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- exe/abank
|
117
|
+
- lib/abank.rb
|
118
|
+
- lib/abank/bigquery.rb
|
119
|
+
- lib/abank/folhacalculo.rb
|
120
|
+
- lib/abank/version.rb
|
121
|
+
homepage: https://github.com/hernanirvaz/abank
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata:
|
125
|
+
homepage_uri: https://github.com/hernanirvaz/abank
|
126
|
+
yard.run: yard
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 2.3.0
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubygems_version: 3.0.3
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Arquiva activobank.xlsx no bigquery.
|
146
|
+
test_files: []
|