enju_loc 0.2.0 → 0.3.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +4 -4
  3. data/app/assets/config/enju_loc_manifest.js +0 -0
  4. data/app/controllers/loc_search_controller.rb +8 -9
  5. data/app/helpers/loc_search_helper.rb +2 -2
  6. data/app/models/loc_search.rb +23 -23
  7. data/lib/enju_loc/loc_search.rb +344 -330
  8. data/lib/enju_loc/version.rb +1 -1
  9. data/spec/cassette_library/LocSearch/_ModsRecord/should_parse_MODS_metadata.yml +7 -7
  10. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_create_a_valid_manifestation.yml +7 -7
  11. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_create_lcsh_subjects_only.yml +17 -16
  12. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_create_multiple_series_statements.yml +10 -10
  13. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_distinguish_title_information_with_subject.yml +7 -7
  14. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_a_manifestation_that_has_invalid_classification.yml +7 -7
  15. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_another_serial.yml +33 -29
  16. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_audio_book.yml +7 -7
  17. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_e-resource.yml +7 -7
  18. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_e-resource_packaged_.yml +7 -7
  19. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_extent.yml +17 -16
  20. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_lccn_exact_math.yml +7 -7
  21. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_notated_music.yml +7 -7
  22. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_note_fields.yml +7 -7
  23. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_publication_year.yml +26 -21
  24. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_serial.yml +30 -29
  25. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_import_video_publication.yml +7 -7
  26. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_parse_title_information_properly.yml +20 -19
  27. data/spec/cassette_library/LocSearch/_import_from_sru_response/should_support_name_and_title_subjects.yml +7 -7
  28. data/spec/cassette_library/LocSearch/_search/should_return_a_search_result.yml +189 -184
  29. data/spec/cassette_library/LocSearchController/GET_index/should_get_index.yml +189 -184
  30. data/spec/cassette_library/LocSearchController/GET_index/should_get_index_with_page_parameter.yml +177 -171
  31. data/spec/cassette_library/LocSearchController/POST_create/should_create_a_bibliographic_record_if_lccn_is_set.yml +19 -22
  32. data/spec/cassette_library/LocSearchController/POST_create/should_not_create_a_bibliographic_record_if_lccn_is_not_set.yml +5 -5
  33. data/spec/cassette_library/loc_search/index/loc_search_menu/should_reflect_query_params_for_views.yml +140 -155
  34. data/spec/controllers/loc_search_controller_spec.rb +16 -16
  35. data/spec/dummy/bin/rails +1 -1
  36. data/spec/dummy/bin/setup +21 -12
  37. data/spec/dummy/bin/update +29 -0
  38. data/spec/dummy/bin/yarn +11 -0
  39. data/spec/dummy/config/application.rb +5 -17
  40. data/spec/dummy/config/cable.yml +10 -0
  41. data/spec/dummy/config/environment.rb +1 -1
  42. data/spec/dummy/config/environments/development.rb +24 -11
  43. data/spec/dummy/config/environments/production.rb +28 -16
  44. data/spec/dummy/config/environments/test.rb +6 -8
  45. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  46. data/spec/dummy/config/initializers/assets.rb +14 -0
  47. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  48. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
  50. data/spec/dummy/config/puma.rb +56 -0
  51. data/spec/dummy/config/secrets.yml +15 -5
  52. data/spec/dummy/config/spring.rb +6 -0
  53. data/spec/dummy/config/sunspot.yml +23 -0
  54. data/spec/dummy/db/migrate/001_create_agents.rb +1 -1
  55. data/spec/dummy/db/migrate/002_devise_create_users.rb +1 -1
  56. data/spec/dummy/db/migrate/005_create_manifestations.rb +1 -1
  57. data/spec/dummy/db/migrate/006_create_items.rb +1 -1
  58. data/spec/dummy/db/migrate/012_create_owns.rb +1 -1
  59. data/spec/dummy/db/migrate/015_create_creates.rb +1 -1
  60. data/spec/dummy/db/migrate/029_create_subjects.rb +1 -1
  61. data/spec/dummy/db/migrate/041_create_roles.rb +1 -1
  62. data/spec/dummy/db/migrate/047_create_produces.rb +1 -1
  63. data/spec/dummy/db/migrate/059_create_libraries.rb +8 -10
  64. data/spec/dummy/db/migrate/069_create_shelves.rb +4 -5
  65. data/spec/dummy/db/migrate/073_create_carrier_types.rb +1 -1
  66. data/spec/dummy/db/migrate/077_create_user_groups.rb +1 -1
  67. data/spec/dummy/db/migrate/080_create_library_groups.rb +3 -4
  68. data/spec/dummy/db/migrate/112_create_frequencies.rb +1 -1
  69. data/spec/dummy/db/migrate/117_create_form_of_works.rb +1 -1
  70. data/spec/dummy/db/migrate/120_create_baskets.rb +3 -4
  71. data/spec/dummy/db/migrate/124_create_bookstores.rb +1 -1
  72. data/spec/dummy/db/migrate/125_create_donates.rb +1 -1
  73. data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -1
  74. data/spec/dummy/db/migrate/131_create_request_types.rb +1 -1
  75. data/spec/dummy/db/migrate/133_create_agent_merges.rb +1 -1
  76. data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +1 -1
  77. data/spec/dummy/db/migrate/142_create_classifications.rb +1 -1
  78. data/spec/dummy/db/migrate/144_create_classification_types.rb +1 -1
  79. data/spec/dummy/db/migrate/145_create_subject_heading_types.rb +1 -1
  80. data/spec/dummy/db/migrate/146_create_subject_types.rb +1 -1
  81. data/spec/dummy/db/migrate/149_create_message_templates.rb +1 -1
  82. data/spec/dummy/db/migrate/154_create_messages.rb +1 -1
  83. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +1 -1
  84. data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +1 -1
  85. data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +1 -1
  86. data/spec/dummy/db/migrate/20080905191442_create_agent_types.rb +1 -1
  87. data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +5 -8
  88. data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +5 -6
  89. data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +1 -1
  90. data/spec/dummy/db/migrate/20081025083323_create_countries.rb +1 -1
  91. data/spec/dummy/db/migrate/20081025083905_create_languages.rb +1 -1
  92. data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +1 -1
  93. data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +1 -1
  94. data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -1
  95. data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +1 -1
  96. data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +1 -1
  97. data/spec/dummy/db/migrate/20090719201843_create_extents.rb +1 -1
  98. data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +1 -1
  99. data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +1 -1
  100. data/spec/dummy/db/migrate/20090812151902_create_agent_relationship_types.rb +1 -1
  101. data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +1 -1
  102. data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +1 -1
  103. data/spec/dummy/db/migrate/20091202124834_create_versions.rb +1 -1
  104. data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +1 -1
  105. data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +1 -1
  106. data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
  107. data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +1 -1
  108. data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
  109. data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +1 -1
  110. data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +1 -1
  111. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +1 -1
  112. data/spec/dummy/db/migrate/20100606073747_create_agent_relationships.rb +1 -1
  113. data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +1 -1
  114. data/spec/dummy/db/migrate/20100814091104_add_position_to_agent_relationship.rb +1 -1
  115. data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +1 -1
  116. data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +1 -1
  117. data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +1 -1
  118. data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
  119. data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +1 -1
  120. data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_agent.rb +1 -1
  121. data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
  122. data/spec/dummy/db/migrate/20110603184217_add_edit_mode_to_resource_import_file.rb +1 -1
  123. data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +1 -1
  124. data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +1 -1
  125. data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +1 -1
  126. data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +1 -1
  127. data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +1 -1
  128. data/spec/dummy/db/migrate/20110913120629_add_lft_and_rgt_to_classification.rb +1 -1
  129. data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +1 -1
  130. data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +1 -1
  131. data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +1 -1
  132. data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +1 -1
  133. data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +1 -1
  134. data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +1 -1
  135. data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +1 -1
  136. data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
  137. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +1 -1
  138. data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +1 -1
  139. data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +1 -1
  140. data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +1 -1
  141. data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +1 -1
  142. data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +4 -7
  143. data/spec/dummy/db/migrate/20120406020752_add_url_to_subject.rb +1 -1
  144. data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +1 -1
  145. data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +1 -1
  146. data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +1 -1
  147. data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +1 -1
  148. data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_agent_import_file.rb +1 -1
  149. data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +1 -1
  150. data/spec/dummy/db/migrate/20120413170720_add_error_message_to_agent_import_file.rb +1 -1
  151. data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +1 -1
  152. data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +1 -1
  153. data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
  154. data/spec/dummy/db/migrate/20120511072422_add_agent_identifier_to_agent.rb +1 -1
  155. data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_agent_import_file.rb +1 -1
  156. data/spec/dummy/db/migrate/20121116031206_add_fulltext_content_to_manifestation.rb +1 -1
  157. data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -1
  158. data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
  159. data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +1 -1
  160. data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +1 -1
  161. data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +1 -1
  162. data/spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb +1 -1
  163. data/spec/dummy/db/migrate/20130504133816_add_manifestation_id_to_subject.rb +1 -1
  164. data/spec/dummy/db/migrate/20130504143515_add_manifestation_id_to_classification.rb +1 -1
  165. data/spec/dummy/db/migrate/20130504195916_add_subject_heading_type_id_to_subject.rb +1 -1
  166. data/spec/dummy/db/migrate/20130506175303_create_identifier_types.rb +1 -1
  167. data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +1 -1
  168. data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +1 -1
  169. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +2 -2
  170. data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +3 -3
  171. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +1 -1
  172. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +1 -1
  173. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +1 -1
  174. data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +1 -1
  175. data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +1 -1
  176. data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +1 -1
  177. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +2 -3
  178. data/spec/dummy/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +1 -1
  179. data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +1 -1
  180. data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +1 -1
  181. data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
  182. data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +1 -1
  183. data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +1 -1
  184. data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +2 -2
  185. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +2 -2
  186. data/spec/dummy/db/migrate/20140720140916_add_binding_item_identifier_to_item.rb +1 -1
  187. data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +2 -2
  188. data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +2 -2
  189. data/spec/dummy/db/migrate/20140721151416_add_default_shelf_id_to_resource_import_file.rb +1 -1
  190. data/spec/dummy/db/migrate/20140802082007_add_manifestation_id_to_item.rb +1 -1
  191. data/spec/dummy/db/migrate/20140811031145_add_expired_at_to_profile.rb +1 -1
  192. data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +1 -1
  193. data/spec/dummy/db/migrate/20140817155043_add_extent_of_text_to_manifestation.rb +1 -1
  194. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +2 -4
  195. data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +1 -1
  196. data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +1 -1
  197. data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +1 -1
  198. data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +1 -1
  199. data/spec/dummy/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +1 -1
  200. data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +1 -1
  201. data/spec/dummy/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +1 -1
  202. data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
  203. data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +1 -1
  204. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +4 -6
  205. data/spec/dummy/db/migrate/20151125004028_add_profile_id_to_agent.rb +1 -1
  206. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +20 -7
  207. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +16 -3
  208. data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
  209. data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
  210. data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
  211. data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +1 -1
  212. data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +1 -1
  213. data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +1 -1
  214. data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +1 -1
  215. data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +1 -1
  216. data/spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb +1 -1
  217. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
  218. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
  219. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
  220. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
  221. data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +1 -1
  222. data/spec/dummy/db/migrate/20160820004638_add_attachment_attachment_to_carrier_types.rb +1 -1
  223. data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +5 -0
  224. data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +5 -0
  225. data/spec/dummy/db/migrate/20171119051258_set_not_null_to_manifestation_id_on_items.rb +5 -0
  226. data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +5 -0
  227. data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +5 -0
  228. data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +5 -0
  229. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +13 -0
  230. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +13 -0
  231. data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +13 -0
  232. data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +13 -0
  233. data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +13 -0
  234. data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +13 -0
  235. data/spec/dummy/db/schema.rb +675 -693
  236. data/spec/models/loc_search_spec.rb +143 -143
  237. data/spec/rails_helper.rb +1 -4
  238. metadata +269 -252
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02705ea8e6f5e989ef15b5af8e99a0f2cbde1a62
4
- data.tar.gz: 9ea8deb70d906514194f05ebff38091f908a8e6b
3
+ metadata.gz: 5df92cc8c1fb95ba8861f40e551be3315289c095
4
+ data.tar.gz: 2fda9f1c77f120a3b95ef1e021384f3ca5b7cb5d
5
5
  SHA512:
6
- metadata.gz: f8ca889b9f75cdce7e77431c3ec615743af92a94d16fc5f109b23cb7e6b089d233cfe21ad9d0262e831fddd994bc1800b2f9326be49e18ba834e82d12cebc17c
7
- data.tar.gz: 1ebadcc88e584d09746ef24ded20c7cea7f43691542a65f933002c34d993a97bb455057fa04b9ae3fea1596514a3e21fbf963255b202ae8ba239cc13883a4c9e
6
+ metadata.gz: 1fd88540628fcd38c8a61c5c2a67da3e3e431aa5994f858fbb7bc050479a096a0e13ecfa5daea116860a1ede7e76276cf3b67f779d04a8f3cec50e452c7e6560
7
+ data.tar.gz: 613e137ead842eb8b90b28dcd955b32b13f1b9ed203fce870878c95d1452bfe06a1bd17fc6361c83d7b2e9b076ed33136c6d3b12c29268086a10a0aa8d5533c5
data/README.rdoc CHANGED
@@ -1,11 +1,11 @@
1
1
  = EnjuLoc
2
- {<img src="https://travis-ci.org/next-l/enju_ndl.svg?branch=1.2" alt="Build Status" />}[https://travis-ci.org/next-l/enju_ndl]
3
- {<img src="https://coveralls.io/repos/next-l/enju_ndl/badge.svg?branch=1.2&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_ndl?branch=1.2]
4
- {<img src="https://hakiri.io/github/next-l/enju_loc/1.2.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_loc/1.2]
2
+ {<img src="https://travis-ci.org/next-l/enju_ndl.svg?branch=1.3" alt="Build Status" />}[https://travis-ci.org/next-l/enju_ndl]
3
+ {<img src="https://coveralls.io/repos/next-l/enju_ndl/badge.svg?branch=1.3&service=github" alt="Coverage Status" />}[https://coveralls.io/github/next-l/enju_ndl?branch=1.3]
4
+ {<img src="https://hakiri.io/github/next-l/enju_loc/1.3.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_loc/1.3]
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
8
8
  == 製作者・貢献者 (Authors and contributors)
9
9
  * {TAKAKU, Masao}[https://github.com/masao] ({@tmasao}[https://twitter.com/tmasao])
10
10
  * {TANABE, Kosuke}[https://github.com/nabeta] ({@nabeta}[https://twitter.com/nabeta])
11
- * {Project Next-L}[http://www.next-l.jp] ({@ProjectNextL}[https://twitter.com/ProjectNextL])
11
+ * {Project Next-L}[https://www.next-l.jp] ({@ProjectNextL}[https://twitter.com/ProjectNextL])
File without changes
@@ -8,11 +8,10 @@ class LocSearchController < ApplicationController
8
8
  page = params[:page].to_i
9
9
  end
10
10
  @query = params[ :query ].to_s.strip
11
- books = LocSearch.search( @query, { :page => page } )
11
+ books = LocSearch.search( @query, { page: page } )
12
12
  @books = Kaminari.paginate_array(
13
13
  books[:items],
14
- :total_count => books[ :total_entries ],
15
- :page => page
14
+ total_count: books[ :total_entries ]
16
15
  ).page( page ).per( 10 )
17
16
  respond_to do |format|
18
17
  format.html
@@ -21,19 +20,19 @@ class LocSearchController < ApplicationController
21
20
 
22
21
  def create
23
22
  begin
24
- @manifestation = LocSearch.import_from_sru_response(params[:book][:lccn])
23
+ @manifestation = LocSearch.import_from_sru_response(params[:book].try(:[], 'lccn'))
25
24
  rescue EnjuLoc::RecordNotFound
26
25
  end
27
26
  respond_to do |format|
28
27
  if @manifestation.try(:save)
29
- flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.manifestation'))
28
+ flash[:notice] = t('controller.successfully_created', model: t('activerecord.models.manifestation'))
30
29
  format.html { redirect_to manifestation_url(@manifestation) }
31
30
  else
32
- if @manifestation and not @manifestation.valid?
33
- flash[:notice] = @manifestation.errors.messages
34
- else
31
+ if @manifestation and not @manifestation.valid?
32
+ flash[:notice] = @manifestation.errors.messages
33
+ else
35
34
  flash[:notice] = t('enju_loc.record_not_found')
36
- end
35
+ end
37
36
  format.html { redirect_to loc_search_index_url }
38
37
  end
39
38
  end
@@ -3,9 +3,9 @@ module LocSearchHelper
3
3
  if lccn.blank?
4
4
  t('enju_loc.not_available')
5
5
  else
6
- identifier_type = IdentifierType.where(:name => 'lccn').first
6
+ identifier_type = IdentifierType.where(name: 'lccn').first
7
7
  if identifier_type
8
- manifestation = Identifier.where(:body => lccn, :identifier_type_id => identifier_type
8
+ manifestation = Identifier.where(body: lccn, identifier_type_id: identifier_type
9
9
  .id).first.try(:manifestation)
10
10
  end
11
11
  unless manifestation
@@ -1,56 +1,56 @@
1
1
  class LocSearch
2
- def initialize( node )
2
+ def initialize(node)
3
3
  @node = node
4
4
  end
5
5
  class ModsRecord < LocSearch
6
6
  MODS_NS = { "mods" => "http://www.loc.gov/mods/v3" }
7
7
  def title
8
- title = @node.xpath( './/mods:titleInfo/mods:title', MODS_NS ).first.content
9
- subtitle = @node.xpath( './/mods:titleInfo/mods:subTitle', MODS_NS ).first
8
+ title = @node.xpath('.//mods:titleInfo/mods:title', MODS_NS).first.content
9
+ subtitle = @node.xpath('.//mods:titleInfo/mods:subTitle', MODS_NS).first
10
10
  title += " : #{ subtitle.content }" if subtitle
11
11
  title
12
12
  end
13
13
  def lccn
14
- @node.xpath( './/mods:mods/mods:identifier[@type="lccn"]', MODS_NS ).first.try( :content )
14
+ @node.xpath('.//mods:mods/mods:identifier[@type="lccn"]', MODS_NS).first.try(:content)
15
15
  end
16
16
  def isbn
17
- @node.xpath( './/mods:mods/mods:identifier[@type="isbn"]', MODS_NS ).first.try( :content )
17
+ @node.xpath('.//mods:mods/mods:identifier[@type="isbn"]', MODS_NS).first.try(:content)
18
18
  end
19
19
  def creator
20
- statement_of_responsibility = @node.at('.//mods:note[@type="statement of responsibility"]',MODS_NS).try(:content)
20
+ statement_of_responsibility = @node.at('.//mods:note[@type="statement of responsibility"]', MODS_NS).try(:content)
21
21
  if statement_of_responsibility
22
22
  statement_of_responsibility
23
23
  else
24
- names = @node.xpath( './/mods:name', MODS_NS )
24
+ names = @node.xpath('.//mods:name', MODS_NS)
25
25
  creator = names.map do |name|
26
- name.xpath( './/mods:namePart', MODS_NS ).map do |part|
26
+ name.xpath('.//mods:namePart', MODS_NS).map do |part|
27
27
  if part.content
28
28
  part.content
29
29
  else
30
30
  nil
31
31
  end
32
- end.compact.join( ", " )
33
- end.join( " ; " )
32
+ end.compact.join(", ")
33
+ end.join(" ; ")
34
34
  creator
35
35
  end
36
36
  end
37
37
  def publisher
38
- @node.xpath( './/mods:publisher', MODS_NS ).map do |e|
38
+ @node.xpath('.//mods:publisher', MODS_NS).map do |e|
39
39
  e.content
40
- end.join( ", " )
40
+ end.join(", ")
41
41
  end
42
42
  def pubyear
43
- @node.xpath( './/mods:dateIssued', MODS_NS ).first.try(:content)
43
+ @node.xpath('.//mods:dateIssued', MODS_NS).first.try(:content)
44
44
  end
45
45
  end
46
46
 
47
47
  class DCRecord < LocSearch
48
48
  DC_NS = { "dc" => "http://purl.org/dc/elements/1.1/" }
49
49
  def title
50
- @node.xpath( './/dc:title', DC_NS ).first.content
50
+ @node.xpath('.//dc:title', DC_NS).first.content
51
51
  end
52
52
  def lccn
53
- @node.xpath( './/dc:identifier[@type="lccn"]', DC_NS ).first.content
53
+ @node.xpath('.//dc:identifier[@type="lccn"]', DC_NS).first.content
54
54
  end
55
55
  def creator
56
56
  end
@@ -58,21 +58,21 @@ class LocSearch
58
58
 
59
59
  # http://www.loc.gov/z3950/lcserver.html
60
60
  LOC_SRU_BASEURL = "http://lx2.loc.gov:210/LCDB"
61
- def self.make_sru_request_uri( query, options = {} )
61
+ def self.make_sru_request_uri(query, options = {})
62
62
  if options[ :page ]
63
63
  page = options[ :page ].to_i
64
- options[ :startRecord ] = ( page - 1 ) * 10 + 1
64
+ options[ :startRecord ] = (page - 1) * 10 + 1
65
65
  options.delete :page
66
66
  end
67
67
  options = { maximumRecords: 10, recordSchema: :mods }.merge(options)
68
- options = options.merge( { query: query, version: "1.1", operation: "searchRetrieve" } )
68
+ options = options.merge({ query: query, version: "1.1", operation: "searchRetrieve" })
69
69
  params = options.map do |k, v|
70
- "#{ URI.escape( k.to_s ) }=#{ URI.escape( v.to_s ) }"
71
- end.join( '&' )
70
+ "#{ URI.escape(k.to_s) }=#{ URI.escape(v.to_s) }"
71
+ end.join('&')
72
72
  uri = "#{ LOC_SRU_BASEURL }?#{ params }"
73
73
  end
74
74
 
75
- def self.search( query, options = {} )
75
+ def self.search(query, options = {})
76
76
  if query and !query.empty?
77
77
  url = make_sru_request_uri(query, options)
78
78
  doc = Nokogiri::XML(Faraday.get(url).body)
@@ -91,10 +91,10 @@ class LocSearch
91
91
  return if identifier
92
92
  url = make_sru_request_uri("bath.lccn=\"^#{ lccn }\"")
93
93
  response = Nokogiri::XML(Faraday.get(url).body)
94
- record = response.at( '//zs:recordData', {"zs" => "http://www.loc.gov/zing/srw/"} )
94
+ record = response.at('//zs:recordData', {"zs" => "http://www.loc.gov/zing/srw/"})
95
95
  return unless record.try(:content)
96
96
  doc = Nokogiri::XML::Document.new
97
- doc << record.at( "//mods:mods", { "mods" => "http://www.loc.gov/mods/v3" } )
97
+ doc << record.at("//mods:mods", { "mods" => "http://www.loc.gov/mods/v3" })
98
98
  Manifestation.import_record_from_loc(doc)
99
99
  end
100
100
  end
@@ -15,7 +15,7 @@ module EnjuLoc
15
15
  end
16
16
  url = LOC_SRU_BASEURL + "?operation=searchRetrieve&version=1.1&=query=#{ URI.escape(query) }"
17
17
  cont = Faraday.get(url).body
18
- parser = LibXML::XML::Parser.string( cont )
18
+ parser = LibXML::XML::Parser.string(cont)
19
19
  doc = parser.parse
20
20
  end
21
21
 
@@ -34,17 +34,17 @@ module EnjuLoc
34
34
  end
35
35
 
36
36
  NS = {"mods"=>"http://www.loc.gov/mods/v3"}
37
- def import_record_from_loc( doc )
38
- record_identifier = doc.at( '//mods:recordInfo/mods:recordIdentifier', NS ).try(:content)
39
- identifier_type = IdentifierType.where(name: 'loc_identifier').first
37
+ def import_record_from_loc(doc)
38
+ record_identifier = doc.at('//mods:recordInfo/mods:recordIdentifier', NS).try(:content)
39
+ identifier_type = IdentifierType.find_by(name: 'loc_identifier')
40
40
  identifier_type = IdentifierType.create!(name: 'loc_identifier') unless identifier_type
41
- loc_identifier = Identifier.where(body: record_identifier, :identifier_type_id => identifier_type.id).first
41
+ loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.id)
42
42
  return loc_identifier.manifestation if loc_identifier
43
43
 
44
44
  publishers = []
45
45
  doc.xpath('//mods:publisher', NS).each do |publisher|
46
46
  publishers << {
47
- :full_name => publisher.content,
47
+ full_name: publisher.content,
48
48
  #:agent_identifier => publisher.attributes["about"].try(:content)
49
49
  }
50
50
  end
@@ -57,7 +57,7 @@ module EnjuLoc
57
57
  # date of publication
58
58
  date = get_mods_date_of_publication(doc)
59
59
 
60
- language = Language.where(:iso_639_2 => get_mods_language(doc)).first
60
+ language = Language.find_by(iso_639_2: get_mods_language(doc))
61
61
  if language
62
62
  language_id = language.id
63
63
  else
@@ -69,7 +69,7 @@ module EnjuLoc
69
69
  issn = StdNum::ISSN.normalize(doc.at('/mods:mods/mods:identifier[@type="issn"]', NS).try(:content).to_s)
70
70
  issn_l = StdNum::ISSN.normalize(doc.at('/mods:mods/mods:identifier[@type="issn-l"]', NS).try(:content).to_s)
71
71
 
72
- types = get_mods_carrier_and_content_types( doc )
72
+ types = get_mods_carrier_and_content_types(doc)
73
73
  content_type = types[ :content_type ]
74
74
  carrier_type = types[ :carrier_type ]
75
75
 
@@ -91,62 +91,76 @@ module EnjuLoc
91
91
  publisher_agents = Agent.import_agents(publishers)
92
92
 
93
93
  manifestation = Manifestation.new(
94
- :manifestation_identifier => record_identifier,
95
- :original_title => titles[:original_title],
96
- :title_alternative => titles[:title_alternative],
97
- :language_id => language_id,
98
- :pub_date => date,
99
- :description => description,
100
- :edition_string => edition_string,
101
- :statement_of_responsibility => statement_of_responsibility,
102
- :start_page => extent[:start_page],
103
- :end_page => extent[:end_page],
104
- :extent => extent[:extent],
105
- :height => extent[:height],
106
- :dimensions => extent[:dimensions],
107
- :access_address => access_address,
108
- :note => note,
109
- :publication_place => publication_place,
110
- :serial => is_serial
94
+ manifestation_identifier: record_identifier,
95
+ original_title: titles[:original_title],
96
+ title_alternative: titles[:title_alternative],
97
+ language_id: language_id,
98
+ pub_date: date,
99
+ description: description,
100
+ edition_string: edition_string,
101
+ statement_of_responsibility: statement_of_responsibility,
102
+ start_page: extent[:start_page],
103
+ end_page: extent[:end_page],
104
+ extent: extent[:extent],
105
+ height: extent[:height],
106
+ dimensions: extent[:dimensions],
107
+ access_address: access_address,
108
+ note: note,
109
+ publication_place: publication_place,
110
+ serial: is_serial
111
111
  )
112
112
  identifier = {}
113
113
  if isbn
114
- identifier[:isbn] = Identifier.new(body: isbn)
115
- identifier[:isbn].identifier_type = IdentifierType.where(name: 'isbn').first || IdnetifierType.create!(name: 'isbn')
114
+ identifier[:isbn] = Identifier.new(
115
+ manifestation: manifestation,
116
+ body: isbn,
117
+ identifier_type: IdentifierType.find_by(name: 'isbn') || IdnetifierType.create!(name: 'isbn')
118
+ )
116
119
  end
117
120
  if loc_identifier
118
- identifier[:loc_identifier] = Identifier.new(body: loc_identifier)
119
- identifier[:loc_identifier].identifier_type = IdentifierType.where(name: 'loc_identifier').first || IdnetifierType.create!(name: 'loc_identifier')
121
+ identifier[:loc_identifier] = Identifier.new(
122
+ manifestation: manifestation,
123
+ body: loc_identifier,
124
+ identifier_type: IdentifierType.find_by(name: 'loc_identifier') || IdnetifierType.create!(name: 'loc_identifier')
125
+ )
120
126
  end
121
127
  if lccn
122
- identifier[:lccn] = Identifier.new(body: lccn)
123
- identifier[:lccn].identifier_type = IdentifierType.where(name: 'lccn').first || IdentifierType.create!(name: 'lccn')
128
+ identifier[:lccn] = Identifier.new(
129
+ manifestation: manifestation,
130
+ body: lccn,
131
+ identifier_type: IdentifierType.find_by(name: 'lccn') || IdentifierType.create!(name: 'lccn')
132
+ )
124
133
  end
125
134
  if issn
126
- identifier[:issn] = Identifier.new(body: issn)
127
- identifier[:issn].identifier_type = IdentifierType.where(name: 'issn').first || IdentifierType.create!(name: 'issn')
135
+ identifier[:issn] = Identifier.new(
136
+ manifestation: manifestation,
137
+ body: issn,
138
+ identifier_type: IdentifierType.find_by(name: 'issn') || IdentifierType.create!(name: 'issn')
139
+ )
128
140
  end
129
141
  if issn_l
130
- identifier[:issn_l] = Identifier.new(body: issn_l)
131
- identifier[:issn_l].identifier_type = IdentifierType.where(name: 'issn_l').first || IdentifierType.create!(name: 'issn_l')
142
+ identifier[:issn_l] = Identifier.new(
143
+ manifestation: manifestation,
144
+ body: issn_l,
145
+ identifier_type: IdentifierType.find_by(name: 'issn_l') || IdentifierType.create!(name: 'issn_l')
146
+ )
132
147
  end
133
148
  manifestation.carrier_type = carrier_type if carrier_type
134
149
  manifestation.manifestation_content_type = content_type if content_type
135
150
  manifestation.frequency = frequency if frequency
136
- if manifestation.save
137
- identifier.each do |k, v|
138
- manifestation.identifiers << v if v.valid?
139
- end
140
- manifestation.publishers << publisher_agents
141
- manifestation.creators << creator_agents
142
- create_loc_subject_related_elements(doc, manifestation)
143
- create_loc_series_statement(doc, manifestation)
144
- if is_serial
145
- create_loc_series_master(doc, manifestation)
146
- end
151
+ manifestation.save!
152
+ identifier.each do |k, v|
153
+ manifestation.identifiers << v if v.valid?
154
+ end
155
+ manifestation.publishers << publisher_agents
156
+ manifestation.creators << creator_agents
157
+ create_loc_subject_related_elements(doc, manifestation)
158
+ create_loc_series_statement(doc, manifestation)
159
+ if is_serial
160
+ create_loc_series_master(doc, manifestation)
147
161
  end
148
162
  end
149
- return manifestation
163
+ manifestation
150
164
  end
151
165
 
152
166
  private
@@ -155,25 +169,25 @@ module EnjuLoc
155
169
  subjects = get_mods_subjects(doc)
156
170
  classifications = get_mods_classifications(doc)
157
171
  if defined?(EnjuSubject)
158
- subject_heading_type = SubjectHeadingType.where(name: 'lcsh').first || SubjectHeadingType.create!(name: 'lcsh')
172
+ subject_heading_type = SubjectHeadingType.find_by(name: 'lcsh') || SubjectHeadingType.create!(name: 'lcsh')
159
173
  subjects.each do |term|
160
- subject = Subject.where(term: term[:term]).first
174
+ subject = Subject.find_by(term: term[:term])
161
175
  unless subject
162
176
  subject = Subject.new(term)
163
177
  subject.subject_heading_type = subject_heading_type
164
- subject.subject_type = SubjectType.where(name: 'concept').first || SubjectType.create!(name: 'concept')
178
+ subject.subject_type = SubjectType.find_by(name: 'concept') || SubjectType.create!(name: 'concept')
165
179
  end
166
180
  manifestation.subjects << subject
167
181
  end
168
182
  if classifications
169
- classification_type = ClassificationType.where(name: 'ddc').first || ClassificationType.create!(name: 'ddc')
183
+ classification_type = ClassificationType.find_by(name: 'ddc') || ClassificationType.create!(name: 'ddc')
170
184
  classifications.each do |ddc|
171
- classification = Classification.where(:category => ddc).first
185
+ classification = Classification.find_by(category: ddc)
172
186
  unless classification
173
- classification = Classification.new(:category => ddc)
187
+ classification = Classification.new(category: ddc)
174
188
  classification.classification_type = classification_type
175
189
  end
176
- manifestation.classifications << classification if classification.valid?
190
+ manifestation.classifications << classification
177
191
  end
178
192
  end
179
193
  end
@@ -186,7 +200,7 @@ module EnjuLoc
186
200
  series_title = title.split(';')[0].strip
187
201
  end
188
202
  if series_title
189
- series_statement = SeriesStatement.where(:original_title => series_title).first || SeriesStatement.create!(original_title: series_title)
203
+ series_statement = SeriesStatement.find_by(original_title: series_title) || SeriesStatement.create!(original_title: series_title)
190
204
  if series_statement.try(:save)
191
205
  manifestation.series_statements << series_statement
192
206
  end
@@ -197,9 +211,9 @@ module EnjuLoc
197
211
  def create_loc_series_master(doc, manifestation)
198
212
  titles = get_mods_titles(doc)
199
213
  series_statement = SeriesStatement.new(
200
- :original_title => titles[:original_title],
201
- :title_alternative => titles[:title_alternative],
202
- :series_master => true
214
+ original_title: titles[:original_title],
215
+ title_alternative: titles[:title_alternative],
216
+ series_master: true
203
217
  )
204
218
  if series_statement.try(:save)
205
219
  manifestation.series_statements << series_statement
@@ -222,315 +236,315 @@ module EnjuLoc
222
236
  original_title << " : #{ subtitle }" if subtitle
223
237
  partnumber = e.at('./mods:partNumber', NS).try(:content)
224
238
  partname = e.at('./mods:partName', NS).try(:content)
225
- partname = [ partnumber, partname ].compact.join( ": " )
239
+ partname = [ partnumber, partname ].compact.join(": ")
226
240
  original_title << ". #{ partname }" unless partname.blank?
227
241
  end
228
242
  end
229
- { :original_title => original_title, :title_alternative => title_alternatives.join( " ; " ) }
243
+ { original_title: original_title, title_alternative: title_alternatives.join(" ; ") }
230
244
  end
231
245
 
232
- def get_mods_language(doc)
233
- language = doc.at('//mods:language/mods:languageTerm[@authority="iso639-2b"]', NS).try(:content)
234
- end
246
+ def get_mods_language(doc)
247
+ language = doc.at('//mods:language/mods:languageTerm[@authority="iso639-2b"]', NS).try(:content)
248
+ end
235
249
 
236
- def get_mods_access_address(doc)
237
- access_address = nil
238
- url = doc.at('//mods:location/mods:url', NS)
239
- if url
240
- usage = url.attributes["usage"].try(:content)
241
- case usage
242
- when "primary display", "primary"
243
- access_address = url.try(:content)
250
+ def get_mods_access_address(doc)
251
+ access_address = nil
252
+ url = doc.at('//mods:location/mods:url', NS)
253
+ if url
254
+ usage = url.attributes["usage"].try(:content)
255
+ case usage
256
+ when "primary display", "primary"
257
+ access_address = url.try(:content)
258
+ end
244
259
  end
260
+ access_address
245
261
  end
246
- access_address
247
- end
248
262
 
249
- def get_mods_publication_place(doc)
250
- place = doc.at('//mods:originInfo/mods:place/mods:placeTerm[@type="text"]', NS).try(:content)
251
- end
263
+ def get_mods_publication_place(doc)
264
+ place = doc.at('//mods:originInfo/mods:place/mods:placeTerm[@type="text"]', NS).try(:content)
265
+ end
252
266
 
253
- def get_mods_extent(doc)
254
- extent = doc.at('//mods:extent', NS).try(:content)
255
- value = {:start_page => nil, :end_page => nil, :height => nil}
256
- if extent
257
- extent = extent.split(';')
258
- page = extent[0].try(:strip)
259
- value[:extent] = page
260
- if page =~ /(\d+)\s*(p|page)/
261
- value[:start_page] = 1
262
- value[:end_page] = $1.dup.to_i
263
- end
264
- height = extent[1].try(:strip)
265
- value[:dimensions] = height
266
- if height =~ /(\d+)\s*cm/
267
- value[:height] = $1.dup.to_i
267
+ def get_mods_extent(doc)
268
+ extent = doc.at('//mods:extent', NS).try(:content)
269
+ value = {start_page: nil, end_page: nil, height: nil}
270
+ if extent
271
+ extent = extent.split(';')
272
+ page = extent[0].try(:strip)
273
+ value[:extent] = page
274
+ if page =~ /(\d+)\s*(p|page)/
275
+ value[:start_page] = 1
276
+ value[:end_page] = $1.dup.to_i
277
+ end
278
+ height = extent[1].try(:strip)
279
+ value[:dimensions] = height
280
+ if height =~ /(\d+)\s*cm/
281
+ value[:height] = $1.dup.to_i
282
+ end
268
283
  end
284
+ value
269
285
  end
270
- value
271
- end
272
286
 
273
- def get_mods_statement_of_responsibility(doc)
274
- note = doc.at('//mods:note[@type="statement of responsibility"]', NS).try(:content)
275
- if note.blank?
276
- note = get_mods_creators(doc).map{|e| e[:full_name] }.join( " ; " )
287
+ def get_mods_statement_of_responsibility(doc)
288
+ note = doc.at('//mods:note[@type="statement of responsibility"]', NS).try(:content)
289
+ if note.blank?
290
+ note = get_mods_creators(doc).map{|e| e[:full_name] }.join(" ; ")
291
+ end
292
+ note
277
293
  end
278
- note
279
- end
280
294
 
281
- def get_mods_note(doc)
282
- notes = []
283
- doc.xpath('//mods:note', NS).each do |note|
284
- type = note.attributes['type'].try(:content)
285
- next if type == "statement of responsibility"
286
- note_s = note.try( :content )
287
- notes << note_s unless note_s.blank?
288
- end
289
- if notes.empty?
290
- nil
291
- else
292
- notes.join( ";\n" )
295
+ def get_mods_note(doc)
296
+ notes = []
297
+ doc.xpath('//mods:note', NS).each do |note|
298
+ type = note.attributes['type'].try(:content)
299
+ next if type == "statement of responsibility"
300
+ note_s = note.try(:content)
301
+ notes << note_s unless note_s.blank?
302
+ end
303
+ if notes.empty?
304
+ nil
305
+ else
306
+ notes.join(";\n")
307
+ end
293
308
  end
294
- end
295
309
 
296
- def get_mods_date_of_publication(doc)
297
- dates = []
298
- doc.xpath('//mods:dateIssued', NS).each do |pub_date|
299
- pub_date = pub_date.content.sub( /\A[cp]/, '' )
300
- next unless pub_date =~ /^\d+(-\d\d?){0,2}$/
301
- date = pub_date.split('-')
302
- if date[0] and date[1]
303
- dates << sprintf("%04d-%02d", date[0], date[1])
304
- else
305
- dates << pub_date
310
+ def get_mods_date_of_publication(doc)
311
+ dates = []
312
+ doc.xpath('//mods:dateIssued', NS).each do |pub_date|
313
+ pub_date = pub_date.content.sub(/\A[cp]/, '')
314
+ next unless pub_date =~ /^\d+(-\d\d?){0,2}$/
315
+ date = pub_date.split('-')
316
+ if date[0] and date[1]
317
+ dates << sprintf("%04d-%02d", date[0], date[1])
318
+ else
319
+ dates << pub_date
320
+ end
306
321
  end
322
+ dates.compact.first
307
323
  end
308
- dates.compact.first
309
- end
310
324
 
311
325
  # derived from marcfrequency: http://www.loc.gov/standards/valuelist/marcfrequency.html
312
- MARCFREQUENCY = [
313
- "Continuously updated",
314
- "Daily",
315
- "Semiweekly",
316
- "Three times a week",
317
- "Weekly",
318
- "Biweekly",
319
- "Three times a month",
320
- "Semimonthly",
321
- "Monthly",
322
- "Bimonthly",
323
- "Quarterly",
324
- "Three times a year",
325
- "Semiannual",
326
- "Annual",
327
- "Biennial",
328
- "Triennial",
329
- "Completely irregular"
330
- ]
331
- def get_mods_frequency(doc)
332
- frequencies = []
333
- doc.xpath('//mods:frequency', NS).each do |freq|
334
- frequency = freq.try(:content)
335
- MARCFREQUENCY.each do |freq_regex|
336
- if /\A(#{freq_regex})/ =~ frequency
337
- frequency_name = freq_regex.downcase.gsub( /\s+/, "_" )
338
- frequencies << Frequency.where( name: frequency_name ).first
326
+ MARCFREQUENCY = [
327
+ "Continuously updated",
328
+ "Daily",
329
+ "Semiweekly",
330
+ "Three times a week",
331
+ "Weekly",
332
+ "Biweekly",
333
+ "Three times a month",
334
+ "Semimonthly",
335
+ "Monthly",
336
+ "Bimonthly",
337
+ "Quarterly",
338
+ "Three times a year",
339
+ "Semiannual",
340
+ "Annual",
341
+ "Biennial",
342
+ "Triennial",
343
+ "Completely irregular"
344
+ ]
345
+ def get_mods_frequency(doc)
346
+ frequencies = []
347
+ doc.xpath('//mods:frequency', NS).each do |freq|
348
+ frequency = freq.try(:content)
349
+ MARCFREQUENCY.each do |freq_regex|
350
+ if /\A(#{freq_regex})/ =~ frequency
351
+ frequency_name = freq_regex.downcase.gsub(/\s+/, "_")
352
+ frequencies << Frequency.find_by(name: frequency_name)
353
+ end
354
+ end
339
355
  end
356
+ frequencies.compact.first
340
357
  end
341
- end
342
- frequencies.compact.first
343
- end
344
358
 
345
- def get_mods_creators(doc)
346
- creators = []
347
- doc.xpath('/mods:mods/mods:name', NS).each do |creator|
348
- creators << {
349
- full_name: creator.xpath('./mods:namePart', NS).collect(&:content).join(", ")
350
- }
351
- end
352
- creators.uniq
353
- end
359
+ def get_mods_creators(doc)
360
+ creators = []
361
+ doc.xpath('/mods:mods/mods:name', NS).each do |creator|
362
+ creators << {
363
+ full_name: creator.xpath('./mods:namePart', NS).collect(&:content).join(", ")
364
+ }
365
+ end
366
+ creators.uniq
367
+ end
354
368
 
355
369
  # TODO:only LCSH-based parsing...
356
- def get_mods_subjects(doc)
357
- subjects = []
358
- doc.xpath('//mods:subject[@authority="lcsh"]', NS).each do |s|
359
- subject = []
360
- s.xpath('./*', NS).each do |subelement|
361
- type = subelement.name
362
- case subelement.name
363
- when "topic", "geographic", "genre", "temporal"
364
- subject << { type: type , term: subelement.try(:content) }
365
- when "titleInfo"
366
- subject << { type: type, term: subelement.at('./mods:title', NS).try(:content) }
367
- when "name"
368
- name = subelement.xpath('./mods:namePart', NS).map{|e| e.try(:content) }.join(", ")
369
- subject << { type: type, term: name }
370
+ def get_mods_subjects(doc)
371
+ subjects = []
372
+ doc.xpath('//mods:subject[@authority="lcsh"]', NS).each do |s|
373
+ subject = []
374
+ s.xpath('./*', NS).each do |subelement|
375
+ type = subelement.name
376
+ case subelement.name
377
+ when "topic", "geographic", "genre", "temporal"
378
+ subject << { type: type , term: subelement.try(:content) }
379
+ when "titleInfo"
380
+ subject << { type: type, term: subelement.at('./mods:title', NS).try(:content) }
381
+ when "name"
382
+ name = subelement.xpath('./mods:namePart', NS).map{|e| e.try(:content) }.join(", ")
383
+ subject << { type: type, term: name }
384
+ end
385
+ end
386
+ next if subject.compact.empty?
387
+ if subject.size > 1 and subject[0][:type] == "name" and subject[1][:type] == "titleInfo"
388
+ subject[0..1] = { term: subject[0..1].map{|e|e[:term]}.join(". ") }
389
+ end
390
+ subjects << {
391
+ term: subject.map{|e|e[:term]}.compact.join("--")
392
+ }
370
393
  end
394
+ subjects
371
395
  end
372
- next if subject.compact.empty?
373
- if subject.size > 1 and subject[0][:type] == "name" and subject[1][:type] == "titleInfo"
374
- subject[0..1] = { term: subject[0..1].map{|e|e[:term]}.join(". ") }
375
- end
376
- subjects << {
377
- term: subject.map{|e|e[:term]}.compact.join("--")
378
- }
379
- end
380
- subjects
381
- end
382
396
 
383
397
  # TODO:support only DDC.
384
- def get_mods_classifications(doc)
385
- classifications = []
386
- doc.xpath('//mods:classification[@authority="ddc"]', NS).each do|c|
387
- ddc = c.content
388
- if ddc
389
- classifications << ddc.split(/[^\d\.]/).first.try(:strip)
398
+ def get_mods_classifications(doc)
399
+ classifications = []
400
+ doc.xpath('//mods:classification[@authority="ddc"]', NS).each do|c|
401
+ ddc = c.content
402
+ if ddc
403
+ classifications << ddc.split(/[^\d\.]/).first.try(:strip)
404
+ end
405
+ end
406
+ classifications.compact
390
407
  end
391
- end
392
- classifications.compact
393
- end
394
408
 
395
- def get_mods_carrier_and_content_types(doc)
396
- carrier_type = content_type = nil
397
- doc.xpath('//mods:form', NS).each do |e|
398
- authority = e.attributes['authority'].try(:content)
399
- case authority
400
- when "gmd"
401
- case e.content
402
- when "electronic resource"
403
- carrier_type = CarrierType.where(name: 'online_resource').first
404
- when "videorecording", "motion picture", "game"
405
- content_type = ContentType.where(name: 'two_dimensional_moving_image').first
406
- when "sound recording"
407
- content_type = ContentType.where(name: 'performed_music').first
408
- when "graphic", "picture"
409
- content_type = ContentType.where(name: 'still_image').first
410
- #TODO: Enju needs more specific mappings...
411
- when "art original",
412
- "microscope slides",
413
- "art reproduction",
414
- "model",
415
- "chart",
416
- "diorama",
417
- "realia",
418
- "filmstrip",
419
- "slide",
420
- "flash card",
421
- "technical drawing",
422
- "toy",
423
- "kit",
424
- "transparency",
425
- "microform"
426
- content_type = ContentType.where(name: 'other').first
427
- end
428
- when "marcsmd" # cf.http://www.loc.gov/standards/valuelist/marcsmd.html
429
- case e.content
430
- when "text", "large print", "regular print", "text in looseleaf binder"
431
- carrier_type = CarrierType.where(name: 'volume').first
432
- content_type = ContentType.where(name: 'text').first
433
- when "braille"
434
- carrier_type = CarrierType.where(name: 'volume').first
435
- content_type = ContentType.where(name: 'tactile_text').first
436
- when "videodisc"
437
- carrier_type = CarrierType.where(name: 'videodisc').first
438
- content_type = ContentType.where(name: 'two_dimensional_moving_image').first
439
- when "videorecording", "videocartridge", "videocassette", "videoreel"
440
- carrier_type = CarrierType.where(name: 'other').first
441
- content_type = ContentType.where(name: 'two_dimensional_moving_image').first
442
- when "electronic resource"
443
- carrier_type = CarrierType.where(name: 'online_resource').first
444
- when "chip cartridge", "computer optical disc cartridge", "magnetic disk", "magneto-optical disc", "optical disc", "remote", "tape cartridge", "tape cassette", "tape reel"
445
- #carrier_type = CarrierType.where(name: 'other').first
446
- when "motion picture", "film cartridge", "film cassette", "film reel"
447
- content_type = ContentType.where(name: 'two_dimensional_moving_image').first
448
- when "sound recording", "cylinder", "roll", "sound cartridge", "sound cassette","sound-tape reel", "sound-track film", "wire recording"
449
- content_type = ContentType.where(name: 'performed_music').first
450
- when "sound disc"
451
- content_type = ContentType.where(name: 'performed_music').first
452
- carrier_type = CarrierType.where(name: 'audio_disc').first
453
- when "nonprojected graphic", "chart", "collage", "drawing", "flash card", "painting", "photomechanical print", "photonegative", "photoprint", "picture", "print", "technical drawing", "projected graphic", "filmslip", "filmstrip cartridge", "filmstrip roll", "other filmstrip type ", "slide", "transparency"
454
- content_type = ContentType.where(name: 'still_image').first
455
- when "tactile material", "braille", "tactile, with no writing system"
456
- content_type = ContentType.where(name: 'tactile_text').first
457
- #TODO: Enju needs more specific mappings...
458
- when "globe",
459
- "celestial globe",
460
- "earth moon globe",
461
- "planetary or lunar globe",
462
- "terrestrial globe",
463
- "map",
464
- "atlas",
465
- "diagram",
466
- "map",
467
- "model",
468
- "profile",
469
- "remote-sensing image",
470
- "section",
471
- "view",
472
- "microform",
473
- "aperture card",
474
- "microfiche",
475
- "microfiche cassette",
476
- "microfilm cartridge",
477
- "microfilm cassette",
478
- "microfilm reel",
479
- "microopaque",
480
- "combination",
481
- "moon"
482
- content_type = ContentType.where(name: 'other').first
483
- end
484
- when "marcform" # cf. http://www.loc.gov/standards/valuelist/marcform.html
409
+ def get_mods_carrier_and_content_types(doc)
410
+ carrier_type = content_type = nil
411
+ doc.xpath('//mods:form', NS).each do |e|
412
+ authority = e.attributes['authority'].try(:content)
413
+ case authority
414
+ when "gmd"
485
415
  case e.content
486
- when "print", "large print"
487
- carrier_type = CarrierType.where(name: 'volume').first
488
- content_type = ContentType.where(name: 'text').first
489
- when "electronic"
490
- carrier_type = CarrierType.where(name: 'online_resource').first
491
- when "braille"
492
- content_type = ContentType.where(name: 'tactile_text').first
416
+ when "electronic resource"
417
+ carrier_type = CarrierType.find_by(name: 'online_resource')
418
+ when "videorecording", "motion picture", "game"
419
+ content_type = ContentType.find_by(name: 'two_dimensional_moving_image')
420
+ when "sound recording"
421
+ content_type = ContentType.find_by(name: 'performed_music')
422
+ when "graphic", "picture"
423
+ content_type = ContentType.find_by(name: 'still_image')
493
424
  #TODO: Enju needs more specific mappings...
494
- when "microfiche", "microfilm"
425
+ when "art original",
426
+ "microscope slides",
427
+ "art reproduction",
428
+ "model",
429
+ "chart",
430
+ "diorama",
431
+ "realia",
432
+ "filmstrip",
433
+ "slide",
434
+ "flash card",
435
+ "technical drawing",
436
+ "toy",
437
+ "kit",
438
+ "transparency",
439
+ "microform"
440
+ content_type = ContentType.find_by(name: 'other')
441
+ end
442
+ when "marcsmd" # cf.http://www.loc.gov/standards/valuelist/marcsmd.html
443
+ case e.content
444
+ when "text", "large print", "regular print", "text in looseleaf binder"
445
+ carrier_type = CarrierType.find_by(name: 'volume')
446
+ content_type = ContentType.find_by(name: 'text')
447
+ when "braille"
448
+ carrier_type = CarrierType.where(name: 'volume').first
449
+ content_type = ContentType.where(name: 'tactile_text').first
450
+ when "videodisc"
451
+ carrier_type = CarrierType.where(name: 'videodisc').first
452
+ content_type = ContentType.where(name: 'two_dimensional_moving_image').first
453
+ when "videorecording", "videocartridge", "videocassette", "videoreel"
454
+ carrier_type = CarrierType.where(name: 'other').first
455
+ content_type = ContentType.where(name: 'two_dimensional_moving_image').first
456
+ when "electronic resource"
457
+ carrier_type = CarrierType.where(name: 'online_resource').first
458
+ when "chip cartridge", "computer optical disc cartridge", "magnetic disk", "magneto-optical disc", "optical disc", "remote", "tape cartridge", "tape cassette", "tape reel"
459
+ #carrier_type = CarrierType.where(name: 'other').first
460
+ when "motion picture", "film cartridge", "film cassette", "film reel"
461
+ content_type = ContentType.where(name: 'two_dimensional_moving_image').first
462
+ when "sound recording", "cylinder", "roll", "sound cartridge", "sound cassette", "sound-tape reel", "sound-track film", "wire recording"
463
+ content_type = ContentType.where(name: 'performed_music').first
464
+ when "sound disc"
465
+ content_type = ContentType.where(name: 'performed_music').first
466
+ carrier_type = CarrierType.where(name: 'audio_disc').first
467
+ when "nonprojected graphic", "chart", "collage", "drawing", "flash card", "painting", "photomechanical print", "photonegative", "photoprint", "picture", "print", "technical drawing", "projected graphic", "filmslip", "filmstrip cartridge", "filmstrip roll", "other filmstrip type ", "slide", "transparency"
468
+ content_type = ContentType.where(name: 'still_image').first
469
+ when "tactile material", "braille", "tactile, with no writing system"
470
+ content_type = ContentType.where(name: 'tactile_text').first
471
+ #TODO: Enju needs more specific mappings...
472
+ when "globe",
473
+ "celestial globe",
474
+ "earth moon globe",
475
+ "planetary or lunar globe",
476
+ "terrestrial globe",
477
+ "map",
478
+ "atlas",
479
+ "diagram",
480
+ "map",
481
+ "model",
482
+ "profile",
483
+ "remote-sensing image",
484
+ "section",
485
+ "view",
486
+ "microform",
487
+ "aperture card",
488
+ "microfiche",
489
+ "microfiche cassette",
490
+ "microfilm cartridge",
491
+ "microfilm cassette",
492
+ "microfilm reel",
493
+ "microopaque",
494
+ "combination",
495
+ "moon"
496
+ content_type = ContentType.where(name: 'other').first
497
+ end
498
+ when "marcform" # cf. http://www.loc.gov/standards/valuelist/marcform.html
499
+ case e.content
500
+ when "print", "large print"
501
+ carrier_type = CarrierType.where(name: 'volume').first
502
+ content_type = ContentType.where(name: 'text').first
503
+ when "electronic"
504
+ carrier_type = CarrierType.where(name: 'online_resource').first
505
+ when "braille"
506
+ content_type = ContentType.where(name: 'tactile_text').first
507
+ #TODO: Enju needs more specific mappings...
508
+ when "microfiche", "microfilm"
509
+ content_type = ContentType.where(name: 'other').first
510
+ end
511
+ end
512
+ end
513
+ doc.xpath('//mods:genre', NS).each do |e|
514
+ authority = e.attributes['authority'].try(:content)
515
+ case authority
516
+ when "rdacontent"
517
+ content_type = ContentType.where(name: e.content.gsub(/\W+/, "_")).first
518
+ content_type = ContentType.where(name: 'other').first unless content_type
519
+ end
520
+ end
521
+ type = doc.at('//mods:typeOfResource', NS).try(:content)
522
+ case type
523
+ when "text"
524
+ content_type = ContentType.where(name: 'text').first
525
+ when "sound recording"
526
+ content_type = ContentType.where(name: 'sounds').first
527
+ when"sound recording-musical"
528
+ content_type = ContentType.where(name: 'performed_music').first
529
+ when"sound recording-nonmusical"
530
+ content_type = ContentType.where(name: 'spoken_word').first
531
+ when "moving image"
532
+ content_type = ContentType.where(name: 'two_dimensional_moving_image').first
533
+ when "software, multimedia"
534
+ content_type = ContentType.where(name: 'other').first
535
+ when "cartographic "
536
+ content_type = ContentType.where(name: 'cartographic_image').first
537
+ when "notated music"
538
+ content_type = ContentType.where(name: 'notated_music').first
539
+ when "still image"
540
+ content_type = ContentType.where(name: 'still_image').first
541
+ when "three dimensional object"
542
+ content_type = ContentType.where(name: 'other').first
543
+ when "mixed material"
495
544
  content_type = ContentType.where(name: 'other').first
496
545
  end
546
+ { carrier_type: carrier_type, content_type: content_type }
497
547
  end
498
- end
499
- doc.xpath('//mods:genre', NS).each do |e|
500
- authority = e.attributes['authority'].try(:content)
501
- case authority
502
- when "rdacontent"
503
- content_type = ContentType.where(name: e.content.gsub(/\W+/, "_")).first
504
- content_type = ContentType.where(name: 'other').first unless content_type
505
- end
506
- end
507
- type = doc.at('//mods:typeOfResource', NS).try(:content)
508
- case type
509
- when "text"
510
- content_type = ContentType.where(name: 'text').first
511
- when "sound recording"
512
- content_type = ContentType.where(name: 'sounds').first
513
- when"sound recording-musical"
514
- content_type = ContentType.where(name: 'performed_music').first
515
- when"sound recording-nonmusical"
516
- content_type = ContentType.where(name: 'spoken_word').first
517
- when "moving image"
518
- content_type = ContentType.where(name: 'two_dimensional_moving_image').first
519
- when "software, multimedia"
520
- content_type = ContentType.where(name: 'other').first
521
- when "cartographic "
522
- content_type = ContentType.where(name: 'cartographic_image').first
523
- when "notated music"
524
- content_type = ContentType.where(name: 'notated_music').first
525
- when "still image"
526
- content_type = ContentType.where(name: 'still_image').first
527
- when "three dimensional object"
528
- content_type = ContentType.where(name: 'other').first
529
- when "mixed material"
530
- content_type = ContentType.where(name: 'other').first
531
- end
532
- { :carrier_type => carrier_type, :content_type => content_type }
533
- end
534
548
  end
535
549
  end
536
550
  end