xmlconv2 2.0.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.
Files changed (108) hide show
  1. data/History.txt +6 -0
  2. data/LICENCE.txt +339 -0
  3. data/Manifest.txt +107 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +28 -0
  6. data/bin/admin +65 -0
  7. data/bin/xmlconvd +19 -0
  8. data/data/grammar/i2.grammar +73 -0
  9. data/src/conversion/bdd_geh.rb +281 -0
  10. data/src/conversion/bdd_i2.rb +102 -0
  11. data/src/conversion/bdd_xml.rb +242 -0
  12. data/src/conversion/geh_bdd.rb +165 -0
  13. data/src/conversion/i2_bdd.rb +271 -0
  14. data/src/conversion/xml_bdd.rb +125 -0
  15. data/src/custom/lookandfeel.rb +47 -0
  16. data/src/i2/address.rb +33 -0
  17. data/src/i2/date.rb +37 -0
  18. data/src/i2/document.rb +26 -0
  19. data/src/i2/header.rb +24 -0
  20. data/src/i2/order.rb +44 -0
  21. data/src/i2/parser.rb +25 -0
  22. data/src/i2/position.rb +37 -0
  23. data/src/i2/record.rb +11 -0
  24. data/src/model/address.rb +20 -0
  25. data/src/model/agreement.rb +10 -0
  26. data/src/model/bdd.rb +26 -0
  27. data/src/model/bsr.rb +16 -0
  28. data/src/model/delivery.rb +15 -0
  29. data/src/model/delivery_item.rb +18 -0
  30. data/src/model/freetext_container.rb +26 -0
  31. data/src/model/id_container.rb +15 -0
  32. data/src/model/invoice.rb +18 -0
  33. data/src/model/invoice_item.rb +11 -0
  34. data/src/model/item.rb +19 -0
  35. data/src/model/item_container.rb +15 -0
  36. data/src/model/name.rb +27 -0
  37. data/src/model/part_info.rb +10 -0
  38. data/src/model/part_info_container.rb +15 -0
  39. data/src/model/party.rb +23 -0
  40. data/src/model/party_container.rb +20 -0
  41. data/src/model/price.rb +10 -0
  42. data/src/model/price_container.rb +18 -0
  43. data/src/model/transaction.rb +28 -0
  44. data/src/state/global.rb +28 -0
  45. data/src/state/global_predefine.rb +11 -0
  46. data/src/state/login.rb +38 -0
  47. data/src/state/transaction.rb +13 -0
  48. data/src/state/transactions.rb +130 -0
  49. data/src/util/application.rb +143 -0
  50. data/src/util/destination.rb +130 -0
  51. data/src/util/invoicer.rb +72 -0
  52. data/src/util/known_user.rb +16 -0
  53. data/src/util/polling_manager.rb +78 -0
  54. data/src/util/session.rb +23 -0
  55. data/src/util/transaction.rb +105 -0
  56. data/src/util/validator.rb +20 -0
  57. data/src/view/foot.rb +27 -0
  58. data/src/view/head.rb +13 -0
  59. data/src/view/login.rb +36 -0
  60. data/src/view/navigation.rb +30 -0
  61. data/src/view/navigationlink.rb +21 -0
  62. data/src/view/pager.rb +73 -0
  63. data/src/view/preformatted.rb +39 -0
  64. data/src/view/template.rb +17 -0
  65. data/src/view/transaction.rb +42 -0
  66. data/src/view/transactions.rb +90 -0
  67. data/test/mock.rb +149 -0
  68. data/test/suite.rb +16 -0
  69. data/test/test_conversion/bdd_geh.rb +533 -0
  70. data/test/test_conversion/bdd_i2.rb +314 -0
  71. data/test/test_conversion/bdd_xml.rb +556 -0
  72. data/test/test_conversion/geh_bdd.rb +372 -0
  73. data/test/test_conversion/i2_bdd.rb +804 -0
  74. data/test/test_conversion/xml_bdd.rb +203 -0
  75. data/test/test_i2/address.rb +88 -0
  76. data/test/test_i2/date.rb +49 -0
  77. data/test/test_i2/document.rb +62 -0
  78. data/test/test_i2/header.rb +39 -0
  79. data/test/test_i2/order.rb +94 -0
  80. data/test/test_i2/parser.rb +309 -0
  81. data/test/test_i2/position.rb +65 -0
  82. data/test/test_integration/geh_i2.rb +312 -0
  83. data/test/test_integration/i2_geh.rb +449 -0
  84. data/test/test_integration/i2_xml.rb +162 -0
  85. data/test/test_integration/xml_i2.rb +254 -0
  86. data/test/test_model/address.rb +35 -0
  87. data/test/test_model/agreement.rb +22 -0
  88. data/test/test_model/bdd.rb +55 -0
  89. data/test/test_model/bsr.rb +38 -0
  90. data/test/test_model/delivery.rb +79 -0
  91. data/test/test_model/delivery_item.rb +52 -0
  92. data/test/test_model/freetext_container.rb +45 -0
  93. data/test/test_model/invoice.rb +65 -0
  94. data/test/test_model/invoice_item.rb +41 -0
  95. data/test/test_model/name.rb +57 -0
  96. data/test/test_model/part_info.rb +24 -0
  97. data/test/test_model/party.rb +96 -0
  98. data/test/test_model/price.rb +24 -0
  99. data/test/test_util/application.rb +168 -0
  100. data/test/test_util/destination.rb +197 -0
  101. data/test/test_util/invoicer.rb +36 -0
  102. data/test/test_util/polling_manager.rb +111 -0
  103. data/test/test_util/transaction.rb +129 -0
  104. data/user-stories/UserStories_XmlConv2.txt +381 -0
  105. data/user-stories/doku/ABB.incoming.HTTP.invoice.xml +315 -0
  106. data/user-stories/doku/ABB.received.xml +259 -0
  107. data/user-stories/doku/BO_OrderProcessing.sxw +0 -0
  108. metadata +195 -0
data/src/i2/date.rb ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Date -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'date'
5
+
6
+ module XmlConv
7
+ module I2
8
+ class Date < ::Date
9
+ attr_accessor :code
10
+ class << self
11
+ def from_date(date)
12
+ self.new(date.year, date.month, date.day)
13
+ end
14
+ end
15
+ def to_s
16
+ # NOTE
17
+ # DTSTTCPW here and now is to allow only two possibilities for
18
+ # I2::Date:
19
+ # Order-Date on the Order-Level (300:4\n301:strftime) and
20
+ # Delivery-Date on the Position-Level (540:2\n540:strftime)
21
+ # This code is likely to change.
22
+ fmtd = strftime("%Y%m%d")
23
+ if(@code == :delivery)
24
+ <<-EOS
25
+ 540:2
26
+ 541:#{fmtd}
27
+ EOS
28
+ else
29
+ <<-EOS
30
+ 300:4
31
+ 301:#{fmtd}
32
+ EOS
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Document -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'i2/header'
5
+ require 'i2/order'
6
+
7
+ module XmlConv
8
+ module I2
9
+ class Document
10
+ attr_accessor :header
11
+ attr_reader :orders
12
+ def initialize
13
+ @orders = []
14
+ end
15
+ def add_order(order)
16
+ @orders.push(order)
17
+ end
18
+ def filename
19
+ @header.filename
20
+ end
21
+ def to_s
22
+ ([@header] + @orders).join
23
+ end
24
+ end
25
+ end
26
+ end
data/src/i2/header.rb ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Header -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module I2
6
+ class Header
7
+ attr_accessor :recipient_id, :filename
8
+ def initialize
9
+ @recipient_id = 'EPIN_PL'
10
+ time = Time.now
11
+ msec = sprintf('%03i', (time.to_f * 1000).to_i % 100)
12
+ @filename = time.strftime("#{@recipient_id}_%Y%m%d%H%M%S#{msec}.dat")
13
+ end
14
+ def to_s
15
+ <<-EOS
16
+ 001:#{@recipient_id}
17
+ 002:ORDERX
18
+ 003:220
19
+ 010:#{@filename}
20
+ EOS
21
+ end
22
+ end
23
+ end
24
+ end
data/src/i2/order.rb ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Order -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module I2
6
+ class Order
7
+ I2_DELIVERY_CODES = {
8
+ :pickup => '070',
9
+ :delivery => '060',
10
+ :camion => '010',
11
+ }
12
+ attr_accessor :sender_id, :delivery_id, :terms_cond
13
+ attr_reader :addresses, :dates, :positions
14
+ def initialize
15
+ @addresses = []
16
+ @dates = []
17
+ @positions = []
18
+ end
19
+ def add_address(address)
20
+ @addresses.push(address)
21
+ end
22
+ def add_date(date)
23
+ @dates.push(date)
24
+ end
25
+ def add_position(position)
26
+ @positions.push(position)
27
+ end
28
+ def to_s
29
+ output = <<-EOS
30
+ 100:#{@sender_id}
31
+ 101:#{@delivery_id}
32
+ EOS
33
+ @addresses.each { |addr| output << addr.to_s }
34
+ output << "237:61\n"
35
+ if(terms = I2_DELIVERY_CODES[@terms_cond])
36
+ output << sprintf("238:%s\n", terms)
37
+ end
38
+ @dates.each { |date| output << date.to_s }
39
+ @positions.each { |pos| output << pos.to_s }
40
+ output
41
+ end
42
+ end
43
+ end
44
+ end
data/src/i2/parser.rb ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Parser -- xmlconv2 -- 28.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'rockit/rockit'
5
+
6
+ module XmlConv
7
+ module I2
8
+ GRAMMAR_DIR = File.expand_path('../../data/grammar',
9
+ File.dirname(__FILE__))
10
+ def cached_parser
11
+ grammar_path = File.expand_path('i2.grammar', GRAMMAR_DIR)
12
+ parser_path = File.expand_path('i2_parser.rb', GRAMMAR_DIR)
13
+ old_path = File.expand_path('i2.grammar.old', GRAMMAR_DIR)
14
+ src = File.read(grammar_path)
15
+ unless(File.exists?(old_path) && File.read(old_path) == src)
16
+ File.delete(old_path) if File.exists?(old_path)
17
+ Parse.generate_parser_from_file_to_file(grammar_path, parser_path, "make_i2_parser", 'XmlConv')
18
+ File.open(old_path, 'w') { |f| f << src }
19
+ end
20
+ require parser_path
21
+ XmlConv.make_i2_parser
22
+ end
23
+ module_function :cached_parser
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Position -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'i2/date'
5
+
6
+ module XmlConv
7
+ module I2
8
+ class Position
9
+ attr_accessor :number, :article_ean, :qty, :customer_id, :price, :unit
10
+ attr_reader :delivery_date
11
+ def delivery_date=(date)
12
+ date.code = :delivery
13
+ @delivery_date = date
14
+ end
15
+ def to_s
16
+ output = <<-EOS
17
+ 500:#{@number}
18
+ 501:#{@article_ean}
19
+ EOS
20
+ if(@customer_id)
21
+ output << sprintf("502:%s\n", @customer_id)
22
+ end
23
+ output << sprintf("520:%s\n", @qty)
24
+ if(@unit)
25
+ output << sprintf("521:%s\n", @unit)
26
+ end
27
+ if(@delivery_date.is_a?(I2::Date))
28
+ output << @delivery_date.to_s
29
+ end
30
+ if(@price)
31
+ output << sprintf("604:%s\n", @price)
32
+ end
33
+ output
34
+ end
35
+ end
36
+ end
37
+ end
data/src/i2/record.rb ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Record -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module I2
6
+ class Record
7
+ def push(num, str)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # AddressLine -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ class Address
7
+ attr_accessor :city, :zip_code, :country
8
+ attr_reader :lines
9
+ def initialize
10
+ @lines = []
11
+ end
12
+ def add_line(line)
13
+ lines.push(line)
14
+ end
15
+ def size
16
+ @lines.size
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::Agreement -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ class Agreement
7
+ attr_accessor :terms_cond
8
+ end
9
+ end
10
+ end
data/src/model/bdd.rb ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # Bdd -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ class Bdd
7
+ attr_accessor :bsr
8
+ attr_reader :deliveries, :invoices
9
+ def initialize
10
+ @deliveries = []
11
+ @invoices = []
12
+ end
13
+ def add_delivery(delivery)
14
+ @deliveries.push(delivery)
15
+ end
16
+ def add_invoice(invoice)
17
+ @invoices.push(invoice)
18
+ end
19
+ def invoiced_amount
20
+ @invoices.inject(0) { |memo, invoice|
21
+ memo + invoice.get_price('SummePositionen').amount.to_f
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
data/src/model/bsr.rb ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # Bsr -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/party_container'
5
+
6
+ module XmlConv
7
+ module Model
8
+ class Bsr
9
+ include PartyContainer
10
+ attr_accessor :timestamp, :noun, :verb
11
+ def bsr_id
12
+ @customer.party_id unless(@customer.nil?)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # Delivery -- xmlconv -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/transaction'
5
+
6
+ module XmlConv
7
+ module Model
8
+ class Delivery < Transaction
9
+ attr_accessor :bsr
10
+ def bsr_id
11
+ @bsr.bsr_id unless(@bsr.nil?)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # DeliveryItem -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/item'
5
+
6
+ module XmlConv
7
+ module Model
8
+ class DeliveryItem < Item
9
+ attr_accessor :delivery_date
10
+ def et_nummer_id
11
+ self.ids['ET-NUMMER']
12
+ end
13
+ def customer_id
14
+ self.ids['LIEFERANTENARTIKEL']
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ # FreeTextContainer -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ class FreeText < String
7
+ attr_accessor :type
8
+ def <<(other)
9
+ if(empty? || other.empty?)
10
+ super
11
+ else
12
+ super("\n" << other)
13
+ end
14
+ end
15
+ end
16
+ module FreeTextContainer
17
+ attr_reader :free_text
18
+ def add_free_text(type, text)
19
+ @free_text ||= FreeText.new
20
+ @free_text.type = type
21
+ @free_text << text.to_s
22
+ @free_text
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # IdContainer -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ module IdContainer
7
+ def add_id(domain, value)
8
+ self.ids.store(domain, value)
9
+ end
10
+ def ids
11
+ @ids ||= {}
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::Invoice -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/transaction'
5
+
6
+ module XmlConv
7
+ module Model
8
+ class Invoice < Transaction
9
+ attr_reader :delivery_id, :invoice_id
10
+ def add_delivery_id(domain, idstr)
11
+ @delivery_id = [domain, idstr]
12
+ end
13
+ def add_invoice_id(domain, idstr)
14
+ @invoice_id = [domain, idstr]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::InvoiceItem -- xmlconv2 -- 23.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/item'
5
+
6
+ module XmlConv
7
+ module Model
8
+ class InvoiceItem < Item
9
+ end
10
+ end
11
+ end
data/src/model/item.rb ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::Item -- xmlconv2 -- 23.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'model/id_container'
5
+ require 'model/freetext_container'
6
+ require 'model/part_info_container'
7
+ require 'model/price_container'
8
+
9
+ module XmlConv
10
+ module Model
11
+ class Item
12
+ attr_accessor :line_no, :qty, :unit
13
+ include IdContainer
14
+ include FreeTextContainer
15
+ include PartInfoContainer
16
+ include PriceContainer
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # Model::ItemContainer -- xmlconv2 -- 22.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module Model
6
+ module ItemContainer
7
+ def add_item(item)
8
+ self.items.push(item)
9
+ end
10
+ def items
11
+ @items ||= []
12
+ end
13
+ end
14
+ end
15
+ end