pb_core 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pb_core/v2/base.rb +65 -3
- data/lib/pb_core/v2/instantiation_document.rb +7 -13
- data/lib/pb_core/version.rb +1 -1
- data/lib/pb_core.rb +6 -0
- metadata +4 -4
data/lib/pb_core/v2/base.rb
CHANGED
@@ -40,21 +40,55 @@ module PBCore
|
|
40
40
|
def self.collection_group; include PBCore::V2::CollectionGroup; end
|
41
41
|
|
42
42
|
def self.instantiation_group; include PBCore::V2::InstantiationGroup; end
|
43
|
+
|
44
|
+
def detect_element(elements_name, atr=:type, values=nil, use_first=true)
|
45
|
+
l = Array(self.send(elements_name))
|
46
|
+
values = Array(values)
|
47
|
+
return nil if l.size <= 0
|
48
|
+
|
49
|
+
e = nil
|
50
|
+
Array(values).each{|v|
|
51
|
+
e = l.detect{|i| element_value(i, atr) == standardize(v) }
|
52
|
+
break if e
|
53
|
+
}
|
54
|
+
e = l.first if use_first && e.nil?
|
55
|
+
return e
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def element_value(ele, atr)
|
61
|
+
standardize(ele.send(atr))
|
62
|
+
end
|
63
|
+
|
64
|
+
def standardize(val)
|
65
|
+
v = val
|
66
|
+
if val && val.is_a?(String)
|
67
|
+
v = val.downcase
|
68
|
+
v = nil if v == ''
|
69
|
+
end
|
70
|
+
v
|
71
|
+
end
|
72
|
+
|
43
73
|
end
|
44
74
|
|
75
|
+
|
76
|
+
|
45
77
|
class Identifier < PBCore::V2::Base
|
46
78
|
source_version_group
|
79
|
+
value :value
|
47
80
|
end
|
48
81
|
|
49
82
|
class Type < PBCore::V2::Base
|
50
83
|
source_version_group
|
84
|
+
value :value
|
51
85
|
end
|
52
86
|
|
53
87
|
class Title < PBCore::V2::Base
|
54
88
|
source_version_group
|
55
89
|
start_end_time_group
|
56
|
-
|
57
90
|
attribute :titleType, :as => :type
|
91
|
+
value :value
|
58
92
|
end
|
59
93
|
|
60
94
|
class Description < PBCore::V2::Base
|
@@ -73,10 +107,25 @@ module PBCore
|
|
73
107
|
attribute :segmentTypeAnnotation, :as => :segment_type_annotation
|
74
108
|
|
75
109
|
attribute :annotation
|
110
|
+
|
111
|
+
value :value
|
76
112
|
end
|
77
113
|
|
78
114
|
class DateType < PBCore::V2::Base
|
79
115
|
attribute :dateType, :as => :type
|
116
|
+
|
117
|
+
value :value
|
118
|
+
|
119
|
+
def date(format=nil)
|
120
|
+
if format
|
121
|
+
DateTime.strptime(self.value, format)
|
122
|
+
elsif PBCore.config[:date_format]
|
123
|
+
DateTime.strptime(self.value, PBCore.config[:date_format])
|
124
|
+
else
|
125
|
+
DateTime.parse(self.value)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
80
129
|
end
|
81
130
|
|
82
131
|
class Subject < PBCore::V2::Base
|
@@ -84,11 +133,15 @@ module PBCore
|
|
84
133
|
start_end_time_group
|
85
134
|
|
86
135
|
attribute :subjectType, :as => :type
|
136
|
+
|
137
|
+
value :value
|
87
138
|
end
|
88
139
|
|
89
140
|
class Genre < PBCore::V2::Base
|
90
141
|
source_version_group
|
91
142
|
start_end_time_group
|
143
|
+
|
144
|
+
value :value
|
92
145
|
end
|
93
146
|
|
94
147
|
class Relation < PBCore::V2::Base
|
@@ -99,6 +152,7 @@ module PBCore
|
|
99
152
|
class CoverageInfo < PBCore::V2::Base
|
100
153
|
source_version_group
|
101
154
|
start_end_time_group
|
155
|
+
value :value
|
102
156
|
end
|
103
157
|
|
104
158
|
class Coverage < PBCore::V2::Base
|
@@ -112,6 +166,8 @@ module PBCore
|
|
112
166
|
attribute :affiliation
|
113
167
|
attribute :ref
|
114
168
|
attribute :annotation
|
169
|
+
|
170
|
+
value :value
|
115
171
|
end
|
116
172
|
|
117
173
|
class Creator < PBCore::V2::Base
|
@@ -123,11 +179,13 @@ module PBCore
|
|
123
179
|
source_version_group
|
124
180
|
|
125
181
|
attribute :portrayal
|
182
|
+
|
183
|
+
value :value
|
126
184
|
end
|
127
185
|
|
128
186
|
class Contributor < PBCore::V2::Base
|
129
|
-
element '
|
130
|
-
element '
|
187
|
+
element 'contributor', :as => :name, :class => PBCore::V2::Affiliate
|
188
|
+
element 'contributorRole', :as => :role, :class => PBCore::V2::ContributorType
|
131
189
|
end
|
132
190
|
|
133
191
|
class Publisher < PBCore::V2::Base
|
@@ -137,6 +195,7 @@ module PBCore
|
|
137
195
|
|
138
196
|
class Annotated < PBCore::V2::Base
|
139
197
|
attribute :annotation
|
198
|
+
value :value
|
140
199
|
end
|
141
200
|
|
142
201
|
class Rights < PBCore::V2::Base
|
@@ -150,17 +209,20 @@ module PBCore
|
|
150
209
|
class Measurement < PBCore::V2::Base
|
151
210
|
attribute :annotation
|
152
211
|
attribute :unitsOfMeasure, :as => :units
|
212
|
+
value :value
|
153
213
|
end
|
154
214
|
|
155
215
|
class Standard < PBCore::V2::Base
|
156
216
|
source_version_group
|
157
217
|
|
158
218
|
attribute :profile
|
219
|
+
value :value
|
159
220
|
end
|
160
221
|
|
161
222
|
class Annotation < PBCore::V2::Base
|
162
223
|
attribute :annotationType, :as => :annotation_type
|
163
224
|
attribute :ref
|
225
|
+
value :value
|
164
226
|
end
|
165
227
|
|
166
228
|
class ExtensionWrap < PBCore::V2::Base
|
@@ -3,18 +3,6 @@ require 'pb_core/v2/base'
|
|
3
3
|
module PBCore
|
4
4
|
module V2
|
5
5
|
|
6
|
-
class InstantiationType < PBCore::V2::Base
|
7
|
-
end
|
8
|
-
|
9
|
-
class InstantiationPart < PBCore::V2::InstantiationType
|
10
|
-
end
|
11
|
-
|
12
|
-
class Instantiation < PBCore::V2::InstantiationType
|
13
|
-
end
|
14
|
-
|
15
|
-
class InstantiationDocument < PBCore::V2::InstantiationType
|
16
|
-
end
|
17
|
-
|
18
6
|
class InstantiationType < PBCore::V2::Base
|
19
7
|
start_end_time_group
|
20
8
|
|
@@ -40,8 +28,14 @@ module PBCore
|
|
40
28
|
elements 'instantiationRelation', :as => :relations, :class => PBCore::V2::InstantiationRelation
|
41
29
|
elements 'instantiationRights', :as => :rights, :class => PBCore::V2::Rights
|
42
30
|
elements 'instantiationAnnotation', :as => :annotations, :class => PBCore::V2::Annotation
|
43
|
-
elements 'instantiationPart', :as => :parts, :class => PBCore::V2::InstantiationPart
|
44
31
|
elements 'instantiationExtension', :as => :extensions, :class => PBCore::V2::Extension
|
32
|
+
elements 'instantiationPart', :as => :parts, :class => PBCore::V2::InstantiationType
|
33
|
+
end
|
34
|
+
|
35
|
+
class Instantiation < PBCore::V2::InstantiationType
|
36
|
+
end
|
37
|
+
|
38
|
+
class InstantiationDocument < PBCore::V2::InstantiationType
|
45
39
|
end
|
46
40
|
|
47
41
|
end
|
data/lib/pb_core/version.rb
CHANGED
data/lib/pb_core.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pb_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sax-machine
|
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash:
|
81
|
+
hash: 216268167160498807
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
segments:
|
89
89
|
- 0
|
90
|
-
hash:
|
90
|
+
hash: 216268167160498807
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
93
|
rubygems_version: 1.8.23
|