enju_oai 0.1.0.pre17 → 0.1.0.pre18

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: c1ed8452c675b787d03487c124014cc8743bb77e
4
- data.tar.gz: 89472c34c9f5dcc8d0e3dbf653d8dfc9283c88b0
3
+ metadata.gz: c43bc35ce6acfb814160534eb055d91f09f5b09c
4
+ data.tar.gz: f325d53d05dd7825b2a17a5aa2b6955c3ebee31c
5
5
  SHA512:
6
- metadata.gz: 75a5577aa209863b0ad304839026fce4426bfaba08b93fdaa550dea7a0b941475b3efdc6e585c04d837f77faaf189f026eab656186d6885fcce8b3e499374ab1
7
- data.tar.gz: 7e26b926ee5c8759f6aaa159cda3c0e0a53a2ac69f53ece3077aeb989f51644e7acbccde05ef4a30d07a86135ca9ebb47fde12e1b805e08f64a2342cbb76ffdd
6
+ metadata.gz: cce3e6a8ef3c0fcb0b8d33c51660410447046f1a8663be57277e9a96c8828eace11135ea450feecebadb797d25d0ab8b39b4b15032b1a1118c41588a31561364
7
+ data.tar.gz: 2c9c053b5f2a8716da4dfa67723945f1210bf7a6e6875686ad72b3076c5c779ad169272f2417a2f0e2a80403aa9d912e42e626ca847b2533cd3f787cb9fd963f
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 Kosuke Tanabe
1
+ Copyright 2015 Project Next-L
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -23,24 +23,13 @@ end
23
23
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
24
  load 'rails/tasks/engine.rake'
25
25
 
26
-
27
-
28
26
  Bundler::GemHelper.install_tasks
29
27
 
30
- require 'rake/testtask'
31
-
32
- Rake::TestTask.new(:test) do |t|
33
- t.libs << 'lib'
34
- t.libs << 'test'
35
- t.pattern = 'test/**/*_test.rb'
36
- t.verbose = false
37
- end
38
-
39
28
  require 'rspec/core'
40
29
  require 'rspec/core/rake_task'
41
30
 
42
31
  RSpec::Core::RakeTask.new(:spec) do |spec|
43
- spec.pattern = FileList['spec/**/*_spec.rb']
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
44
33
  end
45
34
 
46
35
  task :default => :spec
@@ -0,0 +1,113 @@
1
+ xml_builder.junii2 :version => '3.1',
2
+ "xsi:schemaLocation" => "http://irdb.nii.ac.jp/oai http://irdb.nii.ac.jp/oai/junii2-3-1.xsd",
3
+ "xmlns" => "http://irdb.nii.ac.jp/oai",
4
+ "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
5
+ xml_builder.title manifestation.original_title
6
+ unless manifestation.title_alternative.blank?
7
+ xml_builder.alternative manifestation.title_alternative
8
+ end
9
+ manifestation.creators.readable_by(current_user).each do |patron|
10
+ xml_builder.creator patron.full_name
11
+ end
12
+ if manifestation.try(:subjects)
13
+ manifestation.subjects.each do |subject|
14
+ unless subject.subject_type.name =~ /BSH|NDLSH|MeSH|LCSH/io
15
+ xml_builder.subject subject.term
16
+ end
17
+ end
18
+ end
19
+ if manifestation.try(:classifications)
20
+ %w[ NDC NDLC ].each do |c|
21
+ manifestation.classifications.each do |classification|
22
+ if classification.classification_type.name =~ /#{ c }/i
23
+ xml_builder.tag! c, classification.category
24
+ end
25
+ end
26
+ end
27
+ end
28
+ if manifestation.try(:subjects)
29
+ %w[ BSH NDLSH MeSH ].each do |s|
30
+ manifestation.subjects.each do |subject|
31
+ if subject.subject_type.name =~ /#{ s }/i
32
+ xml_builder.tag! subject, subject.term
33
+ end
34
+ end
35
+ end
36
+ end
37
+ if manifestation.try(:classifications)
38
+ %w[ DDC LCC UDC ].each do |c|
39
+ manifestation.classifications.each do |classification|
40
+ if classification.classification_type.name =~ /#{ c }/i
41
+ xml_builder.tag! c, classification.category
42
+ end
43
+ end
44
+ end
45
+ end
46
+ if manifestation.try(:subjects)
47
+ manifestation.subjects.each do |s|
48
+ if s.subject_type.name =~ /LCSH/i
49
+ xml_builder.tag! subject, subject.term
50
+ end
51
+ end
52
+ end
53
+ if manifestation.description?
54
+ xml_builder.description manifestation.description
55
+ end
56
+ manifestation.publishers.readable_by(current_user).each do |patron|
57
+ xml_builder.publisher patron.full_name
58
+ end
59
+ manifestation.contributors.readable_by(current_user).each do |patron|
60
+ xml_builder.contributor patron.full_name
61
+ end
62
+ xml_builder.date manifestation.created_at.to_date.iso8601
63
+ xml_builder.type manifestation.manifestation_content_type.name
64
+ if manifestation.try(:nii_type)
65
+ xml_builder.NIItype manifestation.nii_type.name
66
+ else
67
+ xml_builder.NIItype 'Others'
68
+ end
69
+ unless manifestation.attachment.blank?
70
+ xml_builder.format manifestation.attachment_content_type
71
+ end
72
+ if manifestation.manifestation_identifier?
73
+ xml_builder.identifier manifestation.manifestation_identifier
74
+ end
75
+ manifestation.identifiers.each do |identifier|
76
+ unless identifier.identifier_type.name =~ /isbn|issn|ncid|doi|naid|pmid|ichushi/io
77
+ xml_builder.identifier identifier.body
78
+ end
79
+ end
80
+ xml_builder.URI manifestation_url( manifestation )
81
+ unless manifestation.attachment.blank?
82
+ xml_builder.fulltextURL manifestation_url(id: manifestation.id, format: :download)
83
+ end
84
+ %w[ ISBN ISSN NCID ].each do |identifier|
85
+ manifestation.identifier_contents(identifier.downcase).each do |val|
86
+ xml_builder.tag! identifier, val
87
+ end
88
+ end
89
+ if manifestation.root_series_statement
90
+ xml_builder.jtitle manifestation.root_series_statement.original_title
91
+ end
92
+ xml_builder.volume manifestation.volume_number_string
93
+ xml_builder.issue manifestation.issue_number_string
94
+ xml_builder.spage manifestation.start_page
95
+ xml_builder.epage manifestation.end_page
96
+ xml_builder.dateofissued manifestation.pub_date
97
+ #TODO: junii2: source
98
+ if manifestation.language.blank? or manifestation.language.name == 'unknown'
99
+ xml_builder.language "und"
100
+ else
101
+ xml_builder.language manifestation.language.iso_639_2
102
+ end
103
+ %w[ pmid doi NAID ichushi ].each do |identifier|
104
+ manifestation.identifier_contents(identifier.downcase).each do |val|
105
+ xml_builder.tag! identifier, val
106
+ end
107
+ end
108
+ #TODO: junii2: isVersionOf, hasVersion, isReplaceBy, replaces, isRequiredBy, requires, isPartOf, hasPart, isReferencedBy, references, isFormatOf, hasFormat
109
+ #TODO: junii2: coverage, spatial, NIIspatial, temporal, NIItemporal
110
+ #TODO: junii2: rights
111
+ #TODO: junii2: textversion
112
+ #TODO: junii2: grantid, dateofgranted, degreename, grantor
113
+ end
@@ -0,0 +1,20 @@
1
+ xml_builder.tag! "oai_dc:dc",
2
+ "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd",
3
+ "xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
4
+ "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
5
+ xml_builder.tag! "dc:title", manifestation.original_title
6
+ manifestation.creators.readable_by(current_user).each do |patron|
7
+ xml_builder.tag! "dc:creator", patron.full_name
8
+ end
9
+ manifestation.contributors.readable_by(current_user).each do |patron|
10
+ xml_builder.tag! "dc:contributor", patron.full_name
11
+ end
12
+ manifestation.publishers.readable_by(current_user).each do |patron|
13
+ xml_builder.tag! "dc:publisher", patron.full_name
14
+ end
15
+ manifestation.try(:subjects).try(:each) do |subject|
16
+ xml_builder.tag! "dc:subject", subject.term
17
+ end
18
+ xml_builder.tag! "dc:description", manifestation.description
19
+ xml_builder.tag! "dc:date", manifestation.pub_date
20
+ end
@@ -9,17 +9,19 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
9
9
  end
10
10
  xml.ListIdentifiers do
11
11
  @manifestations.each do |manifestation|
12
- cache([manifestation, fragment: 'list_identifiers_oai', role: current_user_role_name, locale: @locale]) do %>
12
+ cache([manifestation, fragment: 'list_identifiers_oai', role: current_user_role_name, locale: @locale]) do
13
13
  xml.header do
14
14
  xml.identifier manifestation.oai_identifier
15
15
  xml.datestamp manifestation.updated_at.utc.iso8601
16
- xml.setSpec manifestation.series_statement.id if manifestation.series_statement
16
+ manifestation.series_statements.each do |series_statement|
17
+ xml.setSpec series_statement.id
18
+ end
17
19
  end
18
20
  end
19
21
  end
20
22
  if @resumption.present?
21
- if @resumption[:cursor].to_i + @manifestations.per_page < @manifestations.total_entries
22
- xml.resumptionToken @resumption[:token], :completeListSize => @manifestations.total_entries, :cursor => @resumption[:cursor], :expirationDate => @resumption[:expired_at]
23
+ if @resumption[:cursor].to_i + @manifestations.limit_value < @manifestations.total_count
24
+ xml.resumptionToken @resumption[:token], completeListSize: @manifestations.total_count, cursor: @resumption[:cursor], expirationDate: @resumption[:expired_at]
23
25
  end
24
26
  end
25
27
  end
@@ -8,12 +8,12 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
8
8
  xml.metadataFormat do
9
9
  xml.metadataPrefix "oai_dc"
10
10
  xml.schema "http://www.openarchives.org/OAI/2.0/oai_dc.xsd"
11
- xml.metadataNamespace "http://www.openarchives.org/OAI/2.0/oai_dc.xsd"
11
+ xml.metadataNamespace "http://www.openarchives.org/OAI/2.0/oai_dc/"
12
+ end
13
+ xml.metadataFormat do
14
+ xml.metadataPrefix "junii2"
15
+ xml.schema "http://irdb.nii.ac.jp/oai/junii2-3-1.xsd"
16
+ xml.metadataNamespace "http://irdb.nii.ac.jp/oai"
12
17
  end
13
- #xml.metadataFormat do
14
- # xml.metadataPrefix "junii2"
15
- # xml.schema "http://ju.nii.ac.jp/oai/junii2.xsd"
16
- # xml.metadataNamespace "http://ju.nii.ac.jp/junii2"
17
- #end
18
18
  end
19
19
  end
@@ -12,45 +12,32 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
12
12
  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
13
13
  "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" do
14
14
  xml.responseDate Time.zone.now.utc.iso8601
15
- xml.request manifestations_url(format: :oai), request_attr('oai_dc')
15
+ xml.request manifestations_url(format: :oai), request_attr(@oai[:metadataPrefix])
16
16
  @oai[:errors].each do |error|
17
- xml.error :code => error
17
+ xml.error code: error
18
18
  end
19
19
  xml.ListRecords do
20
20
  @manifestations.each do |manifestation|
21
- cache([manifestation, fragment: 'list_records_oai', role: current_user_role_name, locale: @locale]) do %>
21
+ cache([manifestation, fragment: 'list_records_oai', role: current_user_role_name, locale: @locale]) do
22
22
  xml.record do
23
23
  xml.header do
24
24
  xml.identifier manifestation.oai_identifier
25
25
  xml.datestamp manifestation.updated_at.utc.iso8601
26
26
  end
27
27
  xml.metadata do
28
- xml.tag! "oai_dc:dc",
29
- "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd",
30
- "xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
31
- "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
32
- xml.tag! "dc:title", manifestation.original_title
33
- manifestation.creators.readable_by(current_user).each do |patron|
34
- xml.tag! "dc:creator", patron.full_name
35
- end
36
- manifestation.contributors.readable_by(current_user).each do |patron|
37
- xml.tag! "dc:contributor", patron.full_name
38
- end
39
- manifestation.publishers.readable_by(current_user).each do |patron|
40
- xml.tag! "dc:publisher", patron.full_name
41
- end
42
- manifestation.subjects.each do |subject|
43
- xml.tag! "dc:subject", subject.term
44
- end
45
- xml.tag! "dc:description", manifestation.description
28
+ case @oai[:metadataPrefix]
29
+ when 'oai_dc', nil
30
+ render 'record_oai_dc', manifestation: manifestation, xml_builder: xml
31
+ when 'junii2'
32
+ render 'record_junii2', manifestation: manifestation, xml_builder: xml
46
33
  end
47
34
  end
48
35
  end
49
36
  end
50
37
  end
51
38
  if @resumption.present?
52
- if @resumption[:cursor].to_i + @manifestations.per_page < @manifestations.total_entries
53
- xml.resumptionToken @resumption[:token], :completeListSize => @manifestations.total_entries, :cursor => @resumption[:cursor], :expirationDate => @resumption[:expired_at]
39
+ if @resumption[:cursor].to_i + @manifestations.limit_value < @manifestations.total_count
40
+ xml.resumptionToken @resumption[:token], completeListSize: @manifestations.total_count, cursor: @resumption[:cursor], expirationDate: @resumption[:expired_at]
54
41
  end
55
42
  end
56
43
  end
@@ -14,11 +14,11 @@ xml.tag! "OAI-PMH", :xmlns => "http://www.openarchives.org/OAI/2.0/",
14
14
  end
15
15
  end
16
16
  xml.metadata do
17
- xml.tag! "oai_dc:dc",
18
- "xsi:schemaLocation" => "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd",
19
- "xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
20
- "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
21
- xml.tag! "dc:title", @manifestation.original_title
17
+ case @oai[:metadataPrefix]
18
+ when 'oai_dc', nil
19
+ render 'record_oai_dc', manifestation: @manifestation, xml_builder: xml
20
+ when 'junii2'
21
+ render 'record_junii2', manifestation: @manifestation, xml_builder: xml
22
22
  end
23
23
  end
24
24
  end
@@ -1,4 +1,5 @@
1
1
  require 'enju_biblio'
2
+ require 'enju_subject'
2
3
 
3
4
  module EnjuOai
4
5
  class Engine < ::Rails::Engine
@@ -55,6 +55,7 @@ module EnjuOai
55
55
  oai[:errors] << "cannotDisseminateFormat"
56
56
  end
57
57
  when 'ListRecords'
58
+ oai[:metadataPrefix] = params[:metadataPrefix]
58
59
  unless valid_metadata_format?(params[:metadataPrefix])
59
60
  oai[:errors] << "cannotDisseminateFormat"
60
61
  end
@@ -63,6 +64,7 @@ module EnjuOai
63
64
  oai[:need_not_to_search] = true
64
65
  oai[:errors] << "badArgument"
65
66
  end
67
+ oai[:metadataPrefix] = params[:metadataPrefix]
66
68
  unless valid_metadata_format?(params[:metadataPrefix])
67
69
  oai[:errors] << "cannotDisseminateFormat"
68
70
  end
@@ -75,7 +77,7 @@ module EnjuOai
75
77
 
76
78
  def valid_metadata_format?(format)
77
79
  if format.present?
78
- if ['oai_dc'].include?(format)
80
+ if ['oai_dc', 'junii2'].include?(format)
79
81
  true
80
82
  else
81
83
  false
@@ -103,12 +105,11 @@ module EnjuOai
103
105
  end
104
106
  end
105
107
  cursor ||= 0
106
- ttl = EnjuLeaf::Application.config.cache_store.last[:expires_in].to_i
107
108
  resumption = {
108
109
  :token => "f(#{from_time.utc.iso8601.to_s}).u(#{until_time.utc.iso8601.to_s}):#{cursor}",
109
110
  :cursor => cursor,
110
111
  # memcachedの使用が前提
111
- :expired_at => ttl.seconds.from_now.utc.iso8601
112
+ :expired_at => ENV['ENJU_OAI_TTL'].to_i.seconds.from_now.utc.iso8601
112
113
  }
113
114
  Rails.cache.fetch(resumption[:token]){resumption}
114
115
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuOai
2
- VERSION = "0.1.0.pre17"
2
+ VERSION = "0.1.0.pre18"
3
3
  end
@@ -25,6 +25,12 @@ describe ManifestationsController do
25
25
  response.should render_template("manifestations/list_records")
26
26
  end
27
27
 
28
+ it "assigns all manifestations as @manifestations in oai format with ListRecords for junii2 metadata" do
29
+ get :index, :format => 'oai', :verb => 'ListRecords', :metadataPrefix => 'junii2'
30
+ assigns(:manifestations).should_not be_nil
31
+ response.should render_template("manifestations/list_records")
32
+ end
33
+
28
34
  it "assigns all manifestations as @manifestations in oai format with ListIdentifiers" do
29
35
  get :index, :format => 'oai', :verb => 'ListIdentifiers'
30
36
  assigns(:manifestations).should_not be_nil
@@ -44,6 +50,12 @@ describe ManifestationsController do
44
50
  assigns(:manifestation).should_not be_nil
45
51
  response.should render_template('manifestations/show')
46
52
  end
53
+ it "assigns all manifestations as @manifestations in oai format with GetRecord with identifier for junii2 metadata" do
54
+ get :index, :format => 'oai', :verb => 'GetRecord', :identifier => 'oai:localhost:manifestations-1', :metadataPrefix => 'junii2'
55
+ assigns(:manifestations).should be_nil
56
+ assigns(:manifestation).should_not be_nil
57
+ response.should render_template('manifestations/show')
58
+ end
47
59
  end
48
60
  end
49
61
  end
@@ -4,4 +4,5 @@ class ApplicationController < ActionController::Base
4
4
  enju_leaf
5
5
  enju_biblio
6
6
  enju_library
7
+ enju_subject
7
8
  end
@@ -55,3 +55,4 @@ module Dummy
55
55
  end
56
56
 
57
57
  require 'enju_leaf'
58
+ require 'enju_nii'
@@ -0,0 +1,13 @@
1
+ class CreateNiiTypes < ActiveRecord::Migration
2
+ def change
3
+ create_table :nii_types do |t|
4
+ t.string :name, :null => false
5
+ t.text :display_name
6
+ t.text :note
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+ add_index :nii_types, :name, :unique => true
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class AddNiiTypeIdToManifestation < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :manifestations, :nii_type_id, :integer
4
+ add_index :manifestations, :nii_type_id
5
+ end
6
+
7
+ def self.down
8
+ remove_column :manifestations, :nii_type_id
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddSettingsToLibraryGroup < ActiveRecord::Migration
2
+ def change
3
+ add_column :library_groups, :settings, :text
4
+ end
5
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20141014065831) do
14
+ ActiveRecord::Schema.define(version: 20150221063719) do
15
15
 
16
16
  create_table "accepts", force: :cascade do |t|
17
17
  t.integer "basket_id"
@@ -687,6 +687,7 @@ ActiveRecord::Schema.define(version: 20141014065831) do
687
687
  t.datetime "updated_at"
688
688
  t.text "admin_networks"
689
689
  t.string "url", default: "http://localhost:3000/"
690
+ t.text "settings"
690
691
  end
691
692
 
692
693
  add_index "library_groups", ["short_name"], name: "index_library_groups_on_short_name"
@@ -807,6 +808,7 @@ ActiveRecord::Schema.define(version: 20141014065831) do
807
808
  t.string "attachment_content_type"
808
809
  t.integer "attachment_file_size"
809
810
  t.datetime "attachment_updated_at"
811
+ t.integer "nii_type_id"
810
812
  t.text "title_alternative_transcription"
811
813
  t.text "description"
812
814
  t.text "abstract"
@@ -835,6 +837,7 @@ ActiveRecord::Schema.define(version: 20141014065831) do
835
837
  add_index "manifestations", ["access_address"], name: "index_manifestations_on_access_address"
836
838
  add_index "manifestations", ["date_of_publication"], name: "index_manifestations_on_date_of_publication"
837
839
  add_index "manifestations", ["manifestation_identifier"], name: "index_manifestations_on_manifestation_identifier"
840
+ add_index "manifestations", ["nii_type_id"], name: "index_manifestations_on_nii_type_id"
838
841
  add_index "manifestations", ["updated_at"], name: "index_manifestations_on_updated_at"
839
842
 
840
843
  create_table "medium_of_performances", force: :cascade do |t|
@@ -846,6 +849,17 @@ ActiveRecord::Schema.define(version: 20141014065831) do
846
849
  t.datetime "updated_at"
847
850
  end
848
851
 
852
+ create_table "nii_types", force: :cascade do |t|
853
+ t.string "name", null: false
854
+ t.text "display_name"
855
+ t.text "note"
856
+ t.integer "position"
857
+ t.datetime "created_at"
858
+ t.datetime "updated_at"
859
+ end
860
+
861
+ add_index "nii_types", ["name"], name: "index_nii_types_on_name", unique: true
862
+
849
863
  create_table "owns", force: :cascade do |t|
850
864
  t.integer "agent_id", null: false
851
865
  t.integer "item_id", null: false
@@ -7,6 +7,11 @@ one:
7
7
  note:
8
8
  my_networks: 0.0.0.0/0
9
9
  url: "http://localhost:3000/"
10
+ settings: <% if Rails::VERSION::MAJOR > 3 %>
11
+ "{\"max_number_of_results\":200,\"family_name_first\":true}"
12
+ <% else %>
13
+ "---\n:max_number_of_results: 200\n:family_name_first: true\n"
14
+ <% end %>
10
15
 
11
16
 
12
17
  # == Schema Information
@@ -0,0 +1,78 @@
1
+ nii_type_00001:
2
+ id: 1
3
+ name: Journal Article
4
+ display_name: Journal Article
5
+ note:
6
+ position: 1
7
+ nii_type_00002:
8
+ id: 2
9
+ name: Thesis or Dissertation
10
+ display_name: Thesis or Dissertation
11
+ note:
12
+ position: 2
13
+ nii_type_00003:
14
+ id: 3
15
+ name: Departmental Bulletin Paper
16
+ display_name: Departmental Bulletin Paper
17
+ note:
18
+ position: 3
19
+ nii_type_00004:
20
+ id: 4
21
+ name: Conference Paper
22
+ display_name: Conference Paper
23
+ note:
24
+ position: 4
25
+ nii_type_00005:
26
+ id: 5
27
+ name: Presentation
28
+ display_name: Presentation
29
+ note:
30
+ position: 5
31
+ nii_type_00006:
32
+ id: 6
33
+ name: Book
34
+ display_name: Book
35
+ note:
36
+ position: 6
37
+ nii_type_00007:
38
+ id: 7
39
+ name: Technical Report
40
+ display_name: Technical Report
41
+ note:
42
+ position: 7
43
+ nii_type_00008:
44
+ id: 8
45
+ name: Research Paper
46
+ display_name: Research Paper
47
+ note:
48
+ position: 8
49
+ nii_type_00009:
50
+ id: 9
51
+ name: Article
52
+ display_name: Article
53
+ note:
54
+ position: 9
55
+ nii_type_00010:
56
+ id: 10
57
+ name: Preprint
58
+ display_name: Preprint
59
+ note:
60
+ position: 10
61
+ nii_type_00011:
62
+ id: 11
63
+ name: Learning Material
64
+ display_name: Learning Material
65
+ note:
66
+ position: 11
67
+ nii_type_00012:
68
+ id: 12
69
+ name: Data or Dataset
70
+ display_name: Data or Dataset
71
+ note:
72
+ position: 12
73
+ nii_type_00013:
74
+ id: 13
75
+ name: Others
76
+ display_name: Others
77
+ note:
78
+ position: 13
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,6 @@ Coveralls.wear!
7
7
  ENV["RAILS_ENV"] ||= 'test'
8
8
  require File.expand_path("../dummy/config/environment", __FILE__)
9
9
  require 'rspec/rails'
10
- require 'rspec/autorun'
11
10
  require 'factory_girl'
12
11
  require 'sunspot-rails-tester'
13
12
 
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe "manifestations/list_identifiers.oai.builder" do
5
+ fixtures :all
6
+ before(:each) do
7
+ view.stub(:current_user_role_name).and_return('Guest')
8
+ assign(:oai, { :errors => [] })
9
+ assign(:manifestations, [ FactoryGirl.create(:manifestation) ])
10
+ end
11
+ it "renders the XML template" do
12
+ render
13
+ expect(rendered).to match /<ListIdentifiers>/
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe "manifestations/list_metadata_formats.oai.builder" do
5
+ fixtures :all
6
+ it "renders the XML template" do
7
+ render
8
+ expect(rendered).to match /<ListMetadataFormats>/
9
+ end
10
+ it "supports oai_dc metadata format" do
11
+ render
12
+ expect(rendered).to match /oai_dc/
13
+ end
14
+ it "supports junii2 metadata format" do
15
+ render
16
+ expect(rendered).to match /junii2/
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe "manifestations/list_records.oai.builder" do
5
+ fixtures :all
6
+
7
+ before(:each) do
8
+ view.stub(:current_user_role_name).and_return('Guest')
9
+ assign(:oai, { :errors => [] })
10
+ assign(:manifestations, [FactoryGirl.create(:manifestation)])
11
+ end
12
+
13
+ it "renders the XML template" do
14
+ render
15
+ expect(rendered).to match /<metadata>/
16
+ end
17
+
18
+ it "renders dc:date" do
19
+ assign(:manifestations, [FactoryGirl.create(:manifestation, pub_date: '2015-08-15')])
20
+ render
21
+ expect(rendered).to match /2015-08-15/
22
+ end
23
+
24
+ describe "when metadataPrefix is oai_dc" do
25
+ before(:each) do
26
+ assign(:oai, { :errors => [], :metadataPrefix => 'oai_dc' } )
27
+ end
28
+ it "renders the XML template" do
29
+ render
30
+ expect(rendered).to match /<oai_dc/
31
+ end
32
+ end
33
+
34
+ describe "when metadataPrefix is junii2" do
35
+ before(:each) do
36
+ assign(:oai, { :errors => [], :metadataPrefix => 'junii2' } )
37
+ end
38
+ it "renders the XML template" do
39
+ render
40
+ expect(rendered).to match /<junii2/
41
+ end
42
+ it "renders NIItype" do
43
+ assign(:manifestations, [FactoryGirl.create(:manifestation, nii_type_id: 1)])
44
+ render
45
+ expect(rendered).to match /<NIItype>Journal Article<\/NIItype>/
46
+ end
47
+ end
48
+ end