eddy 0.8.2 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -4
- data/CHANGELOG.md +46 -1
- data/Gemfile.lock +8 -8
- data/README.md +2 -5
- data/data/code-lists/333.tsv +8 -0
- data/data/segments/amt.segment.yml +7 -0
- data/data/segments/bia.segment.yml +10 -0
- data/data/segments/cur.segment.yml +8 -0
- data/data/segments/dtm.segment.yml +1 -0
- data/data/segments/fob.segment.yml +8 -0
- data/data/segments/itd.segment.yml +13 -0
- data/data/segments/mtx.segment.yml +7 -0
- data/data/segments/n9.segment.yml +7 -0
- data/data/segments/per.segment.yml +13 -0
- data/data/segments/po1.segment.yml +6 -0
- data/data/segments/po3.segment.yml +13 -0
- data/data/segments/qty.segment.yml +10 -0
- data/data/segments/ref.segment.yml +1 -0
- data/data/segments/sac.segment.yml +4 -0
- data/data/segments/sch.segment.yml +7 -0
- data/data/segments/sdq.segment.yml +8 -0
- data/data/segments/txi.segment.yml +9 -0
- data/data/transaction_sets/810.edi.yml +93 -0
- data/data/transaction_sets/846.edi.yml +57 -0
- data/data/transaction_sets/850.edi.yml +73 -0
- data/data/transaction_sets/855.edi.yml +74 -0
- data/data/transaction_sets/856.edi.yml +54 -0
- data/eddy.gemspec +1 -1
- data/exe/eddy +1 -0
- data/lib/definitions/elements/generated/100.currency_code.rb +200 -0
- data/lib/definitions/elements/generated/146.shipment_method_of_payment.rb +65 -0
- data/lib/definitions/elements/generated/1551.message_text.rb +29 -0
- data/lib/definitions/elements/generated/280.exchange_rate.rb +29 -0
- data/lib/definitions/elements/generated/309.location_qualifier.rb +209 -0
- data/lib/definitions/elements/generated/310.location_identifier.rb +29 -0
- data/lib/definitions/elements/generated/311.shipment_type_code.rb +42 -0
- data/lib/definitions/elements/generated/322.load_empty_status_code.rb +40 -0
- data/lib/definitions/elements/generated/325.tax_identification_number.rb +29 -0
- data/lib/definitions/elements/generated/333.terms_basis_date_code.rb +44 -0
- data/lib/definitions/elements/generated/336.terms_type_code.rb +102 -0
- data/lib/definitions/elements/generated/338.terms_discount_percent.rb +29 -0
- data/lib/definitions/elements/generated/351.terms_discount_days_due.rb +30 -0
- data/lib/definitions/elements/generated/363.note_reference_code.rb +278 -0
- data/lib/definitions/elements/generated/364.communication_number.rb +29 -0
- data/lib/definitions/elements/generated/365.communication_number_qualifier.rb +77 -0
- data/lib/definitions/elements/generated/366.contact_function_code.rb +267 -0
- data/lib/definitions/elements/generated/369.free_form_description.rb +29 -0
- data/lib/definitions/elements/generated/370.terms_discount_due_date.rb +29 -0
- data/lib/definitions/elements/generated/371.change_reason_code.rb +67 -0
- data/lib/definitions/elements/generated/378.allowance_charge_percent_qualifier.rb +48 -0
- data/lib/definitions/elements/generated/386.terms_net_days.rb +30 -0
- data/lib/definitions/elements/generated/446.terms_net_due_date.rb +29 -0
- data/lib/definitions/elements/generated/522.amount_qualifier_code.rb +1510 -0
- data/lib/definitions/elements/generated/673.quantity_qualifier.rb +869 -0
- data/lib/definitions/elements/generated/755.report_type_code.rb +559 -0
- data/lib/definitions/elements/generated/954.percent.rb +29 -0
- data/lib/definitions/elements/generated/963.tax_type_code.rb +111 -0
- data/lib/definitions/elements/manual/i/I10.interchange_control_standards_identifier.rb +2 -2
- data/lib/definitions/elements/manual/i/I11.interchange_control_version_number.rb +1 -0
- data/lib/definitions/segments/generated/amt.rb +56 -0
- data/lib/definitions/segments/generated/bia.rb +107 -0
- data/lib/definitions/segments/generated/cur.rb +73 -0
- data/lib/definitions/segments/generated/dtm.rb +17 -0
- data/lib/definitions/segments/generated/fob.rb +73 -0
- data/lib/definitions/segments/generated/hl.rb +90 -0
- data/lib/definitions/segments/generated/itd.rb +158 -0
- data/lib/definitions/segments/generated/mtx.rb +56 -0
- data/lib/definitions/segments/generated/n2.rb +56 -0
- data/lib/definitions/segments/generated/n9.rb +56 -0
- data/lib/definitions/segments/generated/per.rb +158 -0
- data/lib/definitions/segments/generated/po1.rb +102 -0
- data/lib/definitions/segments/generated/po3.rb +158 -0
- data/lib/definitions/segments/generated/qty.rb +73 -0
- data/lib/definitions/segments/generated/ref.rb +17 -0
- data/lib/definitions/segments/generated/sac.rb +68 -0
- data/lib/definitions/segments/generated/sch.rb +56 -0
- data/lib/definitions/segments/generated/sdq.rb +73 -0
- data/lib/definitions/segments/generated/txi.rb +90 -0
- data/lib/definitions/transaction_sets/manual/846/846.rb +122 -0
- data/lib/definitions/transaction_sets/manual/846/loops/lin.rb +155 -0
- data/lib/definitions/transaction_sets/manual/846/loops/n1.rb +107 -0
- data/lib/definitions/transaction_sets/manual/846/loops/qty.rb +75 -0
- data/lib/definitions/transaction_sets/manual/846/loops/sch.rb +59 -0
- data/lib/definitions/transaction_sets/manual/846/loops/sln.rb +59 -0
- data/lib/definitions/transaction_sets/manual/850/850.rb +108 -1
- data/lib/definitions/transaction_sets/manual/850/loops/ctp.rb +47 -0
- data/lib/definitions/transaction_sets/manual/850/loops/n1.rb +31 -10
- data/lib/definitions/transaction_sets/manual/850/loops/n9.rb +59 -0
- data/lib/definitions/transaction_sets/manual/850/loops/pid.rb +47 -0
- data/lib/definitions/transaction_sets/manual/850/loops/po1.rb +78 -10
- data/lib/definitions/transaction_sets/manual/850/loops/sac.rb +47 -0
- data/lib/eddy.rb +49 -3
- data/lib/eddy/build/transaction_set_builder.rb +1 -1
- data/lib/eddy/config.rb +0 -21
- data/lib/eddy/data.rb +0 -40
- data/lib/eddy/data/persistence/base.rb +5 -11
- data/lib/eddy/data/persistence/memory.rb +14 -22
- data/lib/eddy/errors.rb +13 -9
- data/lib/eddy/models/element/composite.rb +2 -0
- data/lib/eddy/models/element/id.rb +1 -1
- data/lib/eddy/models/element/r.rb +1 -0
- data/lib/eddy/models/functional_group.rb +3 -2
- data/lib/eddy/models/interchange.rb +6 -2
- data/lib/eddy/models/transaction_set.rb +1 -1
- data/lib/eddy/parse.rb +4 -56
- data/lib/eddy/parse/interchange.rb +58 -0
- data/lib/eddy/summary/loop.rb +1 -1
- data/lib/eddy/summary/segment.rb +2 -1
- data/lib/eddy/version.rb +1 -1
- metadata +78 -5
@@ -0,0 +1,47 @@
|
|
1
|
+
module Eddy
|
2
|
+
module TransactionSets
|
3
|
+
module TS850
|
4
|
+
module Loops
|
5
|
+
module CTP
|
6
|
+
|
7
|
+
# ### Loop Summary:
|
8
|
+
#
|
9
|
+
# - Repeat: 1
|
10
|
+
# - Components:
|
11
|
+
# - CTP
|
12
|
+
class Base < Eddy::Models::Loop::Base
|
13
|
+
# @param store [Eddy::Data::Store]
|
14
|
+
# @return [void]
|
15
|
+
def initialize(store)
|
16
|
+
@repeat_limit = 1
|
17
|
+
super(store, Repeat)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# (see Eddy::TransactionSets::TS850::Loops::CTP::Base)
|
22
|
+
class Repeat < Eddy::Models::Loop::Repeat
|
23
|
+
# @param store [Eddy::Data::Store]
|
24
|
+
# @return [void]
|
25
|
+
def initialize(store)
|
26
|
+
@ctp = Eddy::Segments::CTP.new(store)
|
27
|
+
super(
|
28
|
+
store,
|
29
|
+
@ctp,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# (see Eddy::Segments::CTP)
|
34
|
+
#
|
35
|
+
# @yieldparam [Eddy::Segments::CTP]
|
36
|
+
# @return [Eddy::Segments::CTP]
|
37
|
+
def CTP()
|
38
|
+
yield(@ctp) if block_given?
|
39
|
+
return @ctp
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Eddy
|
2
2
|
module TransactionSets
|
3
|
-
# Namespace for Transaction Set 850 and its loops.
|
4
3
|
module TS850
|
5
4
|
module Loops
|
6
5
|
module N1
|
@@ -10,33 +9,37 @@ module Eddy
|
|
10
9
|
# - Repeat: 200
|
11
10
|
# - Components:
|
12
11
|
# - N1
|
12
|
+
# - N2
|
13
13
|
# - N3
|
14
14
|
# - N4
|
15
|
+
# - PER
|
15
16
|
class Base < Eddy::Models::Loop::Base
|
16
17
|
# @param store [Eddy::Data::Store]
|
17
18
|
# @return [void]
|
18
19
|
def initialize(store)
|
19
|
-
super(store, Repeat)
|
20
20
|
@repeat_limit = 200
|
21
|
-
|
22
|
-
|
23
|
-
# @yieldparam [Eddy::TransactionSets::TS850::Loops::N1::Repeat]
|
24
|
-
# @return [void]
|
25
|
-
def repeat(&block)
|
26
|
-
super(&block)
|
21
|
+
super(store, Repeat)
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
30
25
|
# (see Eddy::TransactionSets::TS850::Loops::N1::Base)
|
31
26
|
class Repeat < Eddy::Models::Loop::Repeat
|
32
|
-
|
33
27
|
# @param store [Eddy::Data::Store]
|
34
28
|
# @return [void]
|
35
29
|
def initialize(store)
|
36
30
|
@n1 = Eddy::Segments::N1.new(store)
|
31
|
+
@n2 = Eddy::Segments::N2.new(store)
|
37
32
|
@n3 = Eddy::Segments::N3.new(store)
|
38
33
|
@n4 = Eddy::Segments::N4.new(store)
|
39
|
-
|
34
|
+
@per = Eddy::Segments::PER.new(store)
|
35
|
+
super(
|
36
|
+
store,
|
37
|
+
@n1,
|
38
|
+
@n2,
|
39
|
+
@n3,
|
40
|
+
@n4,
|
41
|
+
@per,
|
42
|
+
)
|
40
43
|
end
|
41
44
|
|
42
45
|
# (see Eddy::Segments::N1)
|
@@ -48,6 +51,15 @@ module Eddy
|
|
48
51
|
return @n1
|
49
52
|
end
|
50
53
|
|
54
|
+
# (see Eddy::Segments::N2)
|
55
|
+
#
|
56
|
+
# @yieldparam [Eddy::Segments::N2]
|
57
|
+
# @return [Eddy::Segments::N2]
|
58
|
+
def N2()
|
59
|
+
yield(@n2) if block_given?
|
60
|
+
return @n2
|
61
|
+
end
|
62
|
+
|
51
63
|
# (see Eddy::Segments::N3)
|
52
64
|
#
|
53
65
|
# @yieldparam [Eddy::Segments::N3]
|
@@ -65,6 +77,15 @@ module Eddy
|
|
65
77
|
yield(@n4) if block_given?
|
66
78
|
return @n4
|
67
79
|
end
|
80
|
+
|
81
|
+
# (see Eddy::Segments::PER)
|
82
|
+
#
|
83
|
+
# @yieldparam [Eddy::Segments::PER]
|
84
|
+
# @return [Eddy::Segments::PER]
|
85
|
+
def PER()
|
86
|
+
yield(@per) if block_given?
|
87
|
+
return @per
|
88
|
+
end
|
68
89
|
end
|
69
90
|
|
70
91
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Eddy
|
2
|
+
module TransactionSets
|
3
|
+
module TS850
|
4
|
+
module Loops
|
5
|
+
module N9
|
6
|
+
|
7
|
+
# ### Loop Summary:
|
8
|
+
#
|
9
|
+
# - Repeat: 1000
|
10
|
+
# - Components:
|
11
|
+
# - N9
|
12
|
+
# - MTX
|
13
|
+
class Base < Eddy::Models::Loop::Base
|
14
|
+
# @param store [Eddy::Data::Store]
|
15
|
+
# @return [void]
|
16
|
+
def initialize(store)
|
17
|
+
@repeat_limit = 1000
|
18
|
+
super(store, Repeat)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# (see Eddy::TransactionSets::TS850::Loops::N9::Base)
|
23
|
+
class Repeat < Eddy::Models::Loop::Repeat
|
24
|
+
# @param store [Eddy::Data::Store]
|
25
|
+
# @return [void]
|
26
|
+
def initialize(store)
|
27
|
+
@n9 = Eddy::Segments::N9.new(store)
|
28
|
+
@mtx = Eddy::Segments::MTX.new(store)
|
29
|
+
super(
|
30
|
+
store,
|
31
|
+
@n9,
|
32
|
+
@mtx,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
# (see Eddy::Segments::N9)
|
37
|
+
#
|
38
|
+
# @yieldparam [Eddy::Segments::N9]
|
39
|
+
# @return [Eddy::Segments::N9]
|
40
|
+
def N9()
|
41
|
+
yield(@n9) if block_given?
|
42
|
+
return @n9
|
43
|
+
end
|
44
|
+
|
45
|
+
# (see Eddy::Segments::MTX)
|
46
|
+
#
|
47
|
+
# @yieldparam [Eddy::Segments::MTX]
|
48
|
+
# @return [Eddy::Segments::MTX]
|
49
|
+
def MTX()
|
50
|
+
yield(@mtx) if block_given?
|
51
|
+
return @mtx
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Eddy
|
2
|
+
module TransactionSets
|
3
|
+
module TS850
|
4
|
+
module Loops
|
5
|
+
module PID
|
6
|
+
|
7
|
+
# ### Loop Summary:
|
8
|
+
#
|
9
|
+
# - Repeat: 1000
|
10
|
+
# - Components:
|
11
|
+
# - PID
|
12
|
+
class Base < Eddy::Models::Loop::Base
|
13
|
+
# @param store [Eddy::Data::Store]
|
14
|
+
# @return [void]
|
15
|
+
def initialize(store)
|
16
|
+
@repeat_limit = 1000
|
17
|
+
super(store, Repeat)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# (see Eddy::TransactionSets::TS850::Loops::PID::Base)
|
22
|
+
class Repeat < Eddy::Models::Loop::Repeat
|
23
|
+
# @param store [Eddy::Data::Store]
|
24
|
+
# @return [void]
|
25
|
+
def initialize(store)
|
26
|
+
@pid = Eddy::Segments::PID.new(store)
|
27
|
+
super(
|
28
|
+
store,
|
29
|
+
@pid,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# (see Eddy::Segments::PID)
|
34
|
+
#
|
35
|
+
# @yieldparam [Eddy::Segments::PID]
|
36
|
+
# @return [Eddy::Segments::PID]
|
37
|
+
def PID()
|
38
|
+
yield(@pid) if block_given?
|
39
|
+
return @pid
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,28 +1,26 @@
|
|
1
1
|
module Eddy
|
2
2
|
module TransactionSets
|
3
|
-
# Namespace for Transaction Set 850 and its loops.
|
4
3
|
module TS850
|
5
4
|
module Loops
|
6
5
|
module PO1
|
7
6
|
|
8
7
|
# ### Loop Summary:
|
9
8
|
#
|
10
|
-
# - Repeat:
|
9
|
+
# - Repeat: 100000
|
11
10
|
# - Components:
|
12
11
|
# - PO1
|
12
|
+
# - CTP (loop)
|
13
|
+
# - PID (loop)
|
14
|
+
# - SAC (loop)
|
15
|
+
# - TXI
|
16
|
+
# - N9 (loop)
|
13
17
|
class Base < Eddy::Models::Loop::Base
|
14
18
|
# @param store [Eddy::Data::Store]
|
15
19
|
# @return [void]
|
16
20
|
def initialize(store)
|
17
|
-
@repeat_limit =
|
21
|
+
@repeat_limit = 100000
|
18
22
|
super(store, Repeat)
|
19
23
|
end
|
20
|
-
|
21
|
-
# @yieldparam [Eddy::TransactionSets::TS850::Loops::PO1::Repeat]
|
22
|
-
# @return [void]
|
23
|
-
def repeat(&block)
|
24
|
-
super(&block)
|
25
|
-
end
|
26
24
|
end
|
27
25
|
|
28
26
|
# (see Eddy::TransactionSets::TS850::Loops::PO1::Base)
|
@@ -31,7 +29,20 @@ module Eddy
|
|
31
29
|
# @return [void]
|
32
30
|
def initialize(store)
|
33
31
|
@po1 = Eddy::Segments::PO1.new(store)
|
34
|
-
|
32
|
+
@l_ctp = Eddy::TransactionSets::TS850::Loops::CTP::Base.new(store)
|
33
|
+
@l_pid = Eddy::TransactionSets::TS850::Loops::PID::Base.new(store)
|
34
|
+
@l_sac = Eddy::TransactionSets::TS850::Loops::SAC::Base.new(store)
|
35
|
+
@txi = Eddy::Segments::TXI.new(store)
|
36
|
+
@l_n9 = Eddy::TransactionSets::TS850::Loops::N9::Base.new(store)
|
37
|
+
super(
|
38
|
+
store,
|
39
|
+
@po1,
|
40
|
+
@l_ctp,
|
41
|
+
@l_pid,
|
42
|
+
@l_sac,
|
43
|
+
@txi,
|
44
|
+
@l_n9,
|
45
|
+
)
|
35
46
|
end
|
36
47
|
|
37
48
|
# (see Eddy::Segments::PO1)
|
@@ -42,6 +53,63 @@ module Eddy
|
|
42
53
|
yield(@po1) if block_given?
|
43
54
|
return @po1
|
44
55
|
end
|
56
|
+
|
57
|
+
# (see Eddy::Segments::CTP)
|
58
|
+
#
|
59
|
+
# @yieldparam [Eddy::Segments::CTP]
|
60
|
+
# @return [Eddy::Segments::CTP]
|
61
|
+
def CTP()
|
62
|
+
yield(@ctp) if block_given?
|
63
|
+
return @ctp
|
64
|
+
end
|
65
|
+
|
66
|
+
# (see Eddy::TransactionSets::TS850::Loops::PID::Base)
|
67
|
+
#
|
68
|
+
# @yieldparam [Eddy::TransactionSets::TS850::Loops::PID::Repeat]
|
69
|
+
# @return [void]
|
70
|
+
def L_PID(&block)
|
71
|
+
if block_given?
|
72
|
+
@l_pid.repeat(&block)
|
73
|
+
else
|
74
|
+
raise Eddy::Errors::Error, "No block given in loop iteration"
|
75
|
+
end
|
76
|
+
return nil
|
77
|
+
end
|
78
|
+
|
79
|
+
# (see Eddy::TransactionSets::TS850::Loops::SAC::Base)
|
80
|
+
#
|
81
|
+
# @yieldparam [Eddy::TransactionSets::TS850::Loops::SAC::Repeat]
|
82
|
+
# @return [void]
|
83
|
+
def L_SAC(&block)
|
84
|
+
if block_given?
|
85
|
+
@l_sac.repeat(&block)
|
86
|
+
else
|
87
|
+
raise Eddy::Errors::Error, "No block given in loop iteration"
|
88
|
+
end
|
89
|
+
return nil
|
90
|
+
end
|
91
|
+
|
92
|
+
# (see Eddy::Segments::TXI)
|
93
|
+
#
|
94
|
+
# @yieldparam [Eddy::Segments::TXI]
|
95
|
+
# @return [Eddy::Segments::TXI]
|
96
|
+
def TXI()
|
97
|
+
yield(@txi) if block_given?
|
98
|
+
return @txi
|
99
|
+
end
|
100
|
+
|
101
|
+
# (see Eddy::TransactionSets::TS850::Loops::N9::Base)
|
102
|
+
#
|
103
|
+
# @yieldparam [Eddy::TransactionSets::TS850::Loops::N9::Repeat]
|
104
|
+
# @return [void]
|
105
|
+
def L_N9(&block)
|
106
|
+
if block_given?
|
107
|
+
@l_n9.repeat(&block)
|
108
|
+
else
|
109
|
+
raise Eddy::Errors::Error, "No block given in loop iteration"
|
110
|
+
end
|
111
|
+
return nil
|
112
|
+
end
|
45
113
|
end
|
46
114
|
|
47
115
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Eddy
|
2
|
+
module TransactionSets
|
3
|
+
module TS850
|
4
|
+
module Loops
|
5
|
+
module SAC
|
6
|
+
|
7
|
+
# ### Loop Summary:
|
8
|
+
#
|
9
|
+
# - Repeat: 25
|
10
|
+
# - Components:
|
11
|
+
# - SAC
|
12
|
+
class Base < Eddy::Models::Loop::Base
|
13
|
+
# @param store [Eddy::Data::Store]
|
14
|
+
# @return [void]
|
15
|
+
def initialize(store)
|
16
|
+
@repeat_limit = 25
|
17
|
+
super(store, Repeat)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# (see Eddy::TransactionSets::TS850::Loops::SAC::Base)
|
22
|
+
class Repeat < Eddy::Models::Loop::Repeat
|
23
|
+
# @param store [Eddy::Data::Store]
|
24
|
+
# @return [void]
|
25
|
+
def initialize(store)
|
26
|
+
@sac = Eddy::Segments::SAC.new(store)
|
27
|
+
super(
|
28
|
+
store,
|
29
|
+
@sac,
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# (see Eddy::Segments::SAC)
|
34
|
+
#
|
35
|
+
# @yieldparam [Eddy::Segments::SAC]
|
36
|
+
# @return [Eddy::Segments::SAC]
|
37
|
+
def SAC()
|
38
|
+
yield(@sac) if block_given?
|
39
|
+
return @sac
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/eddy.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
# EDI Toolkit.
|
2
|
-
module Eddy; end
|
3
|
-
|
4
1
|
require "eddy/version"
|
5
2
|
require "eddy/errors"
|
6
3
|
require "eddy/util"
|
@@ -16,3 +13,52 @@ Dir.glob(File.join(__dir__, "definitions", "segments", "**", "*.rb")).sort.each
|
|
16
13
|
Dir.glob(File.join(__dir__, "definitions", "transaction_sets", "**", "*.rb")).sort.each { |file| require file }
|
17
14
|
|
18
15
|
require "eddy/cli"
|
16
|
+
|
17
|
+
# EDI Toolkit.
|
18
|
+
module Eddy
|
19
|
+
# Configuration for Eddy.
|
20
|
+
#
|
21
|
+
# @return [Eddy::Config]
|
22
|
+
def self.config()
|
23
|
+
@config ||= Config.new
|
24
|
+
end
|
25
|
+
|
26
|
+
# Modify Eddy's current config.
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# Eddy.configure do |config|
|
30
|
+
# config.persistence_method = :file
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# @yieldparam [Eddy::Config] config current Eddy config
|
34
|
+
# @return [void]
|
35
|
+
def self.configure()
|
36
|
+
yield self.config()
|
37
|
+
end
|
38
|
+
|
39
|
+
# Persistent data used by Eddy.
|
40
|
+
#
|
41
|
+
# @return [Eddy::Data::Persistence::Base]
|
42
|
+
def self.data
|
43
|
+
return @data if defined?(@data) && !@data.nil?
|
44
|
+
case Eddy.config.persistence_method
|
45
|
+
when :memory then @data = Eddy::Data::Persistence::Memory.new()
|
46
|
+
when :file then raise NotImplementedError
|
47
|
+
when :active_record
|
48
|
+
if defined?(Rails) && defined?(Eddy::Rails)
|
49
|
+
@data = Eddy::Data::Persistence::ActiveRecord.new()
|
50
|
+
else
|
51
|
+
raise Eddy::Errors::Error, "ActiveRecord persistence method can currently only be used with Ruby on Rails"
|
52
|
+
end
|
53
|
+
else raise Eddy::Errors::Error, "Unsupported persistence method: #{Eddy.config.persistence_method}"
|
54
|
+
end
|
55
|
+
return @data
|
56
|
+
end
|
57
|
+
|
58
|
+
# Set `@data` to `nil` so that a new persistence_method can be set up.
|
59
|
+
#
|
60
|
+
# @return [void]
|
61
|
+
def self.clear_data()
|
62
|
+
@data = nil
|
63
|
+
end
|
64
|
+
end
|