nguyen 1.0.2 → 1.0.3

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
- SHA1:
3
- metadata.gz: 87249f3df0276b081523efa08c46dd8feb43db2f
4
- data.tar.gz: d872b66be7d38fbd3f20f3a053b5cb6b260dda36
2
+ SHA256:
3
+ metadata.gz: acfaf8065a261f6cc2b2f5b95887a48d450686b6529a315664982c13ecc0c8d0
4
+ data.tar.gz: 99729f86c46f23fc9846f1af8c727da593066dc9df39c4283eceba5b6bd2bb68
5
5
  SHA512:
6
- metadata.gz: 0d1e6f777d4603591fc638e70af122cf1913c0aa7df534833062d653ba869bf8696b30a96e25658bc00f202dc5e241adae4acc76728629d117e2259db8bc78b2
7
- data.tar.gz: bef8d65f125f49319afb248023a9be1eda31a44f5679f101d2e22d619309ffe172376a37ed2d3ad64ca323c90a639b96a74702b9e3bc8f8ab3457de6252a0df6
6
+ metadata.gz: 5d65ce412084256c66f6061c32301f4d48772aafd28b438049877191bb93d72592cc13b9727c46d445be4d7cb8d41fb1db2163ba22c1d03d3739fd0a64907d8f
7
+ data.tar.gz: b8ebe36c4cbff4e667b38dad208c305035bfc18623b68bace90ff8753f0a6aa7fb203fcec0332a959b155166c9a646d3cee455bb9601cf26b2abeee9d85f7d07
data/README.md CHANGED
@@ -7,7 +7,7 @@ You could download pdftk at http://www.accesspdf.com/pdftk/
7
7
  Nguyên is a fork of Jens Krämer's pdf-forms with addition of filling forms with XFDF feature.
8
8
 
9
9
  [![Build Status](https://secure.travis-ci.org/ruby-journal/nguyen.png)](http://travis-ci.org/ruby-journal/nguyen)
10
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ruby-journal/nguyen)
10
+ [![Code Climate](https://codeclimate.com/github/ruby-journal/nguyen/badges/gpa.svg)](https://codeclimate.com/github/ruby-journal/nguyen)
11
11
 
12
12
  ## EXAMPLE:
13
13
 
@@ -49,6 +49,14 @@ pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', fdf)
49
49
  # with xfdf
50
50
  xfdf = Nguyen::Xfdf.new(foo: 'bar')
51
51
  pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', xfdf)
52
+
53
+ # will work with xfdf or fdf xml string directly as well
54
+ xfdf_string = <<XML
55
+ <?xml version="1.0" encoding="UTF-8"?>
56
+ <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><fields><field name="foo"><value>bar</value></field></fields></xfdf>
57
+ XML
58
+ # or xfdf_string = Nguyen::Xfdf.new(foo: 'bar').to_xfdf
59
+ pdftk.fill_form('/path/to/form', 'myform.pdf', xfdf_string)
52
60
  ```
53
61
 
54
62
  ## INSTALL:
@@ -37,7 +37,7 @@ module Nguyen
37
37
 
38
38
  # write fdf content to path
39
39
  def save_to(path)
40
- (File.open(path, 'w') << to_fdf).close
40
+ File.write(path, to_fdf)
41
41
  end
42
42
 
43
43
  protected
@@ -86,4 +86,4 @@ EOFOOTER
86
86
  end
87
87
 
88
88
  end
89
- end
89
+ end
@@ -14,11 +14,11 @@ module Nguyen
14
14
  @options = options
15
15
  end
16
16
 
17
- # pdftk.fill_form '/path/to/form.pdf', '/path/to/destination.pdf', xfdf_or_fdf_object
18
- def fill_form(template, destination, form_data_format)
17
+ # pdftk.fill_form '/path/to/form.pdf', '/path/to/destination.pdf', xfdf_or_fdf_object or xfdf_or_fdf_string
18
+ def fill_form(template, destination, form_data)
19
19
  tmp = Tempfile.new('pdf_forms-fdf')
20
20
  tmp.close
21
- form_data_format.save_to tmp.path
21
+ form_data.respond_to?(:save_to) ? form_data.save_to(tmp.path) : File.write(tmp.path, form_data)
22
22
  command = pdftk_command %Q("#{template}"), 'fill_form', %Q("#{tmp.path}"), 'output', destination, add_options(tmp.path)
23
23
  output = %x{#{command}}
24
24
  unless File.readable?(destination) && File.size(destination) > 0
@@ -1,3 +1,3 @@
1
1
  module Nguyen
2
- VERSION = '1.0.2'
3
- end
2
+ VERSION = '1.0.3'
3
+ end
@@ -37,8 +37,8 @@ module Nguyen
37
37
 
38
38
  # write fdf content to path
39
39
  def save_to(path)
40
- (File.open(path, 'w') << to_xfdf).close
40
+ File.write(path, to_xfdf)
41
41
  end
42
42
 
43
43
  end
44
- end
44
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nguyen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trung Lê
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-24 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '1.10'
20
20
  type: :runtime
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.5'
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
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'
27
41
  description: Forms for Nguyên is Ruby library that could merge PDF fields by XFDF/FDF
28
42
  via pdftk.
29
43
  email: trung.le@ruby-journal.com
@@ -52,16 +66,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - ">="
54
68
  - !ruby/object:Gem::Version
55
- version: 1.9.3
69
+ version: 2.5.0
56
70
  required_rubygems_version: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - ">="
59
73
  - !ruby/object:Gem::Version
60
- version: 1.8.25
74
+ version: '0'
61
75
  requirements:
62
76
  - pdtk 1.44.1 or newer
63
- rubyforge_project:
64
- rubygems_version: 2.2.2
77
+ rubygems_version: 3.0.3
65
78
  signing_key:
66
79
  specification_version: 4
67
80
  summary: Fill out PDF forms by XFDF/FDF via pdftk.