enju_oai 0.1.1 → 0.2.0.beta.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1376dbd6746c4368f9ed53617eec78f623f8acb
4
- data.tar.gz: e16ab98de0488f0629f1afef7ed4799c9b93e429
3
+ metadata.gz: fb55730b99dfbe398f5f1f5f40cb66767744a2fa
4
+ data.tar.gz: 08c8795cfce91ea8d562657fed024029c005dbc2
5
5
  SHA512:
6
- metadata.gz: 53c4ea6338d93f41fc4635721ecd8a95826362feb2caa1fac44aef2d9f10fa141522b084095c06721aed499d22adaa9e94e7615aa6e10d5b77b8a9e639ca918a
7
- data.tar.gz: 73f0b4f7c43ea8f725b892e7e728f7b1137fb4ad5a762404a4ea8f79430c0d0917bd357627c49ea768fdd6db4749239dfc52e0a6b5e161d040281d3f848db218
6
+ metadata.gz: bc821e1cd95b764e92b26212cf0973608b8d901c46fd7c709649f59bcb87bcf5aef69a6cdd51d775a9b059b28fec2eedfb89a16d6efc25f7198cbce8893e008e
7
+ data.tar.gz: b0728234f814a5ee37d879b5ab4ef91fd79af850e4314fea837a74a8f53995dd85fdaeb2a44cd8cc94fda344af0599f138c01ab8ca0e3b5d56d7cda1e7b68c52
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = EnjuOai
2
- {<img src="https://travis-ci.org/next-l/enju_oai.png?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_oai]
3
- {<img src="https://coveralls.io/repos/next-l/enju_oai/badge.svg?branch=1.1&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_oai?branch=1.1]
4
- {<img src="https://hakiri.io/github/next-l/enju_oai/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_oai/1.1]
2
+ {<img src="https://travis-ci.org/next-l/enju_oai.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_oai]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_oai/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_oai?branch=1.2]
4
+ {<img src="https://hakiri.io/github/next-l/enju_oai/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_oai/1.2]
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
@@ -1,4 +1,6 @@
1
1
  class OaiController < ApplicationController
2
+ before_action :check_policy, only: :provider
3
+
2
4
  def provider
3
5
  @oai = check_oai_params(params)
4
6
  if params[:verb] == 'GetRecord'
@@ -8,42 +10,21 @@ class OaiController < ApplicationController
8
10
  from_time = @from_time = from_and_until_times[:from]
9
11
  until_time = @until_time = from_and_until_times[:until]
10
12
 
11
- # OAI-PMHのデフォルトの件数
12
- oai_per_page = 200
13
- search = Manifestation.search do
14
- order_by :updated_at, :desc
15
- paginate page: 1, per_page: oai_per_page
16
- end
17
- @count = {query_result: search.execute!.total}
18
-
19
13
  if params[:resumptionToken]
20
- token = params[:resumptionToken].split(',')
21
- if token.size == 3
22
- @cursor = token.reverse.first.to_i
23
- if @cursor <= @count[:query_result]
24
- page = (@cursor.to_i + oai_per_page).div(oai_per_page)
25
- else
26
- @oai[:errors] << 'badResumptionToken'
27
- end
28
- else
29
- @oai[:errors] << 'badResumptionToken'
30
- end
14
+ token = params[:resumptionToken]
15
+ else
16
+ token = '*'
31
17
  end
32
- page ||= 1
33
18
 
34
- search.build do
19
+ # OAI-PMHのデフォルトの件数
20
+ oai_per_page = 500
21
+ search = Manifestation.search do
35
22
  order_by :updated_at, :desc
36
- paginate page: page, per_page: oai_per_page
23
+ paginate cursor: token, per_page: oai_per_page
37
24
  end
38
25
  @manifestations = search.execute!.results
39
26
 
40
- unless @manifestations.empty?
41
- @resumption = set_resumption_token(
42
- params[:resumptionToken],
43
- @from_time || Manifestation.order(:updated_at).first.updated_at,
44
- @until_time || Manifestation.order(:updated_at).last.updated_at
45
- )
46
- else
27
+ if @manifestations.empty?
47
28
  @oai[:errors] << 'noRecordsMatch'
48
29
  end
49
30
  end
@@ -74,6 +55,10 @@ class OaiController < ApplicationController
74
55
  end
75
56
 
76
57
  private
58
+ def check_policy
59
+ authorize Oai
60
+ end
61
+
77
62
  def get_record
78
63
  if params[:identifier]
79
64
  begin
@@ -0,0 +1,15 @@
1
+ module EnjuOai
2
+ module OaiModel
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def find_by_oai_identifier(identifier)
7
+ self.find(identifier.to_s.split(":").last.split("-").last)
8
+ end
9
+ end
10
+
11
+ def oai_identifier
12
+ "oai:#{::Addressable::URI.parse(LibraryGroup.site_config.url).host}:#{self.class.to_s.tableize}-#{self.id}"
13
+ end
14
+ end
15
+ end
data/app/models/oai.rb ADDED
@@ -0,0 +1,2 @@
1
+ class Oai
2
+ end
@@ -0,0 +1,5 @@
1
+ class OaiPolicy < ApplicationPolicy
2
+ def provider?
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,85 @@
1
+ xml_builder.tag! "rdf:RDF",
2
+ "xmlns:rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
3
+ "xmlns:dcterms": "http://purl.org/dc/terms/",
4
+ "xmlns:dcndl": "http://ndl.go.jp/dcndl/terms/",
5
+ "xmlns:dc": "http://purl.org/dc/elements/1.1/",
6
+ "xmlns:rdfs": "http://www.w3.org/2000/01/rdf-schema#",
7
+ "xmlns:owl": "http://www.w3.org/2002/07/owl#",
8
+ "xmlns:foaf": "http://xmlns.com/foaf/0.1/" do
9
+ get_record_url = manifestations_url format: "oai", verb: 'GetRecord', metadataPrefix: 'dcndl', identifier: manifestation.oai_identifier
10
+ xml_builder.tag! "dcndl:BibAdminResource", "rdf:about": get_record_url do
11
+ xml_builder.tag! "dcndl:record", "rdf:resource": get_record_url
12
+ xml_builder.tag! "dcndl:bibRecordCategory", ENV['DCNDL_BIBRECORDCATEGORY']
13
+ end
14
+ xml_builder.tag! "dcndl:BibResource", "rdf:about": get_record_url + "#material" do
15
+ manifestation.identifiers.each do |identifier|
16
+ case identifier.identifier_type.try(:name)
17
+ when 'isbn'
18
+ xml_builder.tag! "rdfs:seeAlso", "rdf:resource": "http://iss.ndl.go.jp/isbn/#{ identifier.body }"
19
+ xml_builder.tag! "dcterms:identifier", identifier.body, "rdf:datatype": "http://ndl.go.jp/dcndl/terms/ISBN"
20
+ when 'issn'
21
+ xml_builder.tag! "dcterms:identifier", identifier.body, "rdf:datatype": "http://ndl.go.jp/dcndl/terms/ISSN"
22
+ when 'ncid'
23
+ xml_builder.tag! "dcterms:identifier", identifier.body, "rdf:datatype": "http://ndl.go.jp/dcndl/terms/NIIBibID"
24
+ end
25
+ end
26
+ xml_builder.tag! "dcterms:title", manifestation.original_title
27
+ xml_builder.tag! "dc:title" do
28
+ xml_builder.tag! "rdf:Description" do
29
+ xml_builder.tag! "rdf:value", manifestation.original_title
30
+ if manifestation.title_transcription?
31
+ xml_builder.tag! "dcndl:transcription", manifestation.title_transcription
32
+ end
33
+ end
34
+ end
35
+ xml_builder.tag! "dcterms:creator" do
36
+ manifestation.creators.each do |creator|
37
+ xml_builder.tag! "foaf:Agent" do
38
+ xml_builder.tag! "foaf:name", creator.full_name
39
+ end
40
+ end
41
+ xml_builder.tag! "dc:creator", manifestation.statement_of_responsibility
42
+ end
43
+ xml_builder.tag! "dcterms:publisher" do
44
+ manifestation.publishers.each do |publisher|
45
+ xml_builder.tag! "foaf:Agent" do
46
+ xml_builder.tag! "foaf:name", publisher.full_name
47
+ end
48
+ end
49
+ end
50
+ xml_builder.tag! "dcterms:issued", manifestation.pub_date, "rdf:datatype": "http://purl.org/dc/terms/W3CDTF"
51
+ xml_builder.tag! "dcndl:materialType", "rdf:resource": "http://ndl.go.jp/ndltype/Book"
52
+ end
53
+ unless manifestation.attachment.blank?
54
+ xml_builder.fulltextURL manifestation_url(id: manifestation.id, format: :download)
55
+ end
56
+ %w( ISBN ISSN NCID ).each do |identifier|
57
+ manifestation.identifier_contents(identifier.downcase).each do |val|
58
+ xml_builder.tag! identifier, val
59
+ end
60
+ end
61
+ if manifestation.root_series_statement
62
+ xml_builder.jtitle manifestation.root_series_statement.original_title
63
+ end
64
+ xml_builder.volume manifestation.volume_number_string
65
+ xml_builder.issue manifestation.issue_number_string
66
+ xml_builder.spage manifestation.start_page
67
+ xml_builder.epage manifestation.end_page
68
+ xml_builder.dateofissued manifestation.pub_date
69
+ #TODO: junii2: source
70
+ if manifestation.language.blank? or manifestation.language.name == 'unknown'
71
+ xml_builder.language "und"
72
+ else
73
+ xml_builder.language manifestation.language.iso_639_2
74
+ end
75
+ %w( pmid doi NAID ichushi ).each do |identifier|
76
+ manifestation.identifier_contents(identifier.downcase).each do |val|
77
+ xml_builder.tag! identifier, val
78
+ end
79
+ end
80
+ #TODO: junii2: isVersionOf, hasVersion, isReplaceBy, replaces, isRequiredBy, requires, isPartOf, hasPart, isReferencedBy, references, isFormatOf, hasFormat
81
+ #TODO: junii2: coverage, spatial, NIIspatial, temporal, NIItemporal
82
+ #TODO: junii2: rights
83
+ #TODO: junii2: textversion
84
+ #TODO: junii2: grantid, dateofgranted, degreename, grantor
85
+ end
@@ -19,6 +19,8 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
19
19
  render 'record_oai_dc', manifestation: @manifestation, xml_builder: xml
20
20
  when 'junii2'
21
21
  render 'record_junii2', manifestation: @manifestation, xml_builder: xml
22
+ when 'dcndl'
23
+ render 'record_dcndl', manifestation: @manifestation, xml_builder: xml
22
24
  end
23
25
  end
24
26
  end
@@ -19,13 +19,10 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
19
19
  end
20
20
  end
21
21
  end
22
- if @resumption.present?
23
- if @resumption[:cursor].to_i <= @count[:query_result]
24
- token = @resumption[:token]
25
- else
26
- token = nil
27
- end
28
- xml.resumptionToken token, completeListSize: @count[:query_result], cursor: @cursor.to_i
22
+ if @manifestations.last_page?
23
+ xml.resumptionToken nil, completeListSize: @manifestations.total_count
24
+ else
25
+ xml.resumptionToken CGI.escape(@manifestations.next_page_cursor), completeListSize: @manifestations.total_count
29
26
  end
30
27
  end
31
28
  end
@@ -15,5 +15,10 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
15
15
  xml.schema "http://irdb.nii.ac.jp/oai/junii2-3-1.xsd"
16
16
  xml.metadataNamespace "http://irdb.nii.ac.jp/oai"
17
17
  end
18
+ xml.metadataFormat do
19
+ xml.metadataPrefix "dcndl"
20
+ xml.schema nil
21
+ xml.metadataNamespace "http://ndl.go.jp/dcndl/terms/"
22
+ end
18
23
  end
19
24
  end
@@ -21,18 +21,17 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
21
21
  render 'record_oai_dc', manifestation: manifestation, xml_builder: xml
22
22
  when 'junii2'
23
23
  render 'record_junii2', manifestation: manifestation, xml_builder: xml
24
+ when 'dcndl'
25
+ render 'record_dcndl', manifestation: manifestation, xml_builder: xml
24
26
  end
25
27
  end
26
28
  end
27
29
  end
28
30
  end
29
- if @resumption.present?
30
- if @resumption[:cursor].to_i <= @count[:query_result]
31
- token = @resumption[:token]
32
- else
33
- token = nil
34
- end
35
- xml.resumptionToken token, completeListSize: @count[:query_result], cursor: @cursor.to_i
31
+ if @manifestations.last_page?
32
+ xml.resumptionToken nil, completeListSize: @manifestations.total_count
33
+ else
34
+ xml.resumptionToken CGI.escape(@manifestations.next_page_cursor), completeListSize: @manifestations.total_count
36
35
  end
37
36
  end
38
37
  end
@@ -42,7 +42,7 @@ module EnjuOai
42
42
 
43
43
  def valid_metadata_format?(format)
44
44
  if format.present?
45
- if ['oai_dc', 'junii2'].include?(format)
45
+ if ['oai_dc', 'junii2', 'dcndl'].include?(format)
46
46
  true
47
47
  else
48
48
  false
@@ -1,3 +1,3 @@
1
1
  module EnjuOai
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0.beta.1"
3
3
  end
data/lib/enju_oai.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "enju_oai/engine"
2
- require 'enju_oai/oai_model'
3
2
  require 'enju_oai/oai_controller'
4
3
 
5
4
  module EnjuOai
@@ -1,8 +1,10 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class ApplicationController < ActionController::Base
3
2
  protect_from_forgery
4
- enju_leaf
5
- enju_biblio
6
- enju_library
7
- enju_subject
3
+ include EnjuLeaf::Controller
4
+ include EnjuBiblio::Controller
5
+ include EnjuLibrary::Controller
6
+ include EnjuSubject::Controller
7
+ after_action :verify_authorized
8
+
9
+ include Pundit
8
10
  end
@@ -1,8 +1,7 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class User < ActiveRecord::Base
3
2
  devise :database_authenticatable, #:registerable,
4
3
  :recoverable, :rememberable, :trackable, #, :validatable
5
4
  :lockable, :lock_strategy => :none, :unlock_strategy => :none
6
5
 
7
- enju_leaf_user_model
6
+ include EnjuLeaf::EnjuUser
8
7
  end
@@ -2,8 +2,10 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'rails/all'
4
4
 
5
- Bundler.require
6
- require "enju_oai"
5
+ Bundler.require(*Rails.groups)
6
+ require 'enju_oai'
7
+ require 'enju_nii'
8
+ require 'enju_leaf'
7
9
 
8
10
  module Dummy
9
11
  class Application < Rails::Application
@@ -11,16 +13,6 @@ module Dummy
11
13
  # Application configuration should go into files in config/initializers
12
14
  # -- all .rb files in that directory are automatically loaded.
13
15
 
14
- # Custom directories with classes and modules you want to be autoloadable.
15
- # config.autoload_paths += %W(#{config.root}/extras)
16
-
17
- # Only load the plugins named here, in the order given (default is alphabetical).
18
- # :all can be used as a placeholder for all plugins not explicitly named.
19
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
-
21
- # Activate observers that should always be running.
22
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
-
24
16
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
17
  # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
18
  # config.time_zone = 'Central Time (US & Canada)'
@@ -29,30 +21,8 @@ module Dummy
29
21
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
22
  # config.i18n.default_locale = :de
31
23
 
32
- # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
34
-
35
- # Configure sensitive parameters which will be filtered from the log file.
36
- config.filter_parameters += [:password]
37
-
38
- # Use SQL instead of Active Record's schema dumper when creating the database.
39
- # This is necessary if your schema can't be completely dumped by the schema dumper,
40
- # like if you have constraints or database-specific column types
41
- # config.active_record.schema_format = :sql
42
-
43
- # Enforce whitelist mode for mass assignment.
44
- # This will create an empty whitelist of attributes available for mass-assignment for all models
45
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
46
- # parameters by using an attr_accessible or attr_protected declaration.
47
- #config.active_record.whitelist_attributes = true
48
-
49
- # Enable the asset pipeline
50
- config.assets.enabled = true
51
-
52
- # Version of your assets, change this if you want to expire all your assets
53
- config.assets.version = '1.0'
24
+ # Do not swallow errors in after_commit/after_rollback callbacks.
25
+ config.active_record.raise_in_transactional_callbacks = true
54
26
  end
55
27
  end
56
28
 
57
- require 'enju_leaf'
58
- require 'enju_nii'
@@ -1,37 +1,41 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching
12
+ # Show full error reports and disable caching.
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
- # Don't care if the mailer can't send
16
+ # Don't care if the mailer can't send.
17
17
  config.action_mailer.raise_delivery_errors = false
18
18
 
19
- # Print deprecation notices to the Rails logger
19
+ # Print deprecation notices to the Rails logger.
20
20
  config.active_support.deprecation = :log
21
21
 
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
24
 
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
27
29
 
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
30
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
+ # yet still be able to expire them through the digest params.
32
+ config.assets.digest = true
31
33
 
32
- # Do not compress assets
33
- config.assets.compress = false
34
+ # Adds additional error checking when serving assets at runtime.
35
+ # Checks for improperly declared sprockets dependencies.
36
+ # Raises helpful error messages.
37
+ config.assets.raise_runtime_errors = true
34
38
 
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
39
+ # Raises error for missing translations
40
+ # config.action_view.raise_on_missing_translations = true
37
41
  end
@@ -1,67 +1,79 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
- # Code is not reloaded between requests
4
+ # Code is not reloaded between requests.
5
5
  config.cache_classes = true
6
6
 
7
- # Full error reports are disabled and caching is turned on
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
8
14
  config.consider_all_requests_local = false
9
15
  config.action_controller.perform_caching = true
10
16
 
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
13
26
 
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
16
30
 
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
18
32
  config.assets.compile = false
19
33
 
20
- # Generate digests for assets URLs
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
21
36
  config.assets.digest = true
22
37
 
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
25
39
 
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
29
43
 
30
44
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
45
  # config.force_ssl = true
32
46
 
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
35
50
 
36
- # Prepend all log lines with the following tags
51
+ # Prepend all log lines with the following tags.
37
52
  # config.log_tags = [ :subdomain, :uuid ]
38
53
 
39
- # Use a different logger for distributed setups
54
+ # Use a different logger for distributed setups.
40
55
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
56
 
42
- # Use a different cache store in production
57
+ # Use a different cache store in production.
43
58
  # config.cache_store = :mem_cache_store
44
59
 
45
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
- # config.action_controller.asset_host = "http://assets.example.com"
47
-
48
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
- # config.assets.precompile += %w( search.js )
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
50
62
 
51
- # Disable delivery errors, bad email addresses will be ignored
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
52
65
  # config.action_mailer.raise_delivery_errors = false
53
66
 
54
- # Enable threaded mode
55
- # config.threadsafe!
56
-
57
67
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation can not be found)
68
+ # the I18n.default_locale when a translation cannot be found).
59
69
  config.i18n.fallbacks = true
60
70
 
61
- # Send deprecation notices to registered listeners
71
+ # Send deprecation notices to registered listeners.
62
72
  config.active_support.deprecation = :notify
63
73
 
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+
77
+ # Do not dump schema after migrations.
78
+ config.active_record.dump_schema_after_migration = false
67
79
  end
@@ -1,5 +1,5 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
@@ -7,31 +7,38 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
13
14
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = 'public, max-age=3600'
16
18
 
17
- # Show full error reports and disable caching
19
+ # Show full error reports and disable caching.
18
20
  config.consider_all_requests_local = true
19
21
  config.action_controller.perform_caching = false
20
22
 
21
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
22
24
  config.action_dispatch.show_exceptions = false
23
25
 
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
26
28
 
27
29
  # Tell Action Mailer not to deliver emails to the real world.
28
30
  # The :test delivery method accumulates sent emails in the
29
31
  # ActionMailer::Base.deliveries array.
30
32
  config.action_mailer.delivery_method = :test
31
33
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- #config.active_record.mass_assignment_sanitizer = :strict
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
34
36
 
35
- # Print deprecation notices to the stderr
37
+ # Print deprecation notices to the stderr.
36
38
  config.active_support.deprecation = :stderr
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+
43
+ config.action_mailer.default_url_options = {:host => 'localhost:3000'}
37
44
  end
@@ -0,0 +1,2 @@
1
+ Item.include(EnjuLibrary::EnjuItem)
2
+ Manifestation.include(EnjuOai::OaiModel)
@@ -1,4 +1,4 @@
1
1
  RSpec.configure do |config|
2
- config.include Devise::TestHelpers, :type => :controller
3
- config.include Devise::TestHelpers, :type => :view
2
+ config.include Devise::Test::ControllerHelpers, type: :controller
3
+ config.include Devise::Test::ControllerHelpers, type: :view
4
4
  end
@@ -29,4 +29,16 @@ describe "oai/show.xml.builder" do
29
29
  rendered.should match /<title>manifestation_title/
30
30
  end
31
31
  end
32
+
33
+ describe "When metadataPrefix is 'dcndl'" do
34
+ before(:each) do
35
+ assign(:oai, metadataPrefix: 'dcndl')
36
+ end
37
+ it "renders the XML template" do
38
+ render
39
+ rendered.should match /<metadata\b/
40
+ rendered.should match /<dcndl\b/
41
+ rendered.should match /<dcterms:title>manifestation_title/
42
+ end
43
+ end
32
44
  end
@@ -7,9 +7,6 @@ describe "oai/identify.xml.builder" do
7
7
  before(:each) do
8
8
  assign(:library_group, LibraryGroup.site_config)
9
9
  view.stub(:current_user).and_return(User.where(username: 'enjuadmin').first)
10
- @ability = Object.new
11
- @ability.extend(CanCan::Ability)
12
- controller.stub(:current_ability) { @ability }
13
10
  end
14
11
 
15
12
  it "renders the XML template" do
@@ -6,7 +6,10 @@ describe "oai/list_identifiers.xml.builder" do
6
6
  before(:each) do
7
7
  view.stub(:current_user_role_name).and_return('Guest')
8
8
  assign(:oai, { :errors => [] })
9
- assign(:manifestations, [ FactoryGirl.create(:manifestation) ])
9
+ manifestations = [ FactoryGirl.create(:manifestation) ]
10
+ manifestations.stub(:last_page?){true}
11
+ manifestations.stub(:total_count){manifestations.size}
12
+ assign(:manifestations, manifestations)
10
13
  end
11
14
  it "renders the XML template" do
12
15
  render
@@ -15,4 +15,8 @@ describe "oai/list_metadata_formats.xml.builder" do
15
15
  render
16
16
  expect(rendered).to match /junii2/
17
17
  end
18
+ it "supports dcndl metadata format" do
19
+ render
20
+ expect(rendered).to match /dcndl/
21
+ end
18
22
  end
@@ -7,7 +7,10 @@ describe "oai/list_records.xml.builder" do
7
7
  before(:each) do
8
8
  view.stub(:current_user_role_name).and_return('Guest')
9
9
  assign(:oai, { :errors => [] })
10
- assign(:manifestations, [FactoryGirl.create(:manifestation)])
10
+ manifestations = [ FactoryGirl.create(:manifestation) ]
11
+ manifestations.stub(:last_page?){true}
12
+ manifestations.stub(:total_count){manifestations.size}
13
+ assign(:manifestations, manifestations)
11
14
  end
12
15
 
13
16
  it "renders the XML template" do
@@ -16,7 +19,10 @@ describe "oai/list_records.xml.builder" do
16
19
  end
17
20
 
18
21
  it "renders dc:date" do
19
- assign(:manifestations, [FactoryGirl.create(:manifestation, pub_date: '2015-08-15')])
22
+ manifestations = [FactoryGirl.create(:manifestation, pub_date: '2015-08-15')]
23
+ manifestations.stub(:last_page?){true}
24
+ manifestations.stub(:total_count){manifestations.size}
25
+ assign(:manifestations, manifestations)
20
26
  render
21
27
  expect(rendered).to match /2015-08-15/
22
28
  end
@@ -40,7 +46,10 @@ describe "oai/list_records.xml.builder" do
40
46
  expect(rendered).to match /<junii2/
41
47
  end
42
48
  it "renders NIItype" do
43
- assign(:manifestations, [FactoryGirl.create(:manifestation, nii_type_id: 1)])
49
+ manifestations = [FactoryGirl.create(:manifestation, nii_type_id: 1)]
50
+ manifestations.stub(:last_page?){true}
51
+ manifestations.stub(:total_count){manifestations.size}
52
+ assign(:manifestations, manifestations)
44
53
  render
45
54
  expect(rendered).to match /<NIItype>Journal Article<\/NIItype>/
46
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_oai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kosuke Tanabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-26 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: enju_biblio
@@ -16,58 +16,100 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: 0.2.0.beta.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: 0.2.0.beta.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: enju_subject
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.1
33
+ version: 0.2.0.beta.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.1
40
+ version: 0.2.0.beta.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: sqlite3
42
+ name: enju_leaf
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.2.0.beta.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.2.0.beta.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: mysql2
56
+ name: enju_library
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.3.20
61
+ version: 0.2.0.beta.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.3.20
68
+ version: 0.2.0.beta.1
69
69
  - !ruby/object:Gem::Dependency
70
- name: pg
70
+ name: enju_manifestation_viewer
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.0.beta.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.0.beta.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: enju_subject
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.2.0.beta.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.2.0.beta.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: enju_nii
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.2.0.beta.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.2.0.beta.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - ">="
@@ -81,21 +123,21 @@ dependencies:
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
- name: rspec-rails
126
+ name: mysql2
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - "~>"
129
+ - - ">="
88
130
  - !ruby/object:Gem::Version
89
- version: '3.4'
131
+ version: '0'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
- - - "~>"
136
+ - - ">="
95
137
  - !ruby/object:Gem::Version
96
- version: '3.4'
138
+ version: '0'
97
139
  - !ruby/object:Gem::Dependency
98
- name: factory_girl_rails
140
+ name: pg
99
141
  requirement: !ruby/object:Gem::Requirement
100
142
  requirements:
101
143
  - - ">="
@@ -109,33 +151,33 @@ dependencies:
109
151
  - !ruby/object:Gem::Version
110
152
  version: '0'
111
153
  - !ruby/object:Gem::Dependency
112
- name: enju_leaf
154
+ name: rspec-rails
113
155
  requirement: !ruby/object:Gem::Requirement
114
156
  requirements:
115
157
  - - "~>"
116
158
  - !ruby/object:Gem::Version
117
- version: 1.1.2
159
+ version: '3.4'
118
160
  type: :development
119
161
  prerelease: false
120
162
  version_requirements: !ruby/object:Gem::Requirement
121
163
  requirements:
122
164
  - - "~>"
123
165
  - !ruby/object:Gem::Version
124
- version: 1.1.2
166
+ version: '3.4'
125
167
  - !ruby/object:Gem::Dependency
126
- name: enju_nii
168
+ name: factory_girl_rails
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
- - - "~>"
171
+ - - ">="
130
172
  - !ruby/object:Gem::Version
131
- version: 0.1.1
173
+ version: '0'
132
174
  type: :development
133
175
  prerelease: false
134
176
  version_requirements: !ruby/object:Gem::Requirement
135
177
  requirements:
136
- - - "~>"
178
+ - - ">="
137
179
  - !ruby/object:Gem::Version
138
- version: 0.1.1
180
+ version: '0'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: simplecov
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +221,7 @@ dependencies:
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
181
223
  - !ruby/object:Gem::Dependency
182
- name: appraisal
224
+ name: coveralls
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - ">="
@@ -203,6 +245,10 @@ files:
203
245
  - README.rdoc
204
246
  - Rakefile
205
247
  - app/controllers/oai_controller.rb
248
+ - app/models/concerns/enju_oai/oai_model.rb
249
+ - app/models/oai.rb
250
+ - app/policies/oai_policy.rb
251
+ - app/views/oai/_record_dcndl.xml.builder
206
252
  - app/views/oai/_record_junii2.xml.builder
207
253
  - app/views/oai/_record_oai_dc.xml.builder
208
254
  - app/views/oai/get_record.xml.builder
@@ -217,7 +263,6 @@ files:
217
263
  - lib/enju_oai.rb
218
264
  - lib/enju_oai/engine.rb
219
265
  - lib/enju_oai/oai_controller.rb
220
- - lib/enju_oai/oai_model.rb
221
266
  - lib/enju_oai/version.rb
222
267
  - lib/tasks/enju_oai_tasks.rake
223
268
  - spec/controllers/oai_controller_spec.rb
@@ -236,7 +281,6 @@ files:
236
281
  - spec/dummy/bin/setup
237
282
  - spec/dummy/config.ru
238
283
  - spec/dummy/config/application.rb
239
- - spec/dummy/config/application.yml
240
284
  - spec/dummy/config/boot.rb
241
285
  - spec/dummy/config/database.yml
242
286
  - spec/dummy/config/environment.rb
@@ -245,6 +289,7 @@ files:
245
289
  - spec/dummy/config/environments/test.rb
246
290
  - spec/dummy/config/initializers/backtrace_silencers.rb
247
291
  - spec/dummy/config/initializers/devise.rb
292
+ - spec/dummy/config/initializers/enju_leaf.rb
248
293
  - spec/dummy/config/initializers/inflections.rb
249
294
  - spec/dummy/config/initializers/mime_types.rb
250
295
  - spec/dummy/config/initializers/secret_token.rb
@@ -528,12 +573,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
528
573
  version: '0'
529
574
  required_rubygems_version: !ruby/object:Gem::Requirement
530
575
  requirements:
531
- - - ">="
576
+ - - ">"
532
577
  - !ruby/object:Gem::Version
533
- version: '0'
578
+ version: 1.3.1
534
579
  requirements: []
535
580
  rubyforge_project:
536
- rubygems_version: 2.5.0
581
+ rubygems_version: 2.5.1
537
582
  signing_key:
538
583
  specification_version: 4
539
584
  summary: enju_oai plugin
@@ -551,7 +596,6 @@ test_files:
551
596
  - spec/dummy/bin/rake
552
597
  - spec/dummy/bin/setup
553
598
  - spec/dummy/config/application.rb
554
- - spec/dummy/config/application.yml
555
599
  - spec/dummy/config/boot.rb
556
600
  - spec/dummy/config/database.yml
557
601
  - spec/dummy/config/environment.rb
@@ -560,6 +604,7 @@ test_files:
560
604
  - spec/dummy/config/environments/test.rb
561
605
  - spec/dummy/config/initializers/backtrace_silencers.rb
562
606
  - spec/dummy/config/initializers/devise.rb
607
+ - spec/dummy/config/initializers/enju_leaf.rb
563
608
  - spec/dummy/config/initializers/inflections.rb
564
609
  - spec/dummy/config/initializers/mime_types.rb
565
610
  - spec/dummy/config/initializers/secret_token.rb
@@ -1,25 +0,0 @@
1
- module EnjuOai
2
- module ActsAsMethods
3
- def self.included(base)
4
- base.extend ClassMethods
5
- end
6
-
7
- module ClassMethods
8
- def enju_oai
9
- include InstanceMethods
10
- end
11
-
12
- def find_by_oai_identifier(identifier)
13
- self.find(identifier.to_s.split(":").last.split("-").last)
14
- end
15
- end
16
-
17
- module InstanceMethods
18
- def oai_identifier
19
- "oai:#{::Addressable::URI.parse(LibraryGroup.site_config.url).host}:#{self.class.to_s.tableize}-#{self.id}"
20
- end
21
- end
22
- end
23
- end
24
-
25
- ActiveRecord::Base.send :include, EnjuOai::ActsAsMethods
@@ -1,42 +0,0 @@
1
- defaults: &defaults
2
- enju:
3
- web_hostname: localhost
4
- web_port_number: 3000
5
-
6
- family_name_first: true
7
- max_number_of_results: 500
8
- write_search_log_to_file: true
9
- csv_charset_conversion: true
10
-
11
- # Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
12
- #AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
13
- amazon:
14
- aws_hostname: ecs.amazonaws.jp
15
- hostname: www.amazon.co.jp
16
- access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
17
- secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
18
-
19
- # :google, :amazon
20
- book_jacket:
21
- source: :google
22
- unknown_resource:
23
-
24
- # :mozshot, :simpleapi, :heartrails, :thumbalizr
25
- screenshot:
26
- generator: :mozshot
27
-
28
- uploaded_file:
29
- storage: :local
30
-
31
- manifestation:
32
- facet:
33
- pub_year_range_interval: 10
34
-
35
- development:
36
- <<: *defaults
37
-
38
- test:
39
- <<: *defaults
40
-
41
- production:
42
- <<: *defaults