bollettino 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +103 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +31 -3
- data/README.md +8 -8
- data/bollettino.gemspec +10 -7
- data/lib/bollettino.rb +15 -12
- data/lib/bollettino/generator.rb +24 -20
- data/lib/bollettino/model/address.rb +22 -0
- data/lib/bollettino/model/base.rb +9 -0
- data/lib/bollettino/model/payee.rb +21 -0
- data/lib/bollettino/model/payer.rb +20 -0
- data/lib/bollettino/model/payment_order.rb +24 -0
- data/lib/bollettino/model/slip.rb +25 -0
- data/lib/bollettino/renderer/address.rb +32 -0
- data/lib/bollettino/renderer/base.rb +46 -0
- data/lib/bollettino/renderer/errors.rb +14 -0
- data/lib/bollettino/renderer/payee.rb +34 -0
- data/lib/bollettino/renderer/payer.rb +28 -0
- data/lib/bollettino/renderer/payment_order.rb +45 -0
- data/lib/bollettino/renderer/slip.rb +29 -0
- data/lib/bollettino/version.rb +3 -1
- data/spec/integration/generation_spec.rb +8 -9
- data/spec/spec_helper.rb +9 -1
- data/spec/unit/bollettino/generator_spec.rb +8 -35
- data/spec/unit/bollettino/model/address_spec.rb +20 -0
- data/spec/unit/bollettino/model/payee_spec.rb +18 -0
- data/spec/unit/bollettino/model/payer_spec.rb +24 -0
- data/spec/unit/bollettino/model/payment_order_spec.rb +19 -0
- data/spec/unit/bollettino/model/slip_spec.rb +29 -0
- data/spec/unit/bollettino/renderer/address_spec.rb +28 -0
- data/spec/unit/bollettino/renderer/payee_spec.rb +39 -0
- data/spec/unit/bollettino/renderer/payer_spec.rb +41 -0
- data/spec/unit/bollettino/renderer/payment_order_spec.rb +40 -0
- data/spec/unit/bollettino/renderer/slip_spec.rb +54 -0
- metadata +81 -51
- data/lib/bollettino/models/address.rb +0 -18
- data/lib/bollettino/models/payee.rb +0 -17
- data/lib/bollettino/models/payer.rb +0 -16
- data/lib/bollettino/models/payment_order.rb +0 -20
- data/lib/bollettino/models/slip.rb +0 -21
- data/lib/bollettino/renderer.rb +0 -47
- data/lib/bollettino/renderers/address_renderer.rb +0 -24
- data/lib/bollettino/renderers/payee_renderer.rb +0 -26
- data/lib/bollettino/renderers/payer_renderer.rb +0 -20
- data/lib/bollettino/renderers/payment_order_renderer.rb +0 -37
- data/lib/bollettino/renderers/slip_renderer.rb +0 -21
- data/spec/unit/bollettino/models/address_spec.rb +0 -12
- data/spec/unit/bollettino/models/payee_spec.rb +0 -10
- data/spec/unit/bollettino/models/payer_spec.rb +0 -12
- data/spec/unit/bollettino/models/payment_order_spec.rb +0 -11
- data/spec/unit/bollettino/models/slip_spec.rb +0 -15
- data/spec/unit/bollettino/renderers/address_renderer_spec.rb +0 -23
- data/spec/unit/bollettino/renderers/payee_renderer_spec.rb +0 -37
- data/spec/unit/bollettino/renderers/payer_renderer_spec.rb +0 -27
- data/spec/unit/bollettino/renderers/payment_order_renderer_spec.rb +0 -39
- data/spec/unit/bollettino/renderers/slip_renderer_spec.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: abb194eae400dfa894bf8fee673189d33acec4c8f6753e9cf19e068642186537
|
4
|
+
data.tar.gz: 434195007bade47b2485b379764d1ed26d4dbfb262d7165231938dee5d7f8f0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3d26f0dd542d77e88ea33bdc71ec97ebf35698b5b14bf74afb9e59bc8bfb1fa9998e800fb605da8465162e528abdfa8102c83aaafdf17f5f5e884493a7ac9ff
|
7
|
+
data.tar.gz: e8f942c19f8d71b2a6bf38942849731fc0e786089a110445feac372df3d3eac0aa454d94f7877a2284f08829a354dcfb731b3cf0c83c44880d6637c714d5c1c5
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.3
|
5
|
+
Include:
|
6
|
+
- '**/Gemfile'
|
7
|
+
- '**/Rakefile'
|
8
|
+
Exclude:
|
9
|
+
- 'bin/*'
|
10
|
+
- 'db/**/*'
|
11
|
+
- 'vendor/bundle/**/*'
|
12
|
+
- 'spec/spec_helper.rb'
|
13
|
+
- 'spec/rails_helper.rb'
|
14
|
+
- 'spec/support/**/*'
|
15
|
+
- 'config/**/*'
|
16
|
+
- '**/Rakefile'
|
17
|
+
- '**/Gemfile'
|
18
|
+
|
19
|
+
RSpec/DescribeClass:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/requests/**/*'
|
22
|
+
- 'spec/integration/**/*'
|
23
|
+
|
24
|
+
Style/BlockDelimiters:
|
25
|
+
Exclude:
|
26
|
+
- 'spec/**/*'
|
27
|
+
|
28
|
+
Layout/AlignParameters:
|
29
|
+
EnforcedStyle: with_fixed_indentation
|
30
|
+
|
31
|
+
Layout/ClosingParenthesisIndentation:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/LineLength:
|
35
|
+
Max: 100
|
36
|
+
AllowURI: true
|
37
|
+
|
38
|
+
Layout/FirstParameterIndentation:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
Layout/MultilineMethodCallIndentation:
|
42
|
+
EnforcedStyle: indented
|
43
|
+
|
44
|
+
Layout/IndentArray:
|
45
|
+
EnforcedStyle: consistent
|
46
|
+
|
47
|
+
Layout/IndentHash:
|
48
|
+
EnforcedStyle: consistent
|
49
|
+
|
50
|
+
Style/SignalException:
|
51
|
+
EnforcedStyle: semantic
|
52
|
+
|
53
|
+
Style/BracesAroundHashParameters:
|
54
|
+
EnforcedStyle: context_dependent
|
55
|
+
|
56
|
+
Lint/EndAlignment:
|
57
|
+
EnforcedStyleAlignWith: variable
|
58
|
+
AutoCorrect: true
|
59
|
+
|
60
|
+
Style/AndOr:
|
61
|
+
EnforcedStyle: conditionals
|
62
|
+
|
63
|
+
Style/MultilineBlockChain:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
RSpec/NamedSubject:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
RSpec/ExampleLength:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Layout/MultilineMethodCallBraceLayout:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Metrics/MethodLength:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Metrics/AbcSize:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Metrics/PerceivedComplexity:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Metrics/CyclomaticComplexity:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
Metrics/ClassLength:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Metrics/BlockLength:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
Style/Documentation:
|
94
|
+
Enabled: false
|
95
|
+
|
96
|
+
Naming/MethodName:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
Naming/AccessorMethodName:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
RSpec/MessageSpies:
|
103
|
+
EnforcedStyle: receive
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [1.0.1]
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Updated and linted codebase.
|
15
|
+
|
16
|
+
## [1.0.0]
|
17
|
+
|
18
|
+
First stable release.
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Fixed overlap issue with payer's name
|
23
|
+
|
24
|
+
## [0.1.0]
|
25
|
+
|
26
|
+
First public release.
|
27
|
+
|
28
|
+
[Unreleased]: https://github.com/pragmarb/pragma/compare/v1.0.1...HEAD
|
29
|
+
[1.0.1]: https://github.com/pragmarb/pragma/compare/v1.0.0...v1.0.1
|
30
|
+
[1.0.0]: https://github.com/pragmarb/pragma/compare/v0.1.0...v1.0.0
|
31
|
+
[0.1.0]: https://github.com/interconn-isp/bollettino/tree/v0.1.0
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Bollettino
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/bollettino.svg)](http://badge.fury.io/rb/bollettino)
|
4
3
|
[![Build Status](https://travis-ci.org/interconn-isp/bollettino.svg?branch=master)](https://travis-ci.org/interconn-isp/bollettino)
|
5
|
-
[![Dependency Status](https://gemnasium.com/interconn-isp/bollettino.svg)](https://gemnasium.com/interconn-isp/bollettino)
|
6
|
-
[![
|
4
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/interconn-isp/bollettino.svg)](https://gemnasium.com/github.com/interconn-isp/bollettino)
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/27f20f87ffab300c2530/maintainability)](https://codeclimate.com/github/interconn-isp/bollettino/maintainability)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/interconn-isp/bollettino/badge.svg?branch=master)](https://coveralls.io/github/interconn-isp/bollettino?branch=master)
|
7
7
|
|
8
8
|
Bollettino is a tool for generating Italian postal payment slips.
|
9
9
|
|
@@ -39,27 +39,27 @@ Or install it yourself as:
|
|
39
39
|
## Usage
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
payee = Bollettino::Payee.new(
|
42
|
+
payee = Bollettino::Model::Payee.new(
|
43
43
|
account_number: '0123456789',
|
44
44
|
name: 'Acme Inc.'
|
45
45
|
)
|
46
46
|
|
47
|
-
payer = Bollettino::Payer.new(
|
47
|
+
payer = Bollettino::Model::Payer.new(
|
48
48
|
name: 'John Doe',
|
49
|
-
address: Bollettino::Address.new(
|
49
|
+
address: Bollettino::Model::Address.new(
|
50
50
|
street: '3681 Foggy Moor',
|
51
51
|
zip: '19147-0834',
|
52
52
|
location: 'Grayson'
|
53
53
|
)
|
54
54
|
)
|
55
55
|
|
56
|
-
payment_order = Bollettino::PaymentOrder.new(
|
56
|
+
payment_order = Bollettino::Model::PaymentOrder.new(
|
57
57
|
numeric_amount: 54.31,
|
58
58
|
text_amount: 'Cinquantaquattro/31',
|
59
59
|
reason: 'Invoice INV-1391'
|
60
60
|
)
|
61
61
|
|
62
|
-
slip = Bollettino::Slip.new(
|
62
|
+
slip = Bollettino::Model::Slip.new(
|
63
63
|
payee: payee,
|
64
64
|
payer: payer,
|
65
65
|
payment_order: payment_order
|
data/bollettino.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path('../lib', __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require 'bollettino/version'
|
@@ -9,7 +11,6 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.authors = ['Alessandro Desantis']
|
10
12
|
spec.email = ['desa.alessandro@gmail.com']
|
11
13
|
spec.summary = 'Bollettino is a tool for generating Italian postal payment slips.'
|
12
|
-
spec.description = 'Bollettino is a tool for generating postal payment slips in the Italian format.'
|
13
14
|
spec.homepage = 'https://github.com/interconn-isp/bollettino'
|
14
15
|
spec.license = 'MIT'
|
15
16
|
|
@@ -18,11 +19,13 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
24
|
-
spec.add_development_dependency '
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
23
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.52'
|
26
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.22'
|
27
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
25
28
|
|
29
|
+
spec.add_runtime_dependency 'mini_magick', '~> 4.8'
|
26
30
|
spec.add_runtime_dependency 'virtus', '~> 1.0'
|
27
|
-
spec.add_runtime_dependency 'mini_magick', '~> 4.0'
|
28
31
|
end
|
data/lib/bollettino.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'virtus'
|
2
4
|
require 'mini_magick'
|
3
5
|
|
4
6
|
require 'bollettino/version'
|
5
7
|
|
6
|
-
require 'bollettino/
|
7
|
-
require 'bollettino/
|
8
|
-
require 'bollettino/
|
9
|
-
require 'bollettino/
|
10
|
-
require 'bollettino/
|
11
|
-
|
12
|
-
require 'bollettino/renderer'
|
8
|
+
require 'bollettino/model/base'
|
9
|
+
require 'bollettino/model/address'
|
10
|
+
require 'bollettino/model/payee'
|
11
|
+
require 'bollettino/model/payer'
|
12
|
+
require 'bollettino/model/payment_order'
|
13
|
+
require 'bollettino/model/slip'
|
13
14
|
|
14
|
-
require 'bollettino/
|
15
|
-
require 'bollettino/
|
16
|
-
require 'bollettino/
|
17
|
-
require 'bollettino/
|
18
|
-
require 'bollettino/
|
15
|
+
require 'bollettino/renderer/base'
|
16
|
+
require 'bollettino/renderer/errors'
|
17
|
+
require 'bollettino/renderer/address'
|
18
|
+
require 'bollettino/renderer/payer'
|
19
|
+
require 'bollettino/renderer/payee'
|
20
|
+
require 'bollettino/renderer/payment_order'
|
21
|
+
require 'bollettino/renderer/slip'
|
19
22
|
|
20
23
|
require 'bollettino/generator'
|
21
24
|
|
data/lib/bollettino/generator.rb
CHANGED
@@ -1,25 +1,29 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Generates an image from a slip.
|
4
|
-
#
|
5
|
-
# @author Alessandro Desantis <desa.alessandro@gmail.com>
|
6
|
-
class Bollettino::Generator
|
7
|
-
attr_reader :options
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
9
|
-
|
3
|
+
module Bollettino
|
4
|
+
# Generator
|
10
5
|
#
|
11
|
-
#
|
12
|
-
def initialize(options = {})
|
13
|
-
@options = options
|
14
|
-
end
|
15
|
-
|
16
|
-
# Generates the given slip.
|
6
|
+
# Generates an image from a slip.
|
17
7
|
#
|
18
|
-
# @
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
8
|
+
# @author Alessandro Desantis <desa.alessandro@gmail.com>
|
9
|
+
class Generator
|
10
|
+
attr_reader :options
|
11
|
+
|
12
|
+
# Initializes the generator.
|
13
|
+
#
|
14
|
+
# @param options [Hash]
|
15
|
+
def initialize(options = {})
|
16
|
+
@options = options
|
17
|
+
end
|
18
|
+
|
19
|
+
# Generates the given slip.
|
20
|
+
#
|
21
|
+
# @param slip [Bollettino::Slip]
|
22
|
+
# @param path [String]
|
23
|
+
def generate!(slip, path)
|
24
|
+
image = MiniMagick::Image.open(File.expand_path('../../../assets/slip.png', __FILE__))
|
25
|
+
Bollettino::Renderer::Slip.render(image, slip)
|
26
|
+
image.write path
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bollettino
|
4
|
+
module Model
|
5
|
+
# Address
|
6
|
+
#
|
7
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
8
|
+
class Address < Base
|
9
|
+
# !@attribute [rw] street
|
10
|
+
# @return [String] the address street
|
11
|
+
attribute :street, String
|
12
|
+
|
13
|
+
# !@attribute [rw] zip
|
14
|
+
# @return [String] the address ZIP
|
15
|
+
attribute :zip, String
|
16
|
+
|
17
|
+
# !@attribute [rw] location
|
18
|
+
# @return [String] the address location (city, state etc.)
|
19
|
+
attribute :location, String
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bollettino
|
4
|
+
module Model
|
5
|
+
# Payee
|
6
|
+
#
|
7
|
+
# The payee is the party requesting payment. A payee is associated with a
|
8
|
+
# postal account.
|
9
|
+
#
|
10
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
11
|
+
class Payee < Base
|
12
|
+
# !@attribute [rw] account_number
|
13
|
+
# @return [String] the postal account's number
|
14
|
+
attribute :account_number, String
|
15
|
+
|
16
|
+
# !@attribute [rw] name
|
17
|
+
# @return [String] the account holder's name
|
18
|
+
attribute :name, String
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bollettino
|
4
|
+
module Model
|
5
|
+
# Payer
|
6
|
+
#
|
7
|
+
# The payer is the party making the payment.
|
8
|
+
#
|
9
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
10
|
+
class Payer < Base
|
11
|
+
# !@attribute [rw] name
|
12
|
+
# @return [String] the payer's full name
|
13
|
+
attribute :name, String
|
14
|
+
|
15
|
+
# !@attribute [rw] address
|
16
|
+
# @return [Address] the payer's address
|
17
|
+
attribute :address, Address
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bollettino
|
4
|
+
module Model
|
5
|
+
# Payment order
|
6
|
+
#
|
7
|
+
# A payment order is a request for payment from the payee to the payer.
|
8
|
+
#
|
9
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
10
|
+
class PaymentOrder < Base
|
11
|
+
# !@attribute [rw] numeric amount
|
12
|
+
# @return [Float] the payment's amount
|
13
|
+
attribute :numeric_amount, Float
|
14
|
+
|
15
|
+
# !@attribute [rw] text amount
|
16
|
+
# @return [String] the payment's amount in letters
|
17
|
+
attribute :text_amount, String
|
18
|
+
|
19
|
+
# !@attribute [rw] reason
|
20
|
+
# @return [String] the reason for the payment
|
21
|
+
attribute :reason, String
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bollettino
|
4
|
+
module Model
|
5
|
+
# Slip
|
6
|
+
#
|
7
|
+
# A slip is just the composition of a Payee, a Payer and a PaymentOrder. It is
|
8
|
+
# passed to {#Bollettino::Generator} to create the final image.
|
9
|
+
#
|
10
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
11
|
+
class Slip < Base
|
12
|
+
# !@attribute [rw] payee
|
13
|
+
# @return [Payee] the payee
|
14
|
+
attribute :payee, Payee
|
15
|
+
|
16
|
+
# !@attribute [rw] payer
|
17
|
+
# @return [Payer] the payer
|
18
|
+
attribute :payer, Payer
|
19
|
+
|
20
|
+
# !@attribute [rw] payment order
|
21
|
+
# @return [PaymentOrder] the payment order
|
22
|
+
attribute :payment_order, PaymentOrder
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|