receipt 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 475fe0f88977bba0b77f4c6d88cb1d95353f3055
4
- data.tar.gz: 9f16ca03828333ce2a1b9bcbda747afb3b331227
3
+ metadata.gz: 12ab362391263b8e6f05606d23904ed34eb7290a
4
+ data.tar.gz: 8aa70f5a8e051218778bc15f9a71b32dabf7d199
5
5
  SHA512:
6
- metadata.gz: 9158b1f8c986f5959fe5afc1f70ed9ac51fb35d50ae8d251b7bc84abaf1083937159ab3ad30bc93587e6201c8b4ec0a8676b5648ff1aaed7226787010af3ec82
7
- data.tar.gz: 367300f007de21384c5e7628df902facf5383e351c914da8dc38c49571be39233cc773d20cdb2ec0bf43bf7cb459b44549d2fe328ecea8046440ebd194eb7d13
6
+ metadata.gz: f97259da7674521fcc66bf95cd1c8ec32fa47e9eea215620fb2a07b9ad7c4c571327c1ca241ecbbe54a2b17db0160162cac5294a7ff5fec458df1b6db7ea8fe3
7
+ data.tar.gz: 0042a4a7da729d65e5cfc0aac0d9166379b90b68dfa81165b7a7e59109c04e16f5cafa29341aadf579f4ac7fbd00907cc08a74151eb8c9e17858befd8de8991f
data/README.md CHANGED
@@ -38,6 +38,9 @@ receipt = Receipt::Pdf.new(
38
38
  locale: :en # or 'pt-BR'
39
39
  )
40
40
 
41
+ receipt.before_receipt_box { my_header_content_for(receipt) }
42
+ receipt.after_receipt_box { my_footer_content_for(receipt) }
43
+
41
44
  # generates file
42
45
  File.open(receipt.file)
43
46
 
@@ -1,11 +1,15 @@
1
1
  ---
2
2
  en:
3
- receipt: Receipt
4
- receipt_number: Number
5
- amount: Amount
6
- received_from: Received from
7
- the_amount_of: the amount of
8
- relating_to: relating to
3
+ receipt:
4
+ title: Receipt
5
+ number: Number
6
+ amount: Amount
7
+ received_from: Received from
8
+ the_amount_of: the amount of
9
+ relating_to: relating to
10
+ currency: $
11
+ errors:
12
+ required_param_not_found: required param not found
9
13
  date:
10
14
  abbr_day_names:
11
15
  - Sun
@@ -1,11 +1,15 @@
1
1
  ---
2
2
  pt-BR:
3
- receipt: Recibo
4
- receipt_number: Numero
5
- amount: Valor
6
- received_from: Recebi de
7
- the_amount_of: a quantia de
8
- relating_to: referente a
3
+ receipt:
4
+ title: Recibo
5
+ number: Número
6
+ amount: Valor
7
+ received_from: Recebi de
8
+ the_amount_of: a quantia de
9
+ relating_to: referente a
10
+ currency: R$
11
+ errors:
12
+ required_param_not_found: parâmetro obrigatório não encontrado
9
13
  date:
10
14
  abbr_day_names:
11
15
  - Dom
@@ -0,0 +1,180 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 1261
21
+ >>
22
+ stream
23
+ q
24
+ 66.0 486.0 500.0 250.0 re
25
+ S
26
+
27
+ BT
28
+ 272.65999999999997 701.64 Td
29
+ /F2.0 20 Tf
30
+ [<52454345495054>] TJ
31
+ ET
32
+
33
+
34
+ BT
35
+ 76 703.5840000000001 Td
36
+ /F1.0 12 Tf
37
+ [<4e756d626572> -30 <3a20>] TJ
38
+ ET
39
+
40
+
41
+ BT
42
+ 125.70400000000001 703.5840000000001 Td
43
+ /F2.0 12 Tf
44
+ [<31>] TJ
45
+ ET
46
+
47
+
48
+ BT
49
+ 467.94399999999996 704.3040000000001 Td
50
+ /F1.0 12 Tf
51
+ [<416d6f756e743a20>] TJ
52
+ ET
53
+
54
+
55
+ BT
56
+ 515.968 704.3040000000001 Td
57
+ /F2.0 12 Tf
58
+ [<24203130302e30>] TJ
59
+ ET
60
+
61
+ 76.0 688.64 m
62
+ 556.0 688.64 l
63
+ S
64
+
65
+ BT
66
+ 76 660.0240000000001 Td
67
+ /F1.0 12 Tf
68
+ [<526563656976> 25 <65642066726f6d20>] TJ
69
+ ET
70
+
71
+
72
+ BT
73
+ 156.388 660.0240000000001 Td
74
+ /F2.0 12 Tf
75
+ [<43687563> 20 <6b79204e6f72726973>] TJ
76
+ ET
77
+
78
+
79
+ BT
80
+ 238.168 660.0240000000001 Td
81
+ /F1.0 12 Tf
82
+ [<2074686520616d6f756e74206f6620>] TJ
83
+ ET
84
+
85
+
86
+ BT
87
+ 318.22 660.0240000000001 Td
88
+ /F2.0 12 Tf
89
+ [<24203130302e30>] TJ
90
+ ET
91
+
92
+
93
+ BT
94
+ 358.252 660.0240000000001 Td
95
+ /F1.0 12 Tf
96
+ [<2072656c6174696e6720746f20>] TJ
97
+ ET
98
+
99
+
100
+ BT
101
+ 417.616 660.0240000000001 Td
102
+ /F2.0 12 Tf
103
+ [<7472616e73616374696f6e2023313233>] TJ
104
+ ET
105
+
106
+
107
+ BT
108
+ 512.3199999999999 660.0240000000001 Td
109
+ /F1.0 12 Tf
110
+ [<2e>] TJ
111
+ ET
112
+
113
+ 76.0 566.0 m
114
+ 556.0 566.0 l
115
+ S
116
+
117
+ BT
118
+ 76 522.384 Td
119
+ /F1.0 12 Tf
120
+ [<53616f2050> 40 <61756c6f> 40 <2c204d617263682031302c2032303135>] TJ
121
+ ET
122
+
123
+ 316.0 531.0 m
124
+ 556.0 531.0 l
125
+ S
126
+
127
+ BT
128
+ 387.01 512.384 Td
129
+ /F1.0 12 Tf
130
+ [<46> 30 <6572> -25 <6e616e646f20416c6d65696461>] TJ
131
+ ET
132
+
133
+ Q
134
+
135
+ endstream
136
+ endobj
137
+ 5 0 obj
138
+ << /Type /Page
139
+ /Parent 3 0 R
140
+ /MediaBox [0 0 612.0 792.0]
141
+ /Contents 4 0 R
142
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
143
+ /Font << /F2.0 6 0 R
144
+ /F1.0 7 0 R
145
+ >>
146
+ >>
147
+ >>
148
+ endobj
149
+ 6 0 obj
150
+ << /Type /Font
151
+ /Subtype /Type1
152
+ /BaseFont /Helvetica-Bold
153
+ /Encoding /WinAnsiEncoding
154
+ >>
155
+ endobj
156
+ 7 0 obj
157
+ << /Type /Font
158
+ /Subtype /Type1
159
+ /BaseFont /Helvetica
160
+ /Encoding /WinAnsiEncoding
161
+ >>
162
+ endobj
163
+ xref
164
+ 0 8
165
+ 0000000000 65535 f
166
+ 0000000015 00000 n
167
+ 0000000109 00000 n
168
+ 0000000158 00000 n
169
+ 0000000215 00000 n
170
+ 0000001528 00000 n
171
+ 0000001718 00000 n
172
+ 0000001820 00000 n
173
+ trailer
174
+ << /Size 8
175
+ /Root 2 0 R
176
+ /Info 1 0 R
177
+ >>
178
+ startxref
179
+ 1917
180
+ %%EOF
@@ -0,0 +1,180 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 1237
21
+ >>
22
+ stream
23
+ q
24
+ 66.0 486.0 500.0 250.0 re
25
+ S
26
+
27
+ BT
28
+ 277.11 701.64 Td
29
+ /F2.0 20 Tf
30
+ [<52454349424f>] TJ
31
+ ET
32
+
33
+
34
+ BT
35
+ 76 703.5840000000001 Td
36
+ /F1.0 12 Tf
37
+ [<4efa6d65726f3a20>] TJ
38
+ ET
39
+
40
+
41
+ BT
42
+ 125.344 703.5840000000001 Td
43
+ /F2.0 12 Tf
44
+ [<31>] TJ
45
+ ET
46
+
47
+
48
+ BT
49
+ 481.76800000000003 704.3040000000001 Td
50
+ /F1.0 12 Tf
51
+ [<56> 70 <616c6f72> -30 <3a20>] TJ
52
+ ET
53
+
54
+
55
+ BT
56
+ 515.9680000000001 704.3040000000001 Td
57
+ /F2.0 12 Tf
58
+ [<24203130302e30>] TJ
59
+ ET
60
+
61
+ 76.0 688.64 m
62
+ 556.0 688.64 l
63
+ S
64
+
65
+ BT
66
+ 76 660.0240000000001 Td
67
+ /F1.0 12 Tf
68
+ [<52656365626920646520>] TJ
69
+ ET
70
+
71
+
72
+ BT
73
+ 133.36 660.0240000000001 Td
74
+ /F2.0 12 Tf
75
+ [<43687563> 20 <6b79204e6f72726973>] TJ
76
+ ET
77
+
78
+
79
+ BT
80
+ 215.14 660.0240000000001 Td
81
+ /F1.0 12 Tf
82
+ [<2061207175616e74696120646520>] TJ
83
+ ET
84
+
85
+
86
+ BT
87
+ 287.86 660.0240000000001 Td
88
+ /F2.0 12 Tf
89
+ [<24203130302e30>] TJ
90
+ ET
91
+
92
+
93
+ BT
94
+ 327.892 660.0240000000001 Td
95
+ /F1.0 12 Tf
96
+ [<20726566> 30 <6572656e7465206120>] TJ
97
+ ET
98
+
99
+
100
+ BT
101
+ 392.236 660.0240000000001 Td
102
+ /F2.0 12 Tf
103
+ [<7472616e73616374696f6e2023313233>] TJ
104
+ ET
105
+
106
+
107
+ BT
108
+ 486.94 660.0240000000001 Td
109
+ /F1.0 12 Tf
110
+ [<2e>] TJ
111
+ ET
112
+
113
+ 76.0 566.0 m
114
+ 556.0 566.0 l
115
+ S
116
+
117
+ BT
118
+ 76 522.384 Td
119
+ /F1.0 12 Tf
120
+ [<53616f2050> 40 <61756c6f> 40 <2c203130206465204d6172e76f2064652032303135>] TJ
121
+ ET
122
+
123
+ 316.0 531.0 m
124
+ 556.0 531.0 l
125
+ S
126
+
127
+ BT
128
+ 387.01 512.384 Td
129
+ /F1.0 12 Tf
130
+ [<46> 30 <6572> -25 <6e616e646f20416c6d65696461>] TJ
131
+ ET
132
+
133
+ Q
134
+
135
+ endstream
136
+ endobj
137
+ 5 0 obj
138
+ << /Type /Page
139
+ /Parent 3 0 R
140
+ /MediaBox [0 0 612.0 792.0]
141
+ /Contents 4 0 R
142
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
143
+ /Font << /F2.0 6 0 R
144
+ /F1.0 7 0 R
145
+ >>
146
+ >>
147
+ >>
148
+ endobj
149
+ 6 0 obj
150
+ << /Type /Font
151
+ /Subtype /Type1
152
+ /BaseFont /Helvetica-Bold
153
+ /Encoding /WinAnsiEncoding
154
+ >>
155
+ endobj
156
+ 7 0 obj
157
+ << /Type /Font
158
+ /Subtype /Type1
159
+ /BaseFont /Helvetica
160
+ /Encoding /WinAnsiEncoding
161
+ >>
162
+ endobj
163
+ xref
164
+ 0 8
165
+ 0000000000 65535 f
166
+ 0000000015 00000 n
167
+ 0000000109 00000 n
168
+ 0000000158 00000 n
169
+ 0000000215 00000 n
170
+ 0000001504 00000 n
171
+ 0000001694 00000 n
172
+ 0000001796 00000 n
173
+ trailer
174
+ << /Size 8
175
+ /Root 2 0 R
176
+ /Info 1 0 R
177
+ >>
178
+ startxref
179
+ 1893
180
+ %%EOF
@@ -18,7 +18,6 @@ module Receipt
18
18
  :receiver,
19
19
  :amount,
20
20
  :date,
21
- :currency,
22
21
  :description,
23
22
  :logo,
24
23
  :location,
@@ -66,7 +65,9 @@ module Receipt
66
65
  :receiver,
67
66
  :description
68
67
  ].each do |p|
69
- @errors[p] = 'required param not found' if params.send(p).to_s.empty?
68
+ if params.send(p).to_s.empty?
69
+ @errors[p] = t('receipt.errors.required_param_not_found')
70
+ end
70
71
  end
71
72
 
72
73
  @errors.size == 0
@@ -80,6 +81,9 @@ module Receipt
80
81
  'application/pdf'
81
82
  end
82
83
 
84
+ def currency
85
+ params.currency || t('receipt.currency')
86
+ end
83
87
  private
84
88
 
85
89
  def generate
@@ -96,13 +100,13 @@ module Receipt
96
100
 
97
101
  def header
98
102
  pad(10) do
99
- text(t(:receipt).upcase, align: :center, style: :bold, size: 20)
103
+ text(t('receipt.title').upcase, align: :center, style: :bold, size: 20)
100
104
 
101
105
  move_up 20
102
- text("#{t(:receipt_number)}: <b>#{id}</b>", inline_format: true)
106
+ text("#{t('receipt.number')}: <b>#{id}</b>", inline_format: true)
103
107
 
104
108
  move_up 15
105
- text("#{t(:amount)}: <b>#{formated_amount}</b>",
109
+ text("#{t('receipt.amount')}: <b>#{formated_amount}</b>",
106
110
  inline_format: true, align: :right)
107
111
  pad(10) { stroke_horizontal_rule }
108
112
  end
@@ -111,9 +115,9 @@ module Receipt
111
115
  def body
112
116
  text(
113
117
  [
114
- "#{t(:received_from)} <b>#{payer}</b>",
115
- "#{t(:the_amount_of)} <b>#{formated_amount}</b>",
116
- "#{t(:relating_to)} <b>#{description}</b>."
118
+ "#{t('receipt.received_from')} <b>#{payer}</b>",
119
+ "#{t('receipt.the_amount_of')} <b>#{formated_amount}</b>",
120
+ "#{t('receipt.relating_to')} <b>#{description}</b>."
117
121
  ].join(' '),
118
122
  inline_format: true
119
123
  )
@@ -190,7 +194,8 @@ module Receipt
190
194
  end
191
195
 
192
196
  def load_translations
193
- I18n.load_path += Dir[File.expand_path('config/locale/*.yml')]
197
+ locales = Dir[File.expand_path('../../../config/locale/*.yml', __FILE__)]
198
+ I18n.load_path += locales
194
199
  I18n.backend.load_translations
195
200
  end
196
201
 
@@ -205,7 +210,7 @@ module Receipt
205
210
  def tempfilepath
206
211
  @tempfilepath ||= File.join(
207
212
  Dir.tmpdir,
208
- Dir::Tmpname.make_tmpname("#{t(:receipt)}", "#{id}.pdf")
213
+ Dir::Tmpname.make_tmpname("#{t('receipt.title')}", "#{id}.pdf")
209
214
  )
210
215
  end
211
216
  end
@@ -1,3 +1,3 @@
1
1
  module Receipt
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: receipt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Almeida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -118,7 +118,6 @@ files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
- - CODE_OF_CONDUCT.md
122
121
  - Gemfile
123
122
  - LICENSE.txt
124
123
  - README.md
@@ -127,6 +126,8 @@ files:
127
126
  - bin/setup
128
127
  - config/locale/en.yml
129
128
  - config/locale/pt-BR.yml
129
+ - example/receipt_en.pdf
130
+ - example/recibo_pt_br.pdf
130
131
  - lib/receipt.rb
131
132
  - lib/receipt/pdf.rb
132
133
  - lib/receipt/version.rb
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)