alego_pdf 2.0.0 → 2.0.1
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 +5 -5
- data/.ruby-version +1 -0
- data/CHANGELOG +18 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +3 -81
- data/README.md +32 -32
- data/alego_pdf.gemspec +10 -14
- data/lib/alego_pdf/version.rb +1 -1
- metadata +5 -46
- data/alego_pdf-1.0.0.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5234d9c582405d545e5beeb7ff2300374e532746609e7ca10302ba5fc7b2db03
|
|
4
|
+
data.tar.gz: ecbc8915bfa7be910c9e7514d344d66a5278a385b4f8d3c5c0a996358f119f1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68ecf437cad98773176cd03e1692ac9a7b2df51f13c138c0712cd4c91b3db1ea8fa8389aadebcb17b2f9acb2c901a04741afda27fe75f2d74ae143b6b942875b
|
|
7
|
+
data.tar.gz: 6becf57defb8b8b848f3842c406d97ff210c496c65743c7df5442ccac48e8760c9468b91da67ab9db9a83cfb3538fe92fdcce57a00c799c82da9bd007aed25ed
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.5.1
|
data/CHANGELOG
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
v2.0.1 - 20/09/2022
|
|
2
|
+
|
|
3
|
+
Ajuste:
|
|
4
|
+
1) Corrigindo gemspec e README
|
|
5
|
+
|
|
6
|
+
----
|
|
7
|
+
|
|
8
|
+
v2.0.0 - 12/09/2022
|
|
9
|
+
|
|
10
|
+
Novidade:
|
|
11
|
+
1) Gem alego_pdf que junta 1 ou mais PDF's num mesmo arquivo via model e ids passados por parâmetro.
|
|
12
|
+
|
|
13
|
+
----
|
|
14
|
+
|
|
15
|
+
v1.0.0 - 09/09/2022
|
|
16
|
+
|
|
17
|
+
Lançamento:
|
|
18
|
+
1) Nova gem alego_pdf que junta 1 ou mais PDF's num mesmo arquivo via URL's.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,112 +1,34 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
alego_pdf (
|
|
5
|
-
factory_bot_rails
|
|
4
|
+
alego_pdf (2.0.1)
|
|
6
5
|
hexapdf
|
|
7
6
|
open-uri
|
|
8
|
-
rspec-rails
|
|
9
7
|
|
|
10
8
|
GEM
|
|
11
9
|
remote: https://rubygems.org/
|
|
12
10
|
specs:
|
|
13
|
-
actionpack (7.0.3.1)
|
|
14
|
-
actionview (= 7.0.3.1)
|
|
15
|
-
activesupport (= 7.0.3.1)
|
|
16
|
-
rack (~> 2.0, >= 2.2.0)
|
|
17
|
-
rack-test (>= 0.6.3)
|
|
18
|
-
rails-dom-testing (~> 2.0)
|
|
19
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
20
|
-
actionview (7.0.3.1)
|
|
21
|
-
activesupport (= 7.0.3.1)
|
|
22
|
-
builder (~> 3.1)
|
|
23
|
-
erubi (~> 1.4)
|
|
24
|
-
rails-dom-testing (~> 2.0)
|
|
25
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
26
|
-
activesupport (7.0.3.1)
|
|
27
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
28
|
-
i18n (>= 1.6, < 2)
|
|
29
|
-
minitest (>= 5.1)
|
|
30
|
-
tzinfo (~> 2.0)
|
|
31
|
-
builder (3.2.4)
|
|
32
11
|
cmdparse (3.0.7)
|
|
33
|
-
concurrent-ruby (1.1.10)
|
|
34
|
-
crass (1.0.6)
|
|
35
12
|
date (3.2.2)
|
|
36
|
-
diff-lcs (1.5.0)
|
|
37
|
-
erubi (1.11.0)
|
|
38
|
-
factory_bot (6.2.1)
|
|
39
|
-
activesupport (>= 5.0.0)
|
|
40
|
-
factory_bot_rails (6.2.0)
|
|
41
|
-
factory_bot (~> 6.2.0)
|
|
42
|
-
railties (>= 5.0.0)
|
|
43
13
|
geom2d (0.3.1)
|
|
44
14
|
hexapdf (0.24.2)
|
|
45
15
|
cmdparse (~> 3.0, >= 3.0.3)
|
|
46
16
|
geom2d (~> 0.3)
|
|
47
|
-
i18n (1.12.0)
|
|
48
|
-
concurrent-ruby (~> 1.0)
|
|
49
|
-
loofah (2.18.0)
|
|
50
|
-
crass (~> 1.0.2)
|
|
51
|
-
nokogiri (>= 1.5.9)
|
|
52
|
-
method_source (1.0.0)
|
|
53
|
-
minitest (5.16.3)
|
|
54
|
-
nokogiri (1.13.8-x86_64-darwin)
|
|
55
|
-
racc (~> 1.4)
|
|
56
17
|
open-uri (0.2.0)
|
|
57
18
|
stringio
|
|
58
19
|
time
|
|
59
20
|
uri
|
|
60
|
-
racc (1.6.0)
|
|
61
|
-
rack (2.2.4)
|
|
62
|
-
rack-test (2.0.2)
|
|
63
|
-
rack (>= 1.3)
|
|
64
|
-
rails-dom-testing (2.0.3)
|
|
65
|
-
activesupport (>= 4.2.0)
|
|
66
|
-
nokogiri (>= 1.6)
|
|
67
|
-
rails-html-sanitizer (1.4.3)
|
|
68
|
-
loofah (~> 2.3)
|
|
69
|
-
railties (7.0.3.1)
|
|
70
|
-
actionpack (= 7.0.3.1)
|
|
71
|
-
activesupport (= 7.0.3.1)
|
|
72
|
-
method_source
|
|
73
|
-
rake (>= 12.2)
|
|
74
|
-
thor (~> 1.0)
|
|
75
|
-
zeitwerk (~> 2.5)
|
|
76
|
-
rake (12.3.3)
|
|
77
|
-
rspec-core (3.11.0)
|
|
78
|
-
rspec-support (~> 3.11.0)
|
|
79
|
-
rspec-expectations (3.11.0)
|
|
80
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
81
|
-
rspec-support (~> 3.11.0)
|
|
82
|
-
rspec-mocks (3.11.1)
|
|
83
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
84
|
-
rspec-support (~> 3.11.0)
|
|
85
|
-
rspec-rails (5.1.2)
|
|
86
|
-
actionpack (>= 5.2)
|
|
87
|
-
activesupport (>= 5.2)
|
|
88
|
-
railties (>= 5.2)
|
|
89
|
-
rspec-core (~> 3.10)
|
|
90
|
-
rspec-expectations (~> 3.10)
|
|
91
|
-
rspec-mocks (~> 3.10)
|
|
92
|
-
rspec-support (~> 3.10)
|
|
93
|
-
rspec-support (3.11.0)
|
|
94
21
|
stringio (3.0.2)
|
|
95
|
-
thor (1.2.1)
|
|
96
22
|
time (0.2.0)
|
|
97
23
|
date
|
|
98
|
-
tzinfo (2.0.5)
|
|
99
|
-
concurrent-ruby (~> 1.0)
|
|
100
24
|
uri (0.11.0)
|
|
101
|
-
zeitwerk (2.6.0)
|
|
102
25
|
|
|
103
26
|
PLATFORMS
|
|
104
|
-
|
|
27
|
+
ruby
|
|
105
28
|
|
|
106
29
|
DEPENDENCIES
|
|
107
30
|
alego_pdf!
|
|
108
31
|
bundler
|
|
109
|
-
rake (~> 12.0)
|
|
110
32
|
|
|
111
33
|
BUNDLED WITH
|
|
112
|
-
2.
|
|
34
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -25,8 +25,8 @@ Ou instale isto você mesmo usando o comando:
|
|
|
25
25
|
|
|
26
26
|
## Uso
|
|
27
27
|
A gem 'alego_pdf' depende da gem 'hexapdf' para fazer a juntada de arquivos.
|
|
28
|
-
Veja mais sobre a gem 'hexapdf' no Github: https://github.com/gettalong/hexapdf
|
|
29
|
-
A gem 'alego_pdf' busca os
|
|
28
|
+
Veja mais sobre a gem 'hexapdf' no Github: https://github.com/gettalong/hexapdf.
|
|
29
|
+
A gem 'alego_pdf' busca os objetos, faz a leitura dos arquivos via URI e Tempfile e a gem 'hexapdf' junta-os. Veja o exemplo na gem alego_pdf:
|
|
30
30
|
```
|
|
31
31
|
require 'hexapdf'
|
|
32
32
|
require 'open-uri'
|
|
@@ -46,9 +46,9 @@ module AlegoPdf
|
|
|
46
46
|
array = model.is_a?(String) ? model.camelize.constantize.where(id: ids) : model.where(id: ids)
|
|
47
47
|
target = HexaPDF::Document.new
|
|
48
48
|
|
|
49
|
-
array.each do |
|
|
50
|
-
file =
|
|
51
|
-
filepath = file.try(:url) ||
|
|
49
|
+
array.each do |object|
|
|
50
|
+
file = object[attribute]
|
|
51
|
+
filepath = file.try(:url) || object.try(:arquivo_url)
|
|
52
52
|
|
|
53
53
|
next if filepath.blank?
|
|
54
54
|
|
|
@@ -66,38 +66,38 @@ module AlegoPdf
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
```
|
|
69
|
-
Obs.: Os parâmetros 'ids', 'model' e 'attribute' são obrigatórios. O parâmetro 'filename' é por default 'tmp/merge_files.pdf', porém pode-se atribuir um caminho pré-definido.
|
|
70
|
-
Após instalar a gem 'alego_pdf', deve criar uma rota '/
|
|
69
|
+
Obs.: Os parâmetros 'ids', 'model' e 'attribute' são obrigatórios. O parâmetro 'filename' é por default 'tmp/merge_files.pdf', porém pode-se atribuir um caminho pré-definido. o atributo 'filename' será o local e nome onde será salvo o arquivo temporário.
|
|
70
|
+
Após instalar a gem 'alego_pdf', deve criar uma rota '/merge_arquivos' e deve buscar os ids dos arquivos e passá-los como parâmetro junto com o model e o atributo que onde é guardado os metadados dos arquivos. A gem procura também por um atributo chamado 'arquivo_url', caso não encontre a 'url' (ex.: attribute.try(:url)) Veja o exemplo a seguir:
|
|
71
71
|
```
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
end
|
|
72
|
+
# organogramas_controller.rb
|
|
73
|
+
def merge_arquivos
|
|
74
|
+
organograma_ids = ::Transparencia::Organograma.order('data desc').map(&:id)
|
|
75
|
+
|
|
76
|
+
respond_to do |format|
|
|
77
|
+
format.html
|
|
78
|
+
format.pdf do
|
|
79
|
+
filename = 'tmp/organogramas.pdf' # nome e local onde será salvo o arquivo temporário
|
|
80
|
+
AlegoPdf::Merging.new(organograma_ids, ::Transparencia::Organograma, :arquivo, filename).call
|
|
81
|
+
|
|
82
|
+
pdf_filename = File.join(Rails.root, filename)
|
|
83
|
+
send_file(pdf_filename, filename: 'organogramas.pdf', type: 'application/pdf')
|
|
85
84
|
end
|
|
86
85
|
end
|
|
86
|
+
end
|
|
87
87
|
```
|
|
88
|
-
PS: caso não exista nenhum arquivo, é feito download de uma página em branco, portanto certifique-se que contenha ao menos 1 objeto com upload PDF antes fazer a chamada AlegoPdf::Merging ou apresentar o botão na view que chama a rota e faz o download dos arquivos. Veja o exemplo:
|
|
88
|
+
PS: caso não exista nenhum arquivo, é feito download de uma página em branco, portanto certifique-se que contenha ao menos 1 objeto com upload PDF antes de fazer a chamada AlegoPdf::Merging ou apresentar o botão na view que chama a rota e faz o download dos arquivos. Veja o exemplo:
|
|
89
89
|
```
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
// index.html.erb
|
|
91
|
+
<% @organograma_pdf_any = ::Transparencia::Organograma.any?(&:arquivo_url) # verifica se existe ao menos 1 url do arquivo %>
|
|
92
|
+
|
|
93
|
+
<% if @organograma_pdf_any %>
|
|
94
|
+
<a href="/organogramas/merge_arquivos.pdf" target="_blank" title="Juntar arquivos" class="bt bt--secundario">
|
|
95
|
+
Todos organogramas
|
|
96
|
+
<svg class="ico">
|
|
97
|
+
<use xlink:href="<%= asset_path('ico.svg#download') %>" />
|
|
98
|
+
</svg>
|
|
99
|
+
</a>
|
|
100
|
+
<% end %>
|
|
101
101
|
```
|
|
102
102
|
## Contribuição
|
|
103
103
|
|
data/alego_pdf.gemspec
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
require_relative 'lib/alego_pdf/version'
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
|
-
spec.name
|
|
5
|
-
spec.version
|
|
6
|
-
spec.
|
|
7
|
-
spec.email
|
|
8
|
-
spec.homepage
|
|
9
|
-
spec.summary
|
|
10
|
-
spec.description
|
|
11
|
-
spec.license
|
|
4
|
+
spec.name = 'alego_pdf'
|
|
5
|
+
spec.version = AlegoPdf::VERSION
|
|
6
|
+
spec.author = 'Rodrigo de Sá'
|
|
7
|
+
spec.email = ['rodrigo.sa@al.go.leg.br']
|
|
8
|
+
spec.homepage = 'https://gitlab.al.go.leg.br/sistemas/gem/alego_pdf'
|
|
9
|
+
spec.summary = "Gem responsible for joining 1 or more PDF in the same file."
|
|
10
|
+
spec.description = "Gem responsible for joining 1 or more PDF in the same file."
|
|
11
|
+
spec.license = 'MIT'
|
|
12
12
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
|
13
13
|
|
|
14
14
|
begin
|
|
15
|
-
|
|
15
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
|
16
16
|
rescue StandardError
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -30,12 +30,8 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
31
|
spec.require_paths = ['lib']
|
|
32
32
|
|
|
33
|
-
spec.add_development_dependency 'bundler'
|
|
34
|
-
spec.add_development_dependency 'rake' # , "~> 11.2.2"
|
|
35
|
-
|
|
36
|
-
spec.add_runtime_dependency 'factory_bot_rails' # , "~> 4.4.1"
|
|
33
|
+
spec.add_development_dependency 'bundler'
|
|
37
34
|
|
|
38
35
|
spec.add_dependency 'hexapdf' # , "~> 0.24.0"
|
|
39
36
|
spec.add_dependency 'open-uri' # , "~> 0.2.0"
|
|
40
|
-
spec.add_dependency 'rspec-rails' # , "~> 3.0.0.beta"
|
|
41
37
|
end
|
data/lib/alego_pdf/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: alego_pdf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rodrigo de Sá
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-09-
|
|
11
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -24,34 +24,6 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
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: factory_bot_rails
|
|
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
27
|
- !ruby/object:Gem::Dependency
|
|
56
28
|
name: hexapdf
|
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,20 +52,6 @@ dependencies:
|
|
|
80
52
|
- - ">="
|
|
81
53
|
- !ruby/object:Gem::Version
|
|
82
54
|
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rspec-rails
|
|
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
55
|
description: Gem responsible for joining 1 or more PDF in the same file.
|
|
98
56
|
email:
|
|
99
57
|
- rodrigo.sa@al.go.leg.br
|
|
@@ -101,13 +59,13 @@ executables: []
|
|
|
101
59
|
extensions: []
|
|
102
60
|
extra_rdoc_files: []
|
|
103
61
|
files:
|
|
62
|
+
- ".ruby-version"
|
|
104
63
|
- CHANGELOG
|
|
105
64
|
- Gemfile
|
|
106
65
|
- Gemfile.lock
|
|
107
66
|
- MIT-LICENSE
|
|
108
67
|
- README.md
|
|
109
68
|
- Rakefile
|
|
110
|
-
- alego_pdf-1.0.0.gem
|
|
111
69
|
- alego_pdf.gemspec
|
|
112
70
|
- bin/console
|
|
113
71
|
- bin/setup
|
|
@@ -118,6 +76,7 @@ homepage: https://gitlab.al.go.leg.br/sistemas/gem/alego_pdf
|
|
|
118
76
|
licenses:
|
|
119
77
|
- MIT
|
|
120
78
|
metadata:
|
|
79
|
+
allowed_push_host: https://rubygems.org
|
|
121
80
|
homepage_uri: https://gitlab.al.go.leg.br/sistemas/gem/alego_pdf
|
|
122
81
|
post_install_message:
|
|
123
82
|
rdoc_options: []
|
|
@@ -135,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
94
|
version: '0'
|
|
136
95
|
requirements: []
|
|
137
96
|
rubyforge_project:
|
|
138
|
-
rubygems_version: 2.6
|
|
97
|
+
rubygems_version: 2.7.6
|
|
139
98
|
signing_key:
|
|
140
99
|
specification_version: 4
|
|
141
100
|
summary: Gem responsible for joining 1 or more PDF in the same file.
|
data/alego_pdf-1.0.0.gem
DELETED
|
Binary file
|