arquivo 0.2.5 → 0.3.0

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: ad6cef1cb6b30603e973af3a7b4d83531cc8038ea2091cb7df88472040cb63c2
4
- data.tar.gz: 4b7e91302b0caae5da7404837a6f4e85d3a45ce54d2773b530a0287c13bdc3b6
3
+ metadata.gz: 8a76870038b98ebfbe1908469787efdc14668f43f9ca378f4006b46f1542bc79
4
+ data.tar.gz: 67a5eaf4bfd86f4f10efa00e5f63ff02de4f9907d2f1f666b46ea4fb1d4f58b4
5
5
  SHA512:
6
- metadata.gz: 63f82d499b0b500483203c1d06154a4e63a8a9001b41c1a19f23622c1557dd7e4417bebb94f4033ffe9b54f64b7a34a7a90ee04df7db035e9e7b32ba94fe4090
7
- data.tar.gz: c9dd3d3324f2563a3ec1f50bc2f0ad43124e83d2842cc000f062b0d7f3b893908d7d93b326d383f25d390894d15492ab5ef56e73c1edd614bfd9f5fec5722792
6
+ metadata.gz: 914e9b3d7986502ac35b0db15b81f5cc1c0a0fa884531adc74d617f9f2a8af832eb5e218edc38f8cf7ae0b6ffe41b15a0f0b4726744ae43234dedb0a4026a4a3
7
+ data.tar.gz: f7d6be4dd6d8dd3a31af523b1ed20c3b03ef076954acc88cc222d9da645df8609ab4847768e57642dc634bbab0dde89c1a5780388bac8490c8ddabe8fbc74f5c
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
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arquivo (0.2.5)
5
- fastimage (~> 2.1)
6
- google-api-client (~> 0.34)
7
- pdf-reader (~> 2.3)
8
- thor (~> 0.1)
9
- yard (~> 0.9)
4
+ arquivo (0.3.0)
5
+ fastimage
6
+ google-api-client
7
+ google-cloud-bigquery
8
+ i18n
9
+ pdf-reader
10
+ thor
11
+ yard
10
12
 
11
13
  GEM
12
14
  remote: https://rubygems.org/
@@ -15,12 +17,13 @@ GEM
15
17
  addressable (2.7.0)
16
18
  public_suffix (>= 2.0.2, < 5.0)
17
19
  afm (0.2.2)
20
+ concurrent-ruby (1.1.6)
18
21
  declarative (0.0.10)
19
22
  declarative-option (0.1.0)
20
- faraday (1.0.0)
23
+ faraday (1.0.1)
21
24
  multipart-post (>= 1.2, < 3)
22
25
  fastimage (2.1.7)
23
- google-api-client (0.37.2)
26
+ google-api-client (0.40.2)
24
27
  addressable (~> 2.5, >= 2.5.1)
25
28
  googleauth (~> 0.9)
26
29
  httpclient (>= 2.8.1, < 3.0)
@@ -28,28 +31,42 @@ GEM
28
31
  representable (~> 3.0)
29
32
  retriable (>= 2.0, < 4.0)
30
33
  signet (~> 0.12)
31
- googleauth (0.11.0)
34
+ google-cloud-bigquery (1.21.1)
35
+ concurrent-ruby (~> 1.0)
36
+ google-api-client (~> 0.33)
37
+ google-cloud-core (~> 1.2)
38
+ googleauth (~> 0.9)
39
+ mini_mime (~> 1.0)
40
+ google-cloud-core (1.5.0)
41
+ google-cloud-env (~> 1.0)
42
+ google-cloud-errors (~> 1.0)
43
+ google-cloud-env (1.3.2)
44
+ faraday (>= 0.17.3, < 2.0)
45
+ google-cloud-errors (1.0.1)
46
+ googleauth (0.13.0)
32
47
  faraday (>= 0.17.3, < 2.0)
33
48
  jwt (>= 1.4, < 3.0)
34
49
  memoist (~> 0.16)
35
50
  multi_json (~> 1.11)
36
51
  os (>= 0.9, < 2.0)
37
- signet (~> 0.12)
52
+ signet (~> 0.14)
38
53
  hashery (2.1.2)
39
54
  httpclient (2.8.3)
55
+ i18n (1.8.3)
56
+ concurrent-ruby (~> 1.0)
40
57
  jwt (2.2.1)
41
58
  memoist (0.16.2)
42
59
  mini_mime (1.0.2)
43
60
  multi_json (1.14.1)
44
61
  multipart-post (2.1.1)
45
- os (1.0.1)
62
+ os (1.1.0)
46
63
  pdf-reader (2.4.0)
47
64
  Ascii85 (~> 1.0.0)
48
65
  afm (~> 0.2.1)
49
66
  hashery (~> 2.0)
50
67
  ruby-rc4
51
68
  ttfunk
52
- public_suffix (4.0.3)
69
+ public_suffix (4.0.5)
53
70
  rake (13.0.1)
54
71
  representable (3.0.4)
55
72
  declarative (< 0.1.0)
@@ -57,23 +74,23 @@ GEM
57
74
  uber (< 0.2.0)
58
75
  retriable (3.1.2)
59
76
  ruby-rc4 (0.1.5)
60
- signet (0.13.0)
77
+ signet (0.14.0)
61
78
  addressable (~> 2.3)
62
79
  faraday (>= 0.17.3, < 2.0)
63
80
  jwt (>= 1.5, < 3.0)
64
81
  multi_json (~> 1.10)
65
- thor (0.20.3)
82
+ thor (1.0.1)
66
83
  ttfunk (1.6.2.1)
67
84
  uber (0.1.0)
68
- yard (0.9.24)
85
+ yard (0.9.25)
69
86
 
70
87
  PLATFORMS
71
88
  ruby
72
89
 
73
90
  DEPENDENCIES
74
91
  arquivo!
75
- bundler (~> 1.17)
92
+ bundler
76
93
  rake
77
94
 
78
95
  BUNDLED WITH
79
- 1.17.2
96
+ 2.1.2
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
@@ -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,19 +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'
41
- spec.add_dependency 'pdf-reader', '~> 2.3'
42
- spec.add_dependency 'thor', '~> 0.1'
43
- spec.add_dependency 'yard', '~> 0.9'
37
+ spec.add_dependency 'fastimage'
38
+ spec.add_dependency 'google-api-client'
39
+ spec.add_dependency 'google-cloud-bigquery'
40
+ spec.add_dependency 'i18n'
41
+ spec.add_dependency 'pdf-reader'
42
+ spec.add_dependency 'thor'
43
+ spec.add_dependency 'yard'
44
44
  end
@@ -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__)
@@ -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,25 +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
- desc 'dir PASTA', 'processa faturas/recibos/extratos/minutas ' \
68
- 'e cria arquivos c118'
69
- option :fuzz, type: :numeric, default: 29,
70
- desc: 'fuzz trim jpg N-1, escolhe menor -> scanned pdf'
71
- option :quality, type: :numeric, default: 15,
72
- desc: 'compress jpg N% -> scanned pdf (less=low quality)'
66
+ desc 'big', 'processa dados bigquery c118'
67
+ # processa bigquery c118
68
+ def big
69
+ C118bigquery.new.processa_big
70
+ end
73
71
 
74
- option :threshold, type: :numeric, default: 9,
75
- desc: 'limiar maximo para silencio, 0% = silencio puro'
76
- option :sound, type: :numeric, default: 1,
77
- desc: 'segundos de som para terminar silencio'
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)'
78
76
 
79
- option :amount, type: :numeric, default: 0.00001,
80
- desc: 'qtd ruido a ser removido'
81
- option :rate, type: :numeric, default: 16,
82
- 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'
83
82
  # arquiva pasta de documentos c118
84
83
  #
85
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
@@ -1,9 +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
-
7
3
  require 'arquivo/noise'
8
4
 
9
5
  module Arquivo
@@ -73,49 +69,20 @@ module Arquivo
73
69
  @item = nil
74
70
  end
75
71
 
76
- # @!group dados online
77
- # @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
78
74
  def obtem_dados
79
75
  @dados = {}
80
76
  # somente faturas e recibos necessitam reclassificacao
81
77
  return unless %i[fft frc].include?(contem)
82
78
 
83
- # sheet c118-contas
84
- dg = '1PbiMrtTtqGztZMhe3AiJbDS6NQE9o3hXebnQEFdt954'
85
- @dados = c118_sheets.get_spreadsheet_values(dg, contem.to_s + '!A2:E')
86
- .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+/] }
87
84
  rescue StandardError
88
85
  @dados = {}
89
86
  end
90
-
91
- # assegura credenciais validas, obtidas dum ficheiro de credencias
92
- #
93
- # @return [Google::Apis::SheetsV4::SheetsService] c118 sheets_v4
94
- def c118_sheets
95
- p = '/home/c118/c118-'
96
- # file obtido console.cloud.google.com/apis OAuth 2.0 client IDs
97
- i = Google::Auth::ClientId.from_file("#{p}credentials.json")
98
- s = Google::Apis::SheetsV4::AUTH_SPREADSHEETS_READONLY
99
- # file criado aquando new_credentials is executed
100
- f = Google::Auth::Stores::FileTokenStore.new(file: "#{p}token.yaml")
101
- z = Google::Auth::UserAuthorizer.new(i, s, f)
102
-
103
- sheets = Google::Apis::SheetsV4::SheetsService.new
104
- sheets.client_options.application_name = 'c118-arquivo'
105
- sheets.authorization = z.get_credentials('default') ||
106
- new_credentials(z, 'urn:ietf:wg:oauth:2.0:oob')
107
- sheets
108
- end
109
-
110
- # inicializar OAuth2 authorization abrindo URL e copiando novo codigo
111
- #
112
- # @return [Google::Auth::UserAuthorizer] OAuth2 credentials
113
- def new_credentials(aut, oob)
114
- puts 'Open URL and copy code after authorization, in <codigo-aqui>',
115
- aut.get_authorization_url(base_url: oob)
116
- aut.get_and_store_credentials_from_code(user_id: 'default',
117
- code: '<codigo-aqui>',
118
- base_url: oob)
119
- end
120
87
  end
121
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
@@ -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
@@ -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, '*'))
@@ -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.5'
4
+ VERSION = '0.3.0'
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.5
4
+ version: 0.3.0
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-03-03 00:00:00.000000000 Z
11
+ date: 2020-07-11 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,72 +42,100 @@ 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
+ - !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: google-cloud-bigquery
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: i18n
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
60
88
  - !ruby/object:Gem::Version
61
- version: '0.34'
89
+ version: '0'
62
90
  type: :runtime
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - "~>"
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
- version: '0.34'
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: pdf-reader
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
- version: '2.3'
103
+ version: '0'
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - "~>"
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
- version: '2.3'
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: thor
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - "~>"
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
- version: '0.1'
117
+ version: '0'
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - "~>"
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
- version: '0.1'
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: yard
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - "~>"
129
+ - - ">="
102
130
  - !ruby/object:Gem::Version
103
- version: '0.9'
131
+ version: '0'
104
132
  type: :runtime
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - "~>"
136
+ - - ">="
109
137
  - !ruby/object:Gem::Version
110
- version: '0.9'
138
+ version: '0'
111
139
  description: Processa documentos do condominio ph1341c118 para arquivo. Pode tambem
112
140
  segmentar PDFs e MINUTAS. Tendo os documentos em pastas separadas, pode ainda criar
113
141
  arquivos apropriados.
@@ -129,12 +157,14 @@ files:
129
157
  - bin/setup
130
158
  - exe/arquivo
131
159
  - lib/arquivo.rb
160
+ - lib/arquivo/bigquery.rb
132
161
  - lib/arquivo/dir.rb
133
162
  - lib/arquivo/extrato.rb
134
163
  - lib/arquivo/jpg.rb
135
164
  - lib/arquivo/mp3.rb
136
165
  - lib/arquivo/noise.rb
137
166
  - lib/arquivo/pdf.rb
167
+ - lib/arquivo/sheets.rb
138
168
  - lib/arquivo/version.rb
139
169
  homepage: https://github.com/ph1341c118/arquivo
140
170
  licenses:
@@ -157,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
187
  - !ruby/object:Gem::Version
158
188
  version: '0'
159
189
  requirements: []
160
- rubygems_version: 3.0.3
190
+ rubygems_version: 3.1.2
161
191
  signing_key:
162
192
  specification_version: 4
163
193
  summary: Processa documentos do condominio ph1341c118 para arquivo.