hybag 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDA1ZjhjNWEzYWE5NTEwNGQ4ODM4NGVkMDY1N2E2MmI4YjVhYWFlOQ==
4
+ NzIzYzEyZjFkNzVjNDUwZTg5OGJiZjZkMjE0YTE4NDc0Mzk3NTE1ZA==
5
5
  data.tar.gz: !binary |-
6
- MjdiYWIzZGIwNDRmOWJjYjFhODFiMDY2NzBiNDM2NmI0OTRiNjIwMA==
6
+ YzBlOGVjNzdiYzkwYTkzZTg5ZmVjOTZlNGQzYmFhODAxOGM2ZWYwMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmVjOGUxZTVkODQyOGJlOTMxZjM1YWU1MzgzNmQ3ODhhOGM2Yjc5NmJkMzUy
10
- NDUyYTI1OTM2MDQyZDY0OWVmNjQxMjI2MDdkYTM5MTBlNjFmN2JjNTNhMmVl
11
- MTMxZTVhYWM5MTYxZWFmZTBlMTg0NTVmOTc2MGNlNzIzZWU4MjA=
9
+ OGM5NWUwNzcxZmM4NjQ0Y2UxZjg1MDljNjMyMDA1NDUxYzllNWRlMjRhZTcw
10
+ MmQ4NDQxNTM2YTUwNTc4YzM3MzA1NjE1MTBmNWFmN2MwNjc5MmI2MGY3MTc3
11
+ ZDY4MjE1MzQxNTExNjI1MmNmNTRiZTBlZjdmYmZjNTk3MGUzNjI=
12
12
  data.tar.gz: !binary |-
13
- Y2IyMmIyODI0NjA3YWI3MWE5YTgxODNjYTY2YmNjZmRjZmQ0NTMzN2UzMDVk
14
- ZTk5MjQ0MmZhNmI3MzAxY2IyMjA3MTcwYjY5ZTIwOGQ3MzlkODI4M2Q4Njdl
15
- YjJlOTAyYWUzYjQ2NzI5ZTAwNGE1N2U2MTk5MDkyNGRjNmMxMTY=
13
+ MmQwN2QyZmVlMmU5MDZjZDA0ZWUwNGNjODI5YzgyODAzNmQ0ZGNlYWE3Y2Qw
14
+ NGE4Y2M2MmQzZjc3ZjM3ZWUxYjc4MTFlZDllNTMyMjg1MmJkYjA1YWI1MWEy
15
+ ODI5ZjJjNjUyOGFjNDUxMTA3YTE5M2ZiNDA3OTQzNzkzZjJiZmQ=
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rspec
5
+ notifications:
6
+ irc: "irc.freenode.org#oregonhydra"
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
 
4
- gem 'pry', '0.9.11.4'
4
+ gem 'pry'
5
5
  # Specify your gem's dependencies in hybag.gemspec
6
6
  gemspec
7
+
@@ -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
- # TODO: Move this to configuration?
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
- subject = statement.subject
71
- subject = ds.rdf_subject if subject == first_subject
72
- new_repository << [subject, statement.predicate, statement.object]
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
- return ds
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
@@ -1,3 +1,3 @@
1
1
  module Hybag
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.read(File.join(bag.data_dir,"content.png"))
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
@@ -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.1.1
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: 2013-12-12 00:00:00.000000000 Z
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: