Top Level Namespace
Defined Under Namespace
Modules: ActiveFedora, RDF
Instance Method Summary collapse
- #with_server(environment) ⇒ Object
-
#with_test_server(&block) ⇒ Object
Starts a fedora server and a solr server on a random port and then yields the passed block.
Instance Method Details
#with_server(environment) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_fedora/rake_support.rb', line 7 def with_server(environment) return yield if ENV["#{environment}_SERVER_STARTED"] ENV["#{environment}_SERVER_STARTED"] = 'true' # setting port: nil assigns a random port. solr_defaults = { port: nil, verbose: true, managed: true } fcrepo_defaults = { port: nil, verbose: true, managed: true, enable_jms: false, fcrepo_home_dir: "tmp/fcrepo4-#{environment}-data" } SolrWrapper.wrap(load_config(:solr, environment, solr_defaults)) do |solr| ENV["SOLR_#{environment.upcase}_PORT"] = solr.port.to_s solr_config_path = File.join('solr', 'conf') # Check to see if configs exist in a path relative to the working directory unless Dir.exist?(solr_config_path) $stderr.puts "Solr configuration not found at #{solr_config_path}. Using ActiveFedora defaults" # Otherwise use the configs delivered with ActiveFedora. solr_config_path = File.join(File.("../..", File.dirname(__FILE__)), 'lib', 'generators', 'active_fedora', 'config', 'solr', 'templates', 'solr', 'conf') end solr.with_collection(name: "hydra-#{environment}", dir: solr_config_path) do FcrepoWrapper.wrap(load_config(:fcrepo, environment, fcrepo_defaults)) do |fcrepo| ENV["FCREPO_#{environment.upcase}_PORT"] = fcrepo.port.to_s yield end end end ENV["#{environment}_SERVER_STARTED"] = 'false' end |
#with_test_server(&block) ⇒ Object
Starts a fedora server and a solr server on a random port and then yields the passed block
3 4 5 |
# File 'lib/active_fedora/rake_support.rb', line 3 def with_test_server(&block) with_server('test', &block) end |