rof 1.0.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -7
  3. data/LICENSE +201 -16
  4. data/Rakefile +46 -0
  5. data/bin/csv_to_rof +1 -2
  6. data/bin/fedora_to_rof +7 -1
  7. data/bin/jsonld_to_rof +26 -0
  8. data/bin/osf_to_rof +6 -2
  9. data/bin/rof +5 -19
  10. data/lib/rof.rb +2 -6
  11. data/lib/rof/access.rb +1 -1
  12. data/lib/rof/cli.rb +104 -67
  13. data/lib/rof/compare_rof.rb +68 -39
  14. data/lib/rof/filter.rb +21 -0
  15. data/lib/rof/filters.rb +38 -0
  16. data/lib/rof/filters/bendo.rb +15 -17
  17. data/lib/rof/filters/date_stamp.rb +5 -4
  18. data/lib/rof/filters/file_to_url.rb +5 -3
  19. data/lib/rof/filters/label.rb +9 -7
  20. data/lib/rof/filters/work.rb +7 -5
  21. data/lib/rof/ingest.rb +5 -0
  22. data/lib/rof/osf_context.rb +2 -2
  23. data/lib/rof/rdf_context.rb +2 -0
  24. data/lib/rof/translator.rb +18 -0
  25. data/lib/rof/translators.rb +23 -0
  26. data/lib/rof/{translate_csv.rb → translators/csv_to_rof.rb} +4 -3
  27. data/lib/rof/translators/fedora_to_rof.rb +244 -0
  28. data/lib/rof/translators/jsonld_to_rof.rb +112 -0
  29. data/lib/rof/translators/jsonld_to_rof/accumulator.rb +175 -0
  30. data/lib/rof/translators/jsonld_to_rof/predicate_handler.rb +223 -0
  31. data/lib/rof/translators/jsonld_to_rof/predicate_object_handler.rb +125 -0
  32. data/lib/rof/translators/jsonld_to_rof/statement_handler.rb +91 -0
  33. data/lib/rof/translators/osf_to_rof.rb +191 -0
  34. data/lib/rof/utility.rb +44 -1
  35. data/lib/rof/version.rb +1 -1
  36. data/rof.gemspec +10 -2
  37. data/spec/coverage_helper.rb +17 -0
  38. data/spec/fixtures/for_utility_load_items_from_json_file/multiple_items.json +8 -0
  39. data/spec/fixtures/for_utility_load_items_from_json_file/parse_error.json +3 -0
  40. data/spec/fixtures/for_utility_load_items_from_json_file/single_item.json +3 -0
  41. data/spec/fixtures/jsonld_to_rof/0g354f18610.jsonld +113 -0
  42. data/spec/fixtures/jsonld_to_rof/0g354f18610.rof +96 -0
  43. data/spec/fixtures/jsonld_to_rof/2j62s467216.jsonld +113 -0
  44. data/spec/fixtures/jsonld_to_rof/2j62s467216.rof +93 -0
  45. data/spec/fixtures/jsonld_to_rof/2v23vt16z2z.jsonld +70 -0
  46. data/spec/fixtures/jsonld_to_rof/2v23vt16z2z.rof +87 -0
  47. data/spec/fixtures/jsonld_to_rof/cr56n01253w.jsonld +84 -0
  48. data/spec/fixtures/jsonld_to_rof/cr56n01253w.rof +95 -0
  49. data/spec/fixtures/jsonld_to_rof/h989r21069m.jsonld +84 -0
  50. data/spec/fixtures/jsonld_to_rof/h989r21069m.rof +98 -0
  51. data/spec/fixtures/jsonld_to_rof/js956d59913.jsonld +79 -0
  52. data/spec/fixtures/jsonld_to_rof/js956d59913.rof +89 -0
  53. data/spec/fixtures/jsonld_to_rof/m039k358q5c.jsonld +80 -0
  54. data/spec/fixtures/jsonld_to_rof/m039k358q5c.rof +64 -0
  55. data/spec/fixtures/jsonld_to_rof/nk322b9161g.jsonld +89 -0
  56. data/spec/fixtures/jsonld_to_rof/nk322b9161g.rof +69 -0
  57. data/spec/fixtures/jsonld_to_rof/p8418k7430d.jsonld +84 -0
  58. data/spec/fixtures/jsonld_to_rof/p8418k7430d.rof +67 -0
  59. data/spec/fixtures/jsonld_to_rof/xg94hm53h0c.jsonld +98 -0
  60. data/spec/fixtures/jsonld_to_rof/xg94hm53h0c.rof +110 -0
  61. data/spec/fixtures/jsonld_to_rof/zk51vd69n1r.jsonld +94 -0
  62. data/spec/fixtures/jsonld_to_rof/zk51vd69n1r.rof +121 -0
  63. data/spec/fixtures/osf/phz6b.tar.gz +0 -0
  64. data/spec/lib/rof/access_spec.rb +30 -23
  65. data/spec/lib/rof/cli_spec.rb +83 -60
  66. data/spec/lib/rof/compare_rof_spec.rb +35 -24
  67. data/spec/lib/rof/filter_spec.rb +10 -0
  68. data/spec/lib/rof/filters/bendo_spec.rb +42 -0
  69. data/spec/lib/rof/filters/date_stamp_spec.rb +9 -5
  70. data/spec/lib/rof/filters/file_to_url_spec.rb +7 -3
  71. data/spec/lib/rof/filters/label_spec.rb +121 -77
  72. data/spec/lib/rof/filters/work_spec.rb +7 -4
  73. data/spec/lib/rof/filters_spec.rb +14 -0
  74. data/spec/lib/rof/translator_spec.rb +15 -0
  75. data/spec/lib/rof/{translate_csv_spec.rb → translators/csv_to_rof_spec.rb} +14 -14
  76. data/spec/lib/rof/translators/fedora_to_rof_spec.rb +64 -0
  77. data/spec/lib/rof/translators/jsonld_to_rof/accumulator_spec.rb +121 -0
  78. data/spec/lib/rof/translators/jsonld_to_rof/predicate_handler_spec.rb +73 -0
  79. data/spec/lib/rof/translators/jsonld_to_rof/predicate_object_handler_spec.rb +48 -0
  80. data/spec/lib/rof/translators/jsonld_to_rof/statement_handler_spec.rb +40 -0
  81. data/spec/lib/rof/translators/jsonld_to_rof_spec.rb +120 -0
  82. data/spec/lib/rof/{osf_to_rof_spec.rb → translators/osf_to_rof_spec.rb} +55 -25
  83. data/spec/lib/rof/translators_spec.rb +14 -0
  84. data/spec/lib/rof/utility_spec.rb +47 -1
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/support/an_rof_filter.rb +10 -0
  87. metadata +186 -15
  88. data/lib/rof/get_from_fedora.rb +0 -211
  89. data/lib/rof/osf_to_rof.rb +0 -123
  90. data/spec/lib/rof/get_from_fedora_spec.rb +0 -22
@@ -0,0 +1,121 @@
1
+ [
2
+ {
3
+ "type": "fobject",
4
+ "pid": "und:zk51vd69n1r",
5
+ "af-model": "Etd",
6
+ "metadata": {
7
+ "@context": {
8
+ "bibo": "http://purl.org/ontology/bibo/",
9
+ "dc": "http://purl.org/dc/terms/",
10
+ "ebucore": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
11
+ "foaf": "http://xmlns.com/foaf/0.1/",
12
+ "hydramata-rel": "http://projecthydra.org/ns/relations#",
13
+ "mrel": "http://id.loc.gov/vocabulary/relators/",
14
+ "ms": "http://www.ndltd.org/standards/metadata/etdms/1.1/",
15
+ "nd": "https://library.nd.edu/ns/terms/",
16
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
17
+ "ths": "http://id.loc.gov/vocabulary/relators/",
18
+ "vracore": "http://purl.org/vra/",
19
+ "dc:dateSubmitted": {
20
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
21
+ },
22
+ "dc:created": {
23
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
24
+ },
25
+ "dc:modified": {
26
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
27
+ }
28
+ },
29
+ "dc:title": "Characterization of the Roles of ADAM17a and ADAM17b during Zebrafish Retinal Regeneration",
30
+ "dc:creator": [
31
+ "Jingling Li"
32
+ ],
33
+ "dc:title#alternate": [
34
+
35
+ ],
36
+ "dc:subject": [
37
+
38
+ ],
39
+ "dc:description#abstract": [
40
+ "<p>The zebrafish retina provides an excellent model to study neuronal regeneration because it possesses the inherent capacity to generate new neurons in the growing retina throughout its life and to restore any neuronal types that are lost upon injury. In response to retinal cell loss caused by injury or disease, zebrafish Müller glial cells re-enter the cell cycle to produce neuronal progenitor cells that continue to proliferate and differentiate into any retinal neuronal type that was lost. We previously demonstrated that tumor necrosis factor α (TNFα) is required and sufficient to initiate this proliferation response (Nelson et al., 2013; Conner et al., 2014). However, the activation and upstream regulator of TNFα signaling during retinal regeneration remained undetermined. </p><p>In this study, I investigated the roles of two A Disintegrin And Metalloproteases 17 (ADAM17) paralogs, ADAM17a and ADAM17b, in stimulating regeneration of the damaged zebrafish retina and TNFα processing. Reduced expression of either ADAM17 paralog significantly suppressed Müller glia cell cycle re-entry in the light-damaged retina, which indicates that both ADAM17a and ADAM17b are necessary and functionally nonredundant in initiating Müller glia proliferation during retinal regeneration. The recombinant soluble TNFα rescued Müller glia proliferation in damaged <i>adam17b</i> morphant retinas, but not <i>adam17a</i> morphant retinas. We also demonstrated that knocking down ADAM17b expression reduced TNFα processing in the light-damaged retina, which results in decreased levels the soluble form of TNFα. In contrast, the <i>adam17a</i> morphant retina did not exhibit reduced amounts of the soluble TNFα. Intravitreal injection of the soluble TNFα into light-damaged retinas rescued Müller glia proliferation in <i>adam17b</i> morphant retinas, which produced proliferating neuronal progenitor cells (NPC). However, fewer NPCs in the TNFα-rescued light-damaged <i>adam17b</i> morphant retinas committed to the <i>atoh7</i> neuronal lineage relative to control retinas and differentiated into greater numbers of amacrine cells rather than photoreceptors. Thus, ADAM17b is required to process TNFα prior to Müller glia proliferation and is necessary for NPC commitment to a neuronal lineage.</p>"
41
+ ],
42
+ "dc:rights": [
43
+ "All rights reserved"
44
+ ],
45
+ "dc:language": [
46
+
47
+ ],
48
+ "dc:date": [
49
+ "2017-02-13"
50
+ ],
51
+ "dc:dateSubmitted": [
52
+ "2017-02-14"
53
+ ],
54
+ "dc:contributor": [
55
+ {
56
+ "dc:contributor": "David R.Hyde",
57
+ "ms:role": "Research Director"
58
+ }
59
+ ],
60
+ "ms:degree": {
61
+ "ms:name": [
62
+ "Doctor of Philosophy"
63
+ ],
64
+ "ms:discipline": [
65
+ "Biological Sciences"
66
+ ],
67
+ "ms:level": "Doctoral Dissertation"
68
+ },
69
+ "dc:modified": "2017-02-25Z"
70
+ },
71
+ "rels-ext": {
72
+ "@context": {
73
+ "bibo": "http://purl.org/ontology/bibo/",
74
+ "dc": "http://purl.org/dc/terms/",
75
+ "ebucore": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
76
+ "foaf": "http://xmlns.com/foaf/0.1/",
77
+ "hydramata-rel": "http://projecthydra.org/ns/relations#",
78
+ "mrel": "http://id.loc.gov/vocabulary/relators/",
79
+ "ms": "http://www.ndltd.org/standards/metadata/etdms/1.1/",
80
+ "nd": "https://library.nd.edu/ns/terms/",
81
+ "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
82
+ "ths": "http://id.loc.gov/vocabulary/relators/",
83
+ "vracore": "http://purl.org/vra/",
84
+ "dc:dateSubmitted": {
85
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
86
+ },
87
+ "dc:created": {
88
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
89
+ },
90
+ "dc:modified": {
91
+ "@type": "http://www.w3.org/2001/XMLSchema#date"
92
+ }
93
+ },
94
+ "hydramata-rel:hasEditor": [
95
+ "und:qb98mc9021z"
96
+ ],
97
+ "hydramata-rel:hasEditorGroup": [
98
+ "und:q524jm23g92"
99
+ ]
100
+ },
101
+ "rights": {
102
+ "read": [
103
+ "ljinglin"
104
+ ],
105
+ "edit": [
106
+ "curate_batch_user"
107
+ ],
108
+ "edit-groups": [
109
+ "und:q524jm23g92"
110
+ ],
111
+ "read-groups": [
112
+ "public"
113
+ ]
114
+ },
115
+ "properties-meta": {
116
+ "mime-type": "text/xml"
117
+ },
118
+ "properties": "<fields><depositor>curate_batch_user</depositor></fields>",
119
+ "bendo-item": "zk51vd69n1r"
120
+ }
121
+ ]
@@ -1,36 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module ROF
4
- describe "Access" do
5
- it "decodes public restricted private" do
6
- s = Access.decode("public", "user1")
7
- expect(s).to eq({"read-groups" => ["public"], "edit" => ["user1"]})
4
+ RSpec.describe Access do
5
+ context '.decode' do
6
+ it 'raises an error on an unknown clause' do
7
+ expect { Access.decode("chicken") }.to raise_error described_class::DecodeError
8
+ end
9
+ it "decodes public restricted private" do
10
+ s = Access.decode("public", "user1")
11
+ expect(s).to eq({"read-groups" => ["public"], "edit" => ["user1"]})
8
12
 
9
- s = Access.decode("restricted", "user1")
10
- expect(s).to eq({"read-groups" => ["registered"], "edit" => ["user1"]})
13
+ s = Access.decode("restricted", "user1")
14
+ expect(s).to eq({"read-groups" => ["registered"], "edit" => ["user1"]})
11
15
 
12
- s = Access.decode("private", "user1")
13
- expect(s).to eq({"edit" => ["user1"]})
14
- end
16
+ s = Access.decode("private", "user1")
17
+ expect(s).to eq({"edit" => ["user1"]})
18
+ end
15
19
 
16
- it "handles embargos" do
17
- s = Access.decode("embargo=2014-12-25", "user1")
18
- expect(s).to eq({"embargo-date" => "2014-12-25"})
19
- end
20
+ it "handles embargos" do
21
+ s = Access.decode("embargo=2014-12-25", "user1")
22
+ expect(s).to eq({"embargo-date" => "2014-12-25"})
23
+ end
20
24
 
21
- it "handles multiple clauses" do
22
- s = Access.decode("public;editgroup=group1,group2;edit=user2", "user1")
23
- expect(s).to eq({"read-groups" => ["public"], "edit" => ["user1","user2"], "edit-groups" => ["group1","group2"]})
24
- end
25
+ it "handles multiple clauses" do
26
+ s = Access.decode("public;editgroup=group1,group2;edit=user2", "user1")
27
+ expect(s).to eq({"read-groups" => ["public"], "edit" => ["user1","user2"], "edit-groups" => ["group1","group2"]})
28
+ end
25
29
 
26
- it "removes duplicates" do
27
- s = Access.decode("edit=user1,user2;edit=user1")
28
- expect(s).to eq({"edit" => ["user1", "user2"]})
30
+ it "removes duplicates" do
31
+ s = Access.decode("edit=user1,user2;edit=user1")
32
+ expect(s).to eq({"edit" => ["user1", "user2"]})
33
+ end
29
34
  end
30
35
 
31
- it "encodes" do
32
- s = Access.encode({"read-groups" => ["public"], "edit" => ["user1","user2"], "edit-groups" => ["group1","group2"]})
33
- expect(s).to eq("readgroup=public;edit=user1,user2;editgroup=group1,group2")
36
+ context '.encode' do
37
+ it "converts a Hash to a String" do
38
+ s = Access.encode({"read-groups" => ["public"], "edit" => ["user1","user2"], "edit-groups" => ["group1","group2"]})
39
+ expect(s).to eq("readgroup=public;edit=user1,user2;editgroup=group1,group2")
40
+ end
34
41
  end
35
42
  end
36
43
  end
@@ -2,68 +2,91 @@ require 'spec_helper'
2
2
  require 'stringio'
3
3
 
4
4
  describe ROF::CLI do
5
- it "ingests an array of items" do
6
- items = [{"pid" => "test:1",
7
- "type" => "fobject"},
8
- {"pid" => "test:2",
9
- "type" => "fobject"}]
10
- output = StringIO.new
11
- ROF::CLI.ingest_array(items, [], output)
12
- expect(output.string).to match(/1\. Verifying test:1 \.\.\.ok\..*\n2\. Verifying test:2 \.\.\.ok\./)
5
+ describe '.ingest_array' do
6
+ it "ingests an array of items" do
7
+ items = [{"pid" => "test:1",
8
+ "type" => "fobject"},
9
+ {"pid" => "test:2",
10
+ "type" => "fobject"}]
11
+ output = StringIO.new
12
+ ROF::CLI.ingest_array(items, [], output)
13
+ expect(output.string).to match(/1\. Verifying test:1 \.\.\.ok\..*\n2\. Verifying test:2 \.\.\.ok\./)
14
+ end
15
+ end
16
+
17
+ describe '.osf_to_rof' do
18
+ let(:outfile) { double(write: true) }
19
+ let(:data_from_file) { [:data_from_file] }
20
+ let(:rof_data) { [{ "rof" => "true" }] }
21
+ let(:config) { {} }
22
+ let(:project_file) { File.join(GEM_ROOT, 'spec/fixtures/for_utility_load_items_from_json_file/single_item.json') }
23
+ it 'loads the JSON file, calls the translator then writes the output as JSON' do
24
+ expect(ROF::Utility).to receive(:load_items_from_json_file).with(project_file, outfile).and_return(data_from_file)
25
+ expect(ROF::Translators::OsfToRof).to receive(:call).with(data_from_file[0], config).and_return(rof_data)
26
+ described_class.osf_to_rof(project_file, config, outfile)
27
+ expect(outfile).to have_received(:write).with(JSON.pretty_generate(rof_data))
28
+ end
13
29
  end
14
30
 
15
- it "retrieves a fedora object and converts it to ROF" do
16
- expected_output = {
17
- "pid" => "und:dev0012829m",
18
- "type" => "fobject",
19
- "af-model" => "GenericFile",
20
- "rels-ext" => {
21
- "@context"=> ROF::RelsExtRefContext,
22
- "@id" => "und:dev0012829m",
23
- "isPartOf"=> "und:dev00128288"
24
- },
25
- "rights" => {
26
- "read-groups" => ["registered"],
27
- "edit" => ["dbrower"]
28
- },
29
- "properties" => "<fields>\n<depositor>batch_ingest</depositor>\n<owner>dbrower</owner>\n</fields>\n",
30
- "properties-meta" => {"mime-type" => "text/xml"},
31
- "metadata" => {
32
- "@context"=> {
33
- "bibo"=>"http://purl.org/ontology/bibo/",
34
- "dc"=>"http://purl.org/dc/terms/",
35
- "ms" => 'http://www.ndltd.org/standards/metadata/etdms/1.1/',
36
- "ebucore"=>"http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
37
- "foaf"=>"http://xmlns.com/foaf/0.1/",
38
- 'hydramata-rel' => 'http://projecthydra.org/ns/relations#',
39
- "mrel"=>"http://id.loc.gov/vocabulary/relators/",
40
- "nd"=>"https://library.nd.edu/ns/terms/",
41
- "rdfs"=>"http://www.w3.org/2000/01/rdf-schema#",
42
- 'ths' => 'http://id.loc.gov/vocabulary/relators/',
43
- "vracore"=>"http://purl.org/vra/",
44
- "dc:dateSubmitted" => {"@type" => "http://www.w3.org/2001/XMLSchema#date"},
45
- "dc:created"=>{"@type"=>"http://www.w3.org/2001/XMLSchema#date"},
46
- "dc:modified" => {"@type" => "http://www.w3.org/2001/XMLSchema#date"}
47
- },
48
- "@id" => "info:fedora/und:dev0012829m",
49
- "dc:dateSubmitted" => "2016-04-12Z",
50
- "dc:modified" => "2016-04-12Z",
51
- "dc:title" => "bonnie+chauncey"
52
- },
53
- "bendo-item" => "dev0012826k",
54
- "characterization-meta" => {"mime-type"=>"text/xml"},
55
- "content-meta" => {"label"=>"bonnie+chauncey", "mime-type"=>"application/octet-stream", "URL"=>"http://libvirt9.library.nd.edu:14000/item/dev0012826k/bonnie+chauncey"},
56
- "thumbnail-meta" => {"label"=>"File Datastream", "mime-type"=>"image/png"},
57
- }
58
- pid = 'und:dev0012829m'
59
- config = {}
60
- fedora = {}
61
- fedora[:url] = 'http://localhost:8080/fedora'
62
- fedora[:user] = 'fedoraAdmin'
63
- fedora[:password] = 'fedoraAdmin'
64
- VCR.use_cassette("fedora_to_rof1") do
65
- fedora_data = ROF::FedoraToRof.GetFromFedora(pid, fedora, config)
66
- expect(fedora_data).to eq(expected_output)
31
+ describe '.fedora_to_rof' do
32
+ let(:outfile) { double(write: true) }
33
+ let(:pids) { [1, 2, 3] }
34
+ let(:rof_data) { [{ "rof" => "true" }] }
35
+ let(:config) { {} }
36
+ it 'calls the translator then writes the output as JSON' do
37
+ expect(ROF::Translators::FedoraToRof).to receive(:call).with(pids, config).and_return(rof_data)
38
+ described_class.fedora_to_rof(pids, config, outfile)
39
+ expect(outfile).to have_received(:write).with(JSON.pretty_generate(rof_data))
40
+ end
41
+ end
42
+
43
+ describe '.csv_to_rof' do
44
+ let(:outfile) { double(write: true) }
45
+ let(:csv) { "1,2,3" }
46
+ let(:rof_data) { [{ "rof" => "true" }] }
47
+ let(:config) { {} }
48
+ it 'calls the translator then writes the output as JSON' do
49
+ expect(ROF::Translators::CsvToRof).to receive(:call).with(csv, config).and_return(rof_data)
50
+ described_class.csv_to_rof(csv, config, outfile)
51
+ expect(outfile).to have_received(:write).with(JSON.pretty_generate(rof_data))
52
+ end
53
+ end
54
+
55
+ describe '.jsonld_to_rof' do
56
+ let(:outfile) { double(write: true) }
57
+ let(:jsonld) { double('JSON-LD') }
58
+ let(:rof_data) { [{ "rof" => "true" }] }
59
+ let(:config) { {} }
60
+ it 'calls the translator then writes the output as JSON' do
61
+ expect(ROF::Translators::JsonldToRof).to receive(:call).with(jsonld, config).and_return(rof_data)
62
+ described_class.jsonld_to_rof(jsonld, config, outfile)
63
+ expect(outfile).to have_received(:write).with(JSON.pretty_generate(rof_data))
64
+ end
65
+ end
66
+
67
+ describe '.with_outfile_handling' do
68
+ let(:writer) { double(close: true) }
69
+ context 'when given a string' do
70
+ let(:outfile) { '/hello/world' }
71
+ it 'will open a file' do
72
+ expect(File).to receive(:open).with('/hello/world', 'w').and_return(writer)
73
+ expect {|b| described_class.with_outfile_handling(outfile, &b) }.to yield_with_args(writer)
74
+ expect(writer).to have_received(:close)
75
+ end
76
+ end
77
+ context 'when given nil' do
78
+ let(:outfile) { nil }
79
+ it 'will write to /dev/null' do
80
+ expect(File).to receive(:open).with('/dev/null', 'w').and_return(writer)
81
+ expect {|b| described_class.with_outfile_handling(outfile, &b) }.to yield_with_args(writer)
82
+ expect(writer).to have_received(:close)
83
+ end
84
+ end
85
+ context 'when given something else' do
86
+ it 'will assume it is can be "written" to' do
87
+ expect {|b| described_class.with_outfile_handling(writer, &b) }.to yield_with_args(writer)
88
+ expect(writer).to have_received(:close)
89
+ end
67
90
  end
68
91
  end
69
92
  end
@@ -1,26 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module ROF
4
- describe "Compare ROF" do
5
- it "compares rights metadata different read-groups" do
6
- fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
7
- bendo = { "rights"=> {"read-groups"=> ["private"], "edit"=> ["rtillman"]}}
8
- test_return = CompareRof.compare_rights(fedora, bendo, {})
9
- expect(test_return).to eq(1)
4
+ describe CompareRof do
5
+ describe '.fedora_vs_bendo' do
6
+ it 'is a convenience method' do
7
+ expect_any_instance_of(described_class).to receive(:error_count)
8
+ fedora = [:f]
9
+ bendo = [:b]
10
+ described_class.fedora_vs_bendo(fedora, bendo)
11
+ end
10
12
  end
11
13
 
12
- it "compares rights metadata same read-groups" do
13
- fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
14
- bendo = { "rights"=> {"read-groups"=> ["public"], "edit"=> ["rtillman"]}}
15
- test_return = CompareRof.compare_rights(fedora, bendo, {})
16
- expect(test_return).to eq(0)
17
- end
14
+ describe '#compare_rights' do
15
+ it "compares rights metadata different read-groups" do
16
+ fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
17
+ bendo = { "rights"=> {"read-groups"=> ["private"], "edit"=> ["rtillman"]}}
18
+ test_return = described_class.new(fedora, bendo).error_count
19
+ expect(test_return).to eq(1)
20
+ end
18
21
 
19
- it "compares rights metadata with different groups" do
20
- fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
21
- bendo = { "rights"=> {"edit"=> ["rtillman"]}}
22
- test_return = CompareRof.compare_rights(fedora, bendo, {})
23
- expect(test_return).to eq(1)
22
+ it "compares rights metadata same read-groups" do
23
+ fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
24
+ bendo = { "rights"=> {"read-groups"=> ["public"], "edit"=> ["rtillman"]}}
25
+ test_return = described_class.new(fedora, bendo).error_count
26
+ expect(test_return).to eq(0)
27
+ end
28
+
29
+ it "compares rights metadata with different groups" do
30
+ fedora = { "rights"=> { "read-groups"=> ["public"], "edit"=> ["rtillman"]}}
31
+ bendo = { "rights"=> {"edit"=> ["rtillman"]}}
32
+ test_return = described_class.new(fedora, bendo).error_count
33
+ expect(test_return).to eq(1)
34
+ end
24
35
  end
25
36
 
26
37
  it "compares metadata (same) " do
@@ -44,7 +55,7 @@ module ROF
44
55
  "dc:modified"=> "2016-07-22Z",
45
56
  "dc:title"=> "carmella.jpeg"
46
57
  }}
47
- test_return = CompareRof.compare_metadata(fedora, bendo)
58
+ test_return = described_class.new(fedora, bendo).error_count
48
59
  expect(test_return).to eq(0)
49
60
  end
50
61
 
@@ -69,7 +80,7 @@ module ROF
69
80
  "dc:modified"=> "2016-07-23Z",
70
81
  "dc:title"=> "carmella.jpeg"
71
82
  }}
72
- test_return = CompareRof.compare_metadata(fedora, bendo)
83
+ test_return = described_class.new(fedora, bendo).error_count
73
84
  expect(test_return).to eq(1)
74
85
  end
75
86
 
@@ -98,7 +109,7 @@ module ROF
98
109
  "dc:modified"=> "2016-07-22Z",
99
110
  "dc:title"=> "carmella.jpeg"
100
111
  }}
101
- test_return = CompareRof.compare_metadata(fedora, bendo)
112
+ test_return = described_class.new(fedora, bendo).error_count
102
113
  expect(test_return).to eq(1)
103
114
  end
104
115
 
@@ -140,7 +151,7 @@ module ROF
140
151
  "und:dev00149x01"
141
152
  ]
142
153
  }}
143
- test_return = CompareRof.compare_rels_ext(fedora, bendo)
154
+ test_return = described_class.new(fedora, bendo).error_count
144
155
  expect(test_return).to eq(0)
145
156
  end
146
157
 
@@ -182,7 +193,7 @@ module ROF
182
193
  "und:dev00148x01"
183
194
  ]
184
195
  }}
185
- test_return = CompareRof.compare_rels_ext(fedora, bendo)
196
+ test_return = described_class.new(fedora, bendo).error_count
186
197
  expect(test_return).to eq(1)
187
198
  end
188
199
 
@@ -219,7 +230,7 @@ module ROF
219
230
  "type"=> "fobject",
220
231
  "bendo-item"=> "dev00149w5f"
221
232
  }
222
- test_return = CompareRof.compare_everything_else(fedora, bendo, {})
233
+ test_return = described_class.new(fedora, bendo).error_count
223
234
  expect(test_return).to eq(0)
224
235
  end
225
236
 
@@ -256,7 +267,7 @@ module ROF
256
267
  "type"=> "fobject",
257
268
  "bendo-item"=> "dev00149w5f"
258
269
  }
259
- test_return = CompareRof.compare_everything_else(fedora, bendo, {})
270
+ test_return = described_class.new(fedora, bendo).error_count
260
271
  expect(test_return).to eq(1)
261
272
  end
262
273
  end