br_boleto 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +13 -0
  5. data/LICENSE +1 -1
  6. data/README.markdown +22 -7
  7. data/br_boleto.gemspec +9 -7
  8. data/lib/br_boleto/active_model_base.rb +28 -0
  9. data/lib/br_boleto/boleto/base.rb +666 -633
  10. data/lib/br_boleto/boleto/caixa.rb +257 -0
  11. data/lib/br_boleto/boleto/sicoob.rb +6 -18
  12. data/lib/br_boleto/helper/format_value.rb +18 -0
  13. data/lib/br_boleto/remessa/base.rb +1 -22
  14. data/lib/br_boleto/remessa/cnab240/base.rb +12 -9
  15. data/lib/br_boleto/remessa/cnab240/caixa.rb +201 -0
  16. data/lib/br_boleto/remessa/cnab240/helper/header_arquivo.rb +2 -2
  17. data/lib/br_boleto/remessa/cnab240/helper/header_lote.rb +10 -1
  18. data/lib/br_boleto/remessa/cnab240/helper/segmento_p.rb +2 -2
  19. data/lib/br_boleto/remessa/cnab240/helper/segmento_q.rb +2 -2
  20. data/lib/br_boleto/remessa/cnab240/helper/trailer_arquivo.rb +7 -0
  21. data/lib/br_boleto/remessa/cnab240/sicoob.rb +6 -6
  22. data/lib/br_boleto/remessa/lote.rb +1 -21
  23. data/lib/br_boleto/remessa/pagamento.rb +22 -36
  24. data/lib/br_boleto/retorno/base.rb +31 -0
  25. data/lib/br_boleto/retorno/cnab240/base.rb +101 -0
  26. data/lib/br_boleto/retorno/cnab240/caixa.rb +30 -0
  27. data/lib/br_boleto/retorno/cnab240/sicoob.rb +35 -0
  28. data/lib/br_boleto/retorno/pagamento.rb +242 -0
  29. data/lib/br_boleto/version.rb +2 -2
  30. data/lib/br_boleto.rb +23 -11
  31. data/test/br_boleto/boleto/base_test.rb +6 -6
  32. data/test/br_boleto/boleto/caixa_test.rb +191 -0
  33. data/test/br_boleto/boleto/sicoob_test.rb +18 -11
  34. data/test/br_boleto/remessa/cnab240/base_test.rb +5 -5
  35. data/test/br_boleto/remessa/cnab240/caixa_test.rb +271 -0
  36. data/test/br_boleto/remessa/cnab240/helper/header_arquivo_test.rb +2 -2
  37. data/test/br_boleto/remessa/cnab240/helper/segmento_p_test.rb +1 -1
  38. data/test/br_boleto/remessa/cnab240/sicoob_test.rb +27 -27
  39. data/test/br_boleto/remessa/pagamento_test.rb +12 -2
  40. data/test/br_boleto/retorno/cnab240/base_test.rb +217 -0
  41. data/test/br_boleto/retorno/cnab240/caixa_test.rb +217 -0
  42. data/test/br_boleto/retorno/cnab240/sicoob_test.rb +217 -0
  43. data/test/br_boleto/retorno/pagamento_test.rb +179 -0
  44. data/test/factories/boleto/boleto_caixa.rb +25 -0
  45. data/test/factories/remessa/cnab240/caixa.rb +14 -0
  46. data/test/factories/remessa/pagamento.rb +1 -0
  47. data/test/factories/retorno/pagamento.rb +6 -0
  48. data/test/files/retorno/cnab240/caixa.ret +14 -0
  49. data/test/files/retorno/cnab240/padrao240.ret +14 -0
  50. metadata +51 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f4e67dfac4e97c20e5e07521b4fb1c8764ffb5e
4
- data.tar.gz: dbf32490aa85187d9976936ca035e6320df8b076
3
+ metadata.gz: 2962941333bce0a4a32fa0f19d3ad7fd32258cbb
4
+ data.tar.gz: f8cd4c4330311b2706ef44bfdcf6d2ed4094b5d4
5
5
  SHA512:
6
- metadata.gz: 04acbbcf7defda9c1aec808fb57f7f36a0a8a49404f204893df392ee1aee60dfeebff66cc344dbadcb2ae19bb0552e439b10df241e9264783924950654c91082
7
- data.tar.gz: 80c07a6bc6e21bdb60751ff6a9671822f00d8ca17db6fdcc29760f2633bcb12237f4de2a9c3edb1e0123c5755e5ab9fb619443538984cdafbe1791e8206f0bf1
6
+ metadata.gz: 5dc034b5393fceb1e351c935e131300aca0ef79e91049e5251d0a0f18095435a1b4ddf89d22445714e115c762d076f7ccc0ea6b7251aa047d38f784c27f5177b
7
+ data.tar.gz: bc45af6e51932b1d7e93deaa60d397f4dc9715f9b60569bfb3a74a4700c2f27ff32b8efbfb4da34f291fc641e27c11faebdff183d49c62701e4c09fadd8951b9
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ coverage/
2
+ .dropbox
3
+ **/*.subl*
4
+ **/*.~lock.*
5
+ dev_load_data.rb
data/Gemfile CHANGED
@@ -2,6 +2,10 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
+ group :development do
6
+ gem 'pry'
7
+ end
8
+
5
9
  group :test do
6
10
  # gem "mocha", :require => false
7
11
  gem "mocha", :require => false
data/Gemfile.lock CHANGED
@@ -5,6 +5,7 @@ PATH
5
5
  activemodel (~> 4.2)
6
6
  activesupport (~> 4.2)
7
7
  rake (>= 0.8.7)
8
+ unidecoder (>= 1.1.2)
8
9
 
9
10
  GEM
10
11
  remote: http://rubygems.org/
@@ -47,6 +48,7 @@ GEM
47
48
  ansi (1.5.0)
48
49
  arel (6.0.2)
49
50
  builder (3.2.2)
51
+ coderay (1.1.1)
50
52
  docile (1.1.5)
51
53
  erubis (2.7.0)
52
54
  factory_girl (4.5.0)
@@ -63,6 +65,7 @@ GEM
63
65
  mail (2.6.3)
64
66
  mime-types (>= 1.16, < 3)
65
67
  metaclass (0.0.4)
68
+ method_source (0.8.2)
66
69
  mime-types (2.6.1)
67
70
  mini_portile (0.6.2)
68
71
  minitest (5.7.0)
@@ -83,6 +86,10 @@ GEM
83
86
  metaclass (~> 0.0.1)
84
87
  nokogiri (1.6.6.2)
85
88
  mini_portile (~> 0.6.0)
89
+ pry (0.10.2)
90
+ coderay (~> 1.1.0)
91
+ method_source (~> 0.8.1)
92
+ slop (~> 3.4)
86
93
  rack (1.6.4)
87
94
  rack-test (0.6.3)
88
95
  rack (>= 1.0)
@@ -119,6 +126,7 @@ GEM
119
126
  json (~> 1.8)
120
127
  simplecov-html (~> 0.10.0)
121
128
  simplecov-html (0.10.0)
129
+ slop (3.6.0)
122
130
  sprockets (3.2.0)
123
131
  rack (~> 1.0)
124
132
  sprockets-rails (2.3.2)
@@ -129,6 +137,7 @@ GEM
129
137
  thread_safe (0.3.5)
130
138
  tzinfo (1.2.2)
131
139
  thread_safe (~> 0.1)
140
+ unidecoder (1.1.2)
132
141
 
133
142
  PLATFORMS
134
143
  ruby
@@ -141,5 +150,9 @@ DEPENDENCIES
141
150
  minitest-reporters
142
151
  minitest-spec-rails
143
152
  mocha
153
+ pry
144
154
  shoulda-matchers
145
155
  simplecov
156
+
157
+ BUNDLED WITH
158
+ 1.11.2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Bruno M. Mergen
1
+ Copyright (c) 2016 Bruno M. Mergen
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.markdown CHANGED
@@ -4,15 +4,19 @@ Emissão de Boletos Bancários em Ruby.
4
4
 
5
5
  [![Code Climate](https://codeclimate.com/github/Brunomm/br_boleto/badges/gpa.svg)](https://codeclimate.com/github/Brunomm/br_boleto)
6
6
  [![Build Status](https://travis-ci.org/Brunomm/br_boleto.svg?branch=master)](https://travis-ci.org/Brunomm/br_boleto)
7
- [![security](https://hakiri.io/github/Brunomm/br_boleto/master.svg)](https://hakiri.io/github/Brunomm/br_boleto/master)
8
7
 
9
- ## Versão 1.0.0
8
+ ## Versão 1.1.0
10
9
  **O que essa gem faz?**
11
10
 
12
- 1. Boleto bancário para os bancos:
13
- - Sicoob (apenas os cálculos para o boleto, sem a interface)
11
+ 1. Boleto bancário (apenas os cálculos para o boleto, sem a interface) para os bancos:
12
+ - Sicoob
13
+ - Caixa
14
14
  2. Arquivo de remessa para os Bancos:
15
- - Sicoob
15
+ - Sicoob (CNAB 240)
16
+ - Caixa (CNAB 240)
17
+ 3. Arquivo de retorno para os Bancos:
18
+ - Sicoob (CNAB 240)
19
+ - Caixa (CNAB 240)
16
20
 
17
21
  ## Alternativas
18
22
 
@@ -56,6 +60,12 @@ Para todos os bancos e carteiras implementadas, **seguimos as documentações**
56
60
  <td>Homologado dia 03/08/2015</td>
57
61
  <td>Bruno M. Mergen</td>
58
62
  </tr>
63
+ <tr>
64
+ <td>Caixa</td>
65
+ <td>1, 2.</td>
66
+ <td>Pendente</td>
67
+ <td></td>
68
+ </tr>
59
69
  </table>
60
70
 
61
71
 
@@ -74,6 +84,11 @@ Para todos os bancos e carteiras implementadas, **seguimos as documentações**
74
84
  <td>Homologado dia 07/08/2015</td>
75
85
  <td>Bruno M. Mergen</td>
76
86
  </tr>
87
+ <tr>
88
+ <td>Caixa</td>
89
+ <td>Pendente</td>
90
+ <td></td>
91
+ </tr>
77
92
  </table>
78
93
 
79
94
  ## Como usar
@@ -118,9 +133,9 @@ Primeiramente, **antes de renderizar qualquer boleto você precisar verificar se
118
133
 
119
134
  ```ruby
120
135
  if boleto_sicoob.valid?
121
- # Renderiza o boleto itau
136
+ # Renderiza o boleto
122
137
  else
123
- # Trata os erros
138
+ # Tratar erros
124
139
  end
125
140
  ```
126
141
 
data/br_boleto.gemspec CHANGED
@@ -2,25 +2,27 @@
2
2
  require File.expand_path('../lib/br_boleto/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
+ gem.name = "br_boleto"
6
+ gem.version = BrBoleto::Version::CURRENT
7
+ gem.licenses = ['MIT']
8
+ gem.summary = %q{Emissão de Boletos Bancários em Ruby}
9
+ gem.description = %q{Emissão de Boletos Bancários em Ruby}
5
10
  gem.authors = ["Bruno M. Mergen"]
6
11
  gem.email = ["brunomergen@gmail.com"]
7
- gem.description = %q{Emissão de Boletos Bancários em Ruby}
8
- gem.summary = %q{Emissão de Boletos Bancários em Ruby}
12
+
9
13
  gem.homepage = "https://github.com/Brunomm/br_boleto"
10
- gem.license = "BSD"
11
14
 
12
15
  gem.files = `git ls-files`.split($\).reject { |f| ['.pdf','.xls'].include?(File.extname(f)) }
13
16
  gem.test_files = `git ls-files -- test/**/*`.split("\n")
14
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
- gem.name = "br_boleto"
16
18
  gem.require_paths = ["lib"]
17
- gem.version = BrBoleto::Version::CURRENT
18
19
 
19
- gem.required_ruby_version = '>= 2.1'
20
+ gem.required_ruby_version = '~> 2.1'
20
21
 
21
22
 
22
23
  gem.add_dependency "rake", '>= 0.8.7'
23
24
  gem.add_dependency "activesupport", '~> 4.2'
24
25
  gem.add_dependency "activemodel", '~> 4.2'
25
-
26
+ gem.add_dependency 'unidecoder', '~> 1.1'
27
+
26
28
  end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ module BrBoleto
3
+ class ActiveModelBase
4
+ # Seguindo a interface do Active Model para:
5
+ # * Validações;
6
+ # * Internacionalização;
7
+ # * Nomes das classes para serem manipuladas;
8
+ #
9
+ include ActiveModel::Model
10
+
11
+ def initialize(attributes = {})
12
+ attributes = default_values.merge!(attributes)
13
+ assign_attributes(attributes)
14
+ yield self if block_given?
15
+ end
16
+
17
+ def assign_attributes(attributes)
18
+ attributes ||= {}
19
+ attributes.each do |name, value|
20
+ send("#{name}=", value)
21
+ end
22
+ end
23
+
24
+ def default_values
25
+ {}
26
+ end
27
+ end
28
+ end