hybag 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +6 -0
- data/Gemfile +2 -1
- data/lib/hybag/ingester.rb +8 -9
- data/lib/hybag/version.rb +1 -1
- data/spec/fixtures/example_datastream.nt +1 -0
- data/spec/lib/hybag/ingester_spec.rb +9 -1
- data/spec/lib/hybag_spec.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzIzYzEyZjFkNzVjNDUwZTg5OGJiZjZkMjE0YTE4NDc0Mzk3NTE1ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzBlOGVjNzdiYzkwYTkzZTg5ZmVjOTZlNGQzYmFhODAxOGM2ZWYwMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGM5NWUwNzcxZmM4NjQ0Y2UxZjg1MDljNjMyMDA1NDUxYzllNWRlMjRhZTcw
|
10
|
+
MmQ4NDQxNTM2YTUwNTc4YzM3MzA1NjE1MTBmNWFmN2MwNjc5MmI2MGY3MTc3
|
11
|
+
ZDY4MjE1MzQxNTExNjI1MmNmNTRiZTBlZjdmYmZjNTk3MGUzNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmQwN2QyZmVlMmU5MDZjZDA0ZWUwNGNjODI5YzgyODAzNmQ0ZGNlYWE3Y2Qw
|
14
|
+
NGE4Y2M2MmQzZjc3ZjM3ZWUxYjc4MTFlZDllNTMyMjg1MmJkYjA1YWI1MWEy
|
15
|
+
ODI5ZjJjNjUyOGFjNDUxMTA3YTE5M2ZiNDA3OTQzNzkzZjJiZmQ=
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/lib/hybag/ingester.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rdf/rdfxml'
|
|
2
2
|
|
3
3
|
module Hybag
|
4
4
|
class Ingester
|
5
|
-
attr_accessor :bag, :model_name
|
5
|
+
attr_accessor :bag, :model_name, :old_subject
|
6
6
|
def initialize(bag)
|
7
7
|
@bag = bag
|
8
8
|
end
|
@@ -63,17 +63,16 @@ module Hybag
|
|
63
63
|
ds.content = content
|
64
64
|
if ds.respond_to?(:rdf_subject)
|
65
65
|
# Assume the first subject in the metadata is about this object.
|
66
|
-
|
67
|
-
first_subject = ds.graph.first_subject
|
66
|
+
old_subject = self.old_subject || ds.graph.first_subject
|
68
67
|
new_repository = RDF::Repository.new
|
69
68
|
ds.graph.each_statement do |statement|
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
if statement.subject == old_subject
|
70
|
+
ds.graph.delete statement
|
71
|
+
ds.graph << RDF::Statement.new(ds.rdf_subject, statement.predicate, statement.object)
|
72
|
+
end
|
73
73
|
end
|
74
|
-
ds.instance_variable_set(:@graph,new_repository)
|
75
74
|
end
|
76
|
-
|
75
|
+
ds
|
77
76
|
end
|
78
77
|
|
79
78
|
def set_file_streams(object)
|
@@ -103,4 +102,4 @@ module Hybag
|
|
103
102
|
File.join(bag.bag_dir,"fedora","RELS-EXT.rdf")
|
104
103
|
end
|
105
104
|
end
|
106
|
-
end
|
105
|
+
end
|
data/lib/hybag/version.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
<info:fedora/filler> <http://purl.org/dc/terms/rights> "Permission to use must be obtained from OSU Archives." .
|
6
6
|
<info:fedora/filler> <http://multimedialab.elis.ugent.be/users/samcoppe/ontologies/Premis/premis.owl#originalName> "P0120_2567" .
|
7
7
|
<info:fedora/filler> <http://purl.org/dc/terms/title> "Mexican workers" .
|
8
|
+
<http://oregondigital.org/resource/oregondigital:1> <http://purl.org/dc/terms/title> "Test Title" .
|
8
9
|
<info:fedora/filler> <http://purl.org/dc/terms/subject> "Agricultural laborers--Mexican--Oregon" .
|
9
10
|
<info:fedora/filler> <http://purl.org/dc/terms/subject> "Agricultural laborers--Housing--Oregon" .
|
10
11
|
<info:fedora/filler> <http://purl.org/dc/terms/identifier> "P120:2567" .
|
@@ -87,7 +87,7 @@ describe Hybag::Ingester do
|
|
87
87
|
Array.wrap(built_model.title).first.should == "Mexican workers"
|
88
88
|
end
|
89
89
|
it "should populate file datastreams" do
|
90
|
-
built_model.content.content.should == File.
|
90
|
+
built_model.content.content.should == File.open(File.join(bag.data_dir, 'content.png'), 'rb').read
|
91
91
|
end
|
92
92
|
it "should be new" do
|
93
93
|
expect(built_model).to be_new
|
@@ -95,6 +95,14 @@ describe Hybag::Ingester do
|
|
95
95
|
it "should not be persisted" do
|
96
96
|
expect(built_model).not_to be_persisted
|
97
97
|
end
|
98
|
+
context "when old_subject has been set" do
|
99
|
+
before(:each) do
|
100
|
+
subject.old_subject = "http://oregondigital.org/resource/oregondigital:1"
|
101
|
+
end
|
102
|
+
it "should only replace those subjects" do
|
103
|
+
expect(built_model.title.first).to eq "Test Title"
|
104
|
+
end
|
105
|
+
end
|
98
106
|
context "when there is a file datastream and no matching datastream defined" do
|
99
107
|
before(:each) do
|
100
108
|
# Add the hydra.png from fixture
|
data/spec/lib/hybag_spec.rb
CHANGED
@@ -60,9 +60,11 @@ describe Hybag do
|
|
60
60
|
Hybag::Ingester.any_instance.should_receive(:ingest).and_return("bla")
|
61
61
|
Hybag.ingest("empty") do |ingester|
|
62
62
|
ingester.model_name = "TestModel"
|
63
|
+
ingester.old_subject = "http://test.org"
|
63
64
|
ingesting = ingester
|
64
65
|
end
|
65
66
|
expect(ingesting.model_name).to eq "TestModel"
|
67
|
+
expect(ingesting.old_subject).to eq "http://test.org"
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hybag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trey Terrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,7 @@ extensions: []
|
|
164
164
|
extra_rdoc_files: []
|
165
165
|
files:
|
166
166
|
- .gitignore
|
167
|
+
- .travis.yml
|
167
168
|
- Gemfile
|
168
169
|
- Guardfile
|
169
170
|
- LICENSE.txt
|
@@ -226,3 +227,4 @@ test_files:
|
|
226
227
|
- spec/lib/hybag_spec.rb
|
227
228
|
- spec/spec_helper.rb
|
228
229
|
- spec/support/fakefs.rb
|
230
|
+
has_rdoc:
|