cmxl 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18a7814325172343b3ae6aee190378823aacd8ab
4
- data.tar.gz: a87474a066345e76dc8b66a15b83a632c26a5c0b
3
+ metadata.gz: ef139423daa5f2df7f4e36f91b99cb9cc0f33a74
4
+ data.tar.gz: 3e3809a8d2fd6a073c198e42222e0545ef40d5ea
5
5
  SHA512:
6
- metadata.gz: 4756b37a6bf9dc970b76d258dd95fef711f86697e64ae9a28c708efc6696ee6df5b076e2d24546bcd977e9fb1481bc1f5a4058eecfe7348b7fb7d9dba2f1446f
7
- data.tar.gz: 1baadae4a20e53efc0f5f9a5bdd04c4e7cd7773f7ec04c468a768d36bddb1a86f96800ddcb28c863aeeaacb06829547ee64fd700809adc0a96f2eea0758f604d
6
+ metadata.gz: 82192a04913840d6ab0e37c19dbfb908a42a249178133bcd2e488441b700ab3526063b823a04e451e54c48374a8ec7a4a4c722369cb319a3a4c86173d39fa82e
7
+ data.tar.gz: c3ce22ebff413224d72061e0714b61201a422168d50d2791efe07d77af2cf4dee26e598dcb6822fe2c99a411d1fae96d198df463760526e984dcbae616b98c20
data/lib/cmxl/field.rb CHANGED
@@ -68,7 +68,9 @@ module Cmxl
68
68
  def to_h
69
69
  self.data.merge('tag' => self.tag)
70
70
  end
71
- alias :to_hash :to_h
71
+ def to_hash
72
+ to_h
73
+ end
72
74
  def to_json(*args)
73
75
  to_h.to_json(*args)
74
76
  end
@@ -77,15 +77,17 @@ module Cmxl
77
77
  'reference' => reference,
78
78
  'sha' => sha,
79
79
  'generation_date' => generation_date,
80
- 'account_identification' => account_identification,
81
- 'opening_balance' => opening_balance,
82
- 'closing_balance' => closing_balance,
83
- 'available_balance' => available_balance,
84
- 'transactions' => transactions,
85
- 'fields' => fields
80
+ 'account_identification' => account_identification.to_h,
81
+ 'opening_balance' => opening_balance.to_h,
82
+ 'closing_balance' => closing_balance.to_h,
83
+ 'available_balance' => available_balance.to_h,
84
+ 'transactions' => transactions.map(&:to_h),
85
+ 'fields' => fields.map(&:to_h)
86
86
  }
87
87
  end
88
- alias :to_hash :to_h
88
+ def to_hash
89
+ to_h
90
+ end
89
91
  def to_json(*args)
90
92
  to_h.to_json(*args)
91
93
  end
@@ -82,7 +82,9 @@ module Cmxl
82
82
  h.merge!(self.details.to_h) if self.details
83
83
  end
84
84
  end
85
- alias :to_hash :to_h
85
+ def to_hash
86
+ to_h
87
+ end
86
88
  def to_json(*args)
87
89
  to_h.to_json(*args)
88
90
  end
data/lib/cmxl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cmxl
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/spec/field_spec.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Cmxl::Field do
4
- subject { Cmxl::Field.new('D140829EUR000000000147,64') }
4
+ subject { Cmxl::Field.new('D140829EUR000000000147,64', nil, 42) }
5
5
 
6
6
  it { expect(Cmxl::Field.parser).to eql(/(?<details>.*)/) } # default must be set
7
7
 
8
+ it { expect(subject.to_h).to eql({'tag' => 42, 'details' => 'D140829EUR000000000147,64'}) }
9
+ it { expect(subject.to_hash).to eql(subject.to_h) }
10
+
8
11
  it { expect(subject.to_amount('123.')).to eql(123.00) }
9
12
  it { expect(subject.to_amount('123.1')).to eql(123.10) }
10
13
  it { expect(subject.to_amount('123.11')).to eql(123.11) }
@@ -9,4 +9,5 @@ describe Cmxl::Fields::Reference do
9
9
  it { expect(subject.statement_identifier).to eql('D') }
10
10
  it { expect(subject.additional_number).to eql('049') }
11
11
  it { expect(subject.to_h).to eql({"tag" => '20', "statement_identifier"=>"D", "date"=> Date.new(2014,9,2), "additional_number"=>"049", "reference"=>"D140902049"}) }
12
+ it { expect(subject.to_hash).to eql(subject.to_h) }
12
13
  end
@@ -35,6 +35,7 @@ describe Cmxl::Fields::StatementDetails do
35
35
  }) }
36
36
 
37
37
  it { expect(subject.to_h).to eql({'bic'=>"HYVEDEMMXXX", 'iban'=>"HUkkbbbsssskcccccccccccccccx", 'name' => "Peter Pan", 'sepa' => {"EREF"=>"TRX-0A4A47C3-F846-4729-8A1B-5DF620F", "MREF"=>"CAC97D2144174318AC18D9BF815BD4FB", "CRED"=>"DE98ZZZ09999999999", "SVWZ"=>"FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F"}, 'information' => "EREF+TRX-0A4A47C3-F846-4729-8A1B-5DF620FMREF+CAC97D2144174318AC18D9BF815BD4FBCRED+DE98ZZZ09999999999SVWZ+FOO TRX-0A4A47C3-F846-4729-8A1B-5DF620F", 'description' => "SEPA LASTSCHRIFT KUNDE", 'sub_fields' => {"00"=>"SEPA LASTSCHRIFT KUNDE", "10"=>"281", "20"=>"EREF+TRX-0A4A47C3-F846-4729", "21"=>"-8A1B-5DF620F", "22"=>"MREF+CAC97D2144174318AC18D9", "23"=>"BF815BD4FB", "24"=>"CRED+DE98ZZZ09999999999", "25"=>"SVWZ+FOO TRX-0A4A47C3-F84", "26"=>"6-4729-8A1B-5DF620F", "30"=>"HYVEDEMMXXX", "31"=>"HUkkbbbsssskcccccccccccccccx", "32"=>"Peter Pan", "34"=>"171"}, 'transaction_code' => "171", 'details' => "?00SEPA LASTSCHRIFT KUNDE?10281?20EREF+TRX-0A4A47C3-F846-4729?21-8A1B-5DF620F?22MREF+CAC97D2144174318AC18D9?23BF815BD4FB?24CRED+DE98ZZZ09999999999?25SVWZ+FOO TRX-0A4A47C3-F84?266-4729-8A1B-5DF620F?30HYVEDEMMXXX?31HUkkbbbsssskcccccccccccccccx?32Peter Pan?34171"}) }
38
+ it { expect(subject.to_hash).to eql(subject.to_h) }
38
39
  end
39
40
 
40
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmxl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bumann