onix 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.markdown +1 -0
- data/lib/onix.rb +1 -1
- data/lib/onix/apa_product.rb +18 -6
- data/lib/onix/supply_detail.rb +1 -0
- data/spec/apa_product_spec.rb +59 -0
- data/spec/supply_detail_spec.rb +3 -0
- metadata +4 -2
data/CHANGELOG
CHANGED
data/README.markdown
CHANGED
data/lib/onix.rb
CHANGED
data/lib/onix/apa_product.rb
CHANGED
@@ -276,7 +276,7 @@ module ONIX
|
|
276
276
|
|
277
277
|
# retrieve the supplier name
|
278
278
|
def supplier_name
|
279
|
-
composite = product.
|
279
|
+
composite = product.supply_details.first
|
280
280
|
composite.nil? ? nil : composite.supplier_name
|
281
281
|
end
|
282
282
|
|
@@ -288,7 +288,7 @@ module ONIX
|
|
288
288
|
|
289
289
|
# retrieve the supplier phone number
|
290
290
|
def supplier_phone
|
291
|
-
composite = product.
|
291
|
+
composite = product.supply_details.first
|
292
292
|
composite.nil? ? nil : composite.telephone_number
|
293
293
|
end
|
294
294
|
|
@@ -300,7 +300,7 @@ module ONIX
|
|
300
300
|
|
301
301
|
# retrieve the supplier fax number
|
302
302
|
def supplier_fax
|
303
|
-
composite = product.
|
303
|
+
composite = product.supply_details.first
|
304
304
|
composite.nil? ? nil : composite.fax_number
|
305
305
|
end
|
306
306
|
|
@@ -312,7 +312,7 @@ module ONIX
|
|
312
312
|
|
313
313
|
# retrieve the supplier email address
|
314
314
|
def supplier_email
|
315
|
-
composite = product.
|
315
|
+
composite = product.supply_details.first
|
316
316
|
composite.nil? ? nil : composite.email_address
|
317
317
|
end
|
318
318
|
|
@@ -324,7 +324,7 @@ module ONIX
|
|
324
324
|
|
325
325
|
# retrieve the supply country code
|
326
326
|
def supply_country
|
327
|
-
composite = product.
|
327
|
+
composite = product.supply_details.first
|
328
328
|
composite.nil? ? nil : composite.supply_to_country
|
329
329
|
end
|
330
330
|
|
@@ -336,7 +336,7 @@ module ONIX
|
|
336
336
|
|
337
337
|
# retrieve the product availability code
|
338
338
|
def product_availability
|
339
|
-
composite = product.
|
339
|
+
composite = product.supply_details.first
|
340
340
|
composite.nil? ? nil : composite.product_availability
|
341
341
|
end
|
342
342
|
|
@@ -390,6 +390,18 @@ module ONIX
|
|
390
390
|
composite.on_order = num
|
391
391
|
end
|
392
392
|
|
393
|
+
# retrieve the supplier phone number
|
394
|
+
def pack_quantity
|
395
|
+
composite = product.supply_details.first
|
396
|
+
composite.nil? ? nil : composite.pack_quantity
|
397
|
+
end
|
398
|
+
|
399
|
+
# set a new supplier phone number
|
400
|
+
def pack_quantity=(val)
|
401
|
+
composite = find_or_create_supply_detail
|
402
|
+
composite.pack_quantity = val.to_i
|
403
|
+
end
|
404
|
+
|
393
405
|
# retrieve the rrp excluding any sales tax
|
394
406
|
def rrp_exc_sales_tax
|
395
407
|
price_get(1).andand.price_amount
|
data/lib/onix/supply_detail.rb
CHANGED
@@ -20,6 +20,7 @@ module ONIX
|
|
20
20
|
xml_accessor :availability_status_code, :from => "AvailabilityStatusCode", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
|
21
21
|
xml_accessor :product_availability, :from => "ProductAvailability", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
|
22
22
|
xml_accessor :stock, :from => "Stock", :as => [ONIX::Stock]
|
23
|
+
xml_accessor :pack_quantity, :from => "PackQuantity", :as => Fixnum
|
23
24
|
xml_accessor :prices, :from => "Price", :as => [ONIX::Price]
|
24
25
|
|
25
26
|
def initialize
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
4
|
+
|
5
|
+
require 'onix'
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
context "ONIX::APAProduct" do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@data_path = File.join(File.dirname(__FILE__),"..","data")
|
12
|
+
file1 = File.join(@data_path, "product.xml")
|
13
|
+
@doc = LibXML::XML::Document.file(file1)
|
14
|
+
@product_node = @doc.root
|
15
|
+
end
|
16
|
+
|
17
|
+
specify "should provide read access to attibutes" do
|
18
|
+
@product = ONIX::Product.from_xml(@product_node.to_s)
|
19
|
+
@apa = ONIX::APAProduct.new(@product)
|
20
|
+
|
21
|
+
@apa.record_reference.should eql("365-9780194351898")
|
22
|
+
@apa.notification_type.should eql(3)
|
23
|
+
@apa.product_form.should eql("BC")
|
24
|
+
@apa.number_of_pages.should eql(100)
|
25
|
+
@apa.bic_main_subject.should eql("EB")
|
26
|
+
@apa.publishing_status.should eql(4)
|
27
|
+
@apa.publication_date.should eql(Date.civil(1998,9,1))
|
28
|
+
@apa.pack_quantity.should eql(12)
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "should provide write access to attibutes" do
|
32
|
+
apa = ONIX::APAProduct.new
|
33
|
+
|
34
|
+
apa.notification_type = 3
|
35
|
+
apa.to_xml.to_s.include?("<NotificationType>03</NotificationType>").should be_true
|
36
|
+
|
37
|
+
apa.record_reference = "365-9780194351898"
|
38
|
+
apa.to_xml.to_s.include?("<RecordReference>365-9780194351898</RecordReference>").should be_true
|
39
|
+
|
40
|
+
apa.product_form = "BC"
|
41
|
+
apa.to_xml.to_s.include?("<ProductForm>BC</ProductForm>").should be_true
|
42
|
+
|
43
|
+
apa.number_of_pages = 100
|
44
|
+
apa.to_xml.to_s.include?("<NumberOfPages>100</NumberOfPages>").should be_true
|
45
|
+
|
46
|
+
apa.bic_main_subject = "EB"
|
47
|
+
apa.to_xml.to_s.include?("<BICMainSubject>EB</BICMainSubject>").should be_true
|
48
|
+
|
49
|
+
apa.publishing_status = 4
|
50
|
+
apa.to_xml.to_s.include?("<PublishingStatus>04</PublishingStatus>").should be_true
|
51
|
+
|
52
|
+
apa.publication_date = Date.civil(1998,9,1)
|
53
|
+
apa.to_xml.to_s.include?("<PublicationDate>19980901</PublicationDate>").should be_true
|
54
|
+
|
55
|
+
apa.pack_quantity = 12
|
56
|
+
apa.to_xml.to_s.include?("<PackQuantity>12</PackQuantity>").should be_true
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
data/spec/supply_detail_spec.rb
CHANGED
@@ -25,6 +25,7 @@ context "ONIX::SupplyDetail" do
|
|
25
25
|
sd.product_availability.should eql(21)
|
26
26
|
sd.stock.should be_a_kind_of(Array)
|
27
27
|
sd.stock.size.should eql(1)
|
28
|
+
sd.pack_quantity.should eql(16)
|
28
29
|
sd.prices.should be_a_kind_of(Array)
|
29
30
|
sd.prices.size.should eql(1)
|
30
31
|
end
|
@@ -44,6 +45,8 @@ context "ONIX::SupplyDetail" do
|
|
44
45
|
sd.product_availability = 3
|
45
46
|
sd.to_xml.to_s.include?("<ProductAvailability>03</ProductAvailability>").should be_true
|
46
47
|
|
48
|
+
sd.pack_quantity = 12
|
49
|
+
sd.to_xml.to_s.include?("<PackQuantity>12</PackQuantity>").should be_true
|
47
50
|
end
|
48
51
|
|
49
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-22 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- spec/supply_detail_spec.rb
|
134
134
|
- spec/title_spec.rb
|
135
135
|
- spec/normaliser_spec.rb
|
136
|
+
- spec/apa_product_spec.rb
|
136
137
|
has_rdoc: true
|
137
138
|
homepage: http://github.com/yob/onix/tree/master
|
138
139
|
licenses: []
|
@@ -185,3 +186,4 @@ test_files:
|
|
185
186
|
- spec/supply_detail_spec.rb
|
186
187
|
- spec/title_spec.rb
|
187
188
|
- spec/normaliser_spec.rb
|
189
|
+
- spec/apa_product_spec.rb
|