publisci 0.1.2

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 (220) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +36 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +51 -0
  8. data/README.rdoc +48 -0
  9. data/Rakefile +68 -0
  10. data/bin/bio-publisci +106 -0
  11. data/bin/bio-publisci-server +50 -0
  12. data/examples/bio-band_integration.rb +9 -0
  13. data/examples/no_magic.prov +58 -0
  14. data/examples/no_magic.rb +58 -0
  15. data/examples/orm.prov +48 -0
  16. data/examples/primer-full.prov +120 -0
  17. data/examples/primer.prov +66 -0
  18. data/examples/prov_dsl.prov +85 -0
  19. data/examples/safe_gen.rb +7 -0
  20. data/examples/visualization/primer.prov +66 -0
  21. data/examples/visualization/prov_viz.rb +140 -0
  22. data/examples/visualization/viz.rb +35 -0
  23. data/features/create_generator.feature +21 -0
  24. data/features/integration.feature +12 -0
  25. data/features/integration_steps.rb +10 -0
  26. data/features/metadata.feature +37 -0
  27. data/features/metadata_steps.rb +40 -0
  28. data/features/orm.feature +60 -0
  29. data/features/orm_steps.rb +74 -0
  30. data/features/prov_dsl.feature +14 -0
  31. data/features/prov_dsl_steps.rb +11 -0
  32. data/features/reader.feature +25 -0
  33. data/features/reader_steps.rb +61 -0
  34. data/features/step_definitions/bio-publisci_steps.rb +0 -0
  35. data/features/store.feature +27 -0
  36. data/features/store_steps.rb +42 -0
  37. data/features/support/env.rb +13 -0
  38. data/features/writer.feature +14 -0
  39. data/features/writer_steps.rb +24 -0
  40. data/lib/bio-publisci.rb +64 -0
  41. data/lib/bio-publisci/analyzer.rb +57 -0
  42. data/lib/bio-publisci/datacube_model.rb +111 -0
  43. data/lib/bio-publisci/dataset/ORM/data_cube_orm.rb +240 -0
  44. data/lib/bio-publisci/dataset/ORM/observation.rb +20 -0
  45. data/lib/bio-publisci/dataset/configuration.rb +31 -0
  46. data/lib/bio-publisci/dataset/data_cube.rb +418 -0
  47. data/lib/bio-publisci/dataset/dataset.rb +11 -0
  48. data/lib/bio-publisci/dataset/dataset_for.rb +186 -0
  49. data/lib/bio-publisci/dataset/interactive.rb +72 -0
  50. data/lib/bio-publisci/dsl/config.rb +34 -0
  51. data/lib/bio-publisci/dsl/dataset_dsl.rb +93 -0
  52. data/lib/bio-publisci/dsl/dsl.rb +72 -0
  53. data/lib/bio-publisci/dsl/metadata_dsl.rb +85 -0
  54. data/lib/bio-publisci/dsl/prov_dsl.rb +143 -0
  55. data/lib/bio-publisci/metadata/generator.rb +323 -0
  56. data/lib/bio-publisci/metadata/metadata.rb +5 -0
  57. data/lib/bio-publisci/metadata/metadata_model.rb +25 -0
  58. data/lib/bio-publisci/metadata/prov/activity.rb +88 -0
  59. data/lib/bio-publisci/metadata/prov/agent.rb +100 -0
  60. data/lib/bio-publisci/metadata/prov/association.rb +107 -0
  61. data/lib/bio-publisci/metadata/prov/config.rb +34 -0
  62. data/lib/bio-publisci/metadata/prov/derivation.rb +60 -0
  63. data/lib/bio-publisci/metadata/prov/element.rb +120 -0
  64. data/lib/bio-publisci/metadata/prov/entity.rb +64 -0
  65. data/lib/bio-publisci/metadata/prov/model/prov_models.rb +109 -0
  66. data/lib/bio-publisci/metadata/prov/plan.rb +32 -0
  67. data/lib/bio-publisci/metadata/prov/prov.rb +78 -0
  68. data/lib/bio-publisci/metadata/prov/role.rb +40 -0
  69. data/lib/bio-publisci/metadata/prov/usage.rb +64 -0
  70. data/lib/bio-publisci/metadata/publisher.rb +25 -0
  71. data/lib/bio-publisci/mixins/custom_predicate.rb +38 -0
  72. data/lib/bio-publisci/mixins/dereferencable.rb +34 -0
  73. data/lib/bio-publisci/mixins/registry.rb +27 -0
  74. data/lib/bio-publisci/mixins/vocabulary.rb +8 -0
  75. data/lib/bio-publisci/output.rb +27 -0
  76. data/lib/bio-publisci/parser.rb +266 -0
  77. data/lib/bio-publisci/post_processor.rb +95 -0
  78. data/lib/bio-publisci/query/query_helper.rb +123 -0
  79. data/lib/bio-publisci/r_client.rb +54 -0
  80. data/lib/bio-publisci/readers/arff.rb +49 -0
  81. data/lib/bio-publisci/readers/base.rb +57 -0
  82. data/lib/bio-publisci/readers/csv.rb +88 -0
  83. data/lib/bio-publisci/readers/dataframe.rb +67 -0
  84. data/lib/bio-publisci/readers/maf.rb +199 -0
  85. data/lib/bio-publisci/readers/r_cross.rb +112 -0
  86. data/lib/bio-publisci/readers/r_matrix.rb +176 -0
  87. data/lib/bio-publisci/store.rb +56 -0
  88. data/lib/bio-publisci/writers/arff.rb +91 -0
  89. data/lib/bio-publisci/writers/base.rb +93 -0
  90. data/lib/bio-publisci/writers/csv.rb +31 -0
  91. data/lib/bio-publisci/writers/dataframe.rb +81 -0
  92. data/lib/bio-publisci/writers/json.rb +18 -0
  93. data/lib/r2rdf.rb +226 -0
  94. data/lib/template_bak.rb +12 -0
  95. data/lib/template_bak/publisci.rb +3 -0
  96. data/lib/vocabs/cc.rb +18 -0
  97. data/lib/vocabs/cert.rb +13 -0
  98. data/lib/vocabs/dc.rb +63 -0
  99. data/lib/vocabs/dc11.rb +23 -0
  100. data/lib/vocabs/doap.rb +45 -0
  101. data/lib/vocabs/exif.rb +168 -0
  102. data/lib/vocabs/foaf.rb +69 -0
  103. data/lib/vocabs/geo.rb +13 -0
  104. data/lib/vocabs/http.rb +26 -0
  105. data/lib/vocabs/ma.rb +78 -0
  106. data/lib/vocabs/owl.rb +59 -0
  107. data/lib/vocabs/rdfs.rb +17 -0
  108. data/lib/vocabs/rsa.rb +12 -0
  109. data/lib/vocabs/rss.rb +14 -0
  110. data/lib/vocabs/sioc.rb +93 -0
  111. data/lib/vocabs/skos.rb +36 -0
  112. data/lib/vocabs/wot.rb +21 -0
  113. data/lib/vocabs/xhtml.rb +9 -0
  114. data/lib/vocabs/xsd.rb +58 -0
  115. data/resources/maf_example.maf +10 -0
  116. data/resources/maf_rdf.ttl +1173 -0
  117. data/resources/primer.ttl +38 -0
  118. data/resources/queries/code_resources.rq +10 -0
  119. data/resources/queries/codes.rq +18 -0
  120. data/resources/queries/dataset.rq +7 -0
  121. data/resources/queries/dimension_ranges.rq +8 -0
  122. data/resources/queries/dimensions.rq +12 -0
  123. data/resources/queries/gene.rq +16 -0
  124. data/resources/queries/hugo_to_ensembl.rq +7 -0
  125. data/resources/queries/maf_column.rq +26 -0
  126. data/resources/queries/measures.rq +12 -0
  127. data/resources/queries/observation_labels.rq +8 -0
  128. data/resources/queries/observations.rq +13 -0
  129. data/resources/queries/patient.rq +11 -0
  130. data/resources/queries/patient_list.rq +11 -0
  131. data/resources/queries/patients_with_mutation.rq +18 -0
  132. data/resources/queries/properties.rq +8 -0
  133. data/resources/queries/test.rq +3 -0
  134. data/resources/weather.numeric.arff +28 -0
  135. data/scripts/get_gene_lengths.rb +50 -0
  136. data/scripts/islet_mlratio.rb +6 -0
  137. data/scripts/scan_islet.rb +6 -0
  138. data/scripts/update_reference.rb +25 -0
  139. data/server/helpers.rb +215 -0
  140. data/server/public/src-min-noconflict/LICENSE +24 -0
  141. data/server/public/src-min-noconflict/ace.js +11 -0
  142. data/server/public/src-min-noconflict/ext-chromevox.js +1 -0
  143. data/server/public/src-min-noconflict/ext-elastic_tabstops_lite.js +1 -0
  144. data/server/public/src-min-noconflict/ext-emmet.js +1 -0
  145. data/server/public/src-min-noconflict/ext-keybinding_menu.js +1 -0
  146. data/server/public/src-min-noconflict/ext-language_tools.js +1 -0
  147. data/server/public/src-min-noconflict/ext-modelist.js +1 -0
  148. data/server/public/src-min-noconflict/ext-old_ie.js +1 -0
  149. data/server/public/src-min-noconflict/ext-searchbox.js +1 -0
  150. data/server/public/src-min-noconflict/ext-settings_menu.js +1 -0
  151. data/server/public/src-min-noconflict/ext-spellcheck.js +1 -0
  152. data/server/public/src-min-noconflict/ext-split.js +1 -0
  153. data/server/public/src-min-noconflict/ext-static_highlight.js +1 -0
  154. data/server/public/src-min-noconflict/ext-statusbar.js +1 -0
  155. data/server/public/src-min-noconflict/ext-textarea.js +1 -0
  156. data/server/public/src-min-noconflict/ext-themelist.js +1 -0
  157. data/server/public/src-min-noconflict/ext-whitespace.js +1 -0
  158. data/server/public/src-min-noconflict/keybinding-emacs.js +1 -0
  159. data/server/public/src-min-noconflict/keybinding-vim.js +1 -0
  160. data/server/public/src-min-noconflict/mode-ruby.js +1 -0
  161. data/server/public/src-min-noconflict/snippets/ruby.js +1 -0
  162. data/server/public/src-min-noconflict/theme-twilight.js +1 -0
  163. data/server/public/src-min-noconflict/worker-coffee.js +1 -0
  164. data/server/public/src-min-noconflict/worker-css.js +1 -0
  165. data/server/public/src-min-noconflict/worker-javascript.js +1 -0
  166. data/server/public/src-min-noconflict/worker-json.js +1 -0
  167. data/server/public/src-min-noconflict/worker-lua.js +1 -0
  168. data/server/public/src-min-noconflict/worker-php.js +1 -0
  169. data/server/public/src-min-noconflict/worker-xquery.js +1 -0
  170. data/server/routes.rb +123 -0
  171. data/server/views/dsl.haml +65 -0
  172. data/server/views/dump.haml +3 -0
  173. data/server/views/import.haml +35 -0
  174. data/server/views/new_repository.haml +25 -0
  175. data/server/views/query.haml +28 -0
  176. data/server/views/repository.haml +25 -0
  177. data/spec/ORM/data_cube_orm_spec.rb +33 -0
  178. data/spec/ORM/prov_model_spec.rb +72 -0
  179. data/spec/analyzer_spec.rb +36 -0
  180. data/spec/bnode_spec.rb +66 -0
  181. data/spec/csv/bacon.csv +4 -0
  182. data/spec/csv/moar_bacon.csv +11 -0
  183. data/spec/data_cube_spec.rb +169 -0
  184. data/spec/dataset_for_spec.rb +77 -0
  185. data/spec/dsl_spec.rb +134 -0
  186. data/spec/generators/csv_spec.rb +44 -0
  187. data/spec/generators/dataframe_spec.rb +44 -0
  188. data/spec/generators/maf_spec.rb +40 -0
  189. data/spec/generators/r_cross_spec.rb +51 -0
  190. data/spec/generators/r_matrix_spec.rb +44 -0
  191. data/spec/length_lookup_spec.rb +0 -0
  192. data/spec/maf_query_spec.rb +343 -0
  193. data/spec/metadata/metadata_dsl_spec.rb +68 -0
  194. data/spec/prov/activity_spec.rb +74 -0
  195. data/spec/prov/agent_spec.rb +54 -0
  196. data/spec/prov/association_spec.rb +55 -0
  197. data/spec/prov/config_spec.rb +28 -0
  198. data/spec/prov/derivation_spec.rb +30 -0
  199. data/spec/prov/entity_spec.rb +52 -0
  200. data/spec/prov/role_spec.rb +94 -0
  201. data/spec/prov/usage_spec.rb +98 -0
  202. data/spec/queries/integrity/1.rq +21 -0
  203. data/spec/queries/integrity/11.rq +29 -0
  204. data/spec/queries/integrity/12.rq +37 -0
  205. data/spec/queries/integrity/14.rq +25 -0
  206. data/spec/queries/integrity/19_1.rq +21 -0
  207. data/spec/queries/integrity/19_2.rq +15 -0
  208. data/spec/queries/integrity/2.rq +22 -0
  209. data/spec/queries/integrity/3.rq +19 -0
  210. data/spec/queries/integrity/4.rq +13 -0
  211. data/spec/queries/integrity/5.rq +14 -0
  212. data/spec/r_builder_spec.rb +33 -0
  213. data/spec/resource/.RData +0 -0
  214. data/spec/resource/example.Rhistory +3 -0
  215. data/spec/spec_helper.rb +17 -0
  216. data/spec/turtle/bacon +147 -0
  217. data/spec/turtle/reference +2064 -0
  218. data/spec/turtle/weather +275 -0
  219. data/spec/writer_spec.rb +75 -0
  220. metadata +589 -0
@@ -0,0 +1,68 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+
3
+ describe PubliSci::Metadata::DSL do
4
+ include PubliSci::Metadata::DSL
5
+
6
+ before(:each) do
7
+ PubliSci::Prov.registry.clear
8
+ end
9
+
10
+ it "can generate basic metadata as n3" do
11
+ dataset 'bacon'
12
+ title 'Bacon Data'
13
+ description 'a dataset about bacon'
14
+ creator 'Will'
15
+ topic 'Delicious Bacon'
16
+ str = generate_n3
17
+ str[/rdfs:label "(.+)";/,1].should == "Bacon Data"
18
+ str[/dct:creator "(.+)";/,1].should == "Will"
19
+ str[/dct:subject "(.+)";/,1].should == "Delicious Bacon"
20
+ str[/dct:description "(.+)";/,1].should == "a dataset about bacon"
21
+ str[/dct:issued "(.+)"\^\^xsd:date/,1].should == Time.now.strftime("%Y-%m-%d")
22
+ end
23
+
24
+ it "can add additional information about publisher" do
25
+ dataset 'bacon'
26
+ p = publisher do
27
+ label "pub"
28
+ uri "http://some-organization.com"
29
+ end
30
+
31
+ p.label.should == "pub"
32
+ generate_n3[%r{dct:publisher <(.+)> .},1].should == "http://some-organization.com"
33
+ end
34
+
35
+ # it "can be created with a block" do
36
+ # a = agent :ag do
37
+ # subject "http://things.com/stuff"
38
+ # name "Mr Person"
39
+ # end
40
+ # a.is_a?(Agent).should be true
41
+ # a.subject.should == "http://things.com/stuff"
42
+ # a.name.should == "Mr Person"
43
+ # end
44
+
45
+ # it "can be given a type corresponding to a subclass of prov:Agent" do
46
+ # a = agent :name, type: "software"
47
+ # a.type.should == :software
48
+ # a.to_n3["prov:SoftwareAgent"].should_not be nil
49
+ # end
50
+
51
+ # it "can be created using the organization helper" do
52
+ # a = organization :group
53
+ # a.type.should == :organization
54
+ # end
55
+
56
+ # it "raises an exception when on_behalf_of does not refer to an agent" do
57
+ # a = agent :name, on_behalf_of: :other
58
+ # expect {a.on_behalf_of[0]}.to raise_error
59
+ # end
60
+
61
+ # it "lazy loads other objects, so declaration order doesn't usually matter" do
62
+ # a = agent :name, on_behalf_of: :other
63
+ # b = agent :other
64
+
65
+ # a.on_behalf_of.should == b
66
+ # end
67
+
68
+ end
@@ -0,0 +1,74 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+ # include PubliSci
4
+
5
+ describe PubliSci::Prov::Activity do
6
+
7
+ before(:each) do
8
+ @evaluator = PubliSci::Prov::DSL::Instance.new
9
+ end
10
+
11
+ it "can generate activity fields from symbol" do
12
+ a = activity :name
13
+ a.is_a?(Prov::Activity).should be true
14
+ a.subject.should == "http://rqtl.org/ns/activity/name"
15
+ end
16
+
17
+ it "can specify fields manually" do
18
+ a = activity :name, subject: "http://example.org/name"
19
+ a.subject.should == "http://example.org/name"
20
+ end
21
+
22
+ it "can be created with a block" do
23
+ e = entity :data
24
+ a = activity :ag do
25
+ subject "http://things.com/stuff"
26
+ generated :data
27
+ end
28
+ a.is_a?(Prov::Activity).should be true
29
+ a.subject.should == "http://things.com/stuff"
30
+ end
31
+
32
+ it "lazy loads other objects" do
33
+ a = activity :ag do
34
+ subject "http://things.com/stuff"
35
+ generated :data
36
+ end
37
+ e = entity :data
38
+
39
+ a.generated[0].should == e
40
+ end
41
+
42
+ it "raises an exception when used does not refer to an entity" do
43
+ a = activity :name, used: :some_data
44
+ expect {a.used[0]}.to raise_error
45
+ end
46
+
47
+ it "raises an exception when generated does not refer to an entity" do
48
+ a = activity :name, generated: :other_data
49
+ expect {a.generated[0]}.to raise_error
50
+ end
51
+
52
+ it "lazy loads generated relationships" do
53
+ a = activity :act, generated: :data
54
+ e = entity :data
55
+
56
+ a.generated[0].should == e
57
+ end
58
+
59
+ it "lazy loads used relationships" do
60
+ a = activity :act, generated: :data, used: :other_data
61
+ e = entity :data
62
+ f = entity :other_data
63
+
64
+ a.used[0].should == f
65
+ end
66
+
67
+ # it "lazy loads other objects, so declaration order doesn't usually matter" do
68
+ # a = activity :name, on_behalf_of: :other
69
+ # b = activity :other
70
+
71
+ # a.on_behalf_of.should == b
72
+ # end
73
+
74
+ end
@@ -0,0 +1,54 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+
4
+ describe PubliSci::Prov::Agent do
5
+
6
+ before(:each) do
7
+ @evaluator = PubliSci::Prov::DSL::Instance.new
8
+ end
9
+
10
+ it "can generate agent fields from symbol" do
11
+ a = agent :name
12
+ a.is_a?(Prov::Agent).should be true
13
+ a.subject.should == "http://rqtl.org/ns/agent/name"
14
+ end
15
+
16
+ it "can specify fields manually" do
17
+ a = agent :name, subject: "http://example.org/name"
18
+ a.subject.should == "http://example.org/name"
19
+ end
20
+
21
+ it "can be created with a block" do
22
+ a = agent :ag do
23
+ subject "http://things.com/stuff"
24
+ name "Mr Person"
25
+ end
26
+ a.is_a?(Prov::Agent).should be true
27
+ a.subject.should == "http://things.com/stuff"
28
+ a.name.should == "Mr Person"
29
+ end
30
+
31
+ it "can be given a type corresponding to a subclass of prov:Agent" do
32
+ a = agent :name, type: "software"
33
+ a.type.should == :software
34
+ a.to_n3["prov:SoftwareAgent"].should_not be nil
35
+ end
36
+
37
+ it "can be created using the organization helper" do
38
+ a = organization :group
39
+ a.type.should == :organization
40
+ end
41
+
42
+ it "raises an exception when on_behalf_of does not refer to an agent" do
43
+ a = agent :name, on_behalf_of: :other
44
+ expect {a.on_behalf_of[0]}.to raise_error
45
+ end
46
+
47
+ it "lazy loads other objects, so declaration order doesn't usually matter" do
48
+ a = agent :name, on_behalf_of: :other
49
+ b = agent :other
50
+
51
+ a.on_behalf_of.should == b
52
+ end
53
+
54
+ end
@@ -0,0 +1,55 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+
4
+ describe PubliSci::Prov::Association do
5
+ before(:each) do
6
+ @ev = PubliSci::Prov::DSL::Instance.new
7
+ end
8
+
9
+ it "can create simple associations" do
10
+ e = @ev.entity :name
11
+ f = @ev.agent :other
12
+ g = @ev.activity :do_things, generated: :name, associated_with: :other
13
+ g.associated_with[0].should == f
14
+ @ev.generate_n3["prov:wasAssociatedWith"].size.should > 0
15
+ end
16
+
17
+ it "creates qualified associations when a block is passed" do
18
+ e = @ev.entity :name
19
+ f = @ev.agent :other
20
+ p = @ev.plan :the_plan
21
+ g = @ev.activity :do_things do
22
+ generated :name
23
+ associated_with do
24
+ agent :other
25
+ plan :the_plan
26
+ end
27
+ end
28
+ g.associated_with.first.agent.should == f
29
+ @ev.generate_n3["prov:wasAssociatedWith"].size.should > 0
30
+ @ev.generate_n3["prov:qualifiedAssociation"].size.should > 0
31
+ end
32
+
33
+ # it "raises an exception when derivation does not refer to an entity" do
34
+ # e = entity :name, derived_from: :dataset
35
+ # expect {e.derived_from[0]}.to raise_error
36
+ # end
37
+
38
+ # it "raises an exception when attribution does not refer to an agent" do
39
+ # e = entity :name, attributed_to: :person
40
+ # expect {e.attributed_to[0]}.to raise_error
41
+ # end
42
+
43
+ # it "raises an exception when generated_by does not refer to an activity" do
44
+ # e = entity :name, generated_by: :act
45
+ # expect {e.generated_by[0]}.to raise_error
46
+ # end
47
+
48
+ # it "lazy loads other objects, so declaration order doesn't usually matter" do
49
+ # e = entity :name, derived_from: :other
50
+ # f = entity :other
51
+
52
+
53
+ # e.derived_from[0].should == f
54
+ # end
55
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+ include PubliSci
4
+
5
+ describe PubliSci::Prov::Configuration do
6
+
7
+ before(:each) do
8
+ @evaluator = PubliSci::Prov::DSL::Instance.new
9
+ end
10
+
11
+ it "can set basic config methods" do
12
+ configure do |cfg|
13
+ cfg.output :to_repository
14
+ end
15
+ settings.output.should == :to_repository
16
+ end
17
+
18
+ it "can configure different repository types", no_travis: true do
19
+ configure do |cfg|
20
+ cfg.repository :fourstore
21
+ end
22
+ a = activity :name
23
+ a.is_a?(Prov::Activity).should be true
24
+ r=to_repository
25
+ a.subject.should == "http://rqtl.org/ns/activity/name"
26
+ r.is_a?(RDF::FourStore::Repository).should be true
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+
4
+ describe PubliSci::Prov::Derivation do
5
+ before(:each) do
6
+ @ev = PubliSci::Prov::DSL::Instance.new
7
+ end
8
+
9
+ it "can create simple derivations" do
10
+ e = @ev.entity :name
11
+ f = @ev.entity :other, derived_from: :name
12
+ # g = @ev.activity :do_things, generated: :name, associated_with: :other
13
+ f.derived_from[0].should == e
14
+ @ev.generate_n3
15
+ @ev.generate_n3["prov:wasDerivedFrom"].size.should > 0
16
+ end
17
+
18
+ it "creates qualified derivations when a block is passed" do
19
+ e = @ev.entity :name
20
+ f = @ev.entity :other do
21
+ derived_from :name do
22
+ had_activity :do_things
23
+ end
24
+ end
25
+ g = @ev.activity :do_things do
26
+ generated :other
27
+ end
28
+ f.derived_from.first.had_activity.should == g
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+
4
+ describe PubliSci::Prov::Entity do
5
+ before(:each) do
6
+ @evaluator = PubliSci::Prov::DSL::Instance.new
7
+ end
8
+
9
+ it "can generate entity fields from symbol" do
10
+ e = entity :name
11
+ e.is_a?(Prov::Entity).should be true
12
+ e.subject.should == "http://rqtl.org/ns/entity/name"
13
+ end
14
+
15
+ it "can specify fields manually" do
16
+ e = entity :name, subject: "http://example.org/name"
17
+ e.subject.should == "http://example.org/name"
18
+ end
19
+
20
+ it "can be created with a block" do
21
+ e = entity :ent do
22
+ subject "http://things.com/stuff"
23
+ source "/somefile.txt"
24
+ end
25
+ e.is_a?(Prov::Entity).should be true
26
+ e.subject.should == "http://things.com/stuff"
27
+ e.source[0].should == "/somefile.txt"
28
+ end
29
+
30
+ it "raises an exception when derivation does not refer to an entity" do
31
+ e = entity :name, derived_from: :dataset
32
+ expect {e.derived_from[0]}.to raise_error
33
+ end
34
+
35
+ it "raises an exception when attribution does not refer to an agent" do
36
+ e = entity :name, attributed_to: :person
37
+ expect {e.attributed_to[0]}.to raise_error
38
+ end
39
+
40
+ it "raises an exception when generated_by does not refer to an activity" do
41
+ e = entity :name, generated_by: :act
42
+ expect {e.generated_by[0]}.to raise_error
43
+ end
44
+
45
+ it "lazy loads other objects, so declaration order doesn't usually matter" do
46
+ e = entity :name, derived_from: :other
47
+ f = entity :other
48
+
49
+
50
+ e.derived_from[0].should == f
51
+ end
52
+ end
@@ -0,0 +1,94 @@
1
+ require_relative '../../lib/bio-publisci.rb'
2
+ include PubliSci::Prov::DSL
3
+
4
+ describe PubliSci::Prov::Role do
5
+
6
+ before(:each) do
7
+ @evaluator = PubliSci::Prov::DSL::Instance.new
8
+ end
9
+
10
+ it "creates a role in a used block" do
11
+ ent1 = @ev.entity :some_data
12
+ ent2 = @ev.entity :other_data
13
+ ag = @ev.agent :some_guy
14
+ act = @ev.activity :do_things do
15
+ generated :some_data
16
+ associated_with :some_guy
17
+ used do
18
+ entity :other_data
19
+ role :plagirized
20
+ end
21
+ end
22
+ act.used[0].role.to_n3["a prov:Role"].size.should > 0
23
+ end
24
+
25
+ it "can have a comment attached" do
26
+ ent1 = @ev.entity :some_data
27
+ ent2 = @ev.entity :other_data
28
+ ag = @ev.agent :some_guy
29
+ act = @ev.activity :do_things do
30
+ generated :some_data
31
+ associated_with :some_guy
32
+ used do
33
+ entity :other_data
34
+ role :plagirized do
35
+ comment "I stole all of this data"
36
+ end
37
+ end
38
+ end
39
+ act.used[0].role.to_n3["rdfs:comment"].size.should > 0
40
+ end
41
+
42
+ # it "can be created with a block" do
43
+ # e = entity :data
44
+ # a = activity :ag do
45
+ # subject "http://things.com/stuff"
46
+ # generated :data
47
+ # end
48
+ # a.is_a?(Activity).should be true
49
+ # a.subject.should == "http://things.com/stuff"
50
+ # end
51
+
52
+ # it "lazy loads other objects" do
53
+ # a = activity :ag do
54
+ # subject "http://things.com/stuff"
55
+ # generated :data
56
+ # end
57
+ # e = entity :data
58
+
59
+ # a.generated[0].should == e
60
+ # end
61
+
62
+ # it "raises an exception when used does not refer to an entity" do
63
+ # a = activity :name, used: :some_data
64
+ # expect {a.used[0]}.to raise_error
65
+ # end
66
+
67
+ # it "raises an exception when generated does not refer to an entity" do
68
+ # a = activity :name, generated: :other_data
69
+ # expect {a.generated[0]}.to raise_error
70
+ # end
71
+
72
+ # it "lazy loads generated relationships" do
73
+ # a = activity :act, generated: :data
74
+ # e = entity :data
75
+
76
+ # a.generated[0].should == e
77
+ # end
78
+
79
+ # it "lazy loads used relationships" do
80
+ # a = activity :act, generated: :data, used: :other_data
81
+ # e = entity :data
82
+ # f = entity :other_data
83
+
84
+ # a.used[0].should == f
85
+ # end
86
+
87
+ # it "lazy loads other objects, so declaration order doesn't usually matter" do
88
+ # a = activity :name, on_behalf_of: :other
89
+ # b = activity :other
90
+
91
+ # a.on_behalf_of.should == b
92
+ # end
93
+
94
+ end