camt_parser 2.0.0 → 2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 683b4dfccdf419dbd3dfd37e7a4002d354283995
4
- data.tar.gz: 87c93c3d59bc8f83d44b7d02323fdfe044cf5e2d
3
+ metadata.gz: 31140c9ad0b6f028ce771ffdecd8a561eb492b72
4
+ data.tar.gz: ebe9f6cd6204ca39036a2b52844aa9be6a1698fc
5
5
  SHA512:
6
- metadata.gz: 0f02b7ecd0a390a709831cbbfe58494f5aa69251b1cf3930f4fe919d297a8f2b87c1c4239899f2b895d25636f12c26fe3ae21d927d719ced342953a6cef2471f
7
- data.tar.gz: aad82828f6b3735eff91d5adfbcc1c3d846a0360331111a556be4b1fa60fc460280d2b3bf31e7763ff9f0e0992d2361e979ad08f9b7623952e013d666594eda2
6
+ metadata.gz: 742a48549a6274d2e7a8615260c490fbd3a61523397832e569d3337575eb2bacaa384355cf03ae7bd00728bb6db71036068c035c43793ea720d858ef0afc5ae6
7
+ data.tar.gz: 923fdcf651f4575c65310a5e9375bec65d8e3f106ebd6b6f653bc81317d538bc312eb17e77868596f3ede3406301f3e5f96a7d8c294457c8dbe135903eeff3e6
@@ -2,5 +2,8 @@ module CamtParser
2
2
  module Errors
3
3
  class UnsupportedNamespaceError < StandardError
4
4
  end
5
+
6
+ class NotXMLError < StandardError
7
+ end
5
8
  end
6
9
  end
@@ -2,18 +2,7 @@ module CamtParser
2
2
  class String
3
3
  def self.parse(raw_camt)
4
4
  doc = Nokogiri::XML raw_camt
5
-
6
- namespaces = doc.namespaces['xmlns']
7
- doc.remove_namespaces!
8
-
9
- case namespaces
10
- when 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.02'
11
- return CamtParser::Format052::Base.new(doc.xpath('Document'))
12
- when 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.02'
13
- return CamtParser::Format053::Base.new(doc.xpath('Document'))
14
- else
15
- raise CamtParser::Errors::UnsupportedNamespaceError, namespaces
16
- end
5
+ CamtParser::Xml.parse(doc)
17
6
  end
18
7
  end
19
8
  end
@@ -1,3 +1,3 @@
1
1
  module CamtParser
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -0,0 +1,19 @@
1
+ module CamtParser
2
+ class Xml
3
+ def self.parse(doc)
4
+ raise CamtParser::Errors::NotXMLError, doc.class unless doc.is_a? Nokogiri::XML::Document
5
+
6
+ namespaces = doc.namespaces['xmlns']
7
+ doc.remove_namespaces!
8
+
9
+ case namespaces
10
+ when 'urn:iso:std:iso:20022:tech:xsd:camt.052.001.02'
11
+ return CamtParser::Format052::Base.new(doc.xpath('Document'))
12
+ when 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.02'
13
+ return CamtParser::Format053::Base.new(doc.xpath('Document'))
14
+ else
15
+ raise CamtParser::Errors::UnsupportedNamespaceError, namespaces
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/camt_parser.rb CHANGED
@@ -20,3 +20,4 @@ require_relative "camt_parser/053/statement"
20
20
  require_relative "camt_parser/053/base"
21
21
  require_relative "camt_parser/file"
22
22
  require_relative "camt_parser/string"
23
+ require_relative "camt_parser/xml"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camt_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -104,6 +104,7 @@ files:
104
104
  - lib/camt_parser/misc.rb
105
105
  - lib/camt_parser/string.rb
106
106
  - lib/camt_parser/version.rb
107
+ - lib/camt_parser/xml.rb
107
108
  homepage: https://github.com/Barzahlen/camt_parser
108
109
  licenses:
109
110
  - MIT