Class: SiSU_XML_Metadata::OAI_PMH

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/xml_md_oai_pmh_dc.rb

Instance Method Summary collapse

Constructor Details

#initialize(opt) ⇒ OAI_PMH

Returns a new instance of OAI_PMH.



61
62
63
64
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 61

def initialize(opt)
  @md=SiSU_Param::Parameters.new(opt).get
  @oai_pmh=[]
end

Instance Method Details

#bodyObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 79

def body
  if defined? @md.title.full \
  and @md.title.full=~/\S+/                                               # DublinCore 1 - title
    @oai_pmh << %{  <dc:title xml:lang="en">#{@md.title.full}</dc:title>\n}
  end
  if defined? @md.creator.author \
  and @md.creator.author=~/\S+/                                           # DublinCore 2 - creator/author (author)
    txt=meta_content_clean(@md.creator.author)
    @oai_pmh << %{  <dc:author>#{txt}</dc:author>\n}
  end
  if defined? @md.classify.subject \
  and @md.classify.subject=~/\S+/                                          # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
    txt=meta_content_clean(@md.classify.subject)
    @oai_pmh << %{  <dc:subject>#{txt}</dc:subject>\n}
  end
  if defined? @md.classify.keywords \
  and @md.classify.keywords=~/\S+/
    txt=meta_content_clean(@md.classify.keywords)
    @oai_pmh << %{  <dc:keywords>#{txt}</dc:keywords>\n}
  end
  if @md.publisher                                                         # DublinCore 5 - publisher (current copy published by)
    txt=meta_content_clean(@md.publisher)
    @oai_pmh << %{  <dc:publisher>#{txt}</dc:publisher>\n}
  end
  if defined? @md.creator.contributor \
  and @md.creator.contributor=~/\S+/                                       # DublinCore 6 - contributor
    txt=meta_content_clean(@md.creator.contributor)
    @oai_pmh << %{  <dc:contributor>#{txt}</dc:contributor>\n}
  end
  if defined? @md.date.published \
  and @md.date.published=~/\S+/                                            # DublinCore 7 - date year-mm-dd
    @oai_pmh << %{  <dc:date>#{@md.date.published}</dc:date>\n}
  end
  if defined? @md.date.created \
  and @md.date.created=~/\S+/                                              # DublinCore 7 - date.created
    @oai_pmh << %{  <dc:date_created>#{@md.date.created}</dc:date_created>\n}
  end
  if defined? @md.date.issued \
  and @md.date.issued=~/\S+/                                               # DublinCore 7 - date.issued
    @oai_pmh << %{  <dc:date_issued>#{@md.date.issued}</dc:date_issued>\n}
  end
  if defined? @md.date.available \
  and @md.date.available=~/\S+/                                            # DublinCore 7 - date.available
    @oai_pmh << %{  <dc:date_available>#{@md.date.available}</dc:date_available>\n}
  end
  if defined? @md.date.valid \
  and @md.date.valid=~/\S+/                                                # DublinCore 7 - date.valid
    @oai_pmh << %{  <dc:date_valid>#{@md.date.valid}</dc:date_valid>\n}
  end
  if defined? @md.date.modified \
  and @md.date.modified=~/\S+/                                             # DublinCore 7 - date.modified
    @oai_pmh <<  %{  <dc:date_modified>#{@md.date.modified}</dc:date_modified>\n}
  end
  if defined? @md.notes.description \
  and @md.notes.description=~/\S+/                                         # DublinCore 4 - description
    txt=meta_content_clean(@md.notes.description)
    @oai_pmh << %{  <dc:description>#{txt}</dc:description>\n}
  end
  if defined? @md.notes.coverage \
  and @md.notes.coverage=~/\S+/                                            # DublinCore 14 - coverage
    txt=meta_content_clean(@md.notes.coverage)
    @oai_pmh << %{  <dc:coverage>#{txt}</dc:coverage>\n}
  end
  if defined? @md.notes.relation \
  and @md.notes.relation=~/\S+/                                            # DublinCore 13 - relation
    txt=meta_content_clean(@md.notes.relation)
    @oai_pmh << %{  <dc:relation>#{txt}</dc:relation>\n}
  end
  if defined? @md.notes.type \
  and @md.notes.type=~/\S+/                                                # DublinCore 8 - type
    txt=meta_content_clean(@md.notes.type)
    @oai_pmh << %{  <dc:type>#{txt}</dc:type>\n}
  end
  if defined? @md.notes.format \
  and @md.notes.format=~/\S+/                                              # DublinCore 9 - format
    txt=meta_content_clean(@md.notes.format)
    @oai_pmh << %{  <dc:format>#{txt}</dc:format>\n}
  end
  #if defined? @md.identifier.sisupod \
  #and @md.identifier.sisupod=~/\S+/                                       # DublinCore 10 - identifier
  #  txt=meta_content_clean(@md.identifier.sisupod)
  #  @oai_pmh << %{  <dc:identifier>#{txt}</dc:identifier>\n}
  #end
  if defined? @md.original.source \
  and @md.original.source=~/\S+/                                           # DublinCore 11 - source
    txt=meta_content_clean(@md.original.source)
    @oai_pmh << %{  <dc:source>#{txt}</dc:source>\n}
  end
  if defined? @md.title.language \
  and @md.title.language=~/\S+/                                            # DublinCore 12 - language (English)
    @oai_pmh << %{  <dc:language>#{@md.title.language}</dc:language>\n}
  end
  if defined? @md.original.language \
  and @md.original.language=~/\S+/
    @oai_pmh << %{  <dc:language>#{@md.original.language}</dc:language>\n}
  end
  if defined? @md.rights.all \
  and @md.rights.all=~/\S+/                                                # DublinCore 15 - rights
    txt=meta_content_clean(@md.rights.all)
    @oai_pmh << %{  <dc:rights>#{txt}</dc:rights>\n}
  end
  @oai_pmh
end

#meta_content_clean(content = '') ⇒ Object



182
183
184
185
186
187
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 182

def meta_content_clean(content='')
  unless content.nil?
    content=content.tr('"',"'")
  end
  content
end

#outputObject



191
192
193
194
195
196
197
198
199
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 191

def output
  SiSU_Env::FileOp.new(@md).mkdir
  oai_pmh=SiSU_Env::FileOp.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param
  oai_pmh << pre
  body.each do |x|
    oai_pmh << x
  end
  oai_pmh << post
end

#postObject



188
189
190
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 188

def post
  '</oai_dc:dc>'
end

#preObject



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 68

def pre
<<WOK
<?xml version="1.0" encoding="UTF-8"?>
<oai_dc:dc
  xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
  http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
WOK
end

#readObject



65
66
67
# File 'lib/sisu/xml_md_oai_pmh_dc.rb', line 65

def read
  output
end