mexico 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +15 -0
  2. data/.document +5 -0
  3. data/.gitmodules +3 -0
  4. data/.project +14 -0
  5. data/.rspec +2 -0
  6. data/Gemfile +31 -0
  7. data/LICENSE.txt +165 -0
  8. data/README.md +116 -0
  9. data/Rakefile +66 -0
  10. data/VERSION +1 -0
  11. data/assets/TESTCORPUS/Corpus.xml +26 -0
  12. data/assets/fiesta/b6/layer_connectors.fst +16 -0
  13. data/assets/fiesta/b6/match_jones_161_CM_neu_checked.parsed.xml +1225 -0
  14. data/assets/fiesta/elan/ElanFileFormat.eaf +76 -0
  15. data/assets/fiesta/elan/ElanFileFormat.pfsx +8 -0
  16. data/assets/fiesta/elan/ElanFileFormatComplexInterLayerLinks.eaf +107 -0
  17. data/assets/fiesta/elan/reflinks_example.eaf +270 -0
  18. data/assets/fiesta/elan/test_all_interlayerrelations.fst +43 -0
  19. data/assets/fiesta/head/head.fst +24 -0
  20. data/assets/fiesta/praat/mexico.ShortTextGrid +81 -0
  21. data/assets/fiesta/praat/mexico.TextGrid +104 -0
  22. data/assets/helpers/collection_ref_handler.rb +29 -0
  23. data/assets/helpers/id_ref_handler.rb +29 -0
  24. data/assets/helpers/roxml_attribute_handler.rb +57 -0
  25. data/assets/out_only/construct_and_write_spec.toe +99 -0
  26. data/assets/spec.html +554 -0
  27. data/bin/mexico +5 -0
  28. data/features/mexico.feature +9 -0
  29. data/features/step_definitions/mexico_steps.rb +0 -0
  30. data/features/support/env.rb +15 -0
  31. data/info/releasenotes/0.0.1.md +5 -0
  32. data/info/releasenotes/0.0.2.md +5 -0
  33. data/info/releasenotes/0.0.3.md +5 -0
  34. data/info/releasenotes/0.0.4.md +5 -0
  35. data/info/releasenotes/0.0.5.md +8 -0
  36. data/info/releasenotes/0.0.6.md +3 -0
  37. data/info/releasenotes/0.0.7.md +4 -0
  38. data/info/releasenotes/0.0.8.md +9 -0
  39. data/info/releasenotes/0.0.9.md +7 -0
  40. data/lib/mexico/cmd.rb +210 -0
  41. data/lib/mexico/constants.rb +82 -0
  42. data/lib/mexico/constraints/constraint.rb +85 -0
  43. data/lib/mexico/constraints/fiesta_constraints.rb +209 -0
  44. data/lib/mexico/constraints.rb +27 -0
  45. data/lib/mexico/core/corpus_core.rb +39 -0
  46. data/lib/mexico/core/design_core.rb +31 -0
  47. data/lib/mexico/core/media_type.rb +61 -0
  48. data/lib/mexico/core.rb +36 -0
  49. data/lib/mexico/fiesta/interfaces/b6_chat_game_interface.rb +222 -0
  50. data/lib/mexico/fiesta/interfaces/elan_interface.rb +143 -0
  51. data/lib/mexico/fiesta/interfaces/short_text_grid_interface.rb +99 -0
  52. data/lib/mexico/fiesta/interfaces/text_grid_interface.rb +103 -0
  53. data/lib/mexico/fiesta/interfaces.rb +31 -0
  54. data/lib/mexico/fiesta.rb +27 -0
  55. data/lib/mexico/file_system/bound_to_corpus.rb +37 -0
  56. data/lib/mexico/file_system/corpus.rb +207 -0
  57. data/lib/mexico/file_system/data.rb +96 -0
  58. data/lib/mexico/file_system/design.rb +75 -0
  59. data/lib/mexico/file_system/design_component.rb +78 -0
  60. data/lib/mexico/file_system/entry.rb +59 -0
  61. data/lib/mexico/file_system/fiesta_document.rb +344 -0
  62. data/lib/mexico/file_system/fiesta_map.rb +112 -0
  63. data/lib/mexico/file_system/head.rb +33 -0
  64. data/lib/mexico/file_system/id_ref.rb +46 -0
  65. data/lib/mexico/file_system/implicit_item_link.rb +19 -0
  66. data/lib/mexico/file_system/interval_link.rb +84 -0
  67. data/lib/mexico/file_system/item.rb +166 -0
  68. data/lib/mexico/file_system/item_link.rb +98 -0
  69. data/lib/mexico/file_system/item_links_proxy.rb +13 -0
  70. data/lib/mexico/file_system/layer.rb +89 -0
  71. data/lib/mexico/file_system/layer_connector.rb +74 -0
  72. data/lib/mexico/file_system/layer_link.rb +75 -0
  73. data/lib/mexico/file_system/local_file.rb +101 -0
  74. data/lib/mexico/file_system/participant.rb +69 -0
  75. data/lib/mexico/file_system/participant_role.rb +43 -0
  76. data/lib/mexico/file_system/point_link.rb +79 -0
  77. data/lib/mexico/file_system/property.rb +35 -0
  78. data/lib/mexico/file_system/property_map.rb +37 -0
  79. data/lib/mexico/file_system/resource.rb +174 -0
  80. data/lib/mexico/file_system/scale.rb +125 -0
  81. data/lib/mexico/file_system/section.rb +41 -0
  82. data/lib/mexico/file_system/static_collection_ref.rb +64 -0
  83. data/lib/mexico/file_system/template.rb +23 -0
  84. data/lib/mexico/file_system/trial.rb +87 -0
  85. data/lib/mexico/file_system/url.rb +65 -0
  86. data/lib/mexico/file_system.rb +62 -0
  87. data/lib/mexico/not_yet_implemented_error.rb +28 -0
  88. data/lib/mexico/util/fancy_container.rb +57 -0
  89. data/lib/mexico/util.rb +51 -0
  90. data/lib/mexico.rb +36 -0
  91. data/spec/constraints/constraints_spec.rb +306 -0
  92. data/spec/core/media_type_spec.rb +50 -0
  93. data/spec/fiesta/b6_spec.rb +43 -0
  94. data/spec/fiesta/elan_spec.rb +43 -0
  95. data/spec/fiesta/head_spec.rb +54 -0
  96. data/spec/fiesta/praat_spec.rb +54 -0
  97. data/spec/fiesta/read_spec.rb +76 -0
  98. data/spec/file_system_based/better_collection_spec.rb +142 -0
  99. data/spec/file_system_based/corpus_spec.rb +194 -0
  100. data/spec/file_system_based/design_spec.rb +100 -0
  101. data/spec/file_system_based/inter_links_spec.rb +100 -0
  102. data/spec/file_system_based/item_links_spec.rb +76 -0
  103. data/spec/file_system_based/rdf_spec.rb +177 -0
  104. data/spec/file_system_based/resource_spec.rb +111 -0
  105. data/spec/file_system_based/trial_spec.rb +129 -0
  106. data/spec/spec_helper.rb +14 -0
  107. data/spec/toe/construct_and_write_spec.rb +82 -0
  108. data/spec/toe/construction_spec.rb +110 -0
  109. data/spec/toe/item_spec.rb +58 -0
  110. data/spec/toe/layer_spec.rb +63 -0
  111. data/spec/toe/scale_spec.rb +89 -0
  112. data/spec/toe/toe_document_spec.rb +39 -0
  113. data/test/helper.rb +19 -0
  114. data/test/test_mexico.rb +7 -0
  115. metadata +357 -0
@@ -0,0 +1,43 @@
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
+ # Participant Roles describe the nature of the associated participant:
20
+ # Possible values are, e.g., naive participants, confederates,
21
+ # experimenters, etc.
22
+ class Mexico::FileSystem::ParticipantRole
23
+
24
+ include Mexico::FileSystem::BoundToCorpus
25
+ extend Mexico::FileSystem::IdRef
26
+
27
+
28
+ include ::ROXML
29
+
30
+ xml_accessor :identifier, :from => '@identifier'
31
+ xml_accessor :name, :from => '@name'
32
+
33
+ xml_accessor :description, :from => "Description"
34
+
35
+
36
+ def initialize(opts={})
37
+ # @corpus = corpus
38
+ [:identifier,:name,:description].each do |att|
39
+ send("#{att}=", opts[att]) if opts.has_key?(att)
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,79 @@
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
+ # a link that targets an interval out of a scale object.
20
+ class Mexico::FileSystem::PointLink
21
+ include ROXML
22
+
23
+ xml_name "PointLink"
24
+
25
+ # identifier
26
+ xml_accessor :identifier, :from => '@id'
27
+
28
+ # type Float
29
+ xml_accessor :point, :as => Float, :from => "@point"
30
+
31
+ # type String
32
+ xml_accessor :role, :from => '@role'
33
+
34
+ # type String
35
+ xml_accessor :target, :from => "@target"
36
+
37
+ attr_accessor :item
38
+ attr_accessor :document
39
+
40
+ # POSEIdON-based RDF augmentation
41
+ include Poseidon
42
+ self_uri %q(http://cats.sfb673.org/PointLink)
43
+ instance_uri_scheme %q(#{document.self_uri}##{identifier})
44
+ rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
45
+ rdf_property :role, %q(http://cats.sfb673.org/role)
46
+ rdf_property :point, %q(http://cats.sfb673.org/point)
47
+ rdf_property :target, %q(http://cats.sfb673.org/target), :value_expression => 'RDF::URI(target_object.self_uri)'
48
+
49
+ def initialize(args={})
50
+ args.each do |k,v|
51
+ if self.respond_to?("#{k}=")
52
+ send("#{k}=", v)
53
+ end
54
+ end
55
+ end
56
+
57
+ # returns the target object, in this case, a Scale.
58
+ # @return (Mexico::FileSystem::Scale) the scale this interval link points to.
59
+ def target_object
60
+ @target_object
61
+ end
62
+
63
+ # Sets a new target object (and updates the corresponding identifier)
64
+ # @param (Mexico::FileSystem::Scale) new_target The new target object to set
65
+ # @return (void)
66
+ def target_object=(new_target)
67
+ @target_object=new_target
68
+ @target=target_object.identifier
69
+ end
70
+
71
+ # This method attempts to link objects from other locations of the XML/object tree
72
+ # into position inside this object, by following the xml ids given in the
73
+ # appropriate fields of this class.
74
+ # @return (void)
75
+ def after_parse
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,35 @@
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::Property
26
+
27
+ include ::ROXML
28
+ xml_name 'Property'
29
+
30
+ xml_accessor :key, :from => '@key'
31
+
32
+ xml_accessor :value, :from => :content
33
+
34
+
35
+ end
@@ -0,0 +1,37 @@
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::PropertyMap
26
+
27
+ include ::ROXML
28
+ xml_name 'PropertyMap'
29
+
30
+ xml_accessor :key, :from => '@key'
31
+
32
+ xml_accessor :properties, :as => [::Mexico::FileSystem::Property], :from => "Property"
33
+ xml_accessor :property_maps, :as => [::Mexico::FileSystem::PropertyMap], :from => "PropertyMap"
34
+
35
+ attr_accessor :values
36
+
37
+ end
@@ -0,0 +1,174 @@
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::Resource
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 :media_type_id, :from => '@media_type_id'
41
+
42
+ # type Mexico::Core::MediaType
43
+ collection_ref :media_type, ::Mexico::Core::MediaType, ::Mexico::Constants::MediaTypes::ALL, ::Mexico::Constants::MediaTypes::OTHER
44
+
45
+ # type Array<Mexico::FileSystem::LocalFile>
46
+ xml_accessor :local_files, :as => [::Mexico::FileSystem::LocalFile], :from => "LocalFile" #, :in => "."
47
+
48
+ # type Array<Mexico::FileSystem::URL>
49
+ xml_accessor :urls, :as => [::Mexico::FileSystem::URL], :from => "URL" # , :in => "."
50
+
51
+ # type String
52
+ xml_accessor :trial_id, :from => "@trial_id"
53
+
54
+ # type Mexico::FileSystem::Trial
55
+ id_ref :trial
56
+
57
+ # type String
58
+ xml_accessor :design_component_id, :from => "@design_component_id"
59
+
60
+ # type Mexico::FileSystem::DesignComponent
61
+ id_ref :design_component
62
+
63
+ # POSEIdON-based RDF augmentation
64
+ include Poseidon
65
+
66
+ self_uri %q(http://cats.sfb673.org/Resource)
67
+ instance_uri_scheme %q(http://phoibos.sfb673.org/corpora/#{corpus.identifier}/resources/#{identifier})
68
+
69
+ rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
70
+ rdf_property :name, %q(http://cats.sfb673.org/name)
71
+ rdf_property :description, %q(http://cats.sfb673.org/description)
72
+ rdf_property :document, %q(http://cats.sfb673.org/document), {:value_expression => 'RDF::URI("#{self_uri}.fst")'}
73
+
74
+ rdf_include :local_files, %q(http://cats.sfb673.org/hasLocalFile)
75
+ rdf_include :urls, %q(http://cats.sfb673.org/hasURLs)
76
+
77
+
78
+ # docme
79
+
80
+ # creates a new Trial object.
81
+ # @option opts [String] :identifier The identifier of the new trial object.
82
+ # @option opts [String] :name The name of the new trial object.
83
+ # @option opts [String] :description The identifier of the new trial object.
84
+ def initialize(opts={})
85
+ # @corpus = corpus
86
+ [:identifier,:name,:description].each do |att|
87
+ send("#{att}=", opts[att]) if opts.has_key?(att)
88
+ end
89
+ end
90
+
91
+
92
+ # Indicates whether this resource is associated with a trial.
93
+ # @return [true,false] +true+ if this resource belongs to a trial, +false+ otherwise.
94
+ def linked_to_trial?
95
+ return trial!=nil
96
+ end
97
+
98
+ # Indicates whether this resource is associated with a design component.
99
+ # @return [true,false] +true+ if this resource belongs to a design component, +false+ otherwise.
100
+ def linked_to_design_component?
101
+ return design_component!=nil
102
+ end
103
+
104
+ # Returns the disk space in bytes used by all local files of this resource.
105
+ # @return (Integer) disk space in bytes used by all local files of this resource.
106
+ def complete_file_size
107
+ local_files.collect{ |f| f.file_size }.inject(:+)
108
+ end
109
+
110
+ # Indicates whether this resource is of the video media type.
111
+ # @return (Boolean) +true+ if this resource has media type video, +false+ otherwise.
112
+ def is_video?
113
+ return media_type==::Mexico::Constants::MediaTypes::VIDEO
114
+ end
115
+
116
+ # Indicates whether this resource is of the audio media type.
117
+ # @return (Boolean) +true+ if this resource has media type audio, +false+ otherwise.
118
+ def is_audio?
119
+ return media_type==::Mexico::Constants::MediaTypes::AUDIO
120
+ end
121
+
122
+ # Indicates whether this resource is of the annotation media type.
123
+ # @return (Boolean) +true+ if this resource has media type annotation, +false+ otherwise.
124
+ def is_annotation?
125
+ return media_type==::Mexico::Constants::MediaTypes::ANNOTATION
126
+ end
127
+
128
+ # Attempts to load the contents of the resource from an appropriate source into an appropriate
129
+ # data structure (for annotation files, into the ToE format, etc.)
130
+ # @return (Mexico::FileSystem::FiestaDocument) the document, or +nil+ if no document could be loaded.
131
+ def load
132
+
133
+ # @todo create a loader interface in a separate package
134
+ # load() then takes a file or url, gets the contents as a stream,
135
+ # and puts it into appropriate data structures.
136
+ # choice depends on: MediaType. Whether LocalFile or URL are available.
137
+ # What kinds of LF / URL are available, and which one is the newest.
138
+ # first goal: When document is of mediatype ANNOTATION, and there is one
139
+ # LocalFile, and it is of a matching type (now: ToE import), then import that
140
+ # one and make the resulting objects available below the resource.
141
+
142
+ # first version:
143
+ # if resource is annotation, and there is a toe file, then: load that toe file
144
+ # as a document, and define the appropriate member variable.
145
+
146
+ # puts "Is anno? %s" % is_annotation?
147
+ if is_annotation?
148
+
149
+ # puts "Toe File? %s" % local_files.find{ |f| f.path=~/toe$/ }
150
+ toe_file = local_files.find{ |f| f.path=~/toe$/ || f.path=~/fiesta$/ }
151
+
152
+ unless toe_file.nil?
153
+ @document = ::Mexico::FileSystem::FiestaDocument.open(toe_file.absolute_path)
154
+ @document.resource = self
155
+ return @document
156
+ end
157
+ end
158
+ end
159
+
160
+ # Returns the annotation document previously loaded in {#load} (this is only the case
161
+ # if resource has media type video, and if an appropriate local file is present).
162
+ # @return (Mexico::FileSystem::FiestaDocument) the document, or +nil+ if no document has been loaded.
163
+ def document
164
+ defined?(@document) ? @document : nil
165
+ end
166
+
167
+ # This method performs additional linking and cleanup after parsing a XML representation.
168
+ def after_parse
169
+ # puts "Parsed Resource #{self.identifier}"
170
+ end
171
+
172
+ # @todo Resource must, upon creation, be bound to a physical resource somewhere in the file system.
173
+
174
+ end
@@ -0,0 +1,125 @@
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
+ # A generic scale.
20
+ class Mexico::FileSystem::Scale
21
+
22
+ DIM_TIME = 'time'
23
+ DIM_SPACE = 'space'
24
+ DIM_OTHER = 'other'
25
+
26
+ include ::ROXML
27
+ xml_name 'Scale'
28
+
29
+ xml_accessor :identifier, :from => '@id'
30
+ xml_accessor :name, :from => '@name'
31
+
32
+ xml_accessor :unit, :from => '@unit'
33
+ xml_accessor :dimension, :from => '@dimension'
34
+ xml_accessor :role, :from => '@role'
35
+ xml_accessor :continuous?, :from => '@continuous'
36
+
37
+ xml_accessor :mode, :from => '@mode'
38
+
39
+ attr_accessor :document
40
+
41
+ # POSEIdON-based RDF augmentation
42
+ include Poseidon
43
+ self_uri %q(http://cats.sfb673.org/Scale)
44
+ instance_uri_scheme 'http://phoibos.sfb673.org/resources/1##{identifier}' # %q(#{document.self_uri}##{identifier})
45
+ rdf_property :identifier, %q(http://cats.sfb673.org/identifier)
46
+ rdf_property :name, %q(http://cats.sfb673.org/name)
47
+
48
+ rdf_property :unit, %q(http://cats.sfb673.org/unit)
49
+ rdf_property :dimension, %q(http://cats.sfb673.org/dimension)
50
+ rdf_property :role, %q(http://cats.sfb673.org/role)
51
+ rdf_property :continuous?, %q(http://cats.sfb673.org/is_continuous)
52
+ rdf_property :mode, %q(http://cats.sfb673.org/mode)
53
+
54
+
55
+ # static collection of MODES
56
+ # mode : MODES collection
57
+ # @todo collection of scale elements (if not continuous)
58
+
59
+ # OKunit : SI units or custom units
60
+ # OK dimension : String (x,y,z,t, etc.)
61
+ # OK role : String (free text)
62
+ # continuous? : Boolean
63
+
64
+ def initialize(args={})
65
+ args.each do |k,v|
66
+ if self.respond_to?("#{k}=")
67
+ send("#{k}=", v)
68
+ end
69
+ end
70
+ end
71
+
72
+ # overrides method in ROXML
73
+ # callback after xml parsing process, to store this element in the
74
+ # document cache.
75
+ def after_parse
76
+ ::Mexico::FileSystem::FiestaDocument.store(self.identifier, self)
77
+ end
78
+
79
+ # Creates an RDF representation in Turtle notation for this class.
80
+ # @return [String] An RDF representation in Turtle notation for this class.
81
+ def self.to_turtle
82
+ rdf_writer = RDF::Turtle::Writer
83
+ return rdf_writer.buffer(:base_uri => 'http://phoibos.sfb673.org/',
84
+ :prefixes => {
85
+ :cats => 'http://cats.sfb673.org/',
86
+ :rdfs => RDF::RDFS.to_uri,
87
+ :foaf => RDF::FOAF.to_uri,
88
+ :dc => RDF::DC.to_uri,
89
+ :owl => RDF::OWL.to_uri,
90
+ :xsd => RDF::XSD.to_uri} #
91
+ ) do |writer|
92
+ as_rdf.each_statement do |statement|
93
+ writer << statement
94
+ end
95
+ end
96
+ end
97
+
98
+ # Creates an RDF representation in Turtle notation for this object.
99
+ # @return [String] An RDF representation in Turtle notation for this object.
100
+ def to_turtle
101
+ rdf_writer = RDF::Turtle::Writer
102
+ return rdf_writer.buffer(:base_uri => 'http://phoibos.sfb673.org/',
103
+ :prefixes => {
104
+ :cats => 'http://cats.sfb673.org/',
105
+ :rdfs => RDF::RDFS.to_uri,
106
+ :foaf => RDF::FOAF.to_uri,
107
+ :dc => RDF::DC.to_uri,
108
+ :owl => RDF::OWL.to_uri,
109
+ :xsd => RDF::XSD.to_uri} #
110
+ ) do |writer|
111
+ as_rdf.each_statement do |statement|
112
+ writer << statement
113
+ end
114
+ end
115
+ end
116
+
117
+ def is_timeline?
118
+ self.dimension == DIM_TIME
119
+ end
120
+
121
+ def is_spatial_axis?
122
+ self.dimension == DIM_SPACE
123
+ end
124
+
125
+ end
@@ -0,0 +1,41 @@
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::Section
26
+
27
+ LIFECYCLE = 'lifecycle'
28
+
29
+ VOCABULARIES = 'vocabularies'
30
+
31
+ include ::ROXML
32
+ xml_name 'Section'
33
+
34
+ xml_accessor :key, :from => '@key'
35
+
36
+ xml_accessor :properties, :as => [::Mexico::FileSystem::Property], :from => "Property"
37
+ xml_accessor :property_maps, :as => [::Mexico::FileSystem::PropertyMap], :from => "PropertyMap"
38
+
39
+
40
+
41
+ end
@@ -0,0 +1,64 @@
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 +IdRef+ module provides a simple mechanism to map IDREF attributes
20
+ # in an XML document to Ruby objects that are stored elsewhere in the
21
+ # object tree. They are retrieved and accessed via the central corpus
22
+ # object.
23
+ module Mexico::FileSystem::StaticCollectionRef
24
+
25
+ # Defines a foreign key reference for an object. By default, it will
26
+ # refer to the corresponding collection in the top-level corpus, and
27
+ # it will retrieve the object via its +identifier+ field.
28
+ def collection_ref(field_identifier, field_class, field_collection, default)
29
+
30
+ field_name = field_identifier.to_s
31
+ pluralized_field_name = "#{field_name}s"
32
+ field_name_id = "#{field_name}_id"
33
+
34
+ define_method field_name do
35
+ if instance_variable_get("@#{field_name}").nil?
36
+ self.send("#{field_name}=", instance_variable_get("@#{field_name_id}"))
37
+ # self.instance_variable_set("@#{field_name}", instance_variable_get("@#{field_name_id}"))
38
+ end
39
+ return instance_variable_get("@#{field_name}")
40
+ end
41
+
42
+ define_method "#{field_name}=" do |param|
43
+ #instance_variable_set("@#{field_name_id}", param.identifier)
44
+ #instance_variable_set("@#{field_name}", param)
45
+
46
+ if param.nil?
47
+ instance_variable_set "@#{field_name}", default # Mexico::Constants::MediaTypes::OTHER
48
+ elsif param.kind_of?(String)
49
+ #@media_type = Mexico::Constants::MediaTypes::ALL.find{|m| m.identifier==new_media_type.to_s}
50
+ instance_variable_set "@#{field_name}", field_collection.find{|i| i.identifier==param.to_s}
51
+ if instance_variable_get("@#{field_name}").blank?
52
+ instance_variable_set "@#{field_name}", default
53
+ end
54
+ elsif param.kind_of?(field_class)
55
+ instance_variable_set "@#{field_name}", param
56
+ end
57
+ @media_type_id = @media_type.identifier
58
+ instance_variable_set "@#{field_name_id}", instance_variable_get("@#{field_name}").identifier
59
+ return instance_variable_get("@#{field_name}")
60
+ end
61
+
62
+ end
63
+
64
+ end
@@ -0,0 +1,23 @@
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
+ # A template class doing nothing.
20
+ class Mexico::FileSystem::Template
21
+
22
+
23
+ end