editx 0.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.
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'editx'
6
+
7
+ context "EDItX::Order" do
8
+
9
+ before(:each) do
10
+ data_path = File.join(File.dirname(__FILE__),"data")
11
+ file1 = File.join(data_path, "order_1_2.xml")
12
+ @doc = LibXML::XML::Document.file(file1)
13
+ @root = @doc.root
14
+ end
15
+
16
+ specify "should correctly convert to a string" do
17
+ order = EDItX::Order.from_xml(@root.to_s)
18
+ order.to_s[0,6].should eql("<Order")
19
+ end
20
+
21
+ specify "should provide read access to version number" do
22
+ order = EDItX::Order.from_xml(@root.to_s)
23
+
24
+ order.version.should eql(BigDecimal.new("1.2"))
25
+ end
26
+
27
+ specify "should provide write access to version number" do
28
+ order = EDItX::Order.from_xml(@root.to_s)
29
+
30
+ order.version = BigDecimal.new("1.1")
31
+ order.to_xml.to_s.include?("<Order version=\"1.1\">").should be_true
32
+ end
33
+
34
+ specify "should provide read access to header attibutes" do
35
+ order = EDItX::Order.from_xml(@root.to_s)
36
+
37
+ order.order_number.should eql("3594")
38
+ order.issue_date_time.should eql(DateTime.civil(2008, 6, 24, 4, 14))
39
+ order.references.should be_a_kind_of(Array)
40
+ order.references.size.should eql(1)
41
+ order.purpose_code.should eql("Original")
42
+ order.currency_code.should eql("AUD")
43
+ order.country_code.should eql("AU")
44
+ order.dates.should be_a_kind_of(Array)
45
+ order.dates.size.should eql(1)
46
+ order.fill_terms_code.should eql("FillPartBackorderRemainderShipAsAvailable")
47
+ order.buyer_party.should be_a_kind_of(EDItX::Order::Party)
48
+ order.seller_party.should be_a_kind_of(EDItX::Order::Party)
49
+ order.ship_to_party.should be_a_kind_of(EDItX::Order::Party)
50
+ order.bill_to_party.should be_a_kind_of(EDItX::Order::Party)
51
+ # TODO: ship_from
52
+ # TODO: qualifiers
53
+ # TODO: delivery
54
+ order.shipping_instructions_code.should eql("ShipCombined")
55
+ order.invoice_instructions_code.should eql("InvoiceCombined")
56
+ # TODO: payment_terms
57
+ # TODO: payment_terms_coded
58
+ order.discount_percentage.should eql(BigDecimal.new("30"))
59
+ # TODO: additional_service
60
+ # TODO: messages
61
+ end
62
+
63
+ specify "should provide write access to header attibutes" do
64
+ order = EDItX::Order.new
65
+
66
+ order.order_number = "1234"
67
+ order.to_xml.to_s.include?("<OrderNumber>1234</OrderNumber>").should be_true
68
+
69
+ order.issue_date_time = DateTime.civil(2009, 3, 10, 00, 15)
70
+ order.to_xml.to_s.include?("<IssueDateTime>20090310</IssueDateTime>").should be_true
71
+
72
+ end
73
+
74
+ specify "should provide read access to order lines" do
75
+ order = EDItX::Order.from_xml(@root.to_s)
76
+
77
+ order.items.should be_a_kind_of(Array)
78
+ order.items.size.should eql(178)
79
+ end
80
+
81
+ specify "should provide write access to order lines"
82
+
83
+ specify "should provide read access to summary values" do
84
+ order = EDItX::Order.from_xml(@root.to_s)
85
+
86
+ order.number_of_lines.should eql(179)
87
+ order.units_ordered.should eql(25)
88
+ end
89
+
90
+ specify "should provide write access to summary values"
91
+
92
+ specify "should be invalid if missing required fields" do
93
+ order = EDItX::Order.new
94
+ order.valid?.should be_false
95
+ end
96
+
97
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'editx'
6
+
7
+ context "spec/data/order_1_1.xml" do
8
+
9
+ before(:each) do
10
+ @schema_dir = File.join(File.dirname(__FILE__),"..", "schemas")
11
+ @schema_path = File.join(@schema_dir, "order_1_1.xsd")
12
+ @data_dir = File.join(File.dirname(__FILE__),"data")
13
+ @file_path = File.join(@data_dir, "order_1_1.xml")
14
+ end
15
+
16
+ specify "should be a valid EDItX Trade Order 1.1 file" do
17
+ system("xmllint --schema #{@schema_path} #{@file_path} &> /dev/null")
18
+ $?.exitstatus.should eql(0)
19
+ end
20
+
21
+ end
22
+
23
+ context "spec/data/order_1_2.xml" do
24
+
25
+ before(:each) do
26
+ @schema_dir = File.join(File.dirname(__FILE__),"..", "schemas")
27
+ @schema_path = File.join(@schema_dir, "order_1_2.xsd")
28
+ @data_dir = File.join(File.dirname(__FILE__),"data")
29
+ @file_path = File.join(@data_dir, "order_1_2.xml")
30
+ end
31
+
32
+ specify "should be a valid EDItX Trade Order 1.2 file" do
33
+ system("xmllint --schema #{@schema_path} #{@file_path} &> /dev/null")
34
+ $?.exitstatus.should eql(0)
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: editx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Healy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-23 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: roxml
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.5.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: libxml-ruby
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.8
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: andand
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: A convient mapping between ruby objects and the various EDItX XML specifications
46
+ email: jimmy@deefa.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files: []
52
+
53
+ files:
54
+ - lib/editx/order/reference_coded.rb
55
+ - lib/editx/order/date_coded.rb
56
+ - lib/editx/order/party.rb
57
+ - lib/editx/order/item_detail.rb
58
+ - lib/editx/order/returns_conditions.rb
59
+ - lib/editx/order/product_id.rb
60
+ - lib/editx/order/price.rb
61
+ - lib/editx/order/order_item_qualifier_coded.rb
62
+ - lib/editx/order/message.rb
63
+ - lib/editx/order/discount_detail.rb
64
+ - lib/editx/order/returns_condition_coded.rb
65
+ - lib/editx/order/discount_part.rb
66
+ - lib/editx/order.rb
67
+ - lib/editx.rb
68
+ - README.markdown
69
+ - CHANGELOG
70
+ - schemas/order_1_1.xsd
71
+ - schemas/order_1_2.xsd
72
+ - schemas/editx_codelists.xsd
73
+ has_rdoc: true
74
+ homepage: http://github.com/yob/editx/tree/master
75
+ post_install_message:
76
+ rdoc_options:
77
+ - --title
78
+ - EDItX - Working with the EDItX XML specs
79
+ - --line-numbers
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ version:
94
+ requirements: []
95
+
96
+ rubyforge_project: rbook
97
+ rubygems_version: 1.3.1
98
+ signing_key:
99
+ specification_version: 2
100
+ summary: A convient mapping between ruby objects and the various EDItX XML specifications
101
+ test_files:
102
+ - spec/order_spec.rb
103
+ - spec/sample_data_spec.rb