check_writer 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,28 +2,28 @@
2
2
 
3
3
  A ruby gem to help generate checks in PDF format.
4
4
 
5
- It generates PDF checks that look something
5
+ It generates PDF checks that look something
6
6
  like this[https://github.com/rylwin/check_writer/raw/master/spec/assets/test-0.12.0.pdf].
7
- Print that PDF on check stock and you've got yourself a real check.
7
+ Print that PDF on check stock using magnetic ink and you've got yourself a real check.
8
8
 
9
9
  Note: This project is being written/maintained using Ruby 1.9.3.
10
10
  Other versions of Ruby have not been tested.
11
11
 
12
12
  == Project Status
13
13
 
14
- A version of this code has been used in a production application for a couple of years
15
- and we are finally getting around to extracting the check writing code. As we go through this
14
+ A version of this code has been used in a production application for a couple of years
15
+ and we are finally getting around to extracting the check writing code. As we go through this
16
16
  process, there may be significant changes to the API. You've been warned.
17
17
 
18
- Currently the only check stock format that is supported is the 1/3 bottom check.
19
- You can get some check stock at
18
+ Currently the only check stock format that is supported is the 1/3 bottom check.
19
+ You can get some check stock at
20
20
  Amazon[http://www.amazon.com/gp/product/B002HIV1KQ/ref=as_li_qf_sp_asn_il_tl?ie=UTF8&tag=checkwriter-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B002HIV1KQ],
21
21
  amongst other places.
22
22
 
23
23
  == GnuMICR
24
24
 
25
- check_writer uses GnuMICR (http://www.sandeen.net/GnuMICR) to print the MICR numbers at the
26
- bottom of the check. Please read the notes on the GnuMICR site. We have not
25
+ check_writer uses GnuMICR (http://www.sandeen.net/GnuMICR) to print the MICR numbers at the
26
+ bottom of the check. Please read the notes on the GnuMICR site. We have not
27
27
  had any issues using this font (2+ years now), but that is no guarantee.
28
28
 
29
29
  == Example
@@ -47,12 +47,12 @@ had any issues using this font (2+ years now), but that is no guarantee.
47
47
 
48
48
  :amount => '1003.23',
49
49
  :memo => 'Memo: Void after 60 days'
50
- )
50
+ )
51
51
 
52
52
  check.to_pdf # returns PDF file data
53
53
 
54
54
  If you set the +with_stubs+ option to +true+ you'll get a bit of formatting
55
- and information displayed in the top and middle check stub.
55
+ and information displayed in the top and middle check stub.
56
56
  Here's an example[https://github.com/rylwin/check_writer/raw/master/spec/assets/with_stubs-0.12.0.pdf].
57
57
 
58
58
  It is also possible to include additional data in the stubs in the form of a table. If +with_stubs+ is true,
@@ -60,8 +60,8 @@ then passing a 2D array to +stub_table_data+ will generate a table within each s
60
60
  #table method, set +stub_table_options+ with a hash of options.
61
61
  Example here[https://github.com/rylwin/check_writer/raw/master/spec/assets/with_stub_table_data-0.12.0.pdf].
62
62
 
63
- Instead of just returning a PDF, you can access the Prawn PDF writer object
64
- (Prawn::Document), which you can use to further customize the check or even
63
+ Instead of just returning a PDF, you can access the Prawn PDF writer object
64
+ (Prawn::Document), which you can use to further customize the check or even
65
65
  include multiple checks on the same PDF:
66
66
 
67
67
  pdf = check1.to_prawn
@@ -74,6 +74,8 @@ include multiple checks on the same PDF:
74
74
  Signatures can be included on the checks by setting the +:signature_image_file+ option, which should
75
75
  reference a JPG or PNG image. The recommended dimensions for a signature image are 175px x 40px.
76
76
 
77
+ If you need a second signature line on the check, +:second_signature_line+ to true.
78
+
77
79
  == Tests
78
80
 
79
81
  check_writer uses the appraisal gem to facilitate testing of various versions of prawn. To run the tests using appraisal:
@@ -87,7 +89,7 @@ Note that if you need modify the Gemfile and need to re-bundle, you will also ha
87
89
  After appraisal installs its gemfiles, you can revert your Gemfile to as it was before.
88
90
 
89
91
  == Contributing to check_writer
90
-
92
+
91
93
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
92
94
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
93
95
  * Fork the project.
@@ -99,9 +101,8 @@ After appraisal installs its gemfiles, you can revert your Gemfile to as it was
99
101
  == Copyright
100
102
 
101
103
  Font: The GnuMICR font is distributed under GPL, but please note the additional comments from
102
- the font creator in the
104
+ the font creator in the
103
105
  GnuMICR README[https://github.com/rylwin/check_writer/tree/master/vendor/GnuMICR-0.30].
104
106
 
105
107
  Copyright (c) 2012 Ryan Winograd. See LICENSE.txt for
106
108
  further details.
107
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.3
data/check_writer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "check_writer"
8
- s.version = "0.4.1"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Winograd"]
12
- s.date = "2012-08-07"
12
+ s.date = "2012-12-12"
13
13
  s.description = "Ruby library for generating PDF checks that you can take to the bank"
14
14
  s.email = "ryan@thewinograds.com"
15
15
  s.extra_rdoc_files = [
@@ -43,6 +43,9 @@ Gem::Specification.new do |s|
43
43
  "spec/assets/two_in_one-0.12.0.pdf",
44
44
  "spec/assets/two_in_one-0.6.1.pdf",
45
45
  "spec/assets/two_in_one-0.6.3.pdf",
46
+ "spec/assets/with_second_signature_line-0.12.0.pdf",
47
+ "spec/assets/with_second_signature_line-0.6.1.pdf",
48
+ "spec/assets/with_second_signature_line-0.6.3.pdf",
46
49
  "spec/assets/with_signature_image-0.12.0.pdf",
47
50
  "spec/assets/with_signature_image-0.6.1.pdf",
48
51
  "spec/assets/with_signature_image-0.6.3.pdf",
@@ -7,11 +7,12 @@ module CheckWriter
7
7
 
8
8
  attr_accessor :number, :date,
9
9
  :payee_name, :payor_name,
10
- :payee_address, :payor_address,
10
+ :payee_address, :payor_address,
11
11
  :bank_name, :bank_address, :bank_fraction,
12
- :routing_number, :account_number,
12
+ :routing_number, :account_number,
13
13
  :amount, :memo,
14
14
  :with_stubs, :stub_table_data, :stub_table_options,
15
+ :second_signature_line,
15
16
  :signature_image_file
16
17
 
17
18
  def initialize(attributes={})
@@ -30,7 +31,7 @@ module CheckWriter
30
31
  to_prawn.render
31
32
  end
32
33
 
33
- # Renders the check and returns the Prawn::Document for
34
+ # Renders the check and returns the Prawn::Document for
34
35
  # further manipulation.
35
36
  #
36
37
  # To use an existing Prawn::Document, pass this in as the
@@ -58,7 +59,7 @@ module CheckWriter
58
59
  check_stub(false) # middle 1/3 stub
59
60
  end
60
61
 
61
- @pdf.bounding_box [@pdf.bounds.left,@pdf.bounds.top - extra_top_margin_height - box_height*2 - between_box_height*2],
62
+ @pdf.bounding_box [@pdf.bounds.left,@pdf.bounds.top - extra_top_margin_height - box_height*2 - between_box_height*2],
62
63
  :width => @pdf.bounds.right - @pdf.bounds.left, :height => check_box_height do
63
64
 
64
65
  @pdf.bounding_box [@pdf.bounds.left + inches(5.5), @pdf.bounds.top - inches(0.25)], :width => inches(2) do
@@ -142,7 +143,7 @@ module CheckWriter
142
143
  @pdf.text formatted_date
143
144
  end
144
145
  @pdf.bounding_box [@pdf.bounds.right - inches(1) - 4, @pdf.bounds.top - inches(1.25)], :width => inches(1) do
145
- @pdf.text formatted_amount, :align => :right
146
+ @pdf.text formatted_amount, :align => :right
146
147
  end
147
148
  @pdf.text_box "#{amount_in_words}#{" -"*72}", :at => [@pdf.bounds.left + 4, @pdf.bounds.top - inches(1.5)], :height => inches(0.2)
148
149
  @pdf.bounding_box [@pdf.bounds.right - inches(3.5), @pdf.bounds.top - inches(1.75)], :width => inches(3.5) do
@@ -168,6 +169,15 @@ module CheckWriter
168
169
 
169
170
  @pdf.image @signature_image_file, :at => sig_at if @signature_image_file
170
171
 
172
+ second_sig_box_at = box_at.dup
173
+ second_sig_box_at[1] += inches(0.6)
174
+ @pdf.bounding_box second_sig_box_at, width: inches(2.5) do
175
+ @pdf.horizontal_rule
176
+ @pdf.move_down 2
177
+ # TODO: better currency formatting
178
+ @pdf.text "TWO SIGNATURES REQUIRED", :size => 8, :align => :center
179
+ end if second_signature_line
180
+
171
181
  @pdf.bounding_box box_at, :width => inches(2.5) do
172
182
  @pdf.horizontal_rule
173
183
  @pdf.move_down 2
@@ -196,13 +206,13 @@ module CheckWriter
196
206
  unless stub_table_data.empty?
197
207
  width = @pdf.bounds.right - @pdf.bounds.left
198
208
 
199
- # Pass different default options to #table depending on version of
209
+ # Pass different default options to #table depending on version of
200
210
  # prawn being used
201
211
  if Gem.loaded_specs["prawn"].version <= Gem::Version.new('0.6.3')
202
212
  headers = stub_table_data.shift
203
213
 
204
214
  opts = stub_table_options.reverse_merge(
205
- :headers => headers,
215
+ :headers => headers,
206
216
  :border_style => :underline_header,
207
217
  :width => width
208
218
  )
@@ -212,7 +222,7 @@ module CheckWriter
212
222
  stub_table_data.insert(0, headers)
213
223
  else
214
224
  opts = stub_table_options.reverse_merge(
215
- :header => true,
225
+ :header => true,
216
226
  :width => width
217
227
  )
218
228
 
@@ -226,22 +236,22 @@ module CheckWriter
226
236
  @pdf.font MICR_FONT do
227
237
  @pdf.text "C#{number}C A#{routing_number}A #{account_number}C"
228
238
  end
229
- end
239
+ end
230
240
  end
231
241
 
232
242
  def box_height
233
243
  180 # 2.5in
234
244
  end
235
245
 
236
- def between_box_height
246
+ def between_box_height
237
247
  54 # 3/4in
238
248
  end
239
249
 
240
- def extra_top_margin_height
250
+ def extra_top_margin_height
241
251
  36 # 1/2in
242
252
  end
243
253
 
244
- def check_box_height
254
+ def check_box_height
245
255
  252 #3.5in
246
256
  end
247
257
  end
Binary file
Binary file
Binary file
data/spec/check_spec.rb CHANGED
@@ -57,7 +57,7 @@ describe "CheckWriter::Check" do
57
57
 
58
58
  it "generates pdf correctly" do
59
59
  data = @check.to_pdf
60
-
60
+
61
61
  # Use this line to re-write the PDF we test against
62
62
  # write_content_to_file('test', data)
63
63
 
@@ -99,6 +99,19 @@ describe "CheckWriter::Check" do
99
99
  end
100
100
  end
101
101
 
102
+ context "with second signature line" do
103
+ before(:each) do
104
+ @check.second_signature_line = true
105
+ @data = @check.to_pdf
106
+ end
107
+ it "generates a pdf with a second signature line" do
108
+ # Use this line to re-write the PDF we test against
109
+ write_content_to_file('with_second_signature_line', @data)
110
+
111
+ assert_data_matches_file_content('with_second_signature_line', @data)
112
+ end
113
+ end
114
+
102
115
  context "with signature image" do
103
116
  before(:each) do
104
117
  @check.signature_image_file = TEST_ASSETS + "/sample-signature.png"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &18598600 !ruby/object:Gem::Requirement
16
+ requirement: &4661240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *18598600
24
+ version_requirements: *4661240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: prawn
27
- requirement: &18597500 !ruby/object:Gem::Requirement
27
+ requirement: &4821120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *18597500
35
+ version_requirements: *4821120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: linguistics
38
- requirement: &18597020 !ruby/object:Gem::Requirement
38
+ requirement: &4840080 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *18597020
46
+ version_requirements: *4840080
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: appraisal
49
- requirement: &18596460 !ruby/object:Gem::Requirement
49
+ requirement: &5116060 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *18596460
57
+ version_requirements: *5116060
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &18595960 !ruby/object:Gem::Requirement
60
+ requirement: &5136480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *18595960
68
+ version_requirements: *5136480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &18595360 !ruby/object:Gem::Requirement
71
+ requirement: &5134100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.8.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *18595360
79
+ version_requirements: *5134100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: appraisal
82
- requirement: &18620140 !ruby/object:Gem::Requirement
82
+ requirement: &5132300 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *18620140
90
+ version_requirements: *5132300
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &18331280 !ruby/object:Gem::Requirement
93
+ requirement: &5130580 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 2.8.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *18331280
101
+ version_requirements: *5130580
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &18329860 !ruby/object:Gem::Requirement
104
+ requirement: &5267620 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '3.12'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *18329860
112
+ version_requirements: *5267620
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: bundler
115
- requirement: &18328760 !ruby/object:Gem::Requirement
115
+ requirement: &5265200 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: 1.1.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *18328760
123
+ version_requirements: *5265200
124
124
  description: Ruby library for generating PDF checks that you can take to the bank
125
125
  email: ryan@thewinograds.com
126
126
  executables: []
@@ -155,6 +155,9 @@ files:
155
155
  - spec/assets/two_in_one-0.12.0.pdf
156
156
  - spec/assets/two_in_one-0.6.1.pdf
157
157
  - spec/assets/two_in_one-0.6.3.pdf
158
+ - spec/assets/with_second_signature_line-0.12.0.pdf
159
+ - spec/assets/with_second_signature_line-0.6.1.pdf
160
+ - spec/assets/with_second_signature_line-0.6.3.pdf
158
161
  - spec/assets/with_signature_image-0.12.0.pdf
159
162
  - spec/assets/with_signature_image-0.6.1.pdf
160
163
  - spec/assets/with_signature_image-0.6.3.pdf
@@ -198,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
201
  version: '0'
199
202
  segments:
200
203
  - 0
201
- hash: 4032726058310001967
204
+ hash: -3966918035493978081
202
205
  required_rubygems_version: !ruby/object:Gem::Requirement
203
206
  none: false
204
207
  requirements: