mexico 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.document +5 -0
- data/.gitmodules +3 -0
- data/.project +14 -0
- data/.rspec +2 -0
- data/Gemfile +31 -0
- data/LICENSE.txt +165 -0
- data/README.md +116 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/assets/TESTCORPUS/Corpus.xml +26 -0
- data/assets/fiesta/b6/layer_connectors.fst +16 -0
- data/assets/fiesta/b6/match_jones_161_CM_neu_checked.parsed.xml +1225 -0
- data/assets/fiesta/elan/ElanFileFormat.eaf +76 -0
- data/assets/fiesta/elan/ElanFileFormat.pfsx +8 -0
- data/assets/fiesta/elan/ElanFileFormatComplexInterLayerLinks.eaf +107 -0
- data/assets/fiesta/elan/reflinks_example.eaf +270 -0
- data/assets/fiesta/elan/test_all_interlayerrelations.fst +43 -0
- data/assets/fiesta/head/head.fst +24 -0
- data/assets/fiesta/praat/mexico.ShortTextGrid +81 -0
- data/assets/fiesta/praat/mexico.TextGrid +104 -0
- data/assets/helpers/collection_ref_handler.rb +29 -0
- data/assets/helpers/id_ref_handler.rb +29 -0
- data/assets/helpers/roxml_attribute_handler.rb +57 -0
- data/assets/out_only/construct_and_write_spec.toe +99 -0
- data/assets/spec.html +554 -0
- data/bin/mexico +5 -0
- data/features/mexico.feature +9 -0
- data/features/step_definitions/mexico_steps.rb +0 -0
- data/features/support/env.rb +15 -0
- data/info/releasenotes/0.0.1.md +5 -0
- data/info/releasenotes/0.0.2.md +5 -0
- data/info/releasenotes/0.0.3.md +5 -0
- data/info/releasenotes/0.0.4.md +5 -0
- data/info/releasenotes/0.0.5.md +8 -0
- data/info/releasenotes/0.0.6.md +3 -0
- data/info/releasenotes/0.0.7.md +4 -0
- data/info/releasenotes/0.0.8.md +9 -0
- data/info/releasenotes/0.0.9.md +7 -0
- data/lib/mexico/cmd.rb +210 -0
- data/lib/mexico/constants.rb +82 -0
- data/lib/mexico/constraints/constraint.rb +85 -0
- data/lib/mexico/constraints/fiesta_constraints.rb +209 -0
- data/lib/mexico/constraints.rb +27 -0
- data/lib/mexico/core/corpus_core.rb +39 -0
- data/lib/mexico/core/design_core.rb +31 -0
- data/lib/mexico/core/media_type.rb +61 -0
- data/lib/mexico/core.rb +36 -0
- data/lib/mexico/fiesta/interfaces/b6_chat_game_interface.rb +222 -0
- data/lib/mexico/fiesta/interfaces/elan_interface.rb +143 -0
- data/lib/mexico/fiesta/interfaces/short_text_grid_interface.rb +99 -0
- data/lib/mexico/fiesta/interfaces/text_grid_interface.rb +103 -0
- data/lib/mexico/fiesta/interfaces.rb +31 -0
- data/lib/mexico/fiesta.rb +27 -0
- data/lib/mexico/file_system/bound_to_corpus.rb +37 -0
- data/lib/mexico/file_system/corpus.rb +207 -0
- data/lib/mexico/file_system/data.rb +96 -0
- data/lib/mexico/file_system/design.rb +75 -0
- data/lib/mexico/file_system/design_component.rb +78 -0
- data/lib/mexico/file_system/entry.rb +59 -0
- data/lib/mexico/file_system/fiesta_document.rb +344 -0
- data/lib/mexico/file_system/fiesta_map.rb +112 -0
- data/lib/mexico/file_system/head.rb +33 -0
- data/lib/mexico/file_system/id_ref.rb +46 -0
- data/lib/mexico/file_system/implicit_item_link.rb +19 -0
- data/lib/mexico/file_system/interval_link.rb +84 -0
- data/lib/mexico/file_system/item.rb +166 -0
- data/lib/mexico/file_system/item_link.rb +98 -0
- data/lib/mexico/file_system/item_links_proxy.rb +13 -0
- data/lib/mexico/file_system/layer.rb +89 -0
- data/lib/mexico/file_system/layer_connector.rb +74 -0
- data/lib/mexico/file_system/layer_link.rb +75 -0
- data/lib/mexico/file_system/local_file.rb +101 -0
- data/lib/mexico/file_system/participant.rb +69 -0
- data/lib/mexico/file_system/participant_role.rb +43 -0
- data/lib/mexico/file_system/point_link.rb +79 -0
- data/lib/mexico/file_system/property.rb +35 -0
- data/lib/mexico/file_system/property_map.rb +37 -0
- data/lib/mexico/file_system/resource.rb +174 -0
- data/lib/mexico/file_system/scale.rb +125 -0
- data/lib/mexico/file_system/section.rb +41 -0
- data/lib/mexico/file_system/static_collection_ref.rb +64 -0
- data/lib/mexico/file_system/template.rb +23 -0
- data/lib/mexico/file_system/trial.rb +87 -0
- data/lib/mexico/file_system/url.rb +65 -0
- data/lib/mexico/file_system.rb +62 -0
- data/lib/mexico/not_yet_implemented_error.rb +28 -0
- data/lib/mexico/util/fancy_container.rb +57 -0
- data/lib/mexico/util.rb +51 -0
- data/lib/mexico.rb +36 -0
- data/spec/constraints/constraints_spec.rb +306 -0
- data/spec/core/media_type_spec.rb +50 -0
- data/spec/fiesta/b6_spec.rb +43 -0
- data/spec/fiesta/elan_spec.rb +43 -0
- data/spec/fiesta/head_spec.rb +54 -0
- data/spec/fiesta/praat_spec.rb +54 -0
- data/spec/fiesta/read_spec.rb +76 -0
- data/spec/file_system_based/better_collection_spec.rb +142 -0
- data/spec/file_system_based/corpus_spec.rb +194 -0
- data/spec/file_system_based/design_spec.rb +100 -0
- data/spec/file_system_based/inter_links_spec.rb +100 -0
- data/spec/file_system_based/item_links_spec.rb +76 -0
- data/spec/file_system_based/rdf_spec.rb +177 -0
- data/spec/file_system_based/resource_spec.rb +111 -0
- data/spec/file_system_based/trial_spec.rb +129 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/toe/construct_and_write_spec.rb +82 -0
- data/spec/toe/construction_spec.rb +110 -0
- data/spec/toe/item_spec.rb +58 -0
- data/spec/toe/layer_spec.rb +63 -0
- data/spec/toe/scale_spec.rb +89 -0
- data/spec/toe/toe_document_spec.rb +39 -0
- data/test/helper.rb +19 -0
- data/test/test_mexico.rb +7 -0
- metadata +357 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# The FileSystem module contains an implementation of the MExiCo
|
20
|
+
# library that works locally with a set of folders and files as
|
21
|
+
# its backend.
|
22
|
+
|
23
|
+
module Mexico::Fiesta::Interfaces
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'mexico/fiesta/interfaces/b6_chat_game_interface.rb'
|
28
|
+
require 'mexico/fiesta/interfaces/elan_interface.rb'
|
29
|
+
require 'mexico/fiesta/interfaces/short_text_grid_interface.rb'
|
30
|
+
require 'mexico/fiesta/interfaces/text_grid_interface.rb'
|
31
|
+
# require 'mexico/fiesta/interfaces/dot_interface.rb'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# The FileSystem module contains an implementation of the MExiCo
|
20
|
+
# library that works locally with a set of folders and files as
|
21
|
+
# its backend.
|
22
|
+
|
23
|
+
module Mexico::Fiesta
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'mexico/fiesta/interfaces'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# XML bound elements know the corpus object, the corpus file, and
|
20
|
+
# the nokogiri element they come from and can write changes back to
|
21
|
+
# that file.
|
22
|
+
|
23
|
+
module Mexico::FileSystem::BoundToCorpus
|
24
|
+
|
25
|
+
attr_accessor :corpus
|
26
|
+
|
27
|
+
#sets up the bound between the object and the corpus elements
|
28
|
+
def bind_to_corpus(param_corpus)
|
29
|
+
@corpus = param_corpus
|
30
|
+
|
31
|
+
if self.respond_to?(:when_bound_to_corpus)
|
32
|
+
self.when_bound_to_corpus
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# This class provides a corpus representation that is backed up by the filesystem.
|
20
|
+
# A central Corpus definition file in the top-level folder contains an
|
21
|
+
# XML representation of the corpus structure, and all actual resources are found
|
22
|
+
# as files on a file system reachable from the top-level folder.
|
23
|
+
|
24
|
+
require 'poseidon'
|
25
|
+
|
26
|
+
class Mexico::FileSystem::Corpus
|
27
|
+
|
28
|
+
### include Mexico::FileSystem::FileSystemUtils
|
29
|
+
|
30
|
+
|
31
|
+
include Mexico::Core::CorpusCore
|
32
|
+
|
33
|
+
attr_accessor :base_path
|
34
|
+
|
35
|
+
include ::ROXML
|
36
|
+
|
37
|
+
xml_name 'Corpus'
|
38
|
+
|
39
|
+
# identifier
|
40
|
+
xml_accessor :identifier, :from => '@identifier'
|
41
|
+
|
42
|
+
# type String
|
43
|
+
xml_accessor :name, :from => '@name'
|
44
|
+
|
45
|
+
# type String
|
46
|
+
xml_accessor :description, :from => "Description"
|
47
|
+
|
48
|
+
# collection of ::Mexico::FileSystem::Participant
|
49
|
+
xml_accessor :participants, :as => [::Mexico::FileSystem::Participant], :from => "Participant", :in => "Participants"
|
50
|
+
|
51
|
+
# collection of ::Mexico::FileSystem::Design
|
52
|
+
xml_accessor :designs, :as => [::Mexico::FileSystem::Design], :from => "Design", :in => "Designs"
|
53
|
+
|
54
|
+
# collection of ::Mexico::FileSystem::Trial
|
55
|
+
xml_accessor :trials, :as => [::Mexico::FileSystem::Trial], :from => "Trial", :in => "Trials"
|
56
|
+
|
57
|
+
# collection of ::Mexico::FileSystem::Resource
|
58
|
+
xml_accessor :resources, :as => [::Mexico::FileSystem::Resource], :from => "Resource", :in => "Resources"
|
59
|
+
|
60
|
+
|
61
|
+
# POSEIdON-based RDF augmentation
|
62
|
+
include Poseidon
|
63
|
+
self_uri %q(http://cats.sfb673.org/Corpus)
|
64
|
+
instance_uri_scheme %q(http://phoibos.sfb673.org/corpora/#{identifier})
|
65
|
+
rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
|
66
|
+
rdf_property :name, %q(http://cats.sfb673.org/name)
|
67
|
+
rdf_property :description, %q(http://cats.sfb673.org/description)
|
68
|
+
rdf_include :designs, %q(http://cats.sfb673.org/hasDesign)
|
69
|
+
rdf_include :trials, %q(http://cats.sfb673.org/hasTrial)
|
70
|
+
rdf_include :resources, %q(http://cats.sfb673.org/hasResource)
|
71
|
+
|
72
|
+
|
73
|
+
public
|
74
|
+
|
75
|
+
# corpus_file : the XML file
|
76
|
+
# corpus_doc : the nokogiri xml document based on that file
|
77
|
+
|
78
|
+
# Opens the corpus folder and its manifest file at the given path.
|
79
|
+
# @param [String] path the path where the corpus is
|
80
|
+
# @option opts [String] :identifier The identifier that will be given if a new corpus is created
|
81
|
+
# @return [Mexico::FileSystem::Corpus] the new or opened Corpus object
|
82
|
+
def self.open(path, opts={})
|
83
|
+
xml = File.open(File.join(path,'Corpus.xml'),'rb') { |f| f.read }
|
84
|
+
c = Mexico::FileSystem::Corpus.from_xml(xml, opts.merge({:path=>path}))
|
85
|
+
return c
|
86
|
+
end
|
87
|
+
|
88
|
+
# Creates a new instance of the {Corpus} class.
|
89
|
+
# @param [String] path the path where the corpus is
|
90
|
+
# @option opts [String] :identifier The identifier that will be given if a new corpus is created
|
91
|
+
def initialize(path, opts={})
|
92
|
+
init_folder(path, opts)
|
93
|
+
@base_path = File.expand_path(path)
|
94
|
+
@corpus_file_name = File.join(@base_path, "Corpus.xml")
|
95
|
+
f = File.open(@corpus_file_name, 'r')
|
96
|
+
@xml_doc = ::Nokogiri::XML(f)
|
97
|
+
f.close
|
98
|
+
end
|
99
|
+
|
100
|
+
# Creates a new corpus object
|
101
|
+
# @option opts [String] :path The path where to create the new corpus. Required.
|
102
|
+
# @option opts [String] :identifier The identifier for the new corpus. Required.
|
103
|
+
# @option opts [String] :name The name for the new corpus.
|
104
|
+
# @option opts [String] :description A description for the new corpus. Required.
|
105
|
+
def initialize(opts = {})
|
106
|
+
init_folder(opts[:path], opts)
|
107
|
+
@base_path = File.expand_path(opts[:path])
|
108
|
+
@corpus_file_name = File.join(@base_path, "Corpus.xml")
|
109
|
+
f = File.open(@corpus_file_name, 'r')
|
110
|
+
@xml_doc = ::Nokogiri::XML(f)
|
111
|
+
f.close
|
112
|
+
end
|
113
|
+
|
114
|
+
# Saves the current data structure to the current file handle.
|
115
|
+
# @return [void]
|
116
|
+
def save_xml
|
117
|
+
doc = Nokogiri::XML::Document.new
|
118
|
+
doc.root = @corpus.to_xml
|
119
|
+
open(File.join(@base_path, "Corpus.OUT.xml"), 'w') do |file|
|
120
|
+
file << doc.serialize
|
121
|
+
end
|
122
|
+
# File.open(@corpus_file, 'w') {|f| f.write(doc.to_xml) }
|
123
|
+
end
|
124
|
+
|
125
|
+
# Creates a new design object and binds it to this corpus object.
|
126
|
+
# @option opts [String] :identifier The identifier of the new design (required).
|
127
|
+
# @option opts [String] :name The name of the new design. (required).
|
128
|
+
# @option opts [String] :description A description of the new design (optional).
|
129
|
+
def create_design(opts={})
|
130
|
+
d = ::Mexico::FileSystem::Design.new(opts)
|
131
|
+
d.bind_to_corpus(self)
|
132
|
+
d
|
133
|
+
end
|
134
|
+
|
135
|
+
# Returns the disk usage in bytes for the whole corpus.
|
136
|
+
# @return [Integer] the number of bytes used by files of this corpus
|
137
|
+
def complete_file_size
|
138
|
+
resources.collect{ |r| r.complete_file_size }.inject(:+)
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# after parsing a XML corpus representation, this method binds all components
|
144
|
+
# to the corpus object.
|
145
|
+
def after_parse
|
146
|
+
|
147
|
+
participants.each do |participant|
|
148
|
+
participant.bind_to_corpus(self)
|
149
|
+
end
|
150
|
+
|
151
|
+
designs.each do |design|
|
152
|
+
design.bind_to_corpus(self)
|
153
|
+
design.design_components.each do |dc|
|
154
|
+
dc.bind_to_corpus(self)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
trials.each do |trial|
|
159
|
+
trial.bind_to_corpus(self)
|
160
|
+
end
|
161
|
+
|
162
|
+
resources.each do |resource|
|
163
|
+
resource.bind_to_corpus(self)
|
164
|
+
resource.local_files.each do |loc|
|
165
|
+
loc.bind_to_corpus(self)
|
166
|
+
end
|
167
|
+
resource.urls.each do |url|
|
168
|
+
url.bind_to_corpus(self)
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
# This method inits a new corpus folder in the file system.
|
176
|
+
# @param [String] path The path where the folder should be initialized.
|
177
|
+
# @param [Hash] opts A hash with additional options and parameters.
|
178
|
+
# @option opts [String] :identifier The identifier of the new corpus (required).
|
179
|
+
# @return +true+ if all operations were successful, false otherwise.
|
180
|
+
def init_folder(path, opts = {})
|
181
|
+
|
182
|
+
# check whether the given folder does not exist and is writable
|
183
|
+
unless File.exists?(path)
|
184
|
+
begin
|
185
|
+
FileUtils.mkpath(path)
|
186
|
+
rescue
|
187
|
+
# if something goes wrong, stop here and return false
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
corpus_file_name = File.join(path, "Corpus.xml")
|
192
|
+
unless File.exists?(corpus_file_name)
|
193
|
+
corpus_file = File.open(corpus_file_name, 'w+')
|
194
|
+
corpus_file << "<Corpus identifier='#{opts[:identifier]}'></Corpus>"
|
195
|
+
corpus_file.close
|
196
|
+
end
|
197
|
+
# create
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
# helping method to retrieve all existing design components
|
203
|
+
def design_components
|
204
|
+
@designs.collect{|d| d.design_components}.flatten
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# the data container
|
20
|
+
class Mexico::FileSystem::Data
|
21
|
+
|
22
|
+
include ::ROXML
|
23
|
+
xml_name 'D'
|
24
|
+
|
25
|
+
xml_accessor :string_value, :from => "String" # , :to_xml => proc{|val| (@type=='string' ? val : '')}
|
26
|
+
xml_accessor :int_value, :as => Integer, :from => "Int"
|
27
|
+
xml_accessor :float_value, :as => Float, :from => "Float"
|
28
|
+
xml_accessor :map, :as => Mexico::FileSystem::FiestaMap, :from => "Map"
|
29
|
+
#xml_accessor :list, :as => Mexico::FileSystem::FiestaList, :from => "List"
|
30
|
+
|
31
|
+
attr_accessor :item, :document
|
32
|
+
|
33
|
+
include Poseidon
|
34
|
+
self_uri %q(http://cats.sfb673.org/Data)
|
35
|
+
instance_uri_scheme %q(#{document.self_uri}##{item.identifier}-data)
|
36
|
+
rdf_property :string_value, %q(http://cats.sfb673.org/string_value)
|
37
|
+
# rdf_property :name, %q(http://cats.sfb673.org/name)
|
38
|
+
|
39
|
+
# keine Bool-Klasse in Ruby. xml_accessor :boolean_value, :as => Bool, :from => "B"
|
40
|
+
# @todo map and list types
|
41
|
+
|
42
|
+
def initialize(args={})
|
43
|
+
args.each do |k,v|
|
44
|
+
if self.respond_to?("#{k}=")
|
45
|
+
send("#{k}=", v)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def after_parse
|
51
|
+
# resolve links
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def map_value
|
56
|
+
# return nil unless @type=="map"
|
57
|
+
@map # ||= JSON::load(@string_value)
|
58
|
+
end
|
59
|
+
|
60
|
+
def list_value
|
61
|
+
# return nil unless @type=="list"
|
62
|
+
@list # ||= JSON::load(@string_value)
|
63
|
+
end
|
64
|
+
|
65
|
+
def map_value=(val)
|
66
|
+
@string_value = nil
|
67
|
+
@list = nil
|
68
|
+
@map = Mexico::FileSystem::FiestaMap.new(val)
|
69
|
+
end
|
70
|
+
|
71
|
+
def list_value=(val=Array.new)
|
72
|
+
@string_value = nil
|
73
|
+
@map = nil
|
74
|
+
@list = val
|
75
|
+
end
|
76
|
+
|
77
|
+
def string_value=(new_string)
|
78
|
+
@map = nil
|
79
|
+
@list = nil
|
80
|
+
@string_value = new_string
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_s
|
84
|
+
return string_value unless string_value.nil?
|
85
|
+
return @map.to_s unless @map.nil?
|
86
|
+
end
|
87
|
+
|
88
|
+
def is_string?
|
89
|
+
(!string_value.nil? && map_value.nil? && list_value.nil?)
|
90
|
+
end
|
91
|
+
|
92
|
+
def is_map?
|
93
|
+
(string_value.nil? && !map_value.nil? && list_value.nil?)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'poseidon'
|
20
|
+
|
21
|
+
class Mexico::FileSystem::Design
|
22
|
+
|
23
|
+
include Mexico::FileSystem::BoundToCorpus
|
24
|
+
|
25
|
+
include Mexico::Core::DesignCore
|
26
|
+
|
27
|
+
include ::ROXML
|
28
|
+
|
29
|
+
# identifier
|
30
|
+
xml_accessor :identifier, :from => '@identifier'
|
31
|
+
|
32
|
+
# type String
|
33
|
+
xml_accessor :name, :from => '@name'
|
34
|
+
|
35
|
+
# type String
|
36
|
+
xml_accessor :description, :from => "Description"
|
37
|
+
|
38
|
+
# collection of ::Mexico::FileSystem::DesignComponent
|
39
|
+
xml_accessor :design_components, :as => [::Mexico::FileSystem::DesignComponent], :from => "DesignComponent" #, :in => "Designs"
|
40
|
+
|
41
|
+
# POSEIdON-based RDF augmentation
|
42
|
+
include Poseidon
|
43
|
+
|
44
|
+
self_uri %q(http://cats.sfb673.org/Design)
|
45
|
+
instance_uri_scheme %q(http://phoibos.sfb673.org/corpora/#{corpus.identifier}/designs/#{identifier})
|
46
|
+
|
47
|
+
rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
|
48
|
+
rdf_property :name, %q(http://cats.sfb673.org/name)
|
49
|
+
rdf_property :description, %q(http://cats.sfb673.org/description)
|
50
|
+
|
51
|
+
rdf_include :design_components, %q(http://cats.sfb673.org/hasDesignComponent)
|
52
|
+
|
53
|
+
# Creates a new design object.
|
54
|
+
# @option opts [String] :identifier The identifier of the new design (required).
|
55
|
+
# @option opts [String] :name The name of the new design. (required).
|
56
|
+
# @option opts [String] :description A description of the new design (optional).
|
57
|
+
def initialize(opts={})
|
58
|
+
[:identifier,:name,:description].each do |att|
|
59
|
+
send("#{att}=", opts[att]) if opts.has_key?(att)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns a collection of trials that are associated with this design.
|
64
|
+
# @return [Array<Trial>] an array of trials associated with this design.
|
65
|
+
def trials
|
66
|
+
@corpus.trials.select{ |i| i.design === self }
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def after_parse
|
71
|
+
design_components.each do |dc|
|
72
|
+
dc.design = self
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# This file is part of the MExiCo gem.
|
2
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
3
|
+
# http://www.sfb673.org
|
4
|
+
#
|
5
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
7
|
+
# published by the Free Software Foundation, either version 3 of
|
8
|
+
# the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# MExiCo is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with MExiCo. If not, see
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'poseidon'
|
20
|
+
|
21
|
+
# A template class doing nothing.
|
22
|
+
class Mexico::FileSystem::DesignComponent
|
23
|
+
|
24
|
+
include Mexico::FileSystem::BoundToCorpus
|
25
|
+
extend Mexico::FileSystem::IdRef
|
26
|
+
extend Mexico::FileSystem::StaticCollectionRef
|
27
|
+
|
28
|
+
include ::ROXML
|
29
|
+
|
30
|
+
# identifier
|
31
|
+
xml_accessor :identifier, :from => '@identifier'
|
32
|
+
|
33
|
+
# type String
|
34
|
+
xml_accessor :name, :from => '@name'
|
35
|
+
|
36
|
+
# type String
|
37
|
+
xml_accessor :description, :from => 'Description'
|
38
|
+
|
39
|
+
# type String
|
40
|
+
xml_accessor :cue, :from => '@cue'
|
41
|
+
|
42
|
+
# type [true,false]
|
43
|
+
xml_accessor :required?, :from => '@required'
|
44
|
+
|
45
|
+
# type Mexico::Core::MediaType
|
46
|
+
xml_accessor :media_type_id, :from => '@media_type_id'
|
47
|
+
|
48
|
+
# type Mexico::Core::MediaType
|
49
|
+
collection_ref :media_type, ::Mexico::Core::MediaType, ::Mexico::Constants::MediaTypes::ALL, ::Mexico::Constants::MediaTypes::OTHER
|
50
|
+
|
51
|
+
#@todo data_type
|
52
|
+
#@todo content_structure
|
53
|
+
#@todo belongs to Design
|
54
|
+
|
55
|
+
|
56
|
+
attr_accessor :design
|
57
|
+
|
58
|
+
|
59
|
+
# POSEIdON-based RDF augmentation
|
60
|
+
include Poseidon
|
61
|
+
|
62
|
+
self_uri %q(http://cats.sfb673.org/DesignComponent)
|
63
|
+
instance_uri_scheme %q(http://phoibos.sfb673.org/corpora/#{design.corpus.identifier}/designs/#{design.identifier}/design_components/#{identifier})
|
64
|
+
|
65
|
+
rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
|
66
|
+
rdf_property :name, %q(http://cats.sfb673.org/name)
|
67
|
+
rdf_property :description, %q(http://cats.sfb673.org/description)
|
68
|
+
rdf_property :cue, %q(http://cats.sfb673.org/cue)
|
69
|
+
rdf_property :running_number, %q(http://cats.sfb673.org/running_number)
|
70
|
+
rdf_property :required?, %q(http://cats.sfb673.org/is_required)
|
71
|
+
|
72
|
+
# Returns a collection of resources that are associated with this design component.
|
73
|
+
# @return [Array<Resource>] an array of resources associated with this design component.
|
74
|
+
def resources
|
75
|
+
@corpus.resources.select{ |i| i.design_component === self }
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is part of the MExiCo gem.
|
3
|
+
# Copyright (c) 2012-2014 Peter Menke, SFB 673, Universität Bielefeld
|
4
|
+
# http://www.sfb673.org
|
5
|
+
#
|
6
|
+
# MExiCo is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as
|
8
|
+
# published by the Free Software Foundation, either version 3 of
|
9
|
+
# the License, or (at your option) any later version.
|
10
|
+
#
|
11
|
+
# MExiCo is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
17
|
+
# License along with MExiCo. If not, see
|
18
|
+
# <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
# This class provides a corpus representation that is backed up by the filesystem.
|
21
|
+
# A central Corpus definition file in the top-level folder contains an
|
22
|
+
# XML representation of the corpus structure, and all actual resources are found
|
23
|
+
# as files on a file system reachable from the top-level folder.
|
24
|
+
|
25
|
+
class Mexico::FileSystem::Entry
|
26
|
+
|
27
|
+
include ::ROXML
|
28
|
+
xml_name 'Entry'
|
29
|
+
|
30
|
+
xml_accessor :key, :from => '@key'
|
31
|
+
|
32
|
+
xml_accessor :entries, :as => [::Mexico::FileSystem::Entry], :from => "Entry"
|
33
|
+
|
34
|
+
attr_accessor :values
|
35
|
+
|
36
|
+
def self.from_xml(node, args={})
|
37
|
+
@values = {}
|
38
|
+
node.elements.each do |el|
|
39
|
+
key = el['key']
|
40
|
+
val = el.text
|
41
|
+
@values[key] = val
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_xml(params = {})
|
46
|
+
params.reverse_merge!(:name => self.class.tag_name, :namespace => self.class.roxml_namespace)
|
47
|
+
params[:namespace] = nil if ['*', 'xmlns'].include?(params[:namespace])
|
48
|
+
node = XML.new_node([params[:namespace], params[:name]].compact.join(':')).tap do |root|
|
49
|
+
@values.each do |k,v|
|
50
|
+
root.children << XML.new_node([params[:namespace], 'Entry']).tap do |ent|
|
51
|
+
ent['key'] = k
|
52
|
+
ent.text = v
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
node
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|