arquivo 0.1.6 → 0.1.7

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: 5c32add30cf30ae788f2ace6ba483e70104a801d5078952ea4d4bb623b3b77da
4
- data.tar.gz: c2137272520d205c30930579d36338d98635b3084f4bb12cdd139a5d27aa928b
3
+ metadata.gz: 48b00d56c13ecf2555807b41e63f2b6f07bad4477665904b32c016d16870bf59
4
+ data.tar.gz: 0db4a79a697243283a101693e8b644c7575a1148f656cf238da0c6d4ec6c7e09
5
5
  SHA512:
6
- metadata.gz: 58dd3ebad2641ac46c45dec416a6b45d911905b9b270ebeebf35e3f4b396bbedf800bd65858593d5a52624eb4bc42998d965e007c8576849621ca3e4c1fe1f6f
7
- data.tar.gz: '09ea0d8b876b8d061a67af94dfc2c30e2b272c0e8a0c349070823f4ec0961b1d87db956cf1fb1da0b98a0405f7d48d9ca5307526f414c51ab00f5e44ebb03df0'
6
+ metadata.gz: 39d899b5e600af1f4ef19c35f0e6ef0425e6762b3482bbaa67eb5e895e971700b4ed73308f15e5a6218e08280f87c24efd7de11afdecc6abca8a220014850eb8
7
+ data.tar.gz: 21965e9af88ef6129dcdb8bfbcb7c5233f19e764aac33c760c497bd71de80eff02ae77bf7c1b1eef17cc734dfe3d096f51a9130956cca75cd5a5df858333e166
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arquivo (0.1.6)
4
+ arquivo (0.1.7)
5
5
  fastimage (~> 2.1)
6
6
  google-api-client (~> 0.34)
7
7
  pdf-reader (~> 2.3)
@@ -36,9 +36,7 @@ module Arquivo
36
36
  def dir(fdir)
37
37
  return unless File.ftype(fdir) == 'directory'
38
38
 
39
- system 'mkdir -p tmp/zip'
40
39
  C118dir.new(fdir).processa_pasta(options)
41
- # system 'rm -rf tmp'
42
40
  end
43
41
  end
44
42
  end
@@ -5,11 +5,12 @@ require 'googleauth'
5
5
  require 'googleauth/stores/file_token_store'
6
6
 
7
7
  module Arquivo
8
- CO = '1>/dev/null 2>&1'
8
+ # CO = '1>/dev/null 2>&1'
9
+ CO = ''
9
10
 
10
11
  # analisar/processar pasta
11
12
  class C118dir < Enumerator
12
- # @return [Enumerator] lista ordenada items dentro duma pasta
13
+ # @return [Enumerator] lista items dentro duma pasta
13
14
  attr_reader :items
14
15
  # @return [String] documento c118
15
16
  attr_reader :item
@@ -24,10 +25,50 @@ module Arquivo
24
25
  @items = Dir.glob(File.join(pasta, '*')).each
25
26
  @base = File.basename(pasta, File.extname(pasta)) +
26
27
  Date.today.strftime('%Y%m%d')
27
- obter_dados(pasta)
28
+ obtem_dados(pasta)
29
+ system 'mkdir -p tmp/zip'
28
30
  end
29
31
 
30
- def obter_dados(dir)
32
+ # @return [String] ficheiro dentro da pasta
33
+ def next_item
34
+ @item = items.next
35
+ rescue StopIteration
36
+ @item = nil
37
+ end
38
+
39
+ def processa_pasta(options)
40
+ n = 0
41
+ while next_item
42
+ if File.ftype(item) == 'directory'
43
+ C118dir.new(item).processa_pasta(options)
44
+ else
45
+ processa_file(options, File.extname(item).downcase)
46
+ n += 1
47
+ end
48
+ end
49
+ processa_fim(n) if n.positive?
50
+ end
51
+
52
+ def processa_fim(num)
53
+ system "rm -f #{base}.*;" \
54
+ "pdftk tmp/stamped*.pdf cat output #{base}.pdf;" \
55
+ "cd tmp/zip;tar cf ../../#{base}.tar *.pdf;" \
56
+ "cd ../..;gzip --best #{base}.tar;" \
57
+ 'rm -rf ./tmp'
58
+ puts "#{base} (#{num})"
59
+ end
60
+
61
+ def processa_file(options, ext)
62
+ case ext
63
+ when '.mp3' then puts item
64
+ when '.jpg' then C118jpg.new(item).processa_jpg(options, dados)
65
+ when '.pdf' then C118pdf.new(item).processa_pdf(options, dados)
66
+ else
67
+ puts "erro: #{item} so posso processar mp3, jpg, pdf"
68
+ end
69
+ end
70
+
71
+ def obtem_dados(dir)
31
72
  return unless /fac?tura/i.match?(dir) ||
32
73
  /recibo/i.match?(dir) ||
33
74
  dados.empty?
@@ -70,41 +111,5 @@ module Arquivo
70
111
  code: '<codigo-aqui>',
71
112
  base_url: oob)
72
113
  end
73
-
74
- # @return [String] texto duma pagina pdf
75
- def next_item
76
- @item = items.next
77
- rescue StopIteration
78
- @item = nil
79
- end
80
-
81
- def processa_pasta(options)
82
- return unless next_item
83
-
84
- if File.ftype(item) == 'directory'
85
- C118dir.new(item).processa_pasta(options)
86
- else
87
- processa_file(options)
88
- processa_pasta(options)
89
- processa_fim
90
- end
91
- end
92
-
93
- def processa_fim
94
- system "rm -f #{base}.*;" \
95
- "pdftk tmp/stamped*.pdf cat output #{base}.pdf;" \
96
- "cd tmp/zip;tar cf ../../#{base}.tar *.pdf;" \
97
- "gzip --best ../../#{base}.tar"
98
- end
99
-
100
- def processa_file(options)
101
- case File.extname(item).downcase
102
- when '.mp3' then puts 'mp3'
103
- when '.jpg' then C118jpg.new(item).processa_jpg(options, dados)
104
- when '.pdf' then C118pdf.new(item).processa_pdf(options, dados)
105
- else
106
- puts "erro: #{item} so posso processar mp3, jpg, pdf"
107
- end
108
- end
109
114
  end
110
115
  end
@@ -22,6 +22,7 @@ module Arquivo
22
22
  system "#{c118_gs} -sOutputFile=tmp/stamp-#{key}.pdf -c \"#{s}\";" \
23
23
  "pdftk tmp/zip/#{base}.pdf " \
24
24
  "stamp tmp/stamp-#{key}.pdf output #{o} #{CO}"
25
+ puts key
25
26
  end
26
27
 
27
28
  def final(kda)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arquivo
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arquivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz