active-fedora 3.2.0.pre2 → 3.2.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active-fedora (3.2.0.pre2)
4
+ active-fedora (3.2.0.pre3)
5
5
  activeresource (>= 3.0.0)
6
6
  activesupport (>= 3.0.0)
7
7
  equivalent-xml
@@ -1,5 +1,6 @@
1
1
  3.2.0
2
2
 
3
+ HYDRA-730 ActiveFedora isn't being initialized unless it is specified in the project Gemfile
3
4
  Don't create pids until save
4
5
  inspect and equality methods
5
6
  Deprecate datastream_collections
@@ -53,6 +53,7 @@ module ActiveFedora #:nodoc:
53
53
  # The configuration hash that gets used by RSolr.connect
54
54
  @solr_config ||= {}
55
55
  @fedora_config ||= {}
56
+ @config_options ||= {}
56
57
 
57
58
  # Initializes ActiveFedora's connection to Fedora and Solr based on the info in fedora.yml and solr.yml
58
59
  # NOTE: this deprecates the use of a solr url in the fedora.yml
@@ -89,28 +90,36 @@ module ActiveFedora #:nodoc:
89
90
  else
90
91
  @config_options = options
91
92
  end
93
+ config_reload!
94
+ end
92
95
 
93
- @config_env = environment
94
- @fedora_config_path = get_config_path(:fedora)
95
- load_config(:fedora)
96
-
97
- @solr_config_path = get_config_path(:solr)
98
- load_config(:solr)
99
-
100
- register_fedora_and_solr
96
+ def self.config_reload!
97
+ reset!
98
+ load_configs
99
+ end
101
100
 
102
- # Retrieve the valid path for the predicate mappings config file
103
- @predicate_config_path = build_predicate_config_path(File.dirname(fedora_config_path))
101
+ def self.reset!
102
+ @config_loaded = false #Force reload of configs
103
+ @predicate_config_path = nil
104
+ end
104
105
 
106
+ def self.config_loaded?
107
+ @config_loaded || false
105
108
  end
106
109
 
107
110
  def self.load_configs
111
+ return if config_loaded?
112
+ @config_env = environment
108
113
  load_config(:fedora)
109
114
  load_config(:solr)
115
+ @config_loaded = true
116
+
110
117
  end
111
118
 
112
119
  def self.load_config(config_type)
120
+ config_path = get_config_path(config_type)
113
121
  config_type = config_type.to_s
122
+ self.instance_variable_set "@#{config_type}_config_path".to_sym, config_path
114
123
  config_path = self.send("#{config_type}_config_path".to_sym)
115
124
 
116
125
  logger.info("#{config_type.upcase}: loading ActiveFedora.#{config_type}_config from #{File.expand_path(config_path)}")
@@ -156,18 +165,6 @@ module ActiveFedora #:nodoc:
156
165
  end
157
166
  end
158
167
 
159
- def self.register_fedora_and_solr
160
- # Register Solr
161
- logger.info("FEDORA: initializing ActiveFedora::SolrService with solr_config: #{ActiveFedora.solr_config.inspect}")
162
- ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
163
- logger.info("FEDORA: initialized Solr with ActiveFedora.solr_config: #{ActiveFedora::SolrService.instance.inspect}")
164
-
165
- logger.info("FEDORA: initializing Fedora with fedora_config: #{ActiveFedora.fedora_config.inspect}")
166
- ActiveFedora::RubydoraConnection.connect(ActiveFedora.fedora_config[:url])
167
- logger.info("FEDORA: initialized Fedora as: #{ActiveFedora::RubydoraConnection.instance.inspect}")
168
-
169
- end
170
-
171
168
  # Determine what environment we're running in. Order of preference is:
172
169
  # 1. config_options[:environment]
173
170
  # 2. Rails.env
@@ -204,7 +201,7 @@ module ActiveFedora #:nodoc:
204
201
  def self.get_config_path(config_type)
205
202
  config_type = config_type.to_s
206
203
  if (config_path = config_options.fetch("#{config_type}_config_path".to_sym,nil) )
207
- raise ActiveFedoraConfigurationException unless File.file? config_path
204
+ raise ActiveFedoraConfigurationException, "file does not exist #{config_path}" unless File.file? config_path
208
205
  return config_path
209
206
  end
210
207
 
@@ -212,7 +209,7 @@ module ActiveFedora #:nodoc:
212
209
  if config_type == "solr" && (config_path = check_fedora_path_for_solr)
213
210
  return config_path
214
211
  elsif config_type == "solr" && fedora_config[environment].fetch("solr",nil)
215
- logger.warn("DEPRECATION WARNING: You appear to be using a deprecated format for your fedora.yml file. The solr url should be stored in a separate solr.yml file in the same directory as the fedora.yml")
212
+ ActiveSupport::Deprecation.warn("You appear to be using a deprecated format for your fedora.yml file. The solr url should be stored in a separate solr.yml file in the same directory as the fedora.yml")
216
213
  raise ActiveFedoraConfigurationException
217
214
  end
218
215
 
@@ -251,7 +248,7 @@ module ActiveFedora #:nodoc:
251
248
  end
252
249
 
253
250
  def self.predicate_config
254
- @predicate_config_path ||= build_predicate_config_path
251
+ @predicate_config_path ||= build_predicate_config_path(File.dirname(@fedora_config_path))
255
252
  end
256
253
 
257
254
  def self.version
@@ -264,7 +261,7 @@ module ActiveFedora #:nodoc:
264
261
  pred_config_paths = [File.expand_path(File.join(File.dirname(__FILE__),"..","config"))]
265
262
  pred_config_paths.unshift config_path if config_path
266
263
  pred_config_paths.each do |path|
267
- testfile = File.join(path,"predicate_mappings.yml")
264
+ testfile = File.expand_path(File.join(path,"predicate_mappings.yml"))
268
265
  if File.exist?(testfile) && valid_predicate_mapping?(testfile)
269
266
  return testfile
270
267
  end
@@ -75,7 +75,7 @@ module ActiveFedora
75
75
  super
76
76
  end
77
77
 
78
- self.ds_specs = {'RELS-EXT'=> {:type=> ActiveFedora::RelsExtDatastream, :label=>"", :block=>nil}}
78
+ self.ds_specs = {'RELS-EXT'=> {:type=> ActiveFedora::RelsExtDatastream, :label=>"", :label=>"Fedora Object-to-Object Relationship Metadata", :control_group=>'X', :block=>nil}}
79
79
 
80
80
  # Has this object been saved?
81
81
  def new_object?
@@ -2,9 +2,9 @@ require 'active-fedora'
2
2
  require 'rails'
3
3
 
4
4
  module ActiveFedora
5
- class Railtie < Rails::Railtie
6
- initializer "active-fedora.configure_rails_initialization" do
7
- ActiveFedora.init
8
- end
9
- end
5
+ # class Railtie < Rails::Railtie
6
+ # initializer "active-fedora.configure_rails_initialization" do
7
+ # ActiveFedora.init
8
+ # end
9
+ # end
10
10
  end
@@ -5,7 +5,6 @@ module ActiveFedora
5
5
  class RubydoraConnection
6
6
  include Singleton
7
7
 
8
- attr_reader :connection
9
8
  attr_accessor :options
10
9
 
11
10
  def self.connect(params={})
@@ -24,6 +23,14 @@ module ActiveFedora
24
23
  instance
25
24
  end
26
25
 
26
+ def connection
27
+ return @connection if @connection
28
+ ActiveFedora.load_configs
29
+ ActiveFedora::RubydoraConnection.connect(ActiveFedora.fedora_config[:url])
30
+ @connection
31
+ end
32
+
33
+
27
34
  def connect(force=false)
28
35
  return unless @connection.nil? or force
29
36
  allowable_options = [:url, :user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key]
@@ -10,7 +10,7 @@ module ActiveFedora
10
10
  load_mappings
11
11
 
12
12
  attr_reader :conn
13
-
13
+
14
14
  def self.register(host=nil, args={})
15
15
  Thread.current[:solr_service]=self.new(host, args)
16
16
 
@@ -22,6 +22,12 @@ module ActiveFedora
22
22
  end
23
23
 
24
24
  def self.instance
25
+ # Register Solr
26
+
27
+ unless Thread.current[:solr_service]
28
+ ActiveFedora.load_configs
29
+ register(ActiveFedora.solr_config[:url])
30
+ end
25
31
  raise SolrNotInitialized unless Thread.current[:solr_service]
26
32
  Thread.current[:solr_service]
27
33
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "3.2.0.pre2"
2
+ VERSION = "3.2.0.pre3"
3
3
  end
@@ -16,6 +16,7 @@ ActiveFedora.init(:fedora_config_path=>File.join(File.dirname(__FILE__), "..", "
16
16
 
17
17
  RSpec.configure do |config|
18
18
  config.mock_with :mocha
19
+ config.color_enabled = true
19
20
  end
20
21
 
21
22
  def fixture(file)
@@ -3,6 +3,7 @@ def mock_client
3
3
  @mock_client = mock("client")
4
4
  @getter = mock("getter")
5
5
  @getter.stubs(:get).returns('')
6
+ @mock_client.stubs(:[]).with("describe?xml=true").returns('')
6
7
  @mock_client
7
8
  end
8
9
 
@@ -11,12 +11,6 @@ describe ActiveFedora do
11
11
  ActiveFedora.init(:environment=>"test", :fedora_config_path=>fedora_config_path)
12
12
  end
13
13
 
14
- before(:each) do
15
- # Stubbing register_fedora_and_solr in order to speed up tests.
16
- # If you have tests that need fedora & solr registered,
17
- # put them in the separate ActiveFedora describe block towards the end of this file.
18
- ActiveFedora.stubs(:register_fedora_and_solr)
19
- end
20
14
 
21
15
  describe "initialization methods" do
22
16
 
@@ -85,6 +79,7 @@ describe ActiveFedora do
85
79
  Dir.expects(:getwd).at_least_once.returns("/current/working/directory")
86
80
  File.expects(:file?).with("/current/working/directory/config/fedora.yml").returns(false)
87
81
  File.expects(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"),'config','fedora.yml'))).returns(true)
82
+ logger.expects(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml) - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
88
83
  ActiveFedora.get_config_path(:fedora).should eql(File.expand_path(File.join(File.dirname("__FILE__"),'config','fedora.yml')))
89
84
  end
90
85
  end
@@ -108,6 +103,7 @@ describe ActiveFedora do
108
103
  ActiveFedora.expects(:fedora_config_path).returns("/path/to/fedora/config/fedora.yml")
109
104
  File.expects(:file?).with("/path/to/fedora/config/solr.yml").returns(false)
110
105
  ActiveFedora.expects(:fedora_config).returns({"test"=>{"solr"=>{"url"=>"http://some_url"}}})
106
+ ActiveSupport::Deprecation.expects(:warn)
111
107
  lambda { ActiveFedora.get_config_path(:solr) }.should raise_exception
112
108
  end
113
109
 
@@ -139,6 +135,7 @@ describe ActiveFedora do
139
135
  Dir.expects(:getwd).at_least_once.returns("/current/working/directory")
140
136
  File.expects(:file?).with("/current/working/directory/config/solr.yml").returns(false)
141
137
  File.expects(:file?).with(File.expand_path(File.join(File.dirname("__FILE__"),'config','solr.yml'))).returns(true)
138
+ logger.expects(:warn).with("Using the default solr.yml that comes with active-fedora. If you want to override this, pass the path to solr.yml to ActiveFedora - ie. ActiveFedora.init(:solr_config_path => '/path/to/solr.yml) - or set Rails.root and put solr.yml into \#{Rails.root}/config.")
142
139
  ActiveFedora.get_config_path(:solr).should eql(File.expand_path(File.join(File.dirname("__FILE__"),'config','solr.yml')))
143
140
  end
144
141
  end
@@ -180,10 +177,28 @@ describe ActiveFedora do
180
177
  end
181
178
 
182
179
  describe "load_configs" do
183
- it "should load the fedora and solr configs" do
184
- ActiveFedora.expects(:load_config).with(:fedora)
185
- ActiveFedora.expects(:load_config).with(:solr)
186
- ActiveFedora.load_configs
180
+ describe "when config is not loaded" do
181
+ before do
182
+ ActiveFedora.instance_variable_set :@config_loaded, nil
183
+ end
184
+ it "should load the fedora and solr configs" do
185
+ ActiveFedora.expects(:load_config).with(:fedora)
186
+ ActiveFedora.expects(:load_config).with(:solr)
187
+ ActiveFedora.config_loaded?.should be_false
188
+ ActiveFedora.load_configs
189
+ ActiveFedora.config_loaded?.should be_true
190
+ end
191
+ end
192
+ describe "when config is loaded" do
193
+ before do
194
+ ActiveFedora.instance_variable_set :@config_loaded, true
195
+ end
196
+ it "should load the fedora and solr configs" do
197
+ ActiveFedora.expects(:load_config).never
198
+ ActiveFedora.config_loaded?.should be_true
199
+ ActiveFedora.load_configs
200
+ ActiveFedora.config_loaded?.should be_true
201
+ end
187
202
  end
188
203
  end
189
204
 
@@ -210,6 +225,7 @@ describe ActiveFedora do
210
225
  before(:all) do
211
226
  @fake_rails_root = File.expand_path(File.dirname(__FILE__) + '/../fixtures/rails_root')
212
227
  end
228
+
213
229
 
214
230
  after(:all) do
215
231
  config_file = File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml")
@@ -230,6 +246,7 @@ describe ActiveFedora do
230
246
  end
231
247
  it "loads the config that ships with this gem as a last choice" do
232
248
  Dir.stubs(:getwd).returns("/fake/path")
249
+ logger.expects(:warn).with("Using the default fedora.yml that comes with active-fedora. If you want to override this, pass the path to fedora.yml to ActiveFedora - ie. ActiveFedora.init(:fedora_config_path => '/path/to/fedora.yml) - or set Rails.root and put fedora.yml into \#{Rails.root}/config.")
233
250
  ActiveFedora.init
234
251
  expected_config = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config"))
235
252
  ActiveFedora.fedora_config_path.should eql(expected_config+'/fedora.yml')
@@ -268,15 +285,6 @@ describe ActiveFedora do
268
285
 
269
286
  ##########################
270
287
 
271
- describe ".push_models_to_fedora" do
272
- it "should push the model definition for each of the ActiveFedora models into Fedora CModel objects" do
273
- pending
274
- # find all of the models
275
- # create a cmodel for each model with the appropriate pid
276
- # push the model definition into the cmodel's datastream (ie. dsname: oral_history.rb vs dsname: ruby)
277
- end
278
- end
279
-
280
288
  describe ".build_predicate_config_path" do
281
289
  it "should return the path to the default config/predicate_mappings.yml if no valid path is given" do
282
290
  ActiveFedora.send(:build_predicate_config_path, nil).should == default_predicate_mapping_file
@@ -296,18 +304,25 @@ describe ActiveFedora do
296
304
  end
297
305
 
298
306
  describe ".predicate_config" do
307
+ before do
308
+ ActiveFedora.instance_variable_set :@config_loaded, nil
309
+ end
299
310
  it "should return the default mapping if it has not been initialized" do
300
- ActiveFedora.instance_variable_set("@predicate_config_path",nil)
301
311
  ActiveFedora.predicate_config().should == default_predicate_mapping_file
302
312
  end
303
- it "should return the path that was set at initialization" do
304
- pending()
305
- File.expects(:exist?).with("/path/to/my/files/predicate_mappings.yml").returns(true)
306
- mock_file = mock("fedora.yml")
307
- File.expects(:open).returns(mock_file)
308
- YAML.expects(:load).returns({"test"=>{"solr"=>{"url"=>"http://127.0.0.1:8983/solr/development"}, "fedora"=>{"url"=>"http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"}}})
309
- ActiveFedora.init(:fedora_config_path => "/path/to/my/files/fedora.yml")
310
- ActiveFedora.predicate_config.should == "/path/to/my/files/predicate_mappings.yml"
313
+ describe "when the path has been set" do
314
+ before do
315
+
316
+ ActiveFedora.instance_variable_set :@predicate_config_path, nil
317
+ ActiveFedora.instance_variable_set(:@fedora_config_path, "/path/to/my/files/fedora.yml")
318
+ # ActiveFedora.expects(:load_config).with(:fedora)
319
+ # ActiveFedora.expects(:load_config).with(:solr)
320
+ end
321
+ it "should return the path that was set at initialization" do
322
+ File.expects(:exist?).with("/path/to/my/files/predicate_mappings.yml").returns(true)
323
+ ActiveFedora.expects(:valid_predicate_mapping?).with("/path/to/my/files/predicate_mappings.yml").returns(true)
324
+ ActiveFedora.predicate_config.should == "/path/to/my/files/predicate_mappings.yml"
325
+ end
311
326
  end
312
327
  end
313
328
 
@@ -344,7 +359,7 @@ describe ActiveFedora do
344
359
  describe "outside of rails" do
345
360
  it "should load the default packaged config/fedora.yml file if no explicit config path is passed" do
346
361
  ActiveFedora.init()
347
- ActiveFedora.fedora.options[:url].to_s.should == "http://127.0.0.1:8983/fedora-test"
362
+ ActiveFedora.fedora_config[:url].to_s.should == "http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora-test"
348
363
  end
349
364
  it "should load the passed config if explicit config passed in as a string" do
350
365
  ActiveFedora.init(:fedora_config_path=>'./spec/fixtures/rails_root/config/fedora.yml')
@@ -371,7 +386,6 @@ describe ActiveFedora do
371
386
  File.stubs(:open).with(fedora_config_path).returns(fedora_config)
372
387
  File.stubs(:open).with(solr_config_path).returns(solr_config)
373
388
 
374
- ActiveFedora.expects(:build_predicate_config_path)
375
389
 
376
390
  ActiveFedora.init(:fedora_config_path=>fedora_config_path,:solr_config_path=>solr_config_path)
377
391
  ActiveFedora.solr.class.should == ActiveFedora::SolrService
@@ -397,24 +411,6 @@ describe ActiveFedora do
397
411
  end
398
412
 
399
413
 
400
- describe ActiveFedora do
401
- after(:all) do
402
- # Restore to default fedora configs
403
- ActiveFedora.init(:environment => "test", :fedora_config_path => File.join(File.dirname(__FILE__), "..", "..", "config", "fedora.yml"))
404
- end
405
-
406
- # Put methods whose tests require registering Fedora & Solr here.
407
- # to allow tests to run fast, keep these to a minimum.
408
- describe "register_solr_and_fedora" do
409
- it "should regiser instances with the appropriate urls" do
410
- ActiveFedora.expects(:solr_config).at_least_once.returns({:url=>"http://megasolr:8983"})
411
- ActiveFedora.expects(:fedora_config).at_least_once.returns({:url=>"http://megafedora:8983"})
412
- ActiveFedora.register_fedora_and_solr
413
- ActiveFedora.solr.conn.url.to_s.should eql("http://megasolr:8983")
414
- ActiveFedora.fedora.options[:url].to_s.should eql("http://megafedora:8983")
415
- end
416
- end
417
- end
418
414
 
419
415
  def mock_yaml(hash, path)
420
416
  mock_file = mock(path.split("/")[-1])
@@ -19,9 +19,6 @@ describe ActiveFedora::Base do
19
19
  @base.expects(:parts).returns(["Foo"])
20
20
  @base.file_objects
21
21
  end
22
- describe "_remove" do
23
- it "should wrap collection_members_remove"
24
- end
25
22
  end
26
23
 
27
24
  describe ".file_objects_append" do
@@ -52,7 +49,6 @@ describe ActiveFedora::Base do
52
49
  it "should return an array" do
53
50
  @base.collection_members.should be_kind_of(Array)
54
51
  end
55
- it "should search for all of the :collection_members"
56
52
  describe "_append" do
57
53
  it "should be a supported method" do
58
54
  @base.should respond_to(:collection_members_append)
@@ -62,13 +58,6 @@ describe ActiveFedora::Base do
62
58
  @base.expects(:add_relationship).with(:has_collection_member, mocko)
63
59
  @base.collection_members_append(mocko)
64
60
  end
65
- it "should support << operator" do
66
- pending
67
- # I can't remember how to do this, and it's not a deal breaker... (MZ)
68
- mocko = mock("object")
69
- @base.expects(:add_relationship).with(:has_collection_member, mocko)
70
- @base.collection_members << mocko
71
- end
72
61
  end
73
62
  describe "_remove" do
74
63
  it "should be a supported method" do
@@ -16,6 +16,20 @@ describe ActiveFedora::RubydoraConnection do
16
16
  end
17
17
  end
18
18
 
19
+ # Put methods whose tests require registering Fedora & Solr here.
20
+ # to allow tests to run fast, keep these to a minimum.
21
+ describe "connection" do
22
+ describe "That is new" do
23
+ before do
24
+ ActiveFedora::RubydoraConnection.instance.instance_variable_set(:@connection, nil)
25
+ end
26
+ it "should regiser instances with the appropriate urls" do
27
+ ActiveFedora.expects(:load_configs)
28
+ ActiveFedora::RubydoraConnection.instance.connection.should be_a Rubydora::Repository
29
+ end
30
+ end
31
+ end
32
+
19
33
  describe 'connect' do
20
34
  before do
21
35
  @instance = ActiveFedora::RubydoraConnection.instance
@@ -2,6 +2,10 @@ require 'spec_helper'
2
2
 
3
3
 
4
4
  describe ActiveFedora::SolrService do
5
+ before do
6
+ Thread.current[:solr_service]=nil
7
+ end
8
+
5
9
  after(:all) do
6
10
  ActiveFedora::SolrService.register(ActiveFedora.solr_config[:url])
7
11
  end
@@ -34,14 +38,13 @@ describe ActiveFedora::SolrService do
34
38
  Thread.current[:solr_service].should == ss
35
39
  ActiveFedora::SolrService.instance.should == ss
36
40
  end
37
- it "should fail fast if solr service not initialized" do
41
+ it "should try to initialize if the service not initialized, and fail if it does not succeed" do
38
42
  Thread.current[:solr_service].should be_nil
43
+ ActiveFedora.expects(:load_configs)
44
+ ActiveFedora::SolrService.expects(:register)
39
45
  proc{ActiveFedora::SolrService.instance}.should raise_error(ActiveFedora::SolrNotInitialized)
40
46
  end
41
- before do
42
- Thread.current[:solr_service]=nil
43
- end
44
-
47
+
45
48
  describe "#reify_solr_results" do
46
49
  before(:each) do
47
50
  class AudioRecord
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1923832045
4
+ hash: 1923832047
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
9
  - 0
10
10
  - pre
11
- - 2
12
- version: 3.2.0.pre2
11
+ - 3
12
+ version: 3.2.0.pre3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Matt Zumwalt
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-12-29 00:00:00 -06:00
21
+ date: 2011-12-30 00:00:00 -06:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency