eddy 0.4.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/eddy.gemspec +1 -1
- data/lib/definitions/segments/manual/envelopes/ge.rb +4 -3
- data/lib/definitions/segments/manual/envelopes/gs.rb +4 -4
- data/lib/definitions/segments/manual/envelopes/iea.rb +4 -3
- data/lib/definitions/segments/manual/envelopes/isa.rb +1 -1
- data/lib/eddy/data/store.rb +11 -23
- data/lib/eddy/data.rb +15 -9
- data/lib/eddy/models/functional_group.rb +16 -14
- data/lib/eddy/models/interchange.rb +36 -6
- data/lib/eddy/models/transaction_set.rb +5 -6
- data/lib/eddy/models.rb +0 -1
- data/lib/eddy/version.rb +1 -1
- metadata +2 -3
- data/lib/eddy/models/simple_interchange.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54eb94b693f0ba6522fb7acdaddd77d3f84c82519f53f8cef07b1f7d67ebf556
|
|
4
|
+
data.tar.gz: 8baff248f6b4dfc3a52a62592540539998619d7244a6c5675ade29f60ff20eae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 870298adcb6cab4c53100d6094edb4a1a028048fcf0cfbe49cc2977aca8412df192bca48edf15bf6a30efb0141d3cd45ea939151466e66dfed1a83647bee1b86
|
|
7
|
+
data.tar.gz: 60822c6c92d13a0fc96c3d33894417ed70e85cbc908302518dbe567ca6c22ee20b4b07ea3c28cea70323f4fc7565d9c089f64b7bf2baf9133ac24f747b5f7454
|
data/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,22 @@ All code should be considered Work In Progress.
|
|
|
13
13
|
|
|
14
14
|
While the API is still changing, enough code exists that EDI documents can currently be written with Eddy (though I wouldn't recommend use in production environments yet).
|
|
15
15
|
|
|
16
|
+
## 0.5.0 (2020-01-05)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Updated the implementation of `Eddy::Interchange` and `Eddy::FunctionalGroup`
|
|
21
|
+
- Added arguments to the `initialize` methods of the following classes:
|
|
22
|
+
- `Eddy::Segments::GS`
|
|
23
|
+
- `Eddy::Segments::GE`
|
|
24
|
+
- `Eddy::Segments::ISA`
|
|
25
|
+
- `Eddy::Segments::IEA`
|
|
26
|
+
- Slightly modified file/folder layout.
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
|
|
30
|
+
- `Eddy::SimpleInterchange` and its associated test.
|
|
31
|
+
|
|
16
32
|
## 0.4.0 (2020-01-05)
|
|
17
33
|
|
|
18
34
|
### Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[travis-ci]: https://travis-ci.org/tcd/eddy
|
|
11
11
|
[coveralls]: https://coveralls.io/github/tcd/eddy?branch=master
|
|
12
12
|
[license]: https://github.com/tcd/eddy/blob/master/LICENSE.txt
|
|
13
|
-
[docs]: https://www.rubydoc.info/gems/eddy/0.
|
|
13
|
+
[docs]: https://www.rubydoc.info/gems/eddy/0.5.0
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
data/eddy.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
"yard.run" => "yri", # use "yard" to build full HTML docs.
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
spec.files
|
|
25
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
|
26
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
27
27
|
end
|
|
28
28
|
spec.bindir = "exe"
|
|
@@ -8,12 +8,13 @@ module Eddy
|
|
|
8
8
|
class GE < Eddy::Segment
|
|
9
9
|
|
|
10
10
|
# @param store [Eddy::Data::Store]
|
|
11
|
-
# @param group_control_number [Integer]
|
|
11
|
+
# @param group_control_number [Integer] A unique *functional group control number*.
|
|
12
|
+
# @param number_of_transaction_sets [Integer] Number of transaction sets included in a functional group.
|
|
12
13
|
# @return [void]
|
|
13
|
-
def initialize(store, group_control_number)
|
|
14
|
+
def initialize(store, group_control_number, number_of_transaction_sets)
|
|
14
15
|
@id = "GE"
|
|
15
16
|
@name = "Functional Group Trailer"
|
|
16
|
-
@ge01 = Eddy::Elements::E97.new(ref: "GE01", req: "M", val:
|
|
17
|
+
@ge01 = Eddy::Elements::E97.new(ref: "GE01", req: "M", val: number_of_transaction_sets)
|
|
17
18
|
@ge02 = Eddy::Elements::E28.new(ref: "GE02", req: "M", val: group_control_number)
|
|
18
19
|
super(store, @ge01, @ge02)
|
|
19
20
|
end
|
|
@@ -8,13 +8,13 @@ module Eddy
|
|
|
8
8
|
class GS < Eddy::Segment
|
|
9
9
|
|
|
10
10
|
# @param store [Eddy::Data::Store]
|
|
11
|
-
# @param group_control_number [Integer]
|
|
12
|
-
# @param
|
|
11
|
+
# @param group_control_number [Integer] A unique *functional group control number*.
|
|
12
|
+
# @param functional_group [String] A two-letter functional group id.
|
|
13
13
|
# @return [void]
|
|
14
|
-
def initialize(store, group_control_number,
|
|
14
|
+
def initialize(store, group_control_number, functional_group)
|
|
15
15
|
@id = "GS"
|
|
16
16
|
@name = "Functional Group Header"
|
|
17
|
-
@gs01 = Eddy::Elements::E479.new(ref: "GS01", req: "M", val:
|
|
17
|
+
@gs01 = Eddy::Elements::E479.new(ref: "GS01", req: "M", val: functional_group)
|
|
18
18
|
@gs02 = Eddy::Elements::E142.new(ref: "GS02", req: "M", val: store.application_senders_code)
|
|
19
19
|
@gs03 = Eddy::Elements::E124.new(ref: "GS03", req: "M", val: store.application_receivers_code)
|
|
20
20
|
@gs04 = Eddy::Elements::E373.new(ref: "GS04", req: "M", val: store.time)
|
|
@@ -8,12 +8,13 @@ module Eddy
|
|
|
8
8
|
class IEA < Eddy::Segment
|
|
9
9
|
|
|
10
10
|
# @param store [Eddy::Data::Store]
|
|
11
|
-
# @param interchange_control_number [Integer]
|
|
11
|
+
# @param interchange_control_number [Integer] A unique *interchange control number*.
|
|
12
|
+
# @param number_of_functional_groups [Integer] Number of functional groups included in an Interchange.
|
|
12
13
|
# @return [void]
|
|
13
|
-
def initialize(store, interchange_control_number)
|
|
14
|
+
def initialize(store, interchange_control_number, number_of_functional_groups)
|
|
14
15
|
@id = "IEA"
|
|
15
16
|
@name = "Interchange Control Trailer"
|
|
16
|
-
@iea01 = Eddy::Elements::I16.new(ref: "IEA01", req: "M", val:
|
|
17
|
+
@iea01 = Eddy::Elements::I16.new(ref: "IEA01", req: "M", val: number_of_functional_groups)
|
|
17
18
|
@iea02 = Eddy::Elements::I12.new(ref: "IEA02", req: "M", val: interchange_control_number)
|
|
18
19
|
super(store, @iea01, @iea02)
|
|
19
20
|
end
|
|
@@ -8,7 +8,7 @@ module Eddy
|
|
|
8
8
|
class ISA < Eddy::Segment
|
|
9
9
|
|
|
10
10
|
# @param store [Eddy::Data::Store]
|
|
11
|
-
# @param interchange_control_number [Integer]
|
|
11
|
+
# @param interchange_control_number [Integer] A unique *interchange control number*.
|
|
12
12
|
# @return [void]
|
|
13
13
|
def initialize(store, interchange_control_number)
|
|
14
14
|
@id = "ISA"
|
data/lib/eddy/data/store.rb
CHANGED
|
@@ -46,13 +46,6 @@ module Eddy
|
|
|
46
46
|
# @return [String]
|
|
47
47
|
attr_accessor :version_release_industry_id_code
|
|
48
48
|
|
|
49
|
-
# Total number of transaction sets included in the functional group or interchange (transmission) group.
|
|
50
|
-
# @return [Integer]
|
|
51
|
-
attr_accessor :number_of_transaction_sets_included
|
|
52
|
-
# A count of the number of functional groups included in an interchange.
|
|
53
|
-
# @return [Integer]
|
|
54
|
-
attr_accessor :number_of_included_functional_groups
|
|
55
|
-
|
|
56
49
|
# Application Sender's Code
|
|
57
50
|
# Code identifying party sending transmission; codes agreed to by trading partners
|
|
58
51
|
# @return [String]
|
|
@@ -70,39 +63,34 @@ module Eddy
|
|
|
70
63
|
self.segment_separator = "~"
|
|
71
64
|
self.element_separator = "*"
|
|
72
65
|
self.edi_version = "00401"
|
|
73
|
-
self.number_of_included_functional_groups = 0
|
|
74
|
-
self.number_of_transaction_sets_included = 0
|
|
75
66
|
self.application_senders_code = "sender_id"
|
|
76
67
|
self.application_receivers_code = "receiver_id"
|
|
77
68
|
self.version_release_industry_id_code = "004010"
|
|
78
|
-
@group_control_number = 1
|
|
79
69
|
end
|
|
80
70
|
|
|
81
|
-
#
|
|
71
|
+
# (see Eddy::Data.new_interchange_control_number)
|
|
82
72
|
#
|
|
83
73
|
# @return [Integer]
|
|
84
74
|
def interchange_control_number()
|
|
85
|
-
|
|
86
|
-
return 1
|
|
75
|
+
return Eddy::Data.new_interchange_control_number()
|
|
87
76
|
end
|
|
88
77
|
|
|
89
|
-
#
|
|
78
|
+
# (see Eddy::Data.new_transaction_set_control_number)
|
|
90
79
|
#
|
|
80
|
+
# @param transaction_set_id [String]
|
|
91
81
|
# @return [Integer]
|
|
92
|
-
def transaction_set_control_number()
|
|
93
|
-
|
|
94
|
-
return 1
|
|
82
|
+
def transaction_set_control_number(transaction_set_id)
|
|
83
|
+
return Eddy::Data.new_transaction_set_control_number(transaction_set_id)
|
|
95
84
|
end
|
|
96
85
|
|
|
97
|
-
#
|
|
86
|
+
# (see Eddy::Data.new_interchange_control_number)
|
|
98
87
|
#
|
|
88
|
+
# @param functional_group [String]
|
|
99
89
|
# @return [Integer]
|
|
100
|
-
def
|
|
101
|
-
|
|
102
|
-
@group_control_number += 1
|
|
103
|
-
return old_count
|
|
90
|
+
def functional_group_control_number(functional_group)
|
|
91
|
+
return Eddy::Data.new_functional_group_control_number(functional_group)
|
|
104
92
|
end
|
|
105
|
-
end
|
|
106
93
|
|
|
94
|
+
end
|
|
107
95
|
end
|
|
108
96
|
end
|
data/lib/eddy/data.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "eddy/data/persistence/memory"
|
|
|
5
5
|
module Eddy
|
|
6
6
|
|
|
7
7
|
# Persistent data used by Eddy.
|
|
8
|
+
#
|
|
8
9
|
# @return [Eddy::Data::Persistence::Base]
|
|
9
10
|
def self.data
|
|
10
11
|
return @data if defined?(@data) && !@data.nil?
|
|
@@ -32,6 +33,8 @@ module Eddy
|
|
|
32
33
|
# Code for storing & generating data used by Eddy when generating EDI documents.
|
|
33
34
|
module Data
|
|
34
35
|
|
|
36
|
+
# Return a new, unique number.
|
|
37
|
+
#
|
|
35
38
|
# @return [Integer]
|
|
36
39
|
def self.new_interchange_control_number
|
|
37
40
|
existing = Eddy.data.interchange_control_numbers()
|
|
@@ -40,24 +43,27 @@ module Eddy
|
|
|
40
43
|
return new_ctrl_num
|
|
41
44
|
end
|
|
42
45
|
|
|
43
|
-
#
|
|
46
|
+
# Return a new, unique number.
|
|
47
|
+
#
|
|
48
|
+
# @param transaction_set_id [String]
|
|
44
49
|
# @return [Integer]
|
|
45
|
-
def self.
|
|
46
|
-
existing = Eddy.data.
|
|
50
|
+
def self.new_transaction_set_control_number(transaction_set_id)
|
|
51
|
+
existing = Eddy.data.transaction_set_control_numbers(transaction_set_id)
|
|
47
52
|
new_ctrl_num = Eddy::Util.new_number(existing)
|
|
48
|
-
Eddy.data.
|
|
53
|
+
Eddy.data.add_transaction_set_control_number(transaction_set_id, new_ctrl_num)
|
|
49
54
|
return new_ctrl_num
|
|
50
55
|
end
|
|
51
56
|
|
|
52
|
-
#
|
|
57
|
+
# Return a new, unique number.
|
|
58
|
+
#
|
|
59
|
+
# @param functional_group [String]
|
|
53
60
|
# @return [Integer]
|
|
54
|
-
def self.
|
|
55
|
-
existing = Eddy.data.
|
|
61
|
+
def self.new_functional_group_control_number(functional_group)
|
|
62
|
+
existing = Eddy.data.functional_group_control_numbers(functional_group)
|
|
56
63
|
new_ctrl_num = Eddy::Util.new_number(existing)
|
|
57
|
-
Eddy.data.
|
|
64
|
+
Eddy.data.add_functional_group_control_number(functional_group, new_ctrl_num)
|
|
58
65
|
return new_ctrl_num
|
|
59
66
|
end
|
|
60
67
|
|
|
61
68
|
end
|
|
62
|
-
|
|
63
69
|
end
|
|
@@ -2,31 +2,33 @@ module Eddy
|
|
|
2
2
|
# A group of `Eddy::TransactionSet::Base` classes.
|
|
3
3
|
class FunctionalGroup
|
|
4
4
|
|
|
5
|
+
# @return [String]
|
|
6
|
+
attr_reader :id
|
|
5
7
|
# @return [Eddy::Data::Store] Data store for the Interchange and all encompassed components.
|
|
6
8
|
attr_accessor :store
|
|
7
|
-
#
|
|
8
|
-
# @return [Eddy::TransactionSet]
|
|
9
|
-
attr_accessor :transaction_set
|
|
10
|
-
# An array of Transaction Set instances
|
|
9
|
+
# An array of Transaction Set instances.
|
|
11
10
|
# @return [Array<Eddy::TransactionSet>]
|
|
12
11
|
attr_accessor :transaction_sets
|
|
13
12
|
|
|
14
13
|
# @param store [Eddy::Data::Store]
|
|
15
|
-
# @param
|
|
14
|
+
# @param transaction_sets [Eddy::TransactionSet]
|
|
16
15
|
# @return [void]
|
|
17
|
-
def initialize(store,
|
|
16
|
+
def initialize(store, *transaction_sets)
|
|
18
17
|
self.store = store
|
|
19
|
-
|
|
20
|
-
self.transaction_sets = []
|
|
18
|
+
transaction_sets.flatten!
|
|
19
|
+
self.transaction_sets = transaction_sets || []
|
|
20
|
+
if self.transaction_sets.length == 0
|
|
21
|
+
raise ArgumentError, "At least one transaction set is required to create a functional group"
|
|
22
|
+
end
|
|
23
|
+
@id = self.transaction_sets.first.functional_group
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
# @return [
|
|
26
|
+
# @return [Array<#render>]
|
|
24
27
|
def render()
|
|
25
|
-
|
|
26
|
-
gs = Eddy::Segments::GS.new(store,
|
|
27
|
-
ge = Eddy::Segments::GE.new(store,
|
|
28
|
-
|
|
29
|
-
return segments.join(self.store.segment_separator) + segment_separator
|
|
28
|
+
f_group_ctrl_num = Eddy::Data.new_functional_group_control_number(@id)
|
|
29
|
+
gs = Eddy::Segments::GS.new(store, f_group_ctrl_num, @id)
|
|
30
|
+
ge = Eddy::Segments::GE.new(store, f_group_ctrl_num, self.transaction_sets.length)
|
|
31
|
+
return [gs, self.transaction_sets, ge].flatten.map(&:render)
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
end
|
|
@@ -3,13 +3,14 @@ module Eddy
|
|
|
3
3
|
class Interchange
|
|
4
4
|
# @return [Eddy::Data::Store] Data store for the Interchange.
|
|
5
5
|
attr_accessor :store
|
|
6
|
-
# @return [Array<Eddy::
|
|
7
|
-
attr_accessor :
|
|
6
|
+
# @return [Array<Eddy::TransactionSet>]
|
|
7
|
+
attr_accessor :transaction_sets
|
|
8
8
|
|
|
9
|
+
# @param store [Eddy::Data::Store] (Eddy::Data::Store.new)
|
|
9
10
|
# @return [void]
|
|
10
|
-
def initialize()
|
|
11
|
-
self.store =
|
|
12
|
-
self.
|
|
11
|
+
def initialize(store = Eddy::Data::Store.new())
|
|
12
|
+
self.store = store
|
|
13
|
+
self.transaction_sets = []
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
# @param _transaction_sets [Array<Eddy::TransactionSet>]
|
|
@@ -21,7 +22,36 @@ module Eddy
|
|
|
21
22
|
|
|
22
23
|
# @return [String]
|
|
23
24
|
def render()
|
|
24
|
-
|
|
25
|
+
ctrl_num = Eddy::Data.new_interchange_control_number()
|
|
26
|
+
f_groups = self.functional_groups()
|
|
27
|
+
sep = self.store.segment_separator
|
|
28
|
+
isa = Eddy::Segments::ISA.new(self.store, ctrl_num)
|
|
29
|
+
iea = Eddy::Segments::IEA.new(self.store, ctrl_num, f_groups.length)
|
|
30
|
+
yield(isa, iea) if block_given?
|
|
31
|
+
return [isa, f_groups, iea].flatten.map(&:render).join(sep) + sep
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# @return [Array<Eddy::FunctionalGroup>]
|
|
35
|
+
def functional_groups()
|
|
36
|
+
sorted_sets = {}
|
|
37
|
+
self.transaction_sets.each do |ts|
|
|
38
|
+
sorted_sets[ts.functional_group] ||= []
|
|
39
|
+
sorted_sets[ts.functional_group] << ts
|
|
40
|
+
end
|
|
41
|
+
return sorted_sets.map { |_, value| Eddy::FunctionalGroup.new(self.store, *value) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
# @raise [ArgumentError] Unless `transaction_set` is a subclass of {Eddy::TransactionSet}
|
|
47
|
+
# @param transaction_set [Eddy::TransactionSet]
|
|
48
|
+
# @return [void]
|
|
49
|
+
def verify_transaction_set(transaction_set)
|
|
50
|
+
raise ArgumentError unless transaction_set < Eddy::TransactionSet
|
|
51
|
+
raise ArgumentError unless transaction_set <= Eddy::TransactionSet
|
|
52
|
+
raise ArgumentError unless transaction_set.ancestors.include?(Eddy::TransactionSet)
|
|
53
|
+
raise ArgumentError unless transaction_set.superclass == Eddy::TransactionSet
|
|
54
|
+
return nil
|
|
25
55
|
end
|
|
26
56
|
|
|
27
57
|
end
|
|
@@ -55,16 +55,16 @@ module Eddy
|
|
|
55
55
|
|
|
56
56
|
# Add `ST` and `SE` segments to the `components` array.
|
|
57
57
|
#
|
|
58
|
-
# @param
|
|
58
|
+
# @param control_number [Integer] (Eddy::Data.new_transaction_set_control_number())
|
|
59
59
|
# @return [void]
|
|
60
|
-
def add_envelope(
|
|
60
|
+
def add_envelope(control_number = Eddy::Data.new_transaction_set_control_number(self.id))
|
|
61
61
|
st = Eddy::Segments::ST.new(self.store)
|
|
62
62
|
st.TransactionSetIdentifierCode = self.id
|
|
63
|
-
st.TransactionSetControlNumber =
|
|
63
|
+
st.TransactionSetControlNumber = control_number
|
|
64
64
|
|
|
65
65
|
se = Eddy::Segments::SE.new(self.store)
|
|
66
66
|
se.NumberOfIncludedSegments = self.all_components.length + 2
|
|
67
|
-
se.TransactionSetControlNumber =
|
|
67
|
+
se.TransactionSetControlNumber = control_number
|
|
68
68
|
|
|
69
69
|
self.components.unshift(st)
|
|
70
70
|
self.components.push(se)
|
|
@@ -77,8 +77,7 @@ module Eddy
|
|
|
77
77
|
# @return [String]
|
|
78
78
|
def render(s_sep = self.store.segment_separator)
|
|
79
79
|
add_envelope()
|
|
80
|
-
|
|
81
|
-
return self.all_components.map { |s| s.render(e_sep) }.join(s_sep) + s_sep
|
|
80
|
+
return self.all_components.map { |s| s.render(self.store.element_separator) }.join(s_sep)
|
|
82
81
|
end
|
|
83
82
|
|
|
84
83
|
# Return all contained Segments in a single, flattened array.
|
data/lib/eddy/models.rb
CHANGED
data/lib/eddy/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eddy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Clay Dunston
|
|
@@ -1523,7 +1523,6 @@ files:
|
|
|
1523
1523
|
- lib/eddy/models/loop/base.rb
|
|
1524
1524
|
- lib/eddy/models/loop/repeat.rb
|
|
1525
1525
|
- lib/eddy/models/segment.rb
|
|
1526
|
-
- lib/eddy/models/simple_interchange.rb
|
|
1527
1526
|
- lib/eddy/models/transaction_set.rb
|
|
1528
1527
|
- lib/eddy/parse.rb
|
|
1529
1528
|
- lib/eddy/schema/element_summary.rb
|
|
@@ -1554,7 +1553,7 @@ metadata:
|
|
|
1554
1553
|
homepage_uri: https://github.com/tcd/eddy
|
|
1555
1554
|
source_code_uri: https://github.com/tcd/eddy
|
|
1556
1555
|
changelog_uri: https://github.com/tcd/eddy/blob/master/CHANGELOG.md
|
|
1557
|
-
documentation_uri: https://www.rubydoc.info/gems/eddy/0.
|
|
1556
|
+
documentation_uri: https://www.rubydoc.info/gems/eddy/0.5.0
|
|
1558
1557
|
yard.run: yri
|
|
1559
1558
|
post_install_message:
|
|
1560
1559
|
rdoc_options: []
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
module Eddy
|
|
2
|
-
# An EDI interchange with one Transaction Set.
|
|
3
|
-
class SimpleInterchange
|
|
4
|
-
# @return [Eddy::Data::Store] Data store for the Interchange and all encompassed components.
|
|
5
|
-
attr_accessor :store
|
|
6
|
-
# @return [Eddy::TransactionSet]
|
|
7
|
-
attr_accessor :transaction_set
|
|
8
|
-
# @return [Array]
|
|
9
|
-
attr_accessor :components
|
|
10
|
-
|
|
11
|
-
# Initialize an interchange with one Functional Group containing one Transaction Set.
|
|
12
|
-
#
|
|
13
|
-
# @param transaction_set [Eddy::TransactionSet]
|
|
14
|
-
# @param store [Eddy::Data::Store] (Eddy::Data::Store.new)
|
|
15
|
-
# @return [void]
|
|
16
|
-
def initialize(transaction_set, store: Eddy::Data::Store.new())
|
|
17
|
-
self.components = []
|
|
18
|
-
self.transaction_set = transaction_set
|
|
19
|
-
self.store = store
|
|
20
|
-
self.store.number_of_transaction_sets_included = 1
|
|
21
|
-
self.store.number_of_included_functional_groups = 1
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# @yieldparam [Eddy::Segments::ISA] isa
|
|
25
|
-
# @yieldparam [Eddy::Segments::IEA] iea
|
|
26
|
-
# @yieldparam [Eddy::Segments::GS] gs
|
|
27
|
-
# @yieldparam [Eddy::Segments::GE] ge
|
|
28
|
-
# @return [String]
|
|
29
|
-
def render()
|
|
30
|
-
itch_ctrl_num = Eddy::Data.new_interchange_control_number()
|
|
31
|
-
isa = Eddy::Segments::ISA.new(store, itch_ctrl_num)
|
|
32
|
-
iea = Eddy::Segments::IEA.new(store, itch_ctrl_num)
|
|
33
|
-
number_of_included_functional_groups = self.store.number_of_included_functional_groups
|
|
34
|
-
gs = Eddy::Segments::GS.new(store, number_of_included_functional_groups, self.transaction_set)
|
|
35
|
-
ge = Eddy::Segments::GE.new(store, number_of_included_functional_groups)
|
|
36
|
-
yield(isa, iea, gs, ge) if block_given?
|
|
37
|
-
self.components.prepend(gs)
|
|
38
|
-
self.components.prepend(isa)
|
|
39
|
-
self.components.append(ge)
|
|
40
|
-
self.components.append(iea)
|
|
41
|
-
segments = self.components.map(&:render).flatten().join(store.segment_separator) + store.segment_separator
|
|
42
|
-
return segments
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# @raise [ArgumentError] Unless `transaction_set` is a subclass of {Eddy::TransactionSet}
|
|
46
|
-
# @param transaction_set [Eddy::TransactionSet]
|
|
47
|
-
# @return [void]
|
|
48
|
-
def verify_transaction_set(transaction_set)
|
|
49
|
-
raise ArgumentError unless transaction_set < Eddy::TransactionSet
|
|
50
|
-
raise ArgumentError unless transaction_set <= Eddy::TransactionSet
|
|
51
|
-
raise ArgumentError unless transaction_set.ancestors.include?(Eddy::TransactionSet)
|
|
52
|
-
raise ArgumentError unless transaction_set.superclass == Eddy::TransactionSet
|
|
53
|
-
return nil
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
end
|