cnab240santander 0.1.0 → 1.0.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.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .idea/*
data/README.rdoc ADDED
@@ -0,0 +1,25 @@
1
+ = CNAB240 Santander
2
+
3
+ == Installing
4
+
5
+ $ require 'cnab240santander'
6
+ $ gem install cnab240santander
7
+
8
+ == Usage
9
+
10
+ You can request all the lines:
11
+
12
+ $ result = Cnab240santander.retorno(:path => '/home/yourname/file.TXT', :retorna => nil)
13
+
14
+ You can request only the header:
15
+
16
+ $ result = Cnab240santander.retorno(:path => '/home/yourname/file.TXT', :retorna => 0)
17
+
18
+ Or you can request only the data, optionally merging the T and U segments:
19
+
20
+ $ result = Cnab240santander.retorno(:path => '/home/yourname/file.TXT', :retorna => 3, :merge => true)
21
+
22
+ == Thanks
23
+
24
+ Thanks to Arthur Alexandre (https://github.com/arthurix), whose project I used as base to this one,
25
+ and to Rafael Macedo (https://github.com/rafaelmacedo), who helped me deploying my first gem.
@@ -1,7 +1,6 @@
1
1
  module Cnab240santander
2
2
  module Formatacao
3
3
  def formataData(dt)
4
- puts dt
5
4
  if dt.split("").uniq != ["0"]
6
5
  return DateTime.strptime(dt[0..1]+"/"+dt[2..3]+"/"+dt[4..7], "%d/%m/%Y").strftime('%d/%m/%Y')
7
6
  end
@@ -52,10 +52,8 @@ module Cnab240santander
52
52
  while (linha = f.gets)
53
53
  tipoLn = linha[7..7].to_i
54
54
  if tipoLn == $HEADER_ARQUIVO and args[:retorna] == $HEADER_ARQUIVO #0
55
- puts "Processando header"
56
55
  linhas << HeaderArquivo.processar(linha)
57
56
  elsif tipoLn == $DETALHE and args[:retorna] == $DETALHE #3
58
- puts "Processando detalhe"
59
57
  segmento = linha[13..13]
60
58
  if args[:merge] == true
61
59
  hash_aux = {}
@@ -75,7 +73,6 @@ module Cnab240santander
75
73
  end
76
74
 
77
75
  elsif args[:retorna].blank?
78
- puts "Processando linha..."
79
76
  linhas << processarLinha(numLn, linha)
80
77
  end
81
78
  numLn += 1
@@ -1,7 +1,7 @@
1
1
  module Cnab240santander
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 1
3
+ MAJOR = 1
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
@@ -3,7 +3,7 @@
3
3
  end
4
4
 
5
5
  module Cnab240santander
6
- def self.retorno(path, retorna)
7
- Cnab240santander::Retorno.new(:path => path, :retorna => retorna)
6
+ def self.retorno(args)
7
+ Cnab240santander::Retorno.new(args)
8
8
  end
9
9
  end
@@ -12,13 +12,13 @@ describe "Cnab240santander" do
12
12
  end
13
13
 
14
14
  it "should return an array" do
15
- cnab = Cnab240santander.retorno(File.dirname(__FILE__)+"/../../RETORNO.TXT", nil)
15
+ cnab = Cnab240santander.retorno(:path => File.dirname(__FILE__)+"/../../RETORNO.TXT", :retorna => nil)
16
16
  cnab.linhas.should be_kind_of(Array)
17
17
  end
18
18
 
19
19
  context "Header file" do
20
20
  it "should parse the header file" do
21
- cnab = Cnab240santander.retorno(File.dirname(__FILE__)+"/../../RETORNO.TXT", 0)
21
+ cnab = Cnab240santander.retorno(:path => File.dirname(__FILE__)+"/../../RETORNO.TXT", :retorna => 0)
22
22
  cnab.linhas.should be_kind_of(Array)
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cnab240santander
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
- - 0
8
7
  - 1
9
8
  - 0
10
- version: 0.1.0
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lairton Borges
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-29 00:00:00 Z
18
+ date: 2011-12-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activesupport
@@ -78,6 +78,7 @@ files:
78
78
  - .gitignore
79
79
  - .rspec
80
80
  - Gemfile
81
+ - README.rdoc
81
82
  - RETORNO.TXT
82
83
  - Rakefile
83
84
  - cnab240santander.gemspec