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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a0b223ed26fc417da43231d1b0b00401f5e7678d
4
- data.tar.gz: ae5d7419f111d646bfdf29ecb247937daf7b249b
2
+ SHA256:
3
+ metadata.gz: abb194eae400dfa894bf8fee673189d33acec4c8f6753e9cf19e068642186537
4
+ data.tar.gz: 434195007bade47b2485b379764d1ed26d4dbfb262d7165231938dee5d7f8f0a
5
5
  SHA512:
6
- metadata.gz: 6df33c335ebcb630c902b4a3430ee085c757995cd3627bd31d345a5eb493b3d0f2ad090402f2fc4cd359c8055ab6fd931bc815c1ce35830d379c9f5231df5533
7
- data.tar.gz: a7a3825d317e1599ec4262554eef27aa4f7b08b22c8e5db5a1405b52c474b6e37d9751f330e97b62193ec03194b942090142109871fcf9a430a0948d701155dd
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
@@ -1,5 +1,5 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 2.1.5
4
- - 2.0.0
5
- - 1.9.3
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
- 0.1.0 (November 23rd, 2014)
2
- ===========================
3
- - First working version
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
- [![Code Climate](https://codeclimate.com/github/interconn-isp/bollettino/badges/gpa.svg)](https://codeclimate.com/github/interconn-isp/bollettino)
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
- # coding: utf-8
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.7'
22
- spec.add_development_dependency 'rake', '~> 10.3'
23
- spec.add_development_dependency 'rspec', '~> 3.1'
24
- spec.add_development_dependency 'mocha', '~> 1.1'
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/models/address'
7
- require 'bollettino/models/payee'
8
- require 'bollettino/models/payer'
9
- require 'bollettino/models/payment_order'
10
- require 'bollettino/models/slip'
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/renderers/address_renderer'
15
- require 'bollettino/renderers/payer_renderer'
16
- require 'bollettino/renderers/payee_renderer'
17
- require 'bollettino/renderers/payment_order_renderer'
18
- require 'bollettino/renderers/slip_renderer'
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
 
@@ -1,25 +1,29 @@
1
- # Generator
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
- # Initializes the generator.
3
+ module Bollettino
4
+ # Generator
10
5
  #
11
- # @param options [Hash]
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
- # @param slip [Bollettino::Slip]
19
- # @param path [String]
20
- def generate!(slip, path)
21
- image = MiniMagick::Image.open(File.expand_path('../../../assets/slip.png', __FILE__))
22
- Bollettino::Renderer::SlipRenderer.render(image, slip)
23
- image.write path
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,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bollettino
4
+ module Model
5
+ class Base
6
+ include Virtus.model
7
+ end
8
+ end
9
+ 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