nguyen 0.0.3 → 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8848e52aa43e27b5937b88621379b911b6ea778
4
+ data.tar.gz: 1b4bb01597e09e17d007aabf17deeb6f0bd0e1de
5
+ SHA512:
6
+ metadata.gz: 884fe21dc1a3f0234dc3066bb9b8173e80b6aa18eb75309ad16924957b1a44414c27dca77421d9944318504e32286e3e0f83cbb612f8d4e91ff97b8c7a5869a9
7
+ data.tar.gz: 7b9a22a82386caa26b7a5dbfeb95168a7122e79c57ca815cc799db0cce110df297f05437fc3d093dd7a066d91ef14546f0d647e5f234f25ba4718aa1aa2fb146
@@ -0,0 +1,49 @@
1
+ ## Filing an issue
2
+
3
+ When filing an issue, please provide these details:
4
+
5
+ * A comprehensive list of steps to reproduce the issue.
6
+ * The version of Nguyen.
7
+ * Any relevant stack traces ("Full trace" preferred)
8
+
9
+ In 99% of cases, this information is enough to determine the cause and solution to the problem that is being described.
10
+
11
+ Any issue that is open for 14 days without actionable information or activity will be marked as "stalled" and then closed. Stalled issues can be re-opened if the information requested is provided.
12
+
13
+ ## Pull requests
14
+
15
+ We gladly accept pull requests to fix bugs and, in some circumstances, add new features to Spree.
16
+
17
+ Here's a quick guide:
18
+
19
+ 1. Fork the repo.
20
+
21
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
22
+ to know that you have a clean slate:
23
+
24
+ bundle install
25
+ bundle exec rake test
26
+
27
+ 3. Add a test for your change. Only refactoring and documentation changes
28
+ require no new tests. If you are adding functionality or fixing a bug, we need
29
+ a test!
30
+
31
+ 4. Make the test pass.
32
+
33
+ 5. Push to your fork and submit a pull request. If the changes will apply cleanly to the latest stable branches and master branch, you will only need to submit one pull request.
34
+
35
+ At this point you're waiting on us. We like to at least comment on, if not
36
+ accept, pull requests within three business days (and, typically, one business
37
+ day). We may suggest some changes or improvements or alternatives.
38
+
39
+ Syntax:
40
+
41
+ * Two spaces, no tabs.
42
+ * No trailing whitespace. Blank lines should not have any space.
43
+ * Prefer &&/|| over and/or.
44
+ * `MyClass.my_method(my_arg)` not `my_method( my_arg )` or my_method my_arg.
45
+ * `a = b` and not `a=b`.
46
+ * `a_method { |block| ... }` and not `a_method { | block | ... }`
47
+ * Follow the conventions you see used in the source already.
48
+
49
+ And in case we didn't emphasize it enough: we love tests!
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2012 Trung Lê
3
+ Copyright (c) 2013 Trung Lê
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -0,0 +1,68 @@
1
+ # Nguyên the PDF Field Merger
2
+
3
+ A very lightweight library that fill PDF forms using XFDF/FDF with pdftk
4
+
5
+ You could download pdftk at http://www.accesspdf.com/pdftk/
6
+
7
+ Nguyên is a fork of Jens Krämer's pdf-forms with addition of filling forms with XFDF feature.
8
+
9
+ [![Build Status](https://secure.travis-ci.org/joneslee85/nguyen.png)](http://travis-ci.org/joneslee85/nguyen)
10
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/joneslee85/nguyen)
11
+
12
+ ## EXAMPLE:
13
+
14
+ ### FDF creation
15
+
16
+ ```ruby
17
+ fdf = Nguyen::Fdf.new(key: 'value', other_key: 'other value')
18
+ # use to_fdf if you just want the FDF data, without writing it to a file
19
+ puts fdf.to_fdf
20
+ # write fdf file
21
+ fdf.save_to('path/to/file.fdf')
22
+ ```
23
+
24
+ ### XFDF creation
25
+
26
+ ```ruby
27
+ xfdf = Nguyen::Xfdf.new(key: 'value', other_key: 'other value')
28
+ # use to_xfdf if you just want the XFDF data, without writing it to a file
29
+ puts xfdf.to_xfdf
30
+ # write xfdf file
31
+ xfdf.save_to('path/to/file.xfdf')
32
+ ```
33
+
34
+ ### Query form fields and fill out PDF forms with pdftk
35
+
36
+ ```ruby
37
+ # adjust the pdftk path to suit your pdftk installation
38
+ pdftk = Nguyen::PdftkWrapper.new('/usr/local/bin/pdftk')
39
+
40
+ # find out the field names that are present in form.pdf
41
+ pdftk.get_field_names('path/to/form.pdf')
42
+
43
+ # take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
44
+
45
+ # with fdf
46
+ fdf = Nguyen::Fdf.new(foo: 'bar')
47
+ pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', fdf)
48
+
49
+ # with xfdf
50
+ xfdf = Nguyen::Xfdf.new(foo: 'bar')
51
+ pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', xfdf)
52
+ ```
53
+
54
+ ## INSTALL:
55
+
56
+ gem install nguyen
57
+
58
+ ## Source Code:
59
+
60
+ git clone http://github.com/joneslee85/nguyen.git
61
+
62
+ ## Contribution:
63
+
64
+ I greatly welcome contributions, please feel free to fork and submit pull request.
65
+
66
+ ## LICENSE
67
+
68
+ see [LICENSE](LICENSE)
@@ -1,4 +1,4 @@
1
- require 'nguyen/fdf'
2
- require 'nguyen/xfdf'
3
- require 'nguyen/pdf'
4
- require 'nguyen/pdftk_wrapper'
1
+ require_relative 'nguyen/fdf'
2
+ require_relative 'nguyen/xfdf'
3
+ require_relative 'nguyen/pdf'
4
+ require_relative 'nguyen/pdftk_wrapper'
@@ -11,9 +11,9 @@ module Nguyen
11
11
  def initialize(data = {}, options = {})
12
12
  @data = data
13
13
  @options = {
14
- :file => nil,
15
- :ufile => nil,
16
- :id => nil
14
+ file: nil,
15
+ ufile: nil,
16
+ id: nil
17
17
  }.merge(options)
18
18
  end
19
19
 
@@ -8,20 +8,20 @@ module Nguyen
8
8
  def initialize(fields = {}, options = {})
9
9
  @fields = fields
10
10
  @options = {
11
- :file => nil,
12
- :id => nil
11
+ file: nil,
12
+ id: nil
13
13
  }.merge(options)
14
14
  end
15
15
 
16
16
  # generate XFDF content
17
17
  def to_xfdf
18
- builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
18
+ builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
19
19
  xml.xfdf('xmlns' => 'http://ns.adobe.com/xfdf/', 'xml:space' => 'preserve') {
20
- xml.f(:href => options[:file]) if options[:file]
21
- xml.ids(:original => options[:id], :modified => options[:id]) if options[:id]
20
+ xml.f(href: options[:file]) if options[:file]
21
+ xml.ids(original: options[:id], modified: options[:id]) if options[:id]
22
22
  xml.fields {
23
23
  @fields.each do |field, value|
24
- xml.field(:name => field) {
24
+ xml.field(name: field) {
25
25
  if value.is_a? Array
26
26
  value.each { |item| xml.value(item.to_s) }
27
27
  else
@@ -32,7 +32,7 @@ module Nguyen
32
32
  }
33
33
  }
34
34
  end
35
- builder.to_xml
35
+ builder.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
36
36
  end
37
37
 
38
38
  # write fdf content to path
metadata CHANGED
@@ -1,32 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nguyen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Trung Lê
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-26 00:00:00.000000000 Z
11
+ date: 2013-02-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: nokogiri
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 1.5.5
19
+ version: 1.5.6
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 1.5.5
26
+ version: 1.5.6
30
27
  description: Forms for Nguyên is Ruby library that could merge PDF fields by XFDF/FDF
31
28
  via pdftk.
32
29
  email: joneslee85@gmail.com
@@ -40,30 +37,31 @@ files:
40
37
  - lib/nguyen/xfdf.rb
41
38
  - lib/nguyen.rb
42
39
  - LICENSE
43
- - README.rdoc
40
+ - CONTRIBUTING.md
41
+ - README.md
44
42
  homepage: http://github.com/joneslee85/nguyen
45
- licenses: []
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
46
  post_install_message:
47
47
  rdoc_options: []
48
48
  require_paths:
49
49
  - lib
50
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
- none: false
52
51
  requirements:
53
- - - ! '>='
52
+ - - '>='
54
53
  - !ruby/object:Gem::Version
55
- version: 1.8.7
54
+ version: 1.9.3
56
55
  required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
56
  requirements:
59
- - - ! '>='
57
+ - - '>='
60
58
  - !ruby/object:Gem::Version
61
- version: 1.3.6
59
+ version: 1.8.25
62
60
  requirements:
63
61
  - pdtk 1.44.1 or newer
64
62
  rubyforge_project:
65
- rubygems_version: 1.8.24
63
+ rubygems_version: 2.0.0
66
64
  signing_key:
67
- specification_version: 3
65
+ specification_version: 4
68
66
  summary: Fill out PDF forms by XFDF/FDF via pdftk.
69
67
  test_files: []
@@ -1,60 +0,0 @@
1
- = Nguyên the PDF Field Merger
2
-
3
- A very lightweight library that fill PDF forms using XFDF/FDF with pdftk
4
-
5
- You could download pdftk at http://www.accesspdf.com/pdftk/
6
-
7
- Nguyên is a fork of Jens Krämer's pdf-forms with addition of filling forms with XFDF feature.
8
-
9
- == EXAMPLE:
10
-
11
- === FDF creation
12
-
13
- fdf = Nguyen::Fdf.new(:key => 'value', :other_key => 'other value')
14
- # use to_fdf if you just want the FDF data, without writing it to a file
15
- puts fdf.to_fdf
16
- # write fdf file
17
- fdf.save_to('path/to/file.fdf')
18
-
19
-
20
- === XFDF creation
21
-
22
- xfdf = Nguyen::Xfdf.new(:key => 'value', :other_key => 'other value')
23
- # use to_xfdf if you just want the XFDF data, without writing it to a file
24
- puts xfdf.to_xfdf
25
- # write xfdf file
26
- xfdf.save_to('path/to/file.xfdf')
27
-
28
- === Query form fields and fill out PDF forms with pdftk
29
-
30
- # adjust the pdftk path to suit your pdftk installation
31
- pdftk = Nguyen::PdftkWrapper.new('/usr/local/bin/pdftk')
32
-
33
- # find out the field names that are present in form.pdf
34
- pdftk.get_field_names('path/to/form.pdf')
35
-
36
- # take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
37
-
38
- # with fdf
39
- fdf = Nguyen::Fdf(:foo => 'bar')
40
- pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', fdf)
41
-
42
- # with xfdf
43
- xfdf = Nguyen::Xfdf(:foo => 'bar')
44
- pdftk.fill_form('/path/to/form.pdf', 'myform.pdf', xfdf)
45
-
46
- == INSTALL:
47
-
48
- $ gem install nguyen
49
-
50
- == Source Code:
51
-
52
- $ git clone http://github.com/joneslee85/nguyen.git
53
-
54
- == Contribution:
55
-
56
- I greatly welcome contributions, please feel free to fork and submit pull request.
57
-
58
- == LICENSE
59
-
60
- see LICENSE