enju_nii 0.2.0.beta.2 → 0.2.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/enju_nii/cinii_book.rb +47 -45
  3. data/lib/enju_nii/version.rb +1 -1
  4. data/spec/cassette_library/CiniiBook/should_import_a_bibliographic_record.yml +345 -346
  5. data/spec/controllers/cinii_books_controller_spec.rb +1 -1
  6. data/spec/controllers/nii_types_controller_spec.rb +2 -2
  7. data/spec/dummy/app/models/user.rb +2 -0
  8. data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
  9. data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
  10. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
  11. data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
  12. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
  13. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
  14. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
  15. data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
  16. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
  17. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
  18. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
  19. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
  20. data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
  21. data/spec/dummy/db/schema.rb +78 -5
  22. data/spec/fixtures/library_groups.yml +1 -1
  23. data/spec/models/cinii_book_spec.rb +3 -1
  24. data/spec/rails_helper.rb +49 -0
  25. data/spec/spec_helper.rb +84 -41
  26. metadata +216 -192
  27. data/spec/dummy/config/initializers/enju_leaf.rb +0 -2
  28. data/spec/dummy/db/migrate/20160813130535_add_email_to_library_group.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccfe1c13a75513c3a8c79b2588d46d72252f70a2
4
- data.tar.gz: fc56817e44bfdbc91eafb2a48baf308aed4b5c2e
3
+ metadata.gz: fbdbc98847c6bfb68f4cb0e54122bc7ba806ddab
4
+ data.tar.gz: ae43df156ae97e4a0a4ff0aa0711d938cda28046
5
5
  SHA512:
6
- metadata.gz: 288c8967ca1ae3546476c289521093b4a51d613fa4c45de6dec91f2d6af6ff6a6cb3b178b954a778d6ed8ff6065f67f3699ab8a120d85eaf8ddaf1fd4f5d37f0
7
- data.tar.gz: 0f309f4c8bd40810e632eb98f4104923c272f61e90a7317351687389668a3be64c94c89ad39c97bcd32e94f5c21e4b737407d788d44f5799a2b1aa6f9e27ced9
6
+ metadata.gz: f80270cdfd6d10e55333716f7acb3c0723aff1386d4fa9b62109e505a9021c031c363dd05d8f74173e5848780abe5f9407557785e507626597af7dc887be37db
7
+ data.tar.gz: f884ceee8a6dff616f7ddffed77e14fe731cef7eb13cb188c544f25e6933f5f640adcd28b439e1ec588df95278b3bce56784fdf743b17a7576cdd302f6dfd70a
@@ -8,8 +8,8 @@ module EnjuNii
8
8
  module ClassMethods
9
9
  def import_from_cinii_books(options)
10
10
  #if options[:isbn]
11
- lisbn = Lisbn.new(options[:isbn])
12
- raise EnjuNii::InvalidIsbn unless lisbn.valid?
11
+ lisbn = Lisbn.new(options[:isbn])
12
+ raise EnjuNii::InvalidIsbn unless lisbn.valid?
13
13
  #end
14
14
 
15
15
  manifestation = Manifestation.find_by_isbn(lisbn.isbn)
@@ -51,6 +51,8 @@ module EnjuNii
51
51
  manifestation.pub_date = pub_date
52
52
 
53
53
  manifestation.statement_of_responsibility = doc.at('//dc:creator').try(:content)
54
+ manifestation.extent = doc.at('//dcterms:extent').try(:content)
55
+ manifestation.dimensions = doc.at('//cinii:size').try(:content)
54
56
 
55
57
  language = Language.where(:iso_639_3 => get_cinii_language(doc)).first
56
58
  if language
@@ -68,21 +70,21 @@ module EnjuNii
68
70
  end
69
71
 
70
72
  identifier = {}
71
- if ncid
72
- identifier[:ncid] = Identifier.new(body: ncid)
73
+ if ncid
74
+ identifier[:ncid] = Identifier.new(body: ncid)
73
75
  identifier_type_ncid = IdentifierType.where(name: 'ncid').first
74
76
  identifier_type_ncid = IdentifierType.where(name: 'ncid').create! unless identifier_type_ncid
75
- identifier[:ncid].identifier_type = identifier_type_ncid
76
- end
77
- if isbn
78
- identifier[:isbn] = Identifier.new(body: isbn)
77
+ identifier[:ncid].identifier_type = identifier_type_ncid
78
+ end
79
+ if isbn
80
+ identifier[:isbn] = Identifier.new(body: isbn)
79
81
  identifier_type_isbn = IdentifierType.where(name: 'isbn').first
80
82
  identifier_type_isbn = IdentifierType.where(name: 'isbn').create! unless identifier_type_isbn
81
- identifier[:isbn].identifier_type = identifier_type_isbn
82
- end
83
- identifier.each do |k, v|
84
- manifestation.identifiers << v
85
- end
83
+ identifier[:isbn].identifier_type = identifier_type_isbn
84
+ end
85
+ identifier.each do |k, v|
86
+ manifestation.identifiers << v
87
+ end
86
88
 
87
89
  manifestation.carrier_type = CarrierType.where(name: 'volume').first
88
90
  manifestation.manifestation_content_type = ContentType.where(name: 'text').first
@@ -96,12 +98,12 @@ module EnjuNii
96
98
  manifestation.publishers = publisher_patrons
97
99
  manifestation.creators = creator_patrons
98
100
  if defined?(EnjuSubject)
99
- subjects = get_cinii_subjects(doc)
101
+ subjects = get_cinii_subjects(doc)
100
102
  subject_heading_type = SubjectHeadingType.where(name: 'bsh').first
101
103
  subject_heading_type = SubjectHeadingType.create!(name: 'bsh') unless subject_heading_type
102
104
  subjects.each do |term|
103
105
  subject = Subject.where(:term => term[:term]).first
104
- unless subject
106
+ unless subject
105
107
  subject = Subject.new(term)
106
108
  subject.subject_heading_type = subject_heading_type
107
109
  subject_type = SubjectType.where(name: 'concept').first
@@ -185,44 +187,44 @@ module EnjuNii
185
187
 
186
188
  def get_cinii_language(doc)
187
189
  language = doc.at("//dc:language").try(:content)
188
- if language.size > 3
189
- language[0..2]
190
- else
191
- language
192
- end
190
+ if language.size > 3
191
+ language[0..2]
192
+ else
193
+ language
194
+ end
193
195
  end
194
196
 
195
197
  def get_cinii_subjects(doc)
196
- subjects = []
197
- doc.xpath('//foaf:topic').each do |s|
198
- subjects << { :term => s["dc:title"] }
199
- end
200
- subjects
198
+ subjects = []
199
+ doc.xpath('//foaf:topic').each do |s|
200
+ subjects << { :term => s["dc:title"] }
201
+ end
202
+ subjects
201
203
  end
202
204
 
203
205
  def create_cinii_series_statements(doc, manifestation)
204
206
  series = doc.at("//dcterms:isPartOf")
205
- if series and parent_url = series["rdf:resource"]
206
- ptbl = series["dc:title"]
207
- parent_url = parent_url.gsub(/\#\w+\Z/, "")
208
- parent_doc = Nokogiri::XML(Faraday.get(parent_url+".rdf").body)
209
- parent_titles = get_cinii_title(parent_doc)
210
- series_statement = SeriesStatement.new(parent_titles)
211
- series_statement.series_statement_identifier = parent_url
212
- manifestation.series_statements << series_statement
213
- if parts = ptbl.split(/ \. /)
214
- parts[1..-1].each do |part|
215
- title, volume_number, = part.split(/ ; /)
216
- original_title, title_transcription, = title.split(/\|\|/)
217
- series_statement = SeriesStatement.new(
218
- :original_title => original_title,
219
- :title_transcription => title_transcription,
220
- :volume_number_string => volume_number,
221
- )
222
- manifestation.series_statements << series_statement
223
- end
207
+ if series and parent_url = series["rdf:resource"]
208
+ ptbl = series["dc:title"]
209
+ parent_url = parent_url.gsub(/\#\w+\Z/, "")
210
+ parent_doc = Nokogiri::XML(Faraday.get(parent_url+".rdf").body)
211
+ parent_titles = get_cinii_title(parent_doc)
212
+ series_statement = SeriesStatement.new(parent_titles)
213
+ series_statement.series_statement_identifier = parent_url
214
+ manifestation.series_statements << series_statement
215
+ if parts = ptbl.split(/ \. /)
216
+ parts[1..-1].each do |part|
217
+ title, volume_number, = part.split(/ ; /)
218
+ original_title, title_transcription, = title.split(/\|\|/)
219
+ series_statement = SeriesStatement.new(
220
+ :original_title => original_title,
221
+ :title_transcription => title_transcription,
222
+ :volume_number_string => volume_number,
223
+ )
224
+ manifestation.series_statements << series_statement
225
+ end
224
226
  end
225
- end
227
+ end
226
228
  end
227
229
  end
228
230
 
@@ -1,3 +1,3 @@
1
1
  module EnjuNii
2
- VERSION = "0.2.0.beta.2"
2
+ VERSION = "0.2.0.beta.3"
3
3
  end