mexico 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,142 @@
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 'spec_helper'
20
+ include Mexico::FileSystem
21
+
22
+ describe Mexico::FileSystem::FiestaDocument do
23
+
24
+ # set up an initial corpus representation from the example file
25
+ before(:each) do
26
+ #@basepath = File.join(File.dirname(__FILE__), '..','..','assets','TESTCORPUS')
27
+ #@corpus = Mexico::FileSystem::Corpus.open(@basepath)
28
+
29
+ @fiesta_document = FiestaDocument.new
30
+
31
+ @scale = @fiesta_document.add_standard_timeline("s")
32
+
33
+ @foo_layer = @fiesta_document.add_layer Layer.new identifier: 'foo', name: 'lily'
34
+ @bar_layer = @fiesta_document.add_layer Layer.new identifier: 'bar', name: 'lotus'
35
+
36
+
37
+ @item1 = @fiesta_document.add_item(identifier: 'i1') do |i|
38
+ i.data = Mexico::FileSystem::Data.new(string_value: 'lion')
39
+ i.add_layer_link(Mexico::FileSystem::LayerLink.new(target_object: @foo_layer))
40
+ end
41
+
42
+
43
+ @item2 = @fiesta_document.add_item(identifier: 'i2') do |i|
44
+ i.data = Mexico::FileSystem::Data.new(string_value: 'tiger')
45
+ i.add_layer_link(Mexico::FileSystem::LayerLink.new(target_object: @bar_layer))
46
+ end
47
+
48
+ @item3 = @fiesta_document.add_item(identifier: 'i1') do |i|
49
+ i.data = Mexico::FileSystem::Data.new(string_value: 'bear')
50
+ i.add_layer_link(Mexico::FileSystem::LayerLink.new(target_object: @bar_layer))
51
+ end
52
+
53
+ end
54
+
55
+ context 'ActiveRecord-like collections' do
56
+
57
+
58
+ it 'should detect the helper modules' do
59
+
60
+ expect do
61
+ ::Mexico
62
+ ::Mexico::Util
63
+ end.to_not raise_error
64
+
65
+ end
66
+
67
+ context 'Scales' do
68
+
69
+ it 'should return the correct scale when asked for a string-based identifier' do
70
+ @fiesta_document.scales(@scale.identifier).should eq @scale
71
+ @fiesta_document.scales('other').should be nil
72
+ end
73
+
74
+ it 'should filter scales correctly by unit' do
75
+ @fiesta_document.scales(unit: 's').should include(@scale)
76
+ @fiesta_document.scales(unit: 'ms').should be_empty
77
+ end
78
+
79
+ it 'should filter scales correctly by dimension' do
80
+ @fiesta_document.scales(dimension: Mexico::FileSystem::Scale::DIM_TIME).should include(@scale)
81
+ @fiesta_document.scales(dimension: Mexico::FileSystem::Scale::DIM_SPACE).should be_empty
82
+ end
83
+
84
+ it 'should filter scales correctly by regexp id' do
85
+ @fiesta_document.scales(identifier: /time/).should include(@scale)
86
+ @fiesta_document.scales(identifier: /cauliflower/).should be_empty
87
+ end
88
+
89
+ it 'should select scales correctly by index' do
90
+ @fiesta_document.scales(0).should eq @scale
91
+ end
92
+
93
+ end
94
+
95
+
96
+ context 'Layers' do
97
+
98
+ it 'should return the correct layer when asked for a string-based identifier' do
99
+ @fiesta_document.layers(@foo_layer.identifier).should eq @foo_layer
100
+ @fiesta_document.layers(@bar_layer.identifier).should eq @bar_layer
101
+ end
102
+
103
+ context 'hash-based filtering' do
104
+
105
+ it 'should return the correct layers when given a hash with string values' do
106
+ @fiesta_document.layers(name: @foo_layer.name).should eq [@foo_layer]
107
+ @fiesta_document.layers(name: @bar_layer.name).should eq [@bar_layer]
108
+ @fiesta_document.layers(identifier: @foo_layer.identifier).should eq [@foo_layer]
109
+ @fiesta_document.layers(identifier: @bar_layer.identifier).should eq [@bar_layer]
110
+ @fiesta_document.layers(identifier: @foo_layer.identifier, name: @foo_layer.name).should eq [@foo_layer]
111
+ @fiesta_document.layers(identifier: @bar_layer.identifier, name: @bar_layer.name).should eq [@bar_layer]
112
+ @fiesta_document.layers(identifier: @foo_layer.identifier, name: @bar_layer.name).should eq []
113
+ end
114
+
115
+ it 'should return the correct layers when given a hash with regexp values' do
116
+ @fiesta_document.layers(name: /lil.*/).should eq [@foo_layer]
117
+ @fiesta_document.layers(name: /lot.*/).should eq [@bar_layer]
118
+ @fiesta_document.layers(name: /l.*/).should include(@foo_layer, @bar_layer)
119
+ end
120
+
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+
127
+ context 'Items' do
128
+
129
+ it 'should return the correct item when asked for a string-based identifier' do
130
+ @fiesta_document.items(@item1.identifier).should eq @item1
131
+ @fiesta_document.items(@item2.identifier).should eq @item2
132
+ end
133
+
134
+ it 'should return the correct layers when given a hash with string values' do
135
+ @fiesta_document.items(identifier: 'i1').should include(@item1)
136
+ @fiesta_document.items(data: 'tiger').should include(@item2)
137
+ end
138
+
139
+ end
140
+
141
+
142
+ end
@@ -0,0 +1,194 @@
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 'spec_helper'
20
+
21
+ describe Mexico::FileSystem::Corpus do
22
+
23
+ def write_corpus
24
+
25
+ doc = Nokogiri::XML::Document.new
26
+ doc.root = @corpus.to_xml
27
+ open(File.join(@basepath, "Corpus.OUT.xml"), 'w') do |file|
28
+ file << doc.serialize
29
+ end
30
+
31
+ end
32
+
33
+ # set up an initial corpus representation from the example file
34
+ before(:each) do
35
+ @basepath = File.join(File.dirname(__FILE__), '..','..','assets','TESTCORPUS')
36
+ @corpus = Mexico::FileSystem::Corpus.open(@basepath)
37
+ end
38
+
39
+ context 'Attributes' do
40
+
41
+ it 'should include the CorpusCore module' do
42
+ @corpus.should respond_to('core_included?')
43
+ end
44
+
45
+ context "identifier" do
46
+
47
+ it "should have accessor methods" do
48
+ @corpus.should respond_to(:identifier, :identifier=)
49
+ end
50
+
51
+ it "should have the right type" do
52
+ @corpus.identifier.kind_of?(String).should be true
53
+ @corpus.identifier.should match /^\w[-\w\d_]*$/
54
+ end
55
+
56
+ it "should have the correct value" do
57
+ @corpus.identifier.should eq "example-corpus"
58
+ end
59
+
60
+ end
61
+
62
+ context "name" do
63
+
64
+ it "should have accessor methods" do
65
+ @corpus.should respond_to(:name, :name=)
66
+ end
67
+
68
+ it "should have the right type" do
69
+ @corpus.name.kind_of?(String).should be true
70
+ end
71
+
72
+ it "should have the correct value" do
73
+ @corpus.name.should eq "Example Corpus"
74
+ end
75
+
76
+ end
77
+
78
+ context "description" do
79
+
80
+ it "should have accessor methods" do
81
+ @corpus.should respond_to(:description, :description=)
82
+ end
83
+
84
+ it "should have the right type" do
85
+ @corpus.description.kind_of?(String).should be true
86
+ end
87
+
88
+ it "should have the correct value" do
89
+ @corpus.description.should eq "This is an example corpus."
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
96
+
97
+ context "Aggregated components" do
98
+
99
+ context "Participants: " do
100
+
101
+ it 'should respond to participant methods' do
102
+ @corpus.should respond_to(:participants)
103
+ end
104
+
105
+ it 'collection accessor returns collection' do
106
+ @corpus.participants.should be_kind_of(Array)
107
+ end
108
+
109
+ it 'should have one member' do
110
+ @corpus.participants.should_not be nil
111
+ @corpus.participants.size.should be 1
112
+ end
113
+
114
+ it 'should have a first member with the correct data' do
115
+ @corpus.participants[0].identifier.should eq "vp01"
116
+ @corpus.participants[0].should respond_to("corpus")
117
+ @corpus.participants[0].corpus.identifier.should eq "example-corpus"
118
+ end
119
+
120
+ it 'should have a first member with the correct participant role' do
121
+ @corpus.participants[0].participant_role.should eq(::Mexico::Constants::ParticipantRoles::NAIVE)
122
+ end
123
+
124
+
125
+ it 'should reflect addition of a new participant' do
126
+ @corpus.participants << ::Mexico::FileSystem::Participant.new(:identifier=>"vp02",:participant_role=>"confederate")
127
+ @corpus.participants.size.should be 2
128
+ write_corpus
129
+ end
130
+
131
+ end
132
+
133
+ context "Designs: " do
134
+
135
+ it 'should respond to design methods' do
136
+ @corpus.should respond_to(:designs)
137
+ end
138
+
139
+ it 'collection accessor returns collection' do
140
+ @corpus.designs.should be_kind_of(Array)
141
+ end
142
+
143
+ it 'should have one design' do
144
+ @corpus.designs.should_not be nil
145
+ @corpus.designs.size.should be 2
146
+ end
147
+
148
+ it 'should have a first design with the correct data' do
149
+ @corpus.designs[0].identifier.should eq "example-design"
150
+ @corpus.designs[0].should respond_to("corpus")
151
+ @corpus.designs[0].corpus.identifier.should eq "example-corpus"
152
+ end
153
+
154
+ end
155
+
156
+
157
+ context "Trials: " do
158
+ it 'should respond to trials methods' do
159
+ @corpus.should respond_to(:trials)
160
+ end
161
+
162
+ it 'should have one trial' do
163
+ @corpus.trials.should_not be nil
164
+ @corpus.trials.size.should be 1
165
+ end
166
+
167
+ it 'after adding a trial, it should have two trials' do
168
+ @corpus.trials.size.should be 1
169
+ @corpus.trials << Mexico::FileSystem::Trial.new(:identifier=>"second-example-trial", :name=>"Second Example Trial", :description=>"This is an example trial.",:cue=>"V0?2",:running_number=>2)
170
+ @corpus.trials.size.should be 2
171
+ end
172
+ end
173
+
174
+
175
+ context "Resources: " do
176
+ it 'should respond to resources methods' do
177
+ @corpus.should respond_to(:resources)
178
+ end
179
+
180
+ it 'should have one resource' do
181
+ @corpus.resources.should_not be nil
182
+ @corpus.resources.size.should be 1
183
+ end
184
+
185
+ it 'after adding a resource, it should have two resources' do
186
+ @corpus.resources.size.should be 1
187
+ @corpus.resources << Mexico::FileSystem::Resource.new(:identifier=>"second-example-resource", :name=>"Second Example Resource", :description=>"This is an example resource.")
188
+ @corpus.resources.size.should be 2
189
+ end
190
+ end
191
+
192
+ end
193
+
194
+ end
@@ -0,0 +1,100 @@
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 'spec_helper'
20
+
21
+ describe Mexico::FileSystem::Design do
22
+
23
+ # set up an initial corpus representation from the example file
24
+ before(:each) do
25
+ @basepath = File.join(File.dirname(__FILE__), '..','..','assets','TESTCORPUS')
26
+ @xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
27
+ @corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
28
+ @design = @corpus.designs.first
29
+ end
30
+
31
+ context "Attributes" do
32
+
33
+ context "identifier" do
34
+
35
+ it "should have accessor methods" do
36
+ @design.should respond_to(:identifier, :identifier=)
37
+ end
38
+
39
+ it "should have the right type" do
40
+ @design.identifier.kind_of?(String).should be true
41
+ @design.identifier.should match /^\w[-\w\d_]*$/
42
+ end
43
+
44
+ it "should have the correct value" do
45
+ @design.identifier.should eq "example-design"
46
+ end
47
+
48
+ end
49
+
50
+ context "name" do
51
+
52
+ it "should have accessor methods" do
53
+ @design.should respond_to(:name, :name=)
54
+ end
55
+
56
+ it "should have the right type" do
57
+ @design.name.kind_of?(String).should be true
58
+ end
59
+
60
+ it "should have the correct value" do
61
+ @design.name.should eq "Example Design"
62
+ end
63
+
64
+ end
65
+
66
+ context "description" do
67
+
68
+ it "should have accessor methods" do
69
+ @design.should respond_to(:description, :description=)
70
+ end
71
+
72
+ it "should have the right type" do
73
+ @design.description.kind_of?(String).should be true
74
+ end
75
+
76
+ it "should have the correct value" do
77
+ @design.description.should eq "Design Description"
78
+ end
79
+
80
+ end
81
+
82
+ end
83
+
84
+
85
+ context "Aggregated components" do
86
+
87
+ it 'should have one or more design components' do
88
+ @design.should respond_to(:design_components)
89
+ @design.design_components.size.should eq 1
90
+ end
91
+
92
+ it 'should return correct values for the first design component' do
93
+ @design.design_components[0].identifier.should eq 'example-design-component'
94
+ @design.design_components[0].name.should eq 'Example Design Component'
95
+ @design.design_components[0].media_type.should eq ::Mexico::Constants::MediaTypes::VIDEO
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,100 @@
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 'spec_helper'
20
+
21
+ describe Mexico::FileSystem::Resource do
22
+
23
+ # set up an initial corpus representation from the example file
24
+ before(:each) do
25
+ @basepath = File.join(File.dirname(__FILE__), '..','..','assets','mexico-testcorpus','structured')
26
+ @xml = File.open(File.join(@basepath,'Corpus.xml'),'rb') { |f| f.read }
27
+ @corpus = Mexico::FileSystem::Corpus.from_xml(@xml, {:path => @basepath})
28
+
29
+ @design_b = @corpus.designs[0]
30
+ @design_c = @corpus.designs[1]
31
+ @design_d = @corpus.designs[2]
32
+ @design_e = @corpus.designs[3]
33
+
34
+ @design_component_x = @design_b.design_components[0]
35
+
36
+ @trial_f = @corpus.trials[0]
37
+ @trial_g = @corpus.trials[1]
38
+ @trial_h = @corpus.trials[2]
39
+ @trial_i = @corpus.trials[3]
40
+
41
+ @resource_j = @corpus.resources[0]
42
+
43
+ end
44
+
45
+ context 'our little corpus on the prairie' do
46
+
47
+ context 'should link from first design to two trials' do
48
+ it 'should have the method' do
49
+ @design_b.should respond_to :trials
50
+ end
51
+ it 'should return a collection' do
52
+ @design_b.trials.should be_kind_of(Enumerable)
53
+ end
54
+ it 'should return a collection with 2 elements' do
55
+ @design_b.trials.size.should eq 2
56
+ end
57
+ it 'a linked trial should say true when asked for linkage to design' do
58
+ @trial_f.linked_to_design?.should eq true
59
+ end
60
+ end
61
+
62
+ context 'resource <j> should link to trial <f>' do
63
+ it 'should have the methods' do
64
+ @resource_j.should respond_to :trial
65
+ @trial_f.should respond_to :resources
66
+ end
67
+ it 'should return appropriate objects' do
68
+ @resource_j.trial.should be_kind_of(Mexico::FileSystem::Trial)
69
+ @trial_f.resources.should be_kind_of(Enumerable)
70
+ end
71
+ it 'should return correct sizes' do
72
+ @trial_f.resources.size.should eq 1
73
+ end
74
+ it 'should return the correct objects' do
75
+ @resource_j.trial.should eq @trial_f
76
+ @trial_f.resources[0].should eq @resource_j
77
+ end
78
+ end
79
+
80
+ context 'resource <j> should link to design component <x>' do
81
+ it 'should have the methods' do
82
+ @resource_j.should respond_to :design_component
83
+ @design_component_x.should respond_to :resources
84
+ end
85
+ it 'should return appropriate objects' do
86
+ @resource_j.design_component.should be_kind_of(Mexico::FileSystem::DesignComponent)
87
+ @design_component_x.resources.should be_kind_of(Enumerable)
88
+ end
89
+ it 'should return correct sizes' do
90
+ @design_component_x.resources.size.should eq 1
91
+ end
92
+ it 'should return the correct objects' do
93
+ @resource_j.design_component.should eq @design_component_x
94
+ @design_component_x.resources[0].should eq @resource_j
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,76 @@
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 'spec_helper'
20
+
21
+ describe Mexico::FileSystem::Resource do
22
+
23
+ # set up an initial corpus representation from the example file
24
+ before(:each) do
25
+ @basepath = File.join(File.dirname(__FILE__), '..','..','assets','fiesta','elan')
26
+ @file = File.open(File.join(@basepath,'ElanFileFormat.eaf'),'rb') { |f| f.read }
27
+ @fiesta_document = ::Mexico::Fiesta::Interfaces::ElanInterface.instance.import(@file)
28
+ end
29
+
30
+ context 'our little corpus on the prairie' do
31
+
32
+ context 'should link from first design to two trials' do
33
+
34
+ it 'should have the method' do
35
+ puts @fiesta_document.scales
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ context 'item linking' do
43
+
44
+ it 'should behave correctly before testing' do
45
+ puts @fiesta_document.items.size
46
+ @fiesta_document.layers.each do |layer|
47
+ puts layer.name
48
+ #puts " /#{layer.items}/"
49
+ #puts " /#{layer.items.class.name}/"
50
+ puts " /#{layer.items.size}/"
51
+ layer.items.each do |i|
52
+ puts " #{i.data.string_value}"
53
+ i.item_links.each do |ili|
54
+ puts " -(#{ili.role})-> #{ili.target_object}"
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ it 'should behave correctly before testing' do
61
+ l1 = Mexico::FileSystem::Layer.new(identifier: 'test1', name: 'test1')
62
+ l2 = Mexico::FileSystem::Layer.new(identifier: 'test2', name: 'test2')
63
+ @fiesta_document.layers << l1
64
+ @fiesta_document.layers << l2
65
+
66
+ puts "L1: %s" % l1
67
+ puts "L2: %s" % l2
68
+
69
+ # add items
70
+ # link them
71
+ # check if additional links occur in the correct way
72
+ end
73
+
74
+ end
75
+
76
+ end