enju_ndl 0.1.0.pre26 → 0.1.0.pre27

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ndl_books_controller.rb +1 -1
  3. data/app/helpers/ndl_books_helper.rb +5 -5
  4. data/app/models/ndl_book.rb +10 -6
  5. data/app/views/ndl_books/index.html.erb +1 -1
  6. data/lib/enju_ndl/ndl_search.rb +8 -2
  7. data/lib/enju_ndl/version.rb +1 -1
  8. data/spec/cassette_library/ImportRequest/should_import_isbn.yml +354 -352
  9. data/spec/cassette_library/Manifestation/should_imporrt_a_bibliographic_record.yml +650 -648
  10. data/spec/cassette_library/Manifestation/should_import_isbn.yml +355 -353
  11. data/spec/cassette_library/NdlBook/import/should_get_series_title.yml +61 -55
  12. data/spec/cassette_library/NdlBook/import/should_get_volume_number.yml +58 -56
  13. data/spec/cassette_library/NdlBook/import/should_import_audio_cd.yml +8 -8
  14. data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record.yml +96 -96
  15. data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record_that_does_not_have_any_classifications.yml +7 -7
  16. data/spec/cassette_library/NdlBook/import/should_import_pud_date_is_nil.yml +55 -55
  17. data/spec/cassette_library/NdlBook/import/should_import_series_statement.yml +7 -7
  18. data/spec/cassette_library/NdlBook/import/should_import_series_statement_if_the_resource_is_periodical.yml +190 -248
  19. data/spec/cassette_library/NdlBook/import/should_import_title_alternative.yml +165 -163
  20. data/spec/cassette_library/NdlBook/import/should_import_url_contain_whitespace.yml +8 -8
  21. data/spec/cassette_library/NdlBook/import/should_import_video_dvd.yml +7 -7
  22. data/spec/cassette_library/NdlBook/import/should_import_volume_number_string.yml +155 -152
  23. data/spec/cassette_library/NdlBook/import/should_not_get_series_title_if_book_has_not_series_title.yml +64 -62
  24. data/spec/cassette_library/NdlBook/import/should_not_get_volume_number_if_book_has_not_volume.yml +54 -52
  25. data/spec/cassette_library/NdlBook/search/should_not_distinguish_double_byte_space_from_one-byte_space_in_a_query.yml +625 -609
  26. data/spec/cassette_library/NdlBook/search/should_search_bibliographic_record.yml +353 -347
  27. data/spec/cassette_library/NdlBooksController/GET_index/should_get_index.yml +425 -423
  28. data/spec/cassette_library/NdlBooksController/POST_create/should_create_a_bibliographic_record_if_jpno_is_set.yml +7 -7
  29. data/spec/cassette_library/NdlBooksController/POST_create/should_not_create_a_bibliographic_record_if_jpno_is_not_set.yml +11 -11
  30. data/spec/cassette_library/Question/should_respond_to_search_crd.yml +296 -497
  31. data/spec/controllers/ndl_books_controller_spec.rb +1 -1
  32. data/spec/dummy/config/initializers/devise.rb +2 -0
  33. data/spec/dummy/db/test.sqlite3 +0 -0
  34. data/spec/models/ndl_book_spec.rb +12 -11
  35. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee1c48789c634e863b03e8e22228eb35ebfef5d5
4
- data.tar.gz: a29e1bac9d9f11dbb171c44c4b870e9d547aacf2
3
+ metadata.gz: 642a6b6fc3846571a344ef0b97c270897bdd6dbb
4
+ data.tar.gz: 71ff1acdc57df33ee51e753e3e1f1a5b64930ed4
5
5
  SHA512:
6
- metadata.gz: a19dcc7d9ba551144e50181df1be9fee83882257f92dde5bf93f0235e35468b9e732764154139809343568fb7f9b781474e4519b0b74e9bbf5f21dbcf5c08161
7
- data.tar.gz: db3ad54d5539bd43fb631fe66c1718850951ccc86ac8c55f74c86891619b3f68a2fc4dc2ecf96d47a5d192993ac1c0cc765da7ce723d5006a8e94b4f60a8a92c
6
+ metadata.gz: a926ae573d2fc136dba65e0f6762b9ae066f0ba2300f94b34612b2ea0493c67aa7436678dbb92009e76e7f562119eada39c57e92739021a0eddf32d781e295ba
7
+ data.tar.gz: 5d9dcbaeb9b58d979129d23460657e43721c1fa9d14e3fd394055364cf6ee344a984279fe383f301ed58b67cae0c11c20c3b5c7ff07c089817eee04ac8cd17ce
@@ -22,7 +22,7 @@ class NdlBooksController < ApplicationController
22
22
  def create
23
23
  if params[:book]
24
24
  begin
25
- @manifestation = NdlBook.import_from_sru_response(params[:book][:jpno])
25
+ @manifestation = NdlBook.import_from_sru_response(params[:book][:iss_itemno])
26
26
  rescue EnjuNdl::RecordNotFound
27
27
  end
28
28
  respond_to do |format|
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module NdlBooksHelper
3
- def link_to_import_from_ndl(jpno)
4
- if jpno.blank?
3
+ def link_to_import_from_ndl(iss_itemno)
4
+ if iss_itemno.blank?
5
5
  t('enju_ndl.not_available')
6
6
  else
7
- identifier_type = IdentifierType.where(:name => 'jpno').first
7
+ identifier_type = IdentifierType.where(:name => 'iss_itemno').first
8
8
  if identifier_type
9
- manifestation = Identifier.where(:body => jpno, :identifier_type_id => identifier_type.id).first.try(:manifestation)
9
+ manifestation = Identifier.where(:body => iss_itemno, :identifier_type_id => identifier_type.id).first.try(:manifestation)
10
10
  end
11
11
  unless manifestation
12
- link_to t('enju_ndl.add'), ndl_books_path(:book => {:jpno => jpno}), :method => :post
12
+ link_to t('enju_ndl.add'), ndl_books_path(:book => {:iss_itemno => iss_itemno}), :method => :post
13
13
  else
14
14
  link_to t('enju_ndl.already_exists'), manifestation
15
15
  end
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class NdlBook
3
- attr_reader :jpno, :permalink, :title, :creator, :publisher, :issued, :isbn
3
+ attr_reader :jpno, :permalink, :title, :creator, :publisher, :issued, :isbn,
4
+ :itemno
4
5
 
5
6
  def initialize(node)
6
7
  @node = node
@@ -14,6 +15,10 @@ class NdlBook
14
15
  @node.at('./link').try(:content).to_s
15
16
  end
16
17
 
18
+ def itemno
19
+ URI.parse(permalink).path.split('/').last
20
+ end
21
+
17
22
  def title
18
23
  @node.at('./title').try(:content).to_s
19
24
  end
@@ -61,15 +66,14 @@ class NdlBook
61
66
  end
62
67
  end
63
68
 
64
- def self.import_from_sru_response(jpno)
65
- identifier = Identifier.where(:body => jpno, :identifier_type_id => IdentifierType.where(:name => 'jpno').first_or_create.id).first
69
+ def self.import_from_sru_response(itemno)
70
+ identifier = Identifier.where(:body => itemno, :identifier_type_id => IdentifierType.where(:name => 'iss_itemno').first_or_create.id).first
66
71
  return if identifier
67
- url = "http://iss.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&&maximumRecords=1&&query=%28jpno=#{jpno}%29&onlyBib=true"
72
+ url = "http://iss.ndl.go.jp/api/sru?operation=searchRetrieve&recordSchema=dcndl&maximumRecords=1&query=%28itemno=#{itemno}%29&onlyBib=true"
68
73
  xml = open(url).read
69
74
  response = Nokogiri::XML(xml).at('//xmlns:recordData')
70
75
  return unless response.try(:content)
71
- doc = Nokogiri::XML(response.content)
72
- Manifestation.import_record(doc)
76
+ Manifestation.import_record(Nokogiri::XML(response.content))
73
77
  end
74
78
 
75
79
  attr_accessor :url
@@ -22,7 +22,7 @@
22
22
  <% @books.each do |book| %>
23
23
  <tr class="line<%= cycle("0", "1") -%>">
24
24
  <td>
25
- <%= link_to_import_from_ndl(book.jpno) %>
25
+ <%= link_to_import_from_ndl(book.itemno) %>
26
26
  </td>
27
27
  <td>
28
28
  <strong><%= link_to "#{book.title} #{book.volume}".strip , book.permalink %></strong>
@@ -27,10 +27,12 @@ module EnjuNdl
27
27
  end
28
28
 
29
29
  def import_record(doc)
30
- jpno = doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/JPNO"]').try(:content)
31
- identifier = Identifier.where(:body => jpno, :identifier_type_id => IdentifierType.where(:name => 'jpno').first_or_create.id).first
30
+ iss_itemno = URI.parse(doc.at('//dcndl:BibAdminResource[@rdf:about]').values.first).path.split('/').last
31
+ identifier = Identifier.where(:body => iss_itemno, :identifier_type_id => IdentifierType.where(:name => 'iss_itemno').first_or_create.id).first
32
32
  return identifier.manifestation if identifier
33
33
 
34
+ jpno = doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/JPNO"]').try(:content)
35
+
34
36
  publishers = get_publishers(doc)
35
37
 
36
38
  # title
@@ -111,6 +113,10 @@ module EnjuNdl
111
113
  identifier[:isbn] = Identifier.new(:body => isbn)
112
114
  identifier[:isbn].identifier_type = IdentifierType.where(:name => 'isbn').first_or_create
113
115
  end
116
+ if iss_itemno
117
+ identifier[:iss_itemno] = Identifier.new(:body => iss_itemno)
118
+ identifier[:iss_itemno].identifier_type = IdentifierType.where(:name => 'iss_itemno').first_or_create
119
+ end
114
120
  if jpno
115
121
  identifier[:jpno] = Identifier.new(:body => jpno)
116
122
  identifier[:jpno].identifier_type = IdentifierType.where(:name => 'jpno').first_or_create
@@ -1,3 +1,3 @@
1
1
  module EnjuNdl
2
- VERSION = "0.1.0.pre26"
2
+ VERSION = "0.1.0.pre27"
3
3
  end