bollettino 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +103 -0
  3. data/.travis.yml +3 -3
  4. data/CHANGELOG.md +31 -3
  5. data/README.md +8 -8
  6. data/bollettino.gemspec +10 -7
  7. data/lib/bollettino.rb +15 -12
  8. data/lib/bollettino/generator.rb +24 -20
  9. data/lib/bollettino/model/address.rb +22 -0
  10. data/lib/bollettino/model/base.rb +9 -0
  11. data/lib/bollettino/model/payee.rb +21 -0
  12. data/lib/bollettino/model/payer.rb +20 -0
  13. data/lib/bollettino/model/payment_order.rb +24 -0
  14. data/lib/bollettino/model/slip.rb +25 -0
  15. data/lib/bollettino/renderer/address.rb +32 -0
  16. data/lib/bollettino/renderer/base.rb +46 -0
  17. data/lib/bollettino/renderer/errors.rb +14 -0
  18. data/lib/bollettino/renderer/payee.rb +34 -0
  19. data/lib/bollettino/renderer/payer.rb +28 -0
  20. data/lib/bollettino/renderer/payment_order.rb +45 -0
  21. data/lib/bollettino/renderer/slip.rb +29 -0
  22. data/lib/bollettino/version.rb +3 -1
  23. data/spec/integration/generation_spec.rb +8 -9
  24. data/spec/spec_helper.rb +9 -1
  25. data/spec/unit/bollettino/generator_spec.rb +8 -35
  26. data/spec/unit/bollettino/model/address_spec.rb +20 -0
  27. data/spec/unit/bollettino/model/payee_spec.rb +18 -0
  28. data/spec/unit/bollettino/model/payer_spec.rb +24 -0
  29. data/spec/unit/bollettino/model/payment_order_spec.rb +19 -0
  30. data/spec/unit/bollettino/model/slip_spec.rb +29 -0
  31. data/spec/unit/bollettino/renderer/address_spec.rb +28 -0
  32. data/spec/unit/bollettino/renderer/payee_spec.rb +39 -0
  33. data/spec/unit/bollettino/renderer/payer_spec.rb +41 -0
  34. data/spec/unit/bollettino/renderer/payment_order_spec.rb +40 -0
  35. data/spec/unit/bollettino/renderer/slip_spec.rb +54 -0
  36. metadata +81 -51
  37. data/lib/bollettino/models/address.rb +0 -18
  38. data/lib/bollettino/models/payee.rb +0 -17
  39. data/lib/bollettino/models/payer.rb +0 -16
  40. data/lib/bollettino/models/payment_order.rb +0 -20
  41. data/lib/bollettino/models/slip.rb +0 -21
  42. data/lib/bollettino/renderer.rb +0 -47
  43. data/lib/bollettino/renderers/address_renderer.rb +0 -24
  44. data/lib/bollettino/renderers/payee_renderer.rb +0 -26
  45. data/lib/bollettino/renderers/payer_renderer.rb +0 -20
  46. data/lib/bollettino/renderers/payment_order_renderer.rb +0 -37
  47. data/lib/bollettino/renderers/slip_renderer.rb +0 -21
  48. data/spec/unit/bollettino/models/address_spec.rb +0 -12
  49. data/spec/unit/bollettino/models/payee_spec.rb +0 -10
  50. data/spec/unit/bollettino/models/payer_spec.rb +0 -12
  51. data/spec/unit/bollettino/models/payment_order_spec.rb +0 -11
  52. data/spec/unit/bollettino/models/slip_spec.rb +0 -15
  53. data/spec/unit/bollettino/renderers/address_renderer_spec.rb +0 -23
  54. data/spec/unit/bollettino/renderers/payee_renderer_spec.rb +0 -37
  55. data/spec/unit/bollettino/renderers/payer_renderer_spec.rb +0 -27
  56. data/spec/unit/bollettino/renderers/payment_order_renderer_spec.rb +0 -39
  57. data/spec/unit/bollettino/renderers/slip_renderer_spec.rb +0 -34
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Model
5
+ RSpec.describe Payee do
6
+ subject do
7
+ described_class.new(
8
+ numeric_amount: 54.31,
9
+ text_amount: 'Cinquantaquattro/31',
10
+ reason: 'Invoice INV-1391'
11
+ )
12
+ end
13
+
14
+ it 'is instantiated correctly' do
15
+ expect { subject }.not_to raise_error
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Model
5
+ RSpec.describe Slip do
6
+ subject do
7
+ described_class.new(
8
+ payee: payee,
9
+ payer: payer,
10
+ payment_order: payment_order
11
+ )
12
+ end
13
+
14
+ let(:payee) { instance_double('Bollettino::Model::Payee') }
15
+ let(:payer) { instance_double('Bollettino::Model::Payer') }
16
+ let(:payment_order) { instance_double('Bollettino::Model::PaymentOrder') }
17
+
18
+ before do
19
+ allow(payee).to receive(:to_hash).and_return({})
20
+ allow(payer).to receive(:to_hash).and_return({})
21
+ allow(payment_order).to receive(:to_hash).and_return({})
22
+ end
23
+
24
+ it 'is instantiated correctly' do
25
+ expect { subject }.not_to raise_error
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Renderer
5
+ RSpec.describe Address do
6
+ subject { described_class }
7
+
8
+ let(:address) { instance_double('Bollettino::Model::Address') }
9
+
10
+ before do
11
+ allow(address).to receive(:street).and_return('Via Fasulla, 123')
12
+ allow(address).to receive(:location).and_return('Roma')
13
+ allow(address).to receive(:zip).and_return('00100')
14
+ end
15
+
16
+ describe '.render' do
17
+ let(:image) { instance_double('MiniMagick::Image') }
18
+
19
+ it 'renders the address' do
20
+ expect(subject).to receive(:write_text)
21
+ .exactly(6).times
22
+
23
+ subject.render image, address
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Renderer
5
+ RSpec.describe Payee do
6
+ subject { described_class }
7
+
8
+ let(:payee) { instance_double('Bollettino::Model::Payee') }
9
+
10
+ before do
11
+ allow(payee).to receive(:account_number).and_return('0123456789')
12
+ allow(payee).to receive(:name).and_return('Acme Inc.')
13
+ end
14
+
15
+ describe '.render' do
16
+ let(:image) { instance_double('MiniMagick::Image') }
17
+
18
+ it 'renders the payee' do
19
+ expect(subject).to receive(:write_text)
20
+ .exactly(6).times
21
+
22
+ subject.render image, payee
23
+ end
24
+
25
+ context 'when account_number is longer than 10 characters' do
26
+ before do
27
+ allow(payee).to receive(:account_number).and_return('01234567891')
28
+ end
29
+
30
+ it 'raises an error' do
31
+ expect {
32
+ subject.render image, payee
33
+ }.to raise_error(RenderingError)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Renderer
5
+ RSpec.describe Payer do
6
+ subject { described_class }
7
+
8
+ let(:payer) { instance_double('Bollettino::Model::Payer') }
9
+ let(:address) { instance_double('Bollettino::Model::Address') }
10
+
11
+ before do
12
+ allow(payer).to receive(:name).and_return('Acme Inc.')
13
+ allow(payer).to receive(:address).and_return(address)
14
+ end
15
+
16
+ describe '.render' do
17
+ let(:image) { instance_double('ImageMagick::Image') }
18
+
19
+ before do
20
+ allow(Address).to receive(:render)
21
+ allow(subject).to receive(:write_text)
22
+ end
23
+
24
+ it 'renders the address' do
25
+ expect(Address).to receive(:render)
26
+ .with(image, payer.address)
27
+ .once
28
+
29
+ subject.render image, payer
30
+ end
31
+
32
+ it 'renders the payer' do
33
+ expect(subject).to receive(:write_text)
34
+ .exactly(4).times
35
+
36
+ subject.render image, payer
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Renderer
5
+ RSpec.describe PaymentOrder do
6
+ subject { described_class }
7
+
8
+ let(:payment_order) { instance_double('Bollettino::Model::PaymentOrder') }
9
+
10
+ before do
11
+ allow(payment_order).to receive(:text_amount).and_return('Millecentociquanta/25')
12
+ allow(payment_order).to receive(:numeric_amount).and_return(1150.25)
13
+ allow(payment_order).to receive(:reason).and_return('Invoice INV-1234')
14
+ end
15
+
16
+ describe '.render' do
17
+ let(:image) { instance_double('MiniMagick::Image') }
18
+
19
+ it 'renders the payment order' do
20
+ expect(subject).to receive(:write_text)
21
+ .exactly(8).times
22
+
23
+ subject.render image, payment_order
24
+ end
25
+
26
+ context 'when numeric_amount is longer than 7 digits' do
27
+ before do
28
+ allow(payment_order).to receive(:numeric_amount).and_return(123_456.78)
29
+ end
30
+
31
+ it 'raises an error' do
32
+ expect {
33
+ subject.render image, payment_order
34
+ }.to raise_error(RenderingError)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Renderer
5
+ RSpec.describe Slip do
6
+ subject { described_class }
7
+
8
+ let(:slip) { instance_double('Bollettino::Model::Slip') }
9
+ let(:payee) { instance_double('Bollettino::Model::Payee') }
10
+ let(:payer) { instance_double('Bollettino::Model::Payer') }
11
+ let(:payment_order) { instance_double('Bollettino::Model::PaymentOrder') }
12
+
13
+ before do
14
+ allow(slip).to receive(:payee).and_return(payee)
15
+ allow(slip).to receive(:payer).and_return(payer)
16
+ allow(slip).to receive(:payment_order).and_return(payment_order)
17
+ end
18
+
19
+ describe '.render' do
20
+ let(:image) { instance_double('MiniMagick::Image') }
21
+
22
+ before do
23
+ allow(Payee).to receive(:render)
24
+ allow(Payer).to receive(:render)
25
+ allow(PaymentOrder).to receive(:render)
26
+ end
27
+
28
+ it 'renders the payee' do
29
+ expect(Payee).to receive(:render)
30
+ .with(image, slip.payee)
31
+ .once
32
+
33
+ subject.render(image, slip)
34
+ end
35
+
36
+ it 'renders the payer' do
37
+ expect(Payer).to receive(:render)
38
+ .with(image, slip.payer)
39
+ .once
40
+
41
+ subject.render(image, slip)
42
+ end
43
+
44
+ it 'renders the payment order' do
45
+ expect(PaymentOrder).to receive(:render)
46
+ .with(image, slip.payment_order)
47
+ .once
48
+
49
+ subject.render(image, slip)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bollettino
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,86 +16,113 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.16'
20
20
  type: :development
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.7'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.3'
33
+ version: '12.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.3'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
47
+ version: '3.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.1'
54
+ version: '3.7'
55
55
  - !ruby/object:Gem::Dependency
56
- name: mocha
56
+ name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.1'
61
+ version: '0.52'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.1'
68
+ version: '0.52'
69
69
  - !ruby/object:Gem::Dependency
70
- name: virtus
70
+ name: rubocop-rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.0'
76
- type: :runtime
75
+ version: '1.22'
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.0'
82
+ version: '1.22'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.8'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: mini_magick
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '4.0'
103
+ version: '4.8'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '4.0'
97
- description: Bollettino is a tool for generating postal payment slips in the Italian
98
- format.
110
+ version: '4.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: virtus
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ description:
99
126
  email:
100
127
  - desa.alessandro@gmail.com
101
128
  executables: []
@@ -104,6 +131,7 @@ extra_rdoc_files: []
104
131
  files:
105
132
  - ".gitignore"
106
133
  - ".rspec"
134
+ - ".rubocop.yml"
107
135
  - ".travis.yml"
108
136
  - CHANGELOG.md
109
137
  - Gemfile
@@ -115,31 +143,33 @@ files:
115
143
  - example-slip.png
116
144
  - lib/bollettino.rb
117
145
  - lib/bollettino/generator.rb
118
- - lib/bollettino/models/address.rb
119
- - lib/bollettino/models/payee.rb
120
- - lib/bollettino/models/payer.rb
121
- - lib/bollettino/models/payment_order.rb
122
- - lib/bollettino/models/slip.rb
123
- - lib/bollettino/renderer.rb
124
- - lib/bollettino/renderers/address_renderer.rb
125
- - lib/bollettino/renderers/payee_renderer.rb
126
- - lib/bollettino/renderers/payer_renderer.rb
127
- - lib/bollettino/renderers/payment_order_renderer.rb
128
- - lib/bollettino/renderers/slip_renderer.rb
146
+ - lib/bollettino/model/address.rb
147
+ - lib/bollettino/model/base.rb
148
+ - lib/bollettino/model/payee.rb
149
+ - lib/bollettino/model/payer.rb
150
+ - lib/bollettino/model/payment_order.rb
151
+ - lib/bollettino/model/slip.rb
152
+ - lib/bollettino/renderer/address.rb
153
+ - lib/bollettino/renderer/base.rb
154
+ - lib/bollettino/renderer/errors.rb
155
+ - lib/bollettino/renderer/payee.rb
156
+ - lib/bollettino/renderer/payer.rb
157
+ - lib/bollettino/renderer/payment_order.rb
158
+ - lib/bollettino/renderer/slip.rb
129
159
  - lib/bollettino/version.rb
130
160
  - spec/integration/generation_spec.rb
131
161
  - spec/spec_helper.rb
132
162
  - spec/unit/bollettino/generator_spec.rb
133
- - spec/unit/bollettino/models/address_spec.rb
134
- - spec/unit/bollettino/models/payee_spec.rb
135
- - spec/unit/bollettino/models/payer_spec.rb
136
- - spec/unit/bollettino/models/payment_order_spec.rb
137
- - spec/unit/bollettino/models/slip_spec.rb
138
- - spec/unit/bollettino/renderers/address_renderer_spec.rb
139
- - spec/unit/bollettino/renderers/payee_renderer_spec.rb
140
- - spec/unit/bollettino/renderers/payer_renderer_spec.rb
141
- - spec/unit/bollettino/renderers/payment_order_renderer_spec.rb
142
- - spec/unit/bollettino/renderers/slip_renderer_spec.rb
163
+ - spec/unit/bollettino/model/address_spec.rb
164
+ - spec/unit/bollettino/model/payee_spec.rb
165
+ - spec/unit/bollettino/model/payer_spec.rb
166
+ - spec/unit/bollettino/model/payment_order_spec.rb
167
+ - spec/unit/bollettino/model/slip_spec.rb
168
+ - spec/unit/bollettino/renderer/address_spec.rb
169
+ - spec/unit/bollettino/renderer/payee_spec.rb
170
+ - spec/unit/bollettino/renderer/payer_spec.rb
171
+ - spec/unit/bollettino/renderer/payment_order_spec.rb
172
+ - spec/unit/bollettino/renderer/slip_spec.rb
143
173
  - tmp/.keep
144
174
  homepage: https://github.com/interconn-isp/bollettino
145
175
  licenses:
@@ -161,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
191
  version: '0'
162
192
  requirements: []
163
193
  rubyforge_project:
164
- rubygems_version: 2.4.3
194
+ rubygems_version: 2.7.4
165
195
  signing_key:
166
196
  specification_version: 4
167
197
  summary: Bollettino is a tool for generating Italian postal payment slips.
@@ -169,13 +199,13 @@ test_files:
169
199
  - spec/integration/generation_spec.rb
170
200
  - spec/spec_helper.rb
171
201
  - spec/unit/bollettino/generator_spec.rb
172
- - spec/unit/bollettino/models/address_spec.rb
173
- - spec/unit/bollettino/models/payee_spec.rb
174
- - spec/unit/bollettino/models/payer_spec.rb
175
- - spec/unit/bollettino/models/payment_order_spec.rb
176
- - spec/unit/bollettino/models/slip_spec.rb
177
- - spec/unit/bollettino/renderers/address_renderer_spec.rb
178
- - spec/unit/bollettino/renderers/payee_renderer_spec.rb
179
- - spec/unit/bollettino/renderers/payer_renderer_spec.rb
180
- - spec/unit/bollettino/renderers/payment_order_renderer_spec.rb
181
- - spec/unit/bollettino/renderers/slip_renderer_spec.rb
202
+ - spec/unit/bollettino/model/address_spec.rb
203
+ - spec/unit/bollettino/model/payee_spec.rb
204
+ - spec/unit/bollettino/model/payer_spec.rb
205
+ - spec/unit/bollettino/model/payment_order_spec.rb
206
+ - spec/unit/bollettino/model/slip_spec.rb
207
+ - spec/unit/bollettino/renderer/address_spec.rb
208
+ - spec/unit/bollettino/renderer/payee_spec.rb
209
+ - spec/unit/bollettino/renderer/payer_spec.rb
210
+ - spec/unit/bollettino/renderer/payment_order_spec.rb
211
+ - spec/unit/bollettino/renderer/slip_spec.rb