milkfarm-onix 0.8.12 → 0.8.13

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.8.13 (18 January 2012)
2
+ - Add Complexity composite
3
+
1
4
  v0.8.12 (28 November 2011)
2
5
  - Cherry pick yob's commits from 13 April to 7 November:
3
6
  - Relax activesupport dependency to work with rails 3 or 3.1
@@ -79,6 +79,7 @@ require "onix/contributor"
79
79
  require "onix/language"
80
80
  require "onix/subject"
81
81
  require "onix/audience_range"
82
+ require "onix/complexity"
82
83
  require "onix/imprint"
83
84
  require "onix/publisher"
84
85
  require "onix/other_text"
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+
3
+ module ONIX
4
+ class Complexity
5
+ include ROXML
6
+ extend ONIX::ListWriter
7
+ include ONIX::Inflector
8
+
9
+ xml_name "Complexity"
10
+
11
+ xml_accessor :complexity_scheme_identifier, :from => "ComplexitySchemeIdentifier", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
12
+ xml_accessor :complexity_code, :from => "ComplexityCode"
13
+ list_writer :complexity_scheme_identifier, :list => 32
14
+ end
15
+ end
@@ -28,6 +28,7 @@ module ONIX
28
28
  xml_accessor :subjects, :from => "Subject", :as => [ONIX::Subject]
29
29
  xml_accessor :audience_code, :from => "AudienceCode", :to_xml => ONIX::Formatters.two_digit
30
30
  xml_accessor :audience_ranges, :from => "AudienceRange", :as => [ONIX::AudienceRange]
31
+ xml_accessor :complexities, :from => "Complexity", :as => [ONIX::Complexity]
31
32
  xml_accessor :text, :from => "OtherText", :as => [ONIX::OtherText]
32
33
  xml_accessor :media_files, :from => "MediaFile", :as => [ONIX::MediaFile]
33
34
  xml_accessor :imprints, :from => "Imprint", :as => [ONIX::Imprint]
@@ -69,6 +70,7 @@ module ONIX
69
70
  self.websites = []
70
71
  self.subjects = []
71
72
  self.audience_ranges = []
73
+ self.complexities = []
72
74
  self.text = []
73
75
  self.languages = []
74
76
  self.media_files = []
@@ -1,3 +1,3 @@
1
1
  module ONIX
2
- VERSION = "0.8.12"
2
+ VERSION = "0.8.13"
3
3
  end
@@ -0,0 +1,47 @@
1
+ # coding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper.rb'
4
+
5
+ describe ONIX::Complexity do
6
+
7
+ before(:each) do
8
+ data_path = File.join(File.dirname(__FILE__), "..", "data")
9
+ file1 = File.join(data_path, "complexity.xml")
10
+ @doc = Nokogiri::XML::Document.parse(File.read(file1))
11
+ @root = @doc.root
12
+ end
13
+
14
+ it "should correctly convert to a string" do
15
+ t = ONIX::Complexity.from_xml(@root.to_s)
16
+ t.to_xml.to_s[0,12].should eql("<Complexity>")
17
+ end
18
+
19
+ it "should provide read access to first level attributes" do
20
+ t = ONIX::Complexity.from_xml(@root.to_s)
21
+ t.complexity_scheme_identifier.should eql(2)
22
+ t.complexity_code.should eql("640")
23
+ end
24
+
25
+ it "should provide write access to first level attributes" do
26
+ t = ONIX::Complexity.new
27
+
28
+ t.complexity_scheme_identifier = 1
29
+ t.to_xml.to_s.include?("<ComplexitySchemeIdentifier>01</ComplexitySchemeIdentifier>").should be_true
30
+
31
+ t.complexity_code = "480"
32
+ t.to_xml.to_s.include?("<ComplexityCode>480</ComplexityCode>").should be_true
33
+ end
34
+
35
+ it "should raise error writing complexity_scheme_identifier value not in list" do
36
+ t = ONIX::Complexity.new
37
+ lambda {t.complexity_scheme_identifier = 999}.should raise_error
38
+ lambda {ONIX::Complexity.new(:complexity_scheme_identifier => 999)}.should raise_error
39
+ end
40
+
41
+ it "should properly initialize attributes when calling new" do
42
+ t = ONIX::Complexity.new(:complexity_scheme_identifier => 1, :complexity_code => "value")
43
+ t.complexity_scheme_identifier.should eql(1)
44
+ t.complexity_code.should eql("value")
45
+ end
46
+
47
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milkfarm-onix
3
3
  version: !ruby/object:Gem::Version
4
- hash: 39
4
+ hash: 37
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 12
10
- version: 0.8.12
9
+ - 13
10
+ version: 0.8.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Healy
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-11-29 00:00:00 Z
19
+ date: 2012-01-19 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: roxml
@@ -123,6 +123,7 @@ files:
123
123
  - lib/onix/apa_product.rb
124
124
  - lib/onix/audience_range.rb
125
125
  - lib/onix/code_list_extractor.rb
126
+ - lib/onix/complexity.rb
126
127
  - lib/onix/contributor.rb
127
128
  - lib/onix/discount_coded.rb
128
129
  - lib/onix/discount_codeds.rb
@@ -341,6 +342,7 @@ files:
341
342
  - CHANGELOG
342
343
  - spec/apa_product_spec.rb
343
344
  - spec/audience_range_spec.rb
345
+ - spec/complexity_spec.rb
344
346
  - spec/contributor_spec.rb
345
347
  - spec/discount_coded_spec.rb
346
348
  - spec/discount_codeds_spec.rb
@@ -416,6 +418,7 @@ summary: A convenient mapping between Ruby objects and the ONIX XML specificatio
416
418
  test_files:
417
419
  - spec/apa_product_spec.rb
418
420
  - spec/audience_range_spec.rb
421
+ - spec/complexity_spec.rb
419
422
  - spec/contributor_spec.rb
420
423
  - spec/discount_coded_spec.rb
421
424
  - spec/discount_codeds_spec.rb