enju_ndl 0.3.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +14 -0
  3. data/Rakefile +1 -1
  4. data/app/models/ndl_book.rb +11 -3
  5. data/app/views/ndl_books/index.html.erb +1 -1
  6. data/lib/enju_ndl/crd.rb +1 -1
  7. data/lib/enju_ndl/engine.rb +1 -1
  8. data/lib/enju_ndl/ndl_search.rb +9 -9
  9. data/lib/enju_ndl/version.rb +1 -1
  10. data/lib/enju_ndl.rb +0 -2
  11. data/spec/cassette_library/ImportRequest/should_import_a_foreign_book.yml +121 -0
  12. data/spec/cassette_library/ImportRequest/should_import_isbn.yml +49 -492
  13. data/spec/cassette_library/Manifestation/should_import_a_bibliographic_record.yml +121 -0
  14. data/spec/cassette_library/Manifestation/should_import_dcterms_issued.yml +121 -0
  15. data/spec/cassette_library/Manifestation/should_import_isbn.yml +52 -495
  16. data/spec/cassette_library/Manifestation/should_import_series_statement.yml +48 -1121
  17. data/spec/cassette_library/Manifestation/should_import_with_ndl_bib_id.yml +20 -23
  18. data/spec/cassette_library/NdlBook/import/should_get_author_IDs_from_NDLA.yml +62 -0
  19. data/spec/cassette_library/NdlBook/import/should_get_series_title.yml +24 -111
  20. data/spec/cassette_library/NdlBook/import/should_get_subject_IDs_from_NDLA.yml +62 -0
  21. data/spec/cassette_library/NdlBook/import/should_get_volume_number.yml +28 -92
  22. data/spec/cassette_library/NdlBook/import/should_import_audio_cd.yml +26 -126
  23. data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record.yml +28 -166
  24. data/spec/cassette_library/NdlBook/import/should_import_bibliographic_record_that_does_not_have_any_classifications.yml +25 -155
  25. data/spec/cassette_library/NdlBook/import/should_import_edition.yml +25 -154
  26. data/spec/cassette_library/NdlBook/import/should_import_even_with_invalid_url.yml +25 -137
  27. data/spec/cassette_library/NdlBook/import/should_import_map.yml +25 -140
  28. data/spec/cassette_library/NdlBook/import/should_import_ndc8_classification.yml +26 -214
  29. data/spec/cassette_library/NdlBook/import/should_import_notated_music.yml +27 -125
  30. data/spec/cassette_library/NdlBook/import/should_import_painting.yml +26 -114
  31. data/spec/cassette_library/NdlBook/import/should_import_photograph.yml +26 -116
  32. data/spec/cassette_library/NdlBook/import/should_import_picture_postcard.yml +26 -136
  33. data/spec/cassette_library/NdlBook/import/should_import_publication_place.yml +28 -192
  34. data/spec/cassette_library/NdlBook/import/should_import_pud_date_is_nil.yml +25 -107
  35. data/spec/cassette_library/NdlBook/import/should_import_series_statement.yml +27 -194
  36. data/spec/cassette_library/NdlBook/import/should_import_series_statement_if_the_resource_is_serial.yml +24 -216
  37. data/spec/cassette_library/NdlBook/import/should_import_series_statement_s_creator.yml +27 -241
  38. data/spec/cassette_library/NdlBook/import/should_import_series_statement_transctiption.yml +27 -207
  39. data/spec/cassette_library/NdlBook/import/should_import_still_image.yml +26 -133
  40. data/spec/cassette_library/NdlBook/import/should_import_tactile_text.yml +28 -121
  41. data/spec/cassette_library/NdlBook/import/should_import_title_alternative.yml +27 -200
  42. data/spec/cassette_library/NdlBook/import/should_import_url_contain_whitespace.yml +24 -177
  43. data/spec/cassette_library/NdlBook/import/should_import_video_dvd.yml +25 -111
  44. data/spec/cassette_library/NdlBook/import/should_import_volume_number_string.yml +24 -193
  45. data/spec/cassette_library/NdlBook/import/should_import_volume_title.yml +25 -145
  46. data/spec/cassette_library/NdlBook/import/should_import_with_DDC_Fic_.yml +21 -24
  47. data/spec/cassette_library/NdlBook/import/should_not_get_series_title_if_book_has_not_series_title.yml +26 -124
  48. data/spec/cassette_library/NdlBook/import/should_not_get_volume_number_if_book_has_not_volume.yml +24 -105
  49. data/spec/cassette_library/NdlBook/search/should_not_distinguish_double_byte_space_from_one-byte_space_in_a_query.yml +53 -785
  50. data/spec/cassette_library/NdlBook/search/should_search_bibliographic_record.yml +26 -386
  51. data/spec/cassette_library/NdlBooksController/GET_index/should_get_index.yml +24 -463
  52. data/spec/cassette_library/NdlBooksController/POST_create/should_create_a_bibliographic_record_if_jpno_is_set.yml +24 -213
  53. data/spec/cassette_library/NdlBooksController/POST_create/should_create_a_serial_record.yml +28 -143
  54. data/spec/cassette_library/NdlBooksController/POST_create/should_not_create_a_bibliographic_record_if_jpno_is_not_set.yml +27 -22
  55. data/spec/cassette_library/Question/should_respond_to_search_crd.yml +12 -220
  56. data/spec/cassette_library/ndl_books/index/ndl_search_menu/should_reflect_query_params_for_views.yml +24 -384
  57. data/spec/dummy/app/models/application_record.rb +3 -0
  58. data/spec/dummy/app/models/user.rb +1 -1
  59. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +5 -0
  60. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +5 -0
  61. data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +12 -0
  62. data/spec/dummy/db/schema.rb +930 -1003
  63. data/spec/models/import_request_spec.rb +4 -0
  64. data/spec/models/manifestation_spec.rb +9 -1
  65. data/spec/models/ndl_book_spec.rb +20 -5
  66. data/spec/views/ndl_books/index.html.erb_spec.rb +1 -1
  67. metadata +454 -329
  68. data/README.rdoc +0 -10
  69. data/spec/cassette_library/Manifestation/should_imporrt_a_bibliographic_record.yml +0 -1211
  70. data/spec/dummy/config/initializers/session_store.rb +0 -8
@@ -6,4 +6,8 @@ describe ImportRequest do
6
6
  it "should import isbn", vcr: true do
7
7
  ImportRequest.import_isbn('4797327030').should be_valid
8
8
  end
9
+
10
+ it "should import a foreign book", vcr: true do
11
+ ImportRequest.import_isbn('0262220733').should be_valid
12
+ end
9
13
  end
@@ -3,7 +3,7 @@ require 'rails_helper'
3
3
  describe Manifestation do
4
4
  fixtures :all
5
5
 
6
- it "should imporrt a bibliographic record", vcr: true do
6
+ it "should import a bibliographic record", vcr: true do
7
7
  manifestation = Manifestation.import_from_ndl_search(isbn: '406258087X')
8
8
  manifestation.should be_valid
9
9
  end
@@ -23,4 +23,12 @@ describe Manifestation do
23
23
  expect(manifestation).to be_valid
24
24
  expect(manifestation.original_title).to eq "化学"
25
25
  end
26
+
27
+ it "should import dcterms:issued", vcr: true do
28
+ manifestation = Manifestation.import_isbn("0262220733")
29
+ expect(manifestation).to be_valid
30
+ expect(manifestation.year_of_publication).to eq 2005
31
+ expect(manifestation.pub_date).to eq '2005'
32
+ expect(manifestation.date_of_publication).to eq Time.zone.parse('2005-01-01')
33
+ end
26
34
  end
@@ -7,9 +7,9 @@ describe NdlBook do
7
7
  NdlBook.per_page.should eq 10
8
8
  end
9
9
 
10
- context "search" do
11
- it "should search bibliographic record", vcr: true do
12
- NdlBook.search('library system')[:total_entries].should eq 5345
10
+ context 'search' do
11
+ it 'should search bibliographic record', vcr: true do
12
+ NdlBook.search('library system')[:total_entries].should eq 5374
13
13
  end
14
14
 
15
15
  it "should not distinguish double byte space from one-byte space in a query", vcr: true do
@@ -102,8 +102,8 @@ describe NdlBook do
102
102
 
103
103
  it "should import url contain whitespace", vcr: true do
104
104
  manifestation = NdlBook.import_from_sru_response('R100000002-I000002109818-00')
105
- manifestation.original_title.should eq "ザ・スコット・フィッツジェラルド・ブック"
106
- manifestation.pub_date.should eq "1991-04"
105
+ manifestation.original_title.should eq 'ザ・スコット・フィッツジェラルド・ブック'
106
+ manifestation.pub_date.should eq '1991'
107
107
  end
108
108
 
109
109
  it "should import audio cd", vcr: true do
@@ -208,5 +208,20 @@ describe NdlBook do
208
208
  manifestation = NdlBook.import_from_sru_response("R100000002-I000008410444-00")
209
209
  expect(manifestation.original_title).to eq "A single shard / Linda Sue Park"
210
210
  end
211
+
212
+ it 'should get subject IDs from NDLA', vcr: true do
213
+ url = "https://iss.ndl.go.jp/books/R100000002-I028087126-00.rdf"
214
+ doc = Nokogiri::XML(Faraday.get(url).body)
215
+ ndl_book = NdlBook.new(doc)
216
+ ndl_book.subjects[0].should eq({id: 'http://id.ndl.go.jp/auth/ndlsh/01058852', value: 'ウェブアプリケーション'})
217
+ ndl_book.subjects[1].should eq({id: 'http://id.ndl.go.jp/auth/ndlsh/00569223', value: 'プログラミング (コンピュータ)'})
218
+ end
219
+
220
+ it 'should get author IDs from NDLA', vcr: true do
221
+ url = "https://iss.ndl.go.jp/books/R100000002-I028087126-00.rdf"
222
+ doc = Nokogiri::XML(Faraday.get(url).body)
223
+ ndl_book = NdlBook.new(doc)
224
+ ndl_book.authors[0].should eq({id: "http://id.ndl.go.jp/auth/entity/00730574", name: "山田, 祥寛", transcription: "ヤマダ, ヨシヒロ"})
225
+ end
211
226
  end
212
227
  end
@@ -10,7 +10,7 @@ describe "ndl_books/index" do
10
10
  total_count: books[:total_entries],
11
11
  ).page(1).per(10))
12
12
  render
13
- expect(rendered).to include "http://iss.ndl.go.jp/books?any=test"
13
+ expect(rendered).to include "https://iss.ndl.go.jp/books?any=test"
14
14
  end
15
15
  end
16
16
  end