arquivo 0.1.7 → 0.1.8
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/arquivo/dir.rb +7 -8
- data/lib/arquivo/mp3.rb +52 -0
- data/lib/arquivo/version.rb +1 -1
- data/lib/arquivo.rb +16 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bc6dc05414fb65fee6c28b6a770014ce70e10e8b7e1f1023314b72f80e041c1
|
4
|
+
data.tar.gz: c99b712b8345da2729edb8074789fd894b81084f84f9b35a21315bd89527687c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25389c92dcf6a17335f86aec88b208c7df6f224c68d893fe7d9b7caebc65d8e242f817ff50b0caed94f205b3f94ad34e4384b88ea8e03e20a69d6776bc62dc09
|
7
|
+
data.tar.gz: 5f4c4feb9bf1142069e677aa567833d28cde155ee200c25258b05c5a32ad1b69111caae4be2978c7c26222482a61ec652a79af6f87b9e8b4b1bc4fab589f93cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
arquivo (0.1.
|
4
|
+
arquivo (0.1.8)
|
5
5
|
fastimage (~> 2.1)
|
6
6
|
google-api-client (~> 0.34)
|
7
7
|
pdf-reader (~> 2.3)
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
faraday (0.17.1)
|
20
20
|
multipart-post (>= 1.2, < 3)
|
21
21
|
fastimage (2.1.7)
|
22
|
-
google-api-client (0.36.
|
22
|
+
google-api-client (0.36.1)
|
23
23
|
addressable (~> 2.5, >= 2.5.1)
|
24
24
|
googleauth (~> 0.9)
|
25
25
|
httpclient (>= 2.8.1, < 3.0)
|
data/lib/arquivo/dir.rb
CHANGED
@@ -29,13 +29,6 @@ module Arquivo
|
|
29
29
|
system 'mkdir -p tmp/zip'
|
30
30
|
end
|
31
31
|
|
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
32
|
def processa_pasta(options)
|
40
33
|
n = 0
|
41
34
|
while next_item
|
@@ -60,7 +53,6 @@ module Arquivo
|
|
60
53
|
|
61
54
|
def processa_file(options, ext)
|
62
55
|
case ext
|
63
|
-
when '.mp3' then puts item
|
64
56
|
when '.jpg' then C118jpg.new(item).processa_jpg(options, dados)
|
65
57
|
when '.pdf' then C118pdf.new(item).processa_pdf(options, dados)
|
66
58
|
else
|
@@ -68,6 +60,13 @@ module Arquivo
|
|
68
60
|
end
|
69
61
|
end
|
70
62
|
|
63
|
+
# @return [String] ficheiro dentro da pasta
|
64
|
+
def next_item
|
65
|
+
@item = items.next
|
66
|
+
rescue StopIteration
|
67
|
+
@item = nil
|
68
|
+
end
|
69
|
+
|
71
70
|
def obtem_dados(dir)
|
72
71
|
return unless /fac?tura/i.match?(dir) ||
|
73
72
|
/recibo/i.match?(dir) ||
|
data/lib/arquivo/mp3.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Arquivo
|
4
|
+
# analisar/processar mp3
|
5
|
+
class C118mp3 < String
|
6
|
+
# @return [String] nome do ficheiro
|
7
|
+
attr_reader :file
|
8
|
+
# @return [String] extensao do ficheiro
|
9
|
+
attr_reader :ext
|
10
|
+
# @return [String] base do ficheiro
|
11
|
+
attr_reader :base
|
12
|
+
# @return [String] key do documento ft????/rc????/ex??0??/sc??????
|
13
|
+
attr_reader :key
|
14
|
+
# @return [Integer] tamanho do mp3
|
15
|
+
attr_reader :size
|
16
|
+
|
17
|
+
# @return [String] nome segmento
|
18
|
+
attr_reader :nome
|
19
|
+
|
20
|
+
# @return [C118mp3] mp3 c118
|
21
|
+
def initialize(fmp3)
|
22
|
+
@file = fmp3
|
23
|
+
@ext = File.extname(fmp3).downcase
|
24
|
+
@base = File.basename(fmp3, File.extname(fmp3))
|
25
|
+
@key = @base[/\w+/]
|
26
|
+
@size = File.size(fmp3)
|
27
|
+
end
|
28
|
+
|
29
|
+
def forca_mp3
|
30
|
+
o = "tmp/#{base}.mp3"
|
31
|
+
system "ffmpeg -i \"#{file}\" -vn #{o} #{CO}" unless ext == '.mp3'
|
32
|
+
File.size?(o) ? C118mp3.new(o) : self
|
33
|
+
end
|
34
|
+
|
35
|
+
def processa_minuta(options)
|
36
|
+
forca_mp3
|
37
|
+
p options
|
38
|
+
end
|
39
|
+
|
40
|
+
def processa_minuta?
|
41
|
+
return true if !File.exist?(base) && File.exist?(file) &&
|
42
|
+
['.mp3', '.m4a', '.wav'].include?(ext)
|
43
|
+
|
44
|
+
if File.exist?(base)
|
45
|
+
puts "erro: #{base} pasta ja existe"
|
46
|
+
else
|
47
|
+
puts "erro: #{file} nao consigo processar #{ext} audio"
|
48
|
+
end
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/arquivo/version.rb
CHANGED
data/lib/arquivo.rb
CHANGED
@@ -6,13 +6,28 @@ require 'arquivo/extrato'
|
|
6
6
|
require 'arquivo/dir'
|
7
7
|
require 'arquivo/pdf'
|
8
8
|
require 'arquivo/jpg'
|
9
|
+
require 'arquivo/mp3'
|
9
10
|
|
10
11
|
module Arquivo
|
11
12
|
class Error < StandardError; end
|
12
13
|
|
13
14
|
# CLI para analisar/processar documentos c118
|
14
15
|
class CLI < Thor
|
15
|
-
desc '
|
16
|
+
desc 'mp3 MINUTA', 'processa MINUTA criando pasta ' \
|
17
|
+
'com segmentos para arquivo'
|
18
|
+
option :times, type: :array, default: [],
|
19
|
+
desc: 'lista (hh:mm:ss) para dividir MINUTA em segmentos'
|
20
|
+
def mp3(file)
|
21
|
+
return unless File.ftype(file) == 'file'
|
22
|
+
|
23
|
+
f = C118mp3.new(file)
|
24
|
+
return unless f.processa_minuta?
|
25
|
+
|
26
|
+
system "mkdir -p tmp #{f.base}"
|
27
|
+
f.processa_minuta(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'pdf PDF', 'processa PDF criando pasta com documentos para arquivo'
|
16
31
|
def pdf(file)
|
17
32
|
return unless File.ftype(file) == 'file'
|
18
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arquivo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
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: 2019-12-
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/arquivo/dir.rb
|
117
117
|
- lib/arquivo/extrato.rb
|
118
118
|
- lib/arquivo/jpg.rb
|
119
|
+
- lib/arquivo/mp3.rb
|
119
120
|
- lib/arquivo/pdf.rb
|
120
121
|
- lib/arquivo/version.rb
|
121
122
|
homepage: https://github.com/ph1341c118/arquivo
|