arquivo 0.2.7 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89558d48120f776a51fec71ba71944581249e3ad23838737c1d424166e47e42b
4
- data.tar.gz: 4cf0050da0b5b1e69a655802981a78bc01d1398eff08d2ab9d8ce7b5d7ef8fb1
3
+ metadata.gz: e3dd40fc11991a17b2259424f2123a16f2d00e40d6145b7c6617ae4f19f036ca
4
+ data.tar.gz: 51eed9bedcbdfe7eff4c9ffe348d70201b6372c54761afeeb6ece28ad10d6c9e
5
5
  SHA512:
6
- metadata.gz: dfb1d7d6a3361c2b9ed6308481a8a87d3252f6be230a2bc2446080915883968dac1d8e9f14eeb372ba2f90fdfb33ef098f1b0fc748c8af49c0344e5f1022987c
7
- data.tar.gz: a4c1d2d860a1f48552e4f0015cf2a8c42e69cfa387615f2776c399b5216233eb2907f06004ce53f04ce3031d34e7a9d18fc438fb73dc377070d24f0e942919ac
6
+ metadata.gz: 23773ca2640c708c49423a78008808642660ef04061fe4b6d5162d549fc98eeb8e1ec38a66b7de1423a12629ab0ffbd74c6684bd816d5e8447298fa56ac6a85e
7
+ data.tar.gz: 1f804bc65f49c0162e69db6b72ce25be1b28550814a93cf16fad89ab420790c7b5d0c63df67175d39abe092aad5fce3e9f0a49b8f826c45a2b218a4a2ab04dcb
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in arquivo.gemspec
6
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,93 +1,136 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arquivo (0.2.7)
5
- fastimage (~> 2.1)
6
- google-api-client (~> 0.34)
4
+ arquivo (0.3.3)
5
+ fastimage
6
+ google-api-client
7
7
  google-cloud-bigquery
8
- pdf-reader (~> 2.3)
9
- thor (~> 0.1)
10
- yard (~> 0.9)
8
+ i18n
9
+ pdf-reader
10
+ thor
11
+ yard
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
15
- Ascii85 (1.0.3)
16
+ Ascii85 (1.1.0)
17
+ activesupport (6.1.3.2)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ tzinfo (~> 2.0)
22
+ zeitwerk (~> 2.3)
16
23
  addressable (2.7.0)
17
24
  public_suffix (>= 2.0.2, < 5.0)
18
25
  afm (0.2.2)
19
- concurrent-ruby (1.1.6)
20
- declarative (0.0.10)
21
- declarative-option (0.1.0)
22
- faraday (1.0.1)
26
+ concurrent-ruby (1.1.8)
27
+ declarative (0.0.20)
28
+ faraday (1.4.2)
29
+ faraday-em_http (~> 1.0)
30
+ faraday-em_synchrony (~> 1.0)
31
+ faraday-excon (~> 1.1)
32
+ faraday-net_http (~> 1.0)
33
+ faraday-net_http_persistent (~> 1.1)
23
34
  multipart-post (>= 1.2, < 3)
24
- fastimage (2.1.7)
25
- google-api-client (0.37.3)
35
+ ruby2_keywords (>= 0.0.4)
36
+ faraday-em_http (1.0.0)
37
+ faraday-em_synchrony (1.0.0)
38
+ faraday-excon (1.1.0)
39
+ faraday-net_http (1.0.1)
40
+ faraday-net_http_persistent (1.1.0)
41
+ fastimage (2.2.4)
42
+ gems (1.2.0)
43
+ google-api-client (0.53.0)
44
+ google-apis-core (~> 0.1)
45
+ google-apis-generator (~> 0.1)
46
+ google-apis-bigquery_v2 (0.12.0)
47
+ google-apis-core (~> 0.1)
48
+ google-apis-core (0.3.0)
26
49
  addressable (~> 2.5, >= 2.5.1)
27
- googleauth (~> 0.9)
50
+ googleauth (~> 0.14)
28
51
  httpclient (>= 2.8.1, < 3.0)
29
52
  mini_mime (~> 1.0)
30
53
  representable (~> 3.0)
31
54
  retriable (>= 2.0, < 4.0)
32
- signet (~> 0.12)
33
- google-cloud-bigquery (1.21.0)
55
+ rexml
56
+ signet (~> 0.14)
57
+ webrick
58
+ google-apis-discovery_v1 (0.4.0)
59
+ google-apis-core (~> 0.1)
60
+ google-apis-generator (0.3.0)
61
+ activesupport (>= 5.0)
62
+ gems (~> 1.2)
63
+ google-apis-core (~> 0.1)
64
+ google-apis-discovery_v1 (~> 0.0)
65
+ thor (>= 0.20, < 2.a)
66
+ google-cloud-bigquery (1.31.0)
34
67
  concurrent-ruby (~> 1.0)
35
- google-api-client (~> 0.33)
68
+ google-apis-bigquery_v2 (~> 0.1)
36
69
  google-cloud-core (~> 1.2)
37
70
  googleauth (~> 0.9)
38
71
  mini_mime (~> 1.0)
39
- google-cloud-core (1.5.0)
72
+ google-cloud-core (1.6.0)
40
73
  google-cloud-env (~> 1.0)
41
74
  google-cloud-errors (~> 1.0)
42
- google-cloud-env (1.3.1)
75
+ google-cloud-env (1.5.0)
43
76
  faraday (>= 0.17.3, < 2.0)
44
- google-cloud-errors (1.0.0)
45
- googleauth (0.11.0)
77
+ google-cloud-errors (1.1.0)
78
+ googleauth (0.16.2)
46
79
  faraday (>= 0.17.3, < 2.0)
47
80
  jwt (>= 1.4, < 3.0)
48
81
  memoist (~> 0.16)
49
82
  multi_json (~> 1.11)
50
83
  os (>= 0.9, < 2.0)
51
- signet (~> 0.12)
84
+ signet (~> 0.14)
52
85
  hashery (2.1.2)
53
86
  httpclient (2.8.3)
54
- jwt (2.2.1)
87
+ i18n (1.8.10)
88
+ concurrent-ruby (~> 1.0)
89
+ jwt (2.2.3)
55
90
  memoist (0.16.2)
56
- mini_mime (1.0.2)
57
- multi_json (1.14.1)
91
+ mini_mime (1.1.0)
92
+ minitest (5.14.4)
93
+ multi_json (1.15.0)
58
94
  multipart-post (2.1.1)
59
- os (1.1.0)
60
- pdf-reader (2.4.0)
61
- Ascii85 (~> 1.0.0)
95
+ os (1.1.1)
96
+ pdf-reader (2.4.2)
97
+ Ascii85 (~> 1.0)
62
98
  afm (~> 0.2.1)
63
99
  hashery (~> 2.0)
64
100
  ruby-rc4
65
101
  ttfunk
66
- public_suffix (4.0.4)
67
- rake (13.0.1)
68
- representable (3.0.4)
102
+ public_suffix (4.0.6)
103
+ rake (13.0.3)
104
+ representable (3.1.1)
69
105
  declarative (< 0.1.0)
70
- declarative-option (< 0.2.0)
106
+ trailblazer-option (>= 0.1.1, < 0.2.0)
71
107
  uber (< 0.2.0)
72
108
  retriable (3.1.2)
109
+ rexml (3.2.5)
73
110
  ruby-rc4 (0.1.5)
74
- signet (0.14.0)
111
+ ruby2_keywords (0.0.4)
112
+ signet (0.15.0)
75
113
  addressable (~> 2.3)
76
114
  faraday (>= 0.17.3, < 2.0)
77
115
  jwt (>= 1.5, < 3.0)
78
116
  multi_json (~> 1.10)
79
- thor (0.20.3)
80
- ttfunk (1.6.2.1)
117
+ thor (1.1.0)
118
+ trailblazer-option (0.1.1)
119
+ ttfunk (1.7.0)
120
+ tzinfo (2.0.4)
121
+ concurrent-ruby (~> 1.0)
81
122
  uber (0.1.0)
82
- yard (0.9.24)
123
+ webrick (1.7.0)
124
+ yard (0.9.26)
125
+ zeitwerk (2.4.2)
83
126
 
84
127
  PLATFORMS
85
128
  ruby
86
129
 
87
130
  DEPENDENCIES
88
131
  arquivo!
89
- bundler (~> 1.17)
132
+ bundler
90
133
  rake
91
134
 
92
135
  BUNDLED WITH
93
- 1.17.2
136
+ 2.2.19
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Arquivo
2
2
 
3
- Processa documentos do condominio ph1341c118 para arquivo. Pode tambem segmentar PDFs e MINUTAS. Tendo os documentos em pastas separadas, pode ainda criar arquivos apropriados.
3
+ Processa documentos do condominio ph1341c118 para arquivo. Pode tambem segmentar PDFs e MINUTAS. Tendo os documentos em pastas separadas, pode ainda criar arquivos apropriados. Parmite ainda processar dados do condominio ph1341c118 no bigquery para arquivo historico.
4
4
 
5
5
  ## Installation
6
6
 
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ task default: :spec
data/arquivo.gemspec CHANGED
@@ -11,8 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['hernanirvaz@gmail.com']
12
12
  spec.homepage = 'https://github.com/ph1341c118/arquivo'
13
13
 
14
- spec.summary = 'Processa documentos do condominio ph1341c118 ' \
15
- 'para arquivo.'
14
+ spec.summary = 'Processa documentos do condominio ph1341c118 para arquivo.'
16
15
  spec.description = spec.summary
17
16
  spec.description += ' Pode tambem segmentar PDFs e MINUTAS. ' \
18
17
  'Tendo os documentos em pastas separadas, pode ainda ' \
@@ -26,20 +25,20 @@ Gem::Specification.new do |spec|
26
25
  # The `git ls-files -z` loads the files in the
27
26
  # RubyGem that have been added into git.
28
27
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
- `git ls-files -z`.split("\x0")
30
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
29
  end
32
30
  spec.bindir = 'exe'
33
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
32
  spec.require_paths = ['lib']
35
33
 
36
- spec.add_development_dependency 'bundler', '~> 1.17'
34
+ spec.add_development_dependency 'bundler'
37
35
  spec.add_development_dependency 'rake'
38
36
 
39
- spec.add_dependency 'fastimage', '~> 2.1'
40
- spec.add_dependency 'google-api-client', '~> 0.34'
37
+ spec.add_dependency 'fastimage'
38
+ spec.add_dependency 'google-api-client'
41
39
  spec.add_dependency 'google-cloud-bigquery'
42
- spec.add_dependency 'pdf-reader', '~> 2.3'
43
- spec.add_dependency 'thor', '~> 0.1'
44
- spec.add_dependency 'yard', '~> 0.9'
40
+ spec.add_dependency 'i18n'
41
+ spec.add_dependency 'pdf-reader'
42
+ spec.add_dependency 'thor'
43
+ spec.add_dependency 'yard'
45
44
  end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "arquivo"
4
+ require 'bundler/setup'
5
+ require 'arquivo'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "arquivo"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/lib/arquivo.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'arquivo/version'
5
+ require 'arquivo/sheets'
6
+ require 'arquivo/bigquery'
5
7
  require 'arquivo/dir'
6
8
  require 'arquivo/pdf'
7
9
  require 'arquivo/jpg'
@@ -17,10 +19,8 @@ module Arquivo
17
19
 
18
20
  # @abstract CLI tarefas segmentar e arquivar
19
21
  class CLI < Thor
20
- desc 'mp3 MINUTA', 'processa MINUTA criando pasta ' \
21
- 'com segmentos para arquivo'
22
- option :tempos, type: :array, default: [],
23
- desc: 'lista tempos para segmentar MINUTA, ex: [[h:]m:]s'
22
+ desc 'mp3 MINUTA', 'processa MINUTA criando pasta com segmentos para arquivo'
23
+ option :tempos, type: :array, default: [], desc: 'lista tempos para segmentar MINUTA, ex: [[h:]m:]s'
24
24
  # segmenta minuta segundo lista tempos
25
25
  #
26
26
  # @param [String] minuta ficheiro audio a segmentar
@@ -34,15 +34,14 @@ module Arquivo
34
34
  f.segmenta_minuta(options[:tempos])
35
35
  end
36
36
 
37
- desc 'pdf EXTRATO', 'processa EXTRATO criando pasta ' \
38
- 'com documentos para arquivo'
37
+ desc 'pdf EXTRATO', 'processa EXTRATO criando pasta com documentos para arquivo'
39
38
  # segmenta extrato limpando publicidade
40
39
  #
41
40
  # @param [String] extrato pdf a segmentar
42
41
  def pdf(extrato)
43
42
  return unless File.exist?(extrato) && File.ftype(extrato) == 'file'
44
43
 
45
- f = C118pdf.new(extrato, options)
44
+ f = C118pdf.new(extrato, {})
46
45
  return unless f.processa_extrato?
47
46
 
48
47
  system "mkdir -p #{f.base}"
@@ -61,31 +60,25 @@ module Arquivo
61
60
  def dsh(dashboard)
62
61
  return unless File.exist?(dashboard) && File.ftype(dashboard) == 'file'
63
62
 
64
- C118pdf.new(dashboard, options).faz_dashboard
63
+ C118pdf.new(dashboard, {}).faz_dashboard
65
64
  end
66
65
 
67
66
  desc 'big', 'processa dados bigquery c118'
68
67
  # processa bigquery c118
69
68
  def big
70
- C118dir.new('/home/c118', options).processa_big
69
+ C118bigquery.new.processa_big
71
70
  end
72
71
 
73
- desc 'dir PASTA', 'processa faturas/recibos/extratos/minutas ' \
74
- 'e cria arquivos c118'
75
- option :fuzz, type: :numeric, default: 29,
76
- desc: 'fuzz trim jpg N-1, escolhe menor -> scanned pdf'
77
- option :quality, type: :numeric, default: 15,
78
- desc: 'compress jpg N% -> scanned pdf (less=low quality)'
72
+ desc 'dir PASTA', 'processa faturas/recibos/extratos/minutas e cria arquivos c118'
73
+ # opcoes para compressao de imagens em PDFs
74
+ option :fuzz, type: :numeric, default: 29, desc: 'fuzz trim jpg N-1, escolhe menor -> scanned pdf'
75
+ option :quality, type: :numeric, default: 15, desc: 'compress jpg N% -> scanned pdf (less=low quality)'
79
76
 
80
- option :threshold, type: :numeric, default: 9,
81
- desc: 'limiar maximo para silencio, 0% = silencio puro'
82
- option :sound, type: :numeric, default: 1,
83
- desc: 'segundos de som para terminar silencio'
84
-
85
- option :amount, type: :numeric, default: 0.00001,
86
- desc: 'qtd ruido a ser removido'
87
- option :rate, type: :numeric, default: 16,
88
- desc: 'sample rate - radio-16k, CD-44.1k, PC-48k, pro-96k'
77
+ # opcoes para compressao de audio
78
+ option :threshold, type: :numeric, default: 9, desc: 'limiar maximo para silencio, 0% = silencio puro'
79
+ option :sound, type: :numeric, default: 1, desc: 'segundos de som para terminar silencio'
80
+ option :amount, type: :numeric, default: 0.00001, desc: 'qtd ruido a ser removido'
81
+ option :rate, type: :numeric, default: 16, desc: 'sample rate - radio-16k, CD-44.1k, PC-48k, pro-96k'
89
82
  # arquiva pasta de documentos c118
90
83
  #
91
84
  # @param [String] pasta contem os documentos para arquivar
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/cloud/bigquery'
4
+
5
+ module Arquivo
6
+ # permite arquivar dados c118 no bigquery
7
+ class C118bigquery < C118sheets
8
+ # @return [Google::Cloud::Bigquery] API bigquery c118
9
+ attr_reader :big
10
+
11
+ # @return [C118bigquery] acesso bigquery c118
12
+ def initialize
13
+ # inicializar API sheets com ID cliente & credenciais
14
+ sheets_credentials
15
+
16
+ # This uses Application Default Credentials to authenticate.
17
+ # @see https://cloud.google.com/bigquery/docs/authentication/getting-started
18
+ @big = Google::Cloud::Bigquery.new
19
+ end
20
+
21
+ # obtem dados da folha c118 & processa no bigquery
22
+ def processa_big
23
+ # folha c118-contas
24
+ s = '1PbiMrtTtqGztZMhe3AiJbDS6NQE9o3hXebnQEFdt954'
25
+ a = folhas.get_spreadsheet_values(s, 'cbd!AJ2').values.flatten[0]
26
+ i = folhas.get_spreadsheet_values(s, 'bal!R2:R').values.flatten.join(',')
27
+ puts 'processamento bigquery feito para ano ' + a + ": [del_bal,del_hise,ins_bal,ins_hise] #{sql_big(a, i)}"
28
+ end
29
+
30
+ # executa comandos DML para processa no bigquery
31
+ #
32
+ # @return [Array<Integer>] numero linhas afetadas pelos DMLs
33
+ def sql_big(ano, lst)
34
+ [dml('delete FROM arquivo.bal WHERE ano=' + ano),
35
+ dml('delete FROM arquivo.hise WHERE ano=' + ano),
36
+ dml("INSERT arquivo.bal (#{col_bal}) VALUES" + lst),
37
+ dml("INSERT arquivo.hise(#{col_hise}) select * from arquivo.vhe where ano=" + ano)]
38
+ end
39
+
40
+ # @return [String] colunas da tabela bal no bigquery
41
+ def col_bal
42
+ 'data,entidade,documento,descricao,valor,tag,dr,banco,conta,ano,id4,dref,daa,paga,desb'
43
+ end
44
+
45
+ # @return [String] colunas da tabela hise no bigquery
46
+ def col_hise
47
+ 'ano,dr,tag,descricao,valor'
48
+ end
49
+
50
+ # executa comando DML (Data Manipulation Language) no bigquery
51
+ #
52
+ # @return [Integer] numero linhas afetadas pelo DML
53
+ def dml(sql)
54
+ job = big.query_job(sql)
55
+ job.wait_until_done!
56
+ puts job.error if job.failed?
57
+ job.num_dml_affected_rows
58
+ end
59
+ end
60
+ end
data/lib/arquivo/dir.rb CHANGED
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'google/apis/sheets_v4'
4
- require 'googleauth'
5
- require 'googleauth/stores/file_token_store'
6
- require 'google/cloud/bigquery'
7
-
8
3
  require 'arquivo/noise'
9
4
 
10
5
  module Arquivo
@@ -67,23 +62,6 @@ module Arquivo
67
62
  processa_items
68
63
  end
69
64
 
70
- def processa_big
71
- # sheet c118-contas
72
- dg = '1PbiMrtTtqGztZMhe3AiJbDS6NQE9o3hXebnQEFdt954'
73
- ano = c118_sheets.get_spreadsheet_values(dg, 'cdb!AJ2').values
74
- ins = c118_sheets.get_spreadsheet_values(dg, 'cbd!AJ:AJ').values
75
- puts ano
76
- puts ins
77
-
78
- # This uses Application Default Credentials to authenticate.
79
- # @see https://cloud.google.com/bigquery/docs/authentication/getting-started
80
- # bigquery = Google::Cloud::Bigquery.new
81
- # r = bigquery.query 'select * from arquivo.bal order by 1 desc limit 10'
82
- # r.each do |row|
83
- # puts "#{row[:data]}: #{row[:documento]}"
84
- # end
85
- end
86
-
87
65
  # @return [String] proximo item dentro da pasta
88
66
  def next_item
89
67
  @item = items.next
@@ -91,49 +69,20 @@ module Arquivo
91
69
  @item = nil
92
70
  end
93
71
 
94
- # @!group dados online
95
- # @return [Hash] dados oficiais para reclassificacao de faturas e recibos
72
+ # @!group dados folhas-calculo c118
73
+ # @return [Hash] dados oficiais para classificacao de faturas e recibos
96
74
  def obtem_dados
97
75
  @dados = {}
98
76
  # somente faturas e recibos necessitam reclassificacao
99
77
  return unless %i[fft frc].include?(contem)
100
78
 
101
- # sheet c118-contas
102
- dg = '1PbiMrtTtqGztZMhe3AiJbDS6NQE9o3hXebnQEFdt954'
103
- @dados = c118_sheets.get_spreadsheet_values(dg, contem.to_s + '!A2:E')
104
- .values.group_by { |k| k[0][/\w+/] }
79
+ # folha c118-contas
80
+ s = '1PbiMrtTtqGztZMhe3AiJbDS6NQE9o3hXebnQEFdt954'
81
+ @dados = C118sheets.new.folhas
82
+ .get_spreadsheet_values(s, contem.to_s + '!A2:E')
83
+ .values.group_by { |k| k[0][/\w+/] }
105
84
  rescue StandardError
106
85
  @dados = {}
107
86
  end
108
-
109
- # assegura credenciais validas, obtidas dum ficheiro de credencias
110
- #
111
- # @return [Google::Apis::SheetsV4::SheetsService] c118 sheets_v4
112
- def c118_sheets
113
- p = '/home/c118/.'
114
- # file obtido console.cloud.google.com/apis OAuth 2.0 client IDs
115
- i = Google::Auth::ClientId.from_file("#{p}sheets.json")
116
- s = Google::Apis::SheetsV4::AUTH_SPREADSHEETS_READONLY
117
- # file criado aquando new_credentials is executed
118
- f = Google::Auth::Stores::FileTokenStore.new(file: "#{p}sheets.yaml")
119
- z = Google::Auth::UserAuthorizer.new(i, s, f)
120
-
121
- sheets = Google::Apis::SheetsV4::SheetsService.new
122
- sheets.client_options.application_name = 'c118-arquivo'
123
- sheets.authorization = z.get_credentials('default') ||
124
- new_credentials(z, 'urn:ietf:wg:oauth:2.0:oob')
125
- sheets
126
- end
127
-
128
- # inicializar OAuth2 authorization abrindo URL e copiando novo codigo
129
- #
130
- # @return [Google::Auth::UserAuthorizer] OAuth2 credentials
131
- def new_credentials(aut, oob)
132
- puts 'Open URL and copy code after authorization, in <codigo-aqui>',
133
- aut.get_authorization_url(base_url: oob)
134
- aut.get_and_store_credentials_from_code(user_id: 'default',
135
- code: '<codigo-aqui>',
136
- base_url: oob)
137
- end
138
87
  end
139
88
  end
@@ -4,7 +4,7 @@ require 'pdf-reader'
4
4
 
5
5
  module Arquivo
6
6
  # permite processar documentos PDF
7
- class C118pdf < String
7
+ class C118pdf
8
8
  # @return [String] nome do documento
9
9
  attr_reader :file
10
10
  # @return [String] extensao do documento
@@ -128,21 +128,5 @@ module Arquivo
128
128
  puts "#{nome}-extrato"
129
129
  nome_extrato
130
130
  end
131
-
132
- # cria PDF do dashboard
133
- def faz_dashboard
134
- c = 'gs -sDEVICE=pdfwrite ' \
135
- '-dNOPAUSE -dBATCH -dQUIET -dPDFSETTINGS=/printer ' \
136
- '-sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dAutoRotatePages=/All'
137
- system "#{c} -sOutputFile=#{base}-a4.pdf \"#{file}\" #{O2}"
138
- puts "#{base}-a4"
139
- end
140
-
141
- # segmenta PDF pelas suas paginas
142
- def split
143
- system "pdftk #{file} burst output #{base}/pg%04d-#{base}.pdf;" \
144
- "rm -f #{base}/*.txt"
145
- puts "#{base}-split"
146
- end
147
131
  end
148
132
  end
data/lib/arquivo/mp3.rb CHANGED
@@ -17,8 +17,7 @@ module Arquivo
17
17
  # @param [String] mp3 MP3 c118
18
18
  # @param [Hash] opt parametrizar MINUTA
19
19
  # @option opt [Numeric] :amount (0.00001) qtd ruido a ser removido,
20
- # @option opt [Numeric] :rate (16) sample rate - radio-16k, CD-44.1k,
21
- # PC-48k, pro-96k
20
+ # @option opt [Numeric] :rate (16) sample rate - radio-16k, CD-44.1k, PC-48k, pro-96k
22
21
  # @return [C118mp3] MP3 c118
23
22
  def initialize(mp3, opt)
24
23
  @file = mp3
data/lib/arquivo/noise.rb CHANGED
@@ -31,16 +31,12 @@ module Arquivo
31
31
 
32
32
  # @param pasta (see CLI#dir)
33
33
  # @param [Hash] opt parametrizar JPG, MINUTA
34
- # @option opt [Numeric] :fuzz (29) trim jpg N-1, escolhe menor ->
35
- # scanned pdf
36
- # @option opt [Numeric] :quality (15) compress jpg N% -> scanned pdf
37
- # (less=low quality)
38
- # @option opt [Numeric] :threshold (9) limiar maximo para silencio,
39
- # 0% = silencio puro
34
+ # @option opt [Numeric] :fuzz (29) trim jpg N-1, escolhe menor -> scanned pdf
35
+ # @option opt [Numeric] :quality (15) compress jpg N% -> scanned pdf (less=low quality)
36
+ # @option opt [Numeric] :threshold (9) limiar maximo para silencio, 0% = silencio puro
40
37
  # @option opt [Numeric] :sound (1) segundos de som para terminar silencio
41
38
  # @option opt [Numeric] :amount (0.00001) qtd ruido a ser removido,
42
- # @option opt [Numeric] :rate (16) sample rate - radio-16k, CD-44.1k,
43
- # PC-48k, pro-96k
39
+ # @option opt [Numeric] :rate (16) sample rate - radio-16k, CD-44.1k, PC-48k, pro-96k
44
40
  # @return [C118dir] pasta de documentos c118
45
41
  def initialize(dir, opt)
46
42
  c = Dir.glob(File.join(dir, '*'))
data/lib/arquivo/pdf.rb CHANGED
@@ -7,7 +7,7 @@ I18n.config.available_locales = :pt
7
7
 
8
8
  module Arquivo
9
9
  # permite processar documentos PDF
10
- class C118pdf < String
10
+ class C118pdf
11
11
  # @!group processamento
12
12
  # processa pdf para arquivo
13
13
  #
@@ -143,5 +143,20 @@ module Arquivo
143
143
  "pdftk tmp/zip/#{base}.pdf " \
144
144
  "stamp tmp/stamp-#{id}.pdf output #{o} #{O2}"
145
145
  end
146
+
147
+ # cria PDF do dashboard
148
+ def faz_dashboard
149
+ c = 'gs -sDEVICE=pdfwrite ' \
150
+ '-dNOPAUSE -dBATCH -dQUIET -dPDFSETTINGS=/printer ' \
151
+ '-sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dAutoRotatePages=/All'
152
+ system "#{c} -sOutputFile=#{base}-a4.pdf \"#{file}\" #{O2}"
153
+ puts "#{base}-a4"
154
+ end
155
+
156
+ # segmenta PDF pelas suas paginas
157
+ def split
158
+ system "pdftk #{file} burst output #{base}/pg%04d-#{base}.pdf;rm -f #{base}/*.txt"
159
+ puts "#{base}-split"
160
+ end
146
161
  end
147
162
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'google/apis/sheets_v4'
4
+ require 'googleauth'
5
+ require 'googleauth/stores/file_token_store'
6
+
7
+ module Arquivo
8
+ # acede a folhas-calculo c118
9
+ class C118sheets
10
+ # @return (see #sheets_credentials)
11
+ attr_reader :folhas
12
+
13
+ # @return [C118sheets] acesso folhas-calculo c118
14
+ def initialize
15
+ sheets_credentials
16
+ end
17
+
18
+ # inicializar API sheets com ID cliente & credenciais
19
+ #
20
+ # @return [Google::Apis::SheetsV4::SheetsService] API folhas-calculo c118
21
+ def sheets_credentials
22
+ l = '/home/c118/.sheets.'
23
+ # file obtido console.cloud.google.com/apis OAuth 2.0 client IDs
24
+ i = Google::Auth::ClientId.from_file(l + 'json')
25
+ s = Google::Apis::SheetsV4::AUTH_SPREADSHEETS_READONLY
26
+ # file criado aquando new_credentials is executed
27
+ f = Google::Auth::Stores::FileTokenStore.new(file: l + 'yaml')
28
+ z = Google::Auth::UserAuthorizer.new(i, s, f)
29
+ @folhas = Google::Apis::SheetsV4::SheetsService.new
30
+ @folhas.client_options.application_name = 'c118-arquivo'
31
+ @folhas.authorization = z.get_credentials('default') || new_credentials(z, 'urn:ietf:wg:oauth:2.0:oob')
32
+ end
33
+
34
+ # inicializar OAuth2 authorization abrindo URL e copiando novo codigo
35
+ #
36
+ # @return [Google::Auth::UserAuthorizer] OAuth2 credentials
37
+ def new_credentials(aut, oob)
38
+ puts 'Open URL and copy code after authorization, in <codigo-aqui>', aut.get_authorization_url(base_url: oob)
39
+ aut.get_and_store_credentials_from_code(user_id: 'default', code: '<codigo-aqui>', base_url: oob)
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arquivo
4
- VERSION = '0.2.7'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arquivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.3
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-04-10 00:00:00.000000000 Z
11
+ date: 2021-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.17'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: fastimage
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '2.1'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '2.1'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: google-api-client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.34'
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0.34'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: google-cloud-bigquery
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,48 +80,62 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: i18n
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'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pdf-reader
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '2.3'
103
+ version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '2.3'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: thor
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '0.1'
117
+ version: '0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0.1'
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: yard
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - "~>"
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
- version: '0.9'
131
+ version: '0'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - "~>"
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
- version: '0.9'
138
+ version: '0'
125
139
  description: Processa documentos do condominio ph1341c118 para arquivo. Pode tambem
126
140
  segmentar PDFs e MINUTAS. Tendo os documentos em pastas separadas, pode ainda criar
127
141
  arquivos apropriados.
@@ -143,12 +157,14 @@ files:
143
157
  - bin/setup
144
158
  - exe/arquivo
145
159
  - lib/arquivo.rb
160
+ - lib/arquivo/bigquery.rb
146
161
  - lib/arquivo/dir.rb
147
162
  - lib/arquivo/extrato.rb
148
163
  - lib/arquivo/jpg.rb
149
164
  - lib/arquivo/mp3.rb
150
165
  - lib/arquivo/noise.rb
151
166
  - lib/arquivo/pdf.rb
167
+ - lib/arquivo/sheets.rb
152
168
  - lib/arquivo/version.rb
153
169
  homepage: https://github.com/ph1341c118/arquivo
154
170
  licenses:
@@ -171,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
187
  - !ruby/object:Gem::Version
172
188
  version: '0'
173
189
  requirements: []
174
- rubygems_version: 3.0.3
190
+ rubygems_version: 3.2.19
175
191
  signing_key:
176
192
  specification_version: 4
177
193
  summary: Processa documentos do condominio ph1341c118 para arquivo.