bollettino 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +2 -5
- data/LICENSE.txt +1 -1
- data/README.md +16 -0
- data/lib/bollettino/generator.rb +12 -0
- data/lib/bollettino/models/address.rb +11 -0
- data/lib/bollettino/models/payee.rb +11 -0
- data/lib/bollettino/models/payer.rb +10 -0
- data/lib/bollettino/models/payment_order.rb +13 -2
- data/lib/bollettino/models/slip.rb +14 -0
- data/lib/bollettino/renderer.rb +21 -0
- data/lib/bollettino/renderers/payer_renderer.rb +1 -1
- data/lib/bollettino/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0b223ed26fc417da43231d1b0b00401f5e7678d
|
4
|
+
data.tar.gz: ae5d7419f111d646bfdf29ecb247937daf7b249b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df33c335ebcb630c902b4a3430ee085c757995cd3627bd31d345a5eb493b3d0f2ad090402f2fc4cd359c8055ab6fd931bc815c1ce35830d379c9f5231df5533
|
7
|
+
data.tar.gz: a7a3825d317e1599ec4262554eef27aa4f7b08b22c8e5db5a1405b52c474b6e37d9751f330e97b62193ec03194b942090142109871fcf9a430a0948d701155dd
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Bollettino
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bollettino.svg)](http://badge.fury.io/rb/bollettino)
|
3
4
|
[![Build Status](https://travis-ci.org/interconn-isp/bollettino.svg?branch=master)](https://travis-ci.org/interconn-isp/bollettino)
|
4
5
|
[![Dependency Status](https://gemnasium.com/interconn-isp/bollettino.svg)](https://gemnasium.com/interconn-isp/bollettino)
|
5
6
|
[![Code Climate](https://codeclimate.com/github/interconn-isp/bollettino/badges/gpa.svg)](https://codeclimate.com/github/interconn-isp/bollettino)
|
@@ -75,3 +76,18 @@ generator.generate!(slip, 'slip.png')
|
|
75
76
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
77
|
4. Push to the branch (`git push origin my-new-feature`)
|
77
78
|
5. Create a new Pull Request
|
79
|
+
|
80
|
+
## Related projects
|
81
|
+
|
82
|
+
- For a command line interface, see [bollettino-cli](https://github.com/interconn-isp/bollettino-cli).
|
83
|
+
- For converting numbers into words, see [Abaco](https://github.com/interconn-isp/abaco).
|
84
|
+
|
85
|
+
## Maintainers
|
86
|
+
|
87
|
+
Bollettino is developed and maintained by [Alessandro Desantis](https://github.com/alessandro1997).
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
Bollettino is released under the MIT license.
|
92
|
+
|
93
|
+
[![InterConn](http://www.gravatar.com/avatar/b3f5893b97323096977545477e0066c5.jpg?s=100)](http://www.interconn.it)
|
data/lib/bollettino/generator.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
|
+
# Generator
|
2
|
+
#
|
3
|
+
# Generates an image from a slip.
|
4
|
+
#
|
5
|
+
# @author Alessandro Desantis <desa.alessandro@gmail.com>
|
1
6
|
class Bollettino::Generator
|
2
7
|
attr_reader :options
|
3
8
|
|
9
|
+
# Initializes the generator.
|
10
|
+
#
|
11
|
+
# @param options [Hash]
|
4
12
|
def initialize(options = {})
|
5
13
|
@options = options
|
6
14
|
end
|
7
15
|
|
16
|
+
# Generates the given slip.
|
17
|
+
#
|
18
|
+
# @param slip [Bollettino::Slip]
|
19
|
+
# @param path [String]
|
8
20
|
def generate!(slip, path)
|
9
21
|
image = MiniMagick::Image.open(File.expand_path('../../../assets/slip.png', __FILE__))
|
10
22
|
Bollettino::Renderer::SlipRenderer.render(image, slip)
|
@@ -1,7 +1,18 @@
|
|
1
|
+
# Address
|
2
|
+
#
|
3
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
1
4
|
class Bollettino::Address
|
2
5
|
include Virtus.model
|
3
6
|
|
7
|
+
# !@attribute [rw] street
|
8
|
+
# @return [String] the address street
|
4
9
|
attribute :street, String
|
10
|
+
|
11
|
+
# !@attribute [rw] zip
|
12
|
+
# @return [String] the address ZIP
|
5
13
|
attribute :zip, String
|
14
|
+
|
15
|
+
# !@attribute [rw] location
|
16
|
+
# @return [String] the address location (city, state etc.)
|
6
17
|
attribute :location, String
|
7
18
|
end
|
@@ -1,6 +1,17 @@
|
|
1
|
+
# Payee
|
2
|
+
#
|
3
|
+
# The payee is the party requesting payment. A payee is associated with a
|
4
|
+
# postal account.
|
5
|
+
#
|
6
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
1
7
|
class Bollettino::Payee
|
2
8
|
include Virtus.model
|
3
9
|
|
10
|
+
# !@attribute [rw] account_number
|
11
|
+
# @return [String] the postal account's number
|
4
12
|
attribute :account_number, String
|
13
|
+
|
14
|
+
# !@attribute [rw] name
|
15
|
+
# @return [String] the account holder's name
|
5
16
|
attribute :name, String
|
6
17
|
end
|
@@ -1,6 +1,16 @@
|
|
1
|
+
# Payer
|
2
|
+
#
|
3
|
+
# The payer is the party making the payment.
|
4
|
+
#
|
5
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
1
6
|
class Bollettino::Payer
|
2
7
|
include Virtus.model
|
3
8
|
|
9
|
+
# !@attribute [rw] name
|
10
|
+
# @return [String] the payer's full name
|
4
11
|
attribute :name, String
|
12
|
+
|
13
|
+
# !@attribute [rw] address
|
14
|
+
# @return [Bollettino::Address] the payer's address
|
5
15
|
attribute :address, Bollettino::Address
|
6
16
|
end
|
@@ -1,9 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Payment order
|
2
|
+
#
|
3
|
+
# A payment order is a request for payment from the payee to the payer.
|
4
|
+
#
|
5
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
3
6
|
class Bollettino::PaymentOrder
|
4
7
|
include Virtus.model
|
5
8
|
|
9
|
+
# !@attribute [rw] numeric amount
|
10
|
+
# @return [Float] the payment's amount
|
6
11
|
attribute :numeric_amount, Float
|
12
|
+
|
13
|
+
# !@attribute [rw] text amount
|
14
|
+
# @return [String] the payment's amount in letters
|
7
15
|
attribute :text_amount, String
|
16
|
+
|
17
|
+
# !@attribute [rw] reason
|
18
|
+
# @return [String] the reason for the payment
|
8
19
|
attribute :reason, String
|
9
20
|
end
|
@@ -1,7 +1,21 @@
|
|
1
|
+
# Slip
|
2
|
+
#
|
3
|
+
# A slip is just the composition of a Payee, a Payer and a PaymentOrder. It is
|
4
|
+
# passed to {#Bollettino::Generator} to create the final image.
|
5
|
+
#
|
6
|
+
# @author Alessandro Desatnis <desa.alessandro@gmail.com>
|
1
7
|
class Bollettino::Slip
|
2
8
|
include Virtus.model
|
3
9
|
|
10
|
+
# !@attribute [rw] payee
|
11
|
+
# @return [Bollettino::Payee] the payee
|
4
12
|
attribute :payee, Bollettino::Payee
|
13
|
+
|
14
|
+
# !@attribute [rw] payer
|
15
|
+
# @return [Bollettino::Payer] the payer
|
5
16
|
attribute :payer, Bollettino::Payer
|
17
|
+
|
18
|
+
# !@attribute [rw] payment order
|
19
|
+
# @return [Bollettino::PaymentOrder] the payment order
|
6
20
|
attribute :payment_order, Bollettino::PaymentOrder
|
7
21
|
end
|
data/lib/bollettino/renderer.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Base rebder
|
2
|
+
#
|
3
|
+
# @abstract Subclass and override {.render} to create a renderer
|
4
|
+
#
|
5
|
+
# @author Alessandro Desantis <desa.alessandro@gmail.com>
|
1
6
|
class Bollettino::Renderer
|
2
7
|
KERNING_NORMAL = 1
|
3
8
|
|
@@ -8,6 +13,16 @@ class Bollettino::Renderer
|
|
8
13
|
FONT_SIZE_NORMAL = 30
|
9
14
|
FONT_SIZE_SMALL = 25
|
10
15
|
|
16
|
+
# Renders the given model on the image.
|
17
|
+
#
|
18
|
+
# @param image [MiniMagick::Image]
|
19
|
+
# @param model
|
20
|
+
#
|
21
|
+
# @abstract This method must be overridden by the renderers
|
22
|
+
def self.render(image, model)
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
|
11
26
|
protected
|
12
27
|
|
13
28
|
def self.write_text(image, coords, text, kerning = KERNING_NORMAL, font_size = FONT_SIZE_NORMAL)
|
@@ -21,6 +36,12 @@ class Bollettino::Renderer
|
|
21
36
|
end
|
22
37
|
end
|
23
38
|
|
39
|
+
# Rendering error
|
40
|
+
#
|
41
|
+
# This error is usually raised when some data can't be renderered because
|
42
|
+
# it's malformed.
|
43
|
+
#
|
44
|
+
# @author Alessandro Desantis <desa.alessandro@gmail.com>
|
24
45
|
class RenderingError < StandardError
|
25
46
|
end
|
26
47
|
end
|
@@ -11,7 +11,7 @@ class Bollettino::Renderer::PayerRenderer < Bollettino::Renderer
|
|
11
11
|
write_text(image, [85, 315], payer.name[25..49])
|
12
12
|
|
13
13
|
write_text(image, [1508, 375], payer.name[0..22], KERNING_BOX_SMALLEST)
|
14
|
-
write_text(image, [1508, 330], payer.name[
|
14
|
+
write_text(image, [1508, 330], payer.name[23..45], KERNING_BOX_SMALLEST)
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.render_address(image, payer)
|
data/lib/bollettino/version.rb
CHANGED
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:
|
4
|
+
version: 1.0.0
|
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-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|