hydra-ezid 0.0.1

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.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +46 -0
  3. data/.gitmodules +4 -0
  4. data/.travis.yml +17 -0
  5. data/CONTRIBUTING.md +111 -0
  6. data/CONTRIBUTORS.md +3 -0
  7. data/Gemfile +17 -0
  8. data/History.md +5 -0
  9. data/LICENSE +191 -0
  10. data/README.md +72 -0
  11. data/Rakefile +16 -0
  12. data/app/assets/images/hydra_ezid/.keep +0 -0
  13. data/app/assets/javascripts/hydra_ezid/.keep +0 -0
  14. data/app/assets/stylesheets/hydra_ezid/.keep +0 -0
  15. data/app/controllers/.keep +0 -0
  16. data/app/controllers/ezid_controller.rb +3 -0
  17. data/app/helpers/.keep +0 -0
  18. data/app/helpers/ezid_helper.rb +3 -0
  19. data/app/mailers/.keep +0 -0
  20. data/app/models/.keep +0 -0
  21. data/app/views/.keep +0 -0
  22. data/app/views/ezid/_button_to_mint_ezid.html.erb +1 -0
  23. data/config/routes.rb +3 -0
  24. data/fedora_conf/conf/development/fedora.fcfg +946 -0
  25. data/fedora_conf/conf/test/fedora.fcfg +946 -0
  26. data/gemfiles/rails3.gemfile +6 -0
  27. data/gemfiles/rails4.gemfile +6 -0
  28. data/hydra-ezid.gemspec +29 -0
  29. data/lib/hydra-ezid.rb +6 -0
  30. data/lib/hydra/ezid.rb +11 -0
  31. data/lib/hydra/ezid/controller_behavior.rb +27 -0
  32. data/lib/hydra/ezid/model_methods.rb +10 -0
  33. data/lib/hydra/ezid/version.rb +5 -0
  34. data/solr_conf/conf/schema.xml +372 -0
  35. data/solr_conf/conf/solrconfig.xml +164 -0
  36. data/solr_conf/solr.xml +35 -0
  37. data/spec/controllers/ezid_controller_spec.rb +4 -0
  38. data/spec/factories.rb +3 -0
  39. data/spec/factories/.keep +0 -0
  40. data/spec/helpers/ezid_helper_spec.rb +6 -0
  41. data/spec/models/ezid_spec.rb +4 -0
  42. data/spec/spec_helper.rb +30 -0
  43. data/spec/support/app/models/sample.rb +36 -0
  44. data/spec/support/app/views/catalog/_sort_and_per_page.html.erb +10 -0
  45. data/spec/support/db/migrate/20111101221803_create_searches.rb +16 -0
  46. data/spec/support/lib/generators/test_app_generator.rb +56 -0
  47. data/spec/support/lib/tasks/rspec.rake +8 -0
  48. data/tasks/hydra-ezid-dev.rake +68 -0
  49. data/tasks/jetty.rake +40 -0
  50. metadata +207 -0
@@ -0,0 +1,164 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <config>
3
+ <!-- NOTE: various comments and unused configuration possibilities have been purged
4
+ from this file. Please refer to http://wiki.apache.org/solr/SolrConfigXml,
5
+ as well as the default solrconfig file included with Solr -->
6
+
7
+ <abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
8
+
9
+ <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
10
+
11
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
12
+
13
+ <!-- solr lib dirs -->
14
+ <lib dir="../lib/contrib/analysis-extras/lib" />
15
+ <lib dir="../lib/contrib/analysis-extras/lucene-libs" />
16
+
17
+ <dataDir>${solr.data.dir:}</dataDir>
18
+
19
+ <requestHandler name="search" class="solr.SearchHandler" default="true">
20
+ <!-- default values for query parameters can be specified, these
21
+ will be overridden by parameters in the request
22
+ -->
23
+ <lst name="defaults">
24
+ <str name="defType">edismax</str>
25
+ <str name="echoParams">explicit</str>
26
+ <str name="q.alt">*:*</str>
27
+ <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
28
+ <int name="qs">1</int>
29
+ <int name="ps">2</int>
30
+ <float name="tie">0.01</float>
31
+ <!-- this qf and pf are used by default, if not otherwise specified by
32
+ client. The default blacklight_config will use these for the
33
+ "keywords" search. See the author_qf/author_pf, title_qf, etc
34
+ below, which the default blacklight_config will specify for
35
+ those searches. You may also be interested in:
36
+ http://wiki.apache.org/solr/LocalParams
37
+ -->
38
+ <str name="qf">
39
+ id
40
+ all_text_timv
41
+ active_fedora_model_ssi
42
+ object_type_si
43
+ label_tesim
44
+ </str>
45
+ <str name="pf">
46
+ all_text_timv^10
47
+ </str>
48
+
49
+ <str name="author_qf">
50
+ </str>
51
+ <str name="author_pf">
52
+ </str>
53
+ <str name="title_qf">
54
+ </str>
55
+ <str name="title_pf">
56
+ </str>
57
+ <str name="subject_qf">
58
+ </str>
59
+ <str name="subject_pf">
60
+ </str>
61
+
62
+ <str name="fl">
63
+ *,
64
+ score
65
+ </str>
66
+
67
+ <str name="facet">true</str>
68
+ <str name="facet.mincount">1</str>
69
+ <str name="facet.limit">10</str>
70
+ <str name="facet.field">active_fedora_model_ssi</str>
71
+ <str name="facet.field">object_type_si</str>
72
+
73
+ <str name="spellcheck">true</str>
74
+ <str name="spellcheck.dictionary">default</str>
75
+ <str name="spellcheck.onlyMorePopular">true</str>
76
+ <str name="spellcheck.extendedResults">true</str>
77
+ <str name="spellcheck.collate">false</str>
78
+ <str name="spellcheck.count">5</str>
79
+
80
+ </lst>
81
+ <arr name="last-components">
82
+ <str>spellcheck</str>
83
+ </arr>
84
+ </requestHandler>
85
+
86
+ <requestHandler name="permissions" class="solr.SearchHandler" >
87
+ <lst name="defaults">
88
+ <str name="facet">off</str>
89
+ <str name="echoParams">all</str>
90
+ <str name="rows">1</str>
91
+ <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
92
+ <str name="fl">
93
+ id,
94
+ access_ssim,
95
+ discover_access_group_ssim,discover_access_person_ssim,
96
+ read_access_group_ssim,read_access_person_ssim,
97
+ edit_access_group_ssim,edit_access_person_ssim,
98
+ depositor_ti,
99
+ embargo_release_date_dtsi
100
+ inheritable_access_ssim,
101
+ inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
102
+ inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
103
+ inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
104
+ inheritable_embargo_release_date_dtsi
105
+ </str>
106
+ </lst>
107
+ </requestHandler>
108
+
109
+ <requestHandler name="standard" class="solr.SearchHandler">
110
+ <lst name="defaults">
111
+ <str name="echoParams">explicit</str>
112
+ <str name="defType">lucene</str>
113
+ </lst>
114
+ </requestHandler>
115
+
116
+ <!-- for requests to get a single document; use id=666 instead of q=id:666 -->
117
+ <requestHandler name="document" class="solr.SearchHandler" >
118
+ <lst name="defaults">
119
+ <str name="echoParams">all</str>
120
+ <str name="fl">*</str>
121
+ <str name="rows">1</str>
122
+ <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
123
+ </lst>
124
+ </requestHandler>
125
+
126
+
127
+ <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
128
+ <str name="queryAnalyzerFieldType">textSpell</str>
129
+ <!-- Multiple "Spell Checkers" can be declared and used by this component
130
+ (e.g. for title_spell field)
131
+ -->
132
+ <lst name="spellchecker">
133
+ <str name="name">default</str>
134
+ <str name="field">spell</str>
135
+ <str name="spellcheckIndexDir">./spell</str>
136
+ <str name="buildOnOptimize">true</str>
137
+ </lst>
138
+ </searchComponent>
139
+
140
+ <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
141
+
142
+ <requestDispatcher handleSelect="true" >
143
+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
144
+ </requestDispatcher>
145
+
146
+ <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
147
+ <requestHandler name="/update" class="solr.UpdateRequestHandler" />
148
+ <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
149
+
150
+ <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
151
+ <lst name="invariants">
152
+ <str name="q">solrpingquery</str>
153
+ </lst>
154
+ <lst name="defaults">
155
+ <str name="echoParams">all</str>
156
+ </lst>
157
+ </requestHandler>
158
+
159
+ <!-- config for the admin interface -->
160
+ <admin>
161
+ <defaultQuery>search</defaultQuery>
162
+ </admin>
163
+
164
+ </config>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <!--
3
+ Licensed to the Apache Software Foundation (ASF) under one or more
4
+ contributor license agreements. See the NOTICE file distributed with
5
+ this work for additional information regarding copyright ownership.
6
+ The ASF licenses this file to You under the Apache License, Version 2.0
7
+ (the "License"); you may not use this file except in compliance with
8
+ the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+
19
+ <!--
20
+ All (relative) paths are relative to the installation path
21
+
22
+ persistent: Save changes made via the API to this file
23
+ sharedLib: path to a lib directory that will be shared across all cores
24
+ -->
25
+ <solr persistent="false" sharedLib="lib">
26
+
27
+ <!--
28
+ adminPath: RequestHandler path to manage cores.
29
+ If 'null' (or absent), cores will not be manageable via REST
30
+ -->
31
+ <cores adminPath="/admin/cores" defaultCoreName="development">
32
+ <core name="development" instanceDir="development-core" />
33
+ <core name="test" instanceDir="test-core" />
34
+ </cores>
35
+ </solr>
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe EzidController do
4
+ end
data/spec/factories.rb ADDED
@@ -0,0 +1,3 @@
1
+ FactoryGirl.define do
2
+ factory :ezid
3
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ include Hydra::Ezid::Engine.routes.url_helpers
4
+
5
+ describe EzidHelper do
6
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hydra::Ezid do
4
+ end
@@ -0,0 +1,30 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+
5
+ require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../internal", __FILE__))
6
+ require 'rspec/rails'
7
+ require 'hydra-ezid'
8
+
9
+ FactoryGirl.definition_file_paths = [File.expand_path("../factories", __FILE__)]
10
+ FactoryGirl.find_definitions
11
+
12
+ module EngineRoutes
13
+ def self.included(base)
14
+ base.routes { Hydra::Ezid::Engine.routes }
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.use_transactional_fixtures = true
20
+ config.include Devise::TestHelpers, :type => :controller
21
+ config.before(:each, :type=>"controller") { @routes = Hydra::Ezid::Engine.routes }
22
+ config.include EngineRoutes, :type => :controller
23
+ end
24
+
25
+ module FactoryGirl
26
+ def self.find_or_create(handle, by=:email)
27
+ tmpl = FactoryGirl.build(handle)
28
+ tmpl.class.send("find_by_#{by}".to_sym, tmpl.send(by)) || FactoryGirl.create(handle)
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ class Sample
2
+ # This is a stub model for testing.
3
+
4
+ cattr_accessor :objects
5
+ self.objects = {}
6
+
7
+ def self.create(params={})
8
+ obj = Sample.new
9
+ obj.save
10
+ obj
11
+ end
12
+
13
+ def save()
14
+ @pid ||= "sample:#{(rand * 1000).to_i}"
15
+ self.class.objects[@pid] = self
16
+ end
17
+
18
+ def update_attributes(attributes)
19
+ attributes.each do |k, v|
20
+ instance_variable_set "@#{k.to_s}".to_sym, v
21
+ self.class.send :attr_accessor, k
22
+ end
23
+ end
24
+
25
+ def self.find(pid)
26
+ objects[pid]
27
+ end
28
+
29
+ def pid
30
+ @pid
31
+ end
32
+
33
+ def destroy
34
+ self.class.objects.delete(@pid)
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ <div id="sortAndPerPage">
2
+ <div class="page_links">
3
+ <%= render :partial => "paginate_compact" %>
4
+ </div>
5
+ <%= render :partial => 'sort_widget' %>
6
+
7
+ <%= render :partial => 'per_page_widget' %>
8
+
9
+ <%= button_for_mint_ezid %>
10
+ </div>
@@ -0,0 +1,16 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class CreateSearches < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :searches do |t|
5
+ t.text :query_params
6
+ t.integer :user_id
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :searches, :user_id
11
+ end
12
+
13
+ def self.down
14
+ drop_table :searches
15
+ end
16
+ end
@@ -0,0 +1,56 @@
1
+ require 'rails/generators'
2
+
3
+ class TestAppGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../../../support", __FILE__)
5
+
6
+ def run_blacklight_generator
7
+ say_status("warning", "GENERATING BL", :yellow)
8
+
9
+ generate 'blacklight', '--devise'
10
+ end
11
+
12
+ def run_hydra_head_generator
13
+ say_status("warning", "GENERATING HH", :yellow)
14
+
15
+ generate 'hydra:head', '-f'
16
+ end
17
+
18
+ def run_migrations
19
+ rake("db:migrate")
20
+ end
21
+
22
+ # Inject call to Hydra::Ezid.add_routes in config/routes.rb
23
+ def inject_routes
24
+ insert_into_file "config/routes.rb", :after => '.draw do' do
25
+ "\n # Add Collections routes."
26
+ "\n mount Hydra::Ezid::Engine => '/'"
27
+ end
28
+ end
29
+
30
+ def copy_rspec_rake_task
31
+ copy_file "lib/tasks/rspec.rake"
32
+ end
33
+
34
+ def delete_generated_noise
35
+ remove_file("public/index.html")
36
+ remove_file("spec/models/user_spec.rb")
37
+ end
38
+
39
+ def copy_view_overrides
40
+ directory("app/views/catalog")
41
+ end
42
+
43
+ # Inject javascript into application.js
44
+ def inject_javascript
45
+ insert_into_file "app/assets/javascripts/application.js", :after => '//= require_tree .' do
46
+ "\n //include javascript for ezid\n//= require hydra_ezid"
47
+ end
48
+ end
49
+
50
+ # Inject javascript into application.js
51
+ def inject_css
52
+ insert_into_file "app/assets/stylesheets/application.css", :after => '*= require_tree .' do
53
+ "\n *= require hydra_ezid"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,8 @@
1
+ require 'rspec/core/rake_task'
2
+ desc "run the hydra-ezid gem spec"
3
+ gem_home = File.expand_path('../../../../..', __FILE__)
4
+ RSpec::Core::RakeTask.new(:myspec) do |t|
5
+ t.pattern = gem_home + '/spec/**/*_spec.rb'
6
+ t.rspec_opts = "--colour"
7
+ t.ruby_opts = "-I#{gem_home}/spec"
8
+ end
@@ -0,0 +1,68 @@
1
+ require 'rspec/core'
2
+ require 'rspec/core/rake_task'
3
+ APP_ROOT="." # for jettywrapper
4
+ require 'jettywrapper'
5
+ ENV["RAILS_ROOT"] ||= 'spec/internal'
6
+
7
+ desc 'Spin up hydra-jetty and run specs'
8
+ task :ci => ['jetty:config'] do
9
+ puts 'running continuous integration'
10
+ jetty_params = Jettywrapper.load_config
11
+ error = Jettywrapper.wrap(jetty_params) do
12
+ Rake::Task['spec'].invoke
13
+ end
14
+ raise "test failures: #{error}" if error
15
+ end
16
+
17
+ desc "Run specs"
18
+ # Note: this is _not_ an RSpec::Core::RakeTask.
19
+ # It's a regular rake task that calls the RSpec RakeTask that's defined in spec/support/lib/tasks/rspec.rake
20
+ task :spec => [:generate] do |t|
21
+ focused_spec = ENV['SPEC'] ? " SPEC=#{File.join(GEM_ROOT, ENV['SPEC'])}" : ''
22
+ Bundler.with_clean_env do
23
+ within_test_app do
24
+ system "rake myspec#{focused_spec}"
25
+ abort "Error running hydra-ezid" unless $?.success?
26
+ end
27
+ end
28
+ end
29
+
30
+ desc "Create the test rails app"
31
+ task :generate do
32
+ unless File.exists?('spec/internal/Rakefile')
33
+ puts "Generating rails app"
34
+ `rails new spec/internal`
35
+ puts "Updating gemfile"
36
+
37
+ `echo "gem 'hydra-ezid', :path=>'../../../hydra-ezid'
38
+ gem 'factory_girl_rails'
39
+ " >> spec/internal/Gemfile`
40
+ puts "Copying generator"
41
+ `cp -r spec/support/lib/generators spec/internal/lib`
42
+ Bundler.with_clean_env do
43
+ within_test_app do
44
+ puts "Bundle install"
45
+ `bundle install`
46
+ puts "running test_app_generator"
47
+ system "rails generate test_app"
48
+ # These factories are autogenerated and conflict with our factories
49
+ system 'rm test/factories/users.rb'
50
+ puts "running migrations"
51
+ puts `rake db:migrate db:test:prepare`
52
+ end
53
+ end
54
+ end
55
+ puts "Done generating test app"
56
+ end
57
+
58
+ desc "Clean out the test rails app"
59
+ task :clean do
60
+ puts "Removing sample rails app"
61
+ `rm -rf spec/internal`
62
+ end
63
+
64
+ def within_test_app
65
+ FileUtils.cd('spec/internal')
66
+ yield
67
+ FileUtils.cd('../..')
68
+ end