efo_nelfo 0.0.3 → 0.0.4
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/lib/efo_nelfo/array.rb +1 -1
- data/lib/efo_nelfo/v40/order/line.rb +9 -1
- data/lib/efo_nelfo/v40/order/order.rb +15 -4
- data/lib/efo_nelfo/version.rb +1 -1
- data/spec/efo_nelfo_spec.rb +38 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b620fd9d75306ced61c3f6148388f8374b72571
|
4
|
+
data.tar.gz: 71f2bc405a4d973c56fe69c802e18863889ec9e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df7f92694016d934b40b32ba5ae9789b14a403026f4a9fa0ea100c873ea6eedf5bbed937901fd5417cbb2362e9a8afa000aa83cee78651b79a5a68f2d8f32ee9
|
7
|
+
data.tar.gz: ce15e9bd79b5ef9de7165241eec3ab69e23da57241f74f077ae05bd40fd29515925755a7b6a0f465082b9cfb3b2cdb33e34724ac88c49f97ab8da4dda6e0cf03
|
data/lib/efo_nelfo/array.rb
CHANGED
@@ -24,13 +24,21 @@ module EfoNelfo
|
|
24
24
|
property :splitable, alias: :DelLev, type: :boolean, default: true
|
25
25
|
property :replacable, alias: :AltKode, type: :boolean, default: true
|
26
26
|
|
27
|
-
|
27
|
+
attr_reader :text
|
28
28
|
|
29
29
|
# Returns an array with one or more elements
|
30
30
|
def to_a
|
31
31
|
[ super, text.to_a ].reject(&:empty?)
|
32
32
|
end
|
33
33
|
|
34
|
+
def text=(txt)
|
35
|
+
if txt.is_a? String
|
36
|
+
@text = EfoNelfo::V40::Order::Text.new text: txt
|
37
|
+
else
|
38
|
+
@text = txt
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
34
42
|
end
|
35
43
|
|
36
44
|
end
|
@@ -61,14 +61,25 @@ module EfoNelfo
|
|
61
61
|
property :seller_country, alias: :SLandK, limit: 2
|
62
62
|
|
63
63
|
def initialize(*args)
|
64
|
-
super
|
65
64
|
@lines = EfoNelfo::Array.new
|
65
|
+
super
|
66
66
|
end
|
67
67
|
|
68
68
|
def add(post_type)
|
69
69
|
case
|
70
|
-
when post_type.is_a?(Order::Line)
|
71
|
-
|
70
|
+
when post_type.is_a?(Order::Line)
|
71
|
+
add_order_line(post_type)
|
72
|
+
when post_type.is_a?(Order::Text)
|
73
|
+
add_text_to_order_line(post_type)
|
74
|
+
when post_type.is_a?(Hash)
|
75
|
+
add_order_line(EfoNelfo::V40::Order::Line.new(post_type))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def lines=(values)
|
80
|
+
@lines = EfoNelfo::Array.new
|
81
|
+
values.each do |item|
|
82
|
+
add item
|
72
83
|
end
|
73
84
|
end
|
74
85
|
|
@@ -88,7 +99,7 @@ module EfoNelfo
|
|
88
99
|
|
89
100
|
# Appends a order line to the order
|
90
101
|
def add_order_line(line)
|
91
|
-
line.index = lines.
|
102
|
+
line.index = lines.size + 1
|
92
103
|
lines << line
|
93
104
|
end
|
94
105
|
|
data/lib/efo_nelfo/version.rb
CHANGED
data/spec/efo_nelfo_spec.rb
CHANGED
@@ -27,6 +27,44 @@ describe EfoNelfo do
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
+
describe "assign via hash" do
|
31
|
+
let(:json) {
|
32
|
+
{ customer_id: "123",
|
33
|
+
order_number: "abc-123-efg",
|
34
|
+
seller_warehouse: "Somewhere",
|
35
|
+
label: "Some label",
|
36
|
+
lines: [
|
37
|
+
{ item_type: 1, order_number: "12345", item_name: "Foo", price_unit: "NOK" },
|
38
|
+
{ item_type: 1, order_number: "12345", item_name: "Bar", price_unit: "SEK", text: "This is freetext"},
|
39
|
+
]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
let(:order) { EfoNelfo::V40::Order.new json }
|
43
|
+
|
44
|
+
it "creates an order" do
|
45
|
+
order.must_be_instance_of EfoNelfo::V40::Order
|
46
|
+
end
|
47
|
+
|
48
|
+
it "assigns attributes" do
|
49
|
+
order.order_number.must_equal "abc-123-efg"
|
50
|
+
order.seller_warehouse.must_equal "Somewhere"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "assigns order lines" do
|
54
|
+
order.lines.size.must_equal 2
|
55
|
+
order.lines[0].index.must_equal 1
|
56
|
+
order.lines[1].index.must_equal 2
|
57
|
+
order.lines[1].item_name.must_equal "Bar"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "adds text to order lines" do
|
61
|
+
order.lines.first.text.must_be_nil
|
62
|
+
order.lines[1].text.must_be_instance_of EfoNelfo::V40::Order::Text
|
63
|
+
order.lines[1].text.to_s.must_equal "This is freetext"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
30
68
|
describe ".parse" do
|
31
69
|
|
32
70
|
it "parses CSV and does the same as .load" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: efo_nelfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gudleik Rasch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-02-
|
11
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,3 +171,4 @@ test_files:
|
|
171
171
|
- spec/samples/B650517.032.csv
|
172
172
|
- spec/samples/V4_varefil.csv
|
173
173
|
- spec/spec_helper.rb
|
174
|
+
has_rdoc:
|