swifty 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/swifty.rb +12 -69
- metadata +20 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3beb3e3fc5ab4f4be270b6455adfc5679e21a96f5f3431e006560af47c282560
|
4
|
+
data.tar.gz: 3a4de3f1edbec7a7aad288f75333650486437daf50650b4112c0e83c3d8c34dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae901ac2fec440239e5dbaa3ec0af48d03e8a3f5e50596e0bb9a932a4babe968c55ddacb829ca3c3c2cd49f743927ea1d15546cd11ea568056328b7ed9c75f8b
|
7
|
+
data.tar.gz: c26addc74def93429bb50b5d4924d63e9d64fbe9cf34ddfb27fe2b8a1bdb8738e5d0433c8365e2e702f4c28027bf426abc3c4e18b3a6a13ba12d43d30150598a
|
data/lib/swifty.rb
CHANGED
@@ -1,76 +1,19 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.setup
|
3
|
+
|
1
4
|
require 'active_support/all'
|
2
5
|
require 'cmxl'
|
3
|
-
require 'choice'
|
4
|
-
require 'pp'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
Cmxl.config[:statement_separator] = /-\}/m
|
8
|
-
Cmxl.config[:raise_line_format_errors] = true
|
9
|
-
|
10
|
-
module Cmxl
|
11
|
-
# Field parser to handle the header field.
|
12
|
-
class HeaderFieldParser < Cmxl::Field
|
13
|
-
self.tag = 1
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
require 'statements'
|
8
|
+
require 'export_info'
|
9
|
+
require 'import_info'
|
10
|
+
require 'meta_info'
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
# This ensures that we can parse the header (field 1, 2, and 3) in the SWIFT messages. See the example.swift.txt for
|
23
|
-
# an example.
|
24
|
-
#
|
25
|
-
# See also http://ibm.co/1K0zURs
|
26
|
-
def self.parse(line)
|
27
|
-
if line.match(/^:(\d{2,2})(\w)?:(.*)$/)
|
28
|
-
tag, modifier, content = $1, $2, $3
|
29
|
-
Field.parsers[tag.to_s].new(content, modifier, tag)
|
30
|
-
elsif line.match Regexp.new('\d:([^}]+)') # Header
|
31
|
-
basic_header, application_header = $1, $2
|
32
|
-
Field.parsers['1'].new(basic_header, application_header, '1')
|
33
|
-
else
|
34
|
-
raise LineFormatError, "Wrong line format: #{line.dump}" if Cmxl.config[:raise_line_format_errors]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
12
|
+
require 'types/base'
|
13
|
+
require 'types/mt940'
|
39
14
|
|
40
15
|
module Swifty
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def initialize(content, **options)
|
45
|
-
content = File.read(content) if File.exists?(content)
|
46
|
-
@options = options
|
47
|
-
@content = content.is_a?(File) ? content.read : content
|
48
|
-
@statement ||= Cmxl.parse(content, encoding: options[:encoding]).first
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_hash
|
52
|
-
statement.to_hash
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_yaml
|
56
|
-
to_hash.to_yaml
|
57
|
-
end
|
58
|
-
alias_method :to_yml, :to_yaml
|
59
|
-
|
60
|
-
def save(file)
|
61
|
-
File.open(file, 'w+') { |f| f.write to_yaml }
|
62
|
-
to_hash
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def method_missing(name, *args)
|
68
|
-
return statement.send(name, *args)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def new(*args)
|
73
|
-
Parser.new(*args)
|
74
|
-
end
|
75
|
-
module_function :new
|
16
|
+
BaseError = Class.new(StandardError)
|
17
|
+
IncorrectType = Class.new(StandardError)
|
18
|
+
IncorrectFile = Class.new(StandardError)
|
76
19
|
end
|
metadata
CHANGED
@@ -1,79 +1,65 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swifty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Kampp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.7.3
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.7.3
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: choices
|
28
|
+
name: cmxl
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- -
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
33
|
+
version: '0.1'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- -
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
40
|
+
version: '0.1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
type: :
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
description:
|
70
|
-
email:
|
54
|
+
version: '3.3'
|
55
|
+
description: Supports simple extension for customization of SWIFT message parsing.
|
56
|
+
email: emil@kampp.me
|
71
57
|
executables: []
|
72
58
|
extensions: []
|
73
59
|
extra_rdoc_files: []
|
74
60
|
files:
|
75
61
|
- lib/swifty.rb
|
76
|
-
homepage: https://github.com/
|
62
|
+
homepage: https://github.com/ekampp/swifty
|
77
63
|
licenses:
|
78
64
|
- MIT
|
79
65
|
metadata: {}
|
@@ -83,9 +69,9 @@ require_paths:
|
|
83
69
|
- lib
|
84
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
71
|
requirements:
|
86
|
-
- - "
|
72
|
+
- - "~>"
|
87
73
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
74
|
+
version: '2.2'
|
89
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
76
|
requirements:
|
91
77
|
- - ">="
|
@@ -93,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
79
|
version: '0'
|
94
80
|
requirements: []
|
95
81
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.7.7
|
97
83
|
signing_key:
|
98
84
|
specification_version: 4
|
99
|
-
summary:
|
85
|
+
summary: Simple parsing of SWIFT messages
|
100
86
|
test_files: []
|