krikri 0.2.1 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (332) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/krikri/harvesters/oai_harvester.rb~ +10 -0
  3. data/app/models/krikri/original_record_desc.rb~ +6 -0
  4. data/app/models/krikri/original_record_metadata.rb~ +9 -0
  5. data/app/models/krikri/parser.rb~ +5 -0
  6. data/app/models/krikri/parsers/xml_parser.rb~ +5 -0
  7. data/config/initializers/config.rb~ +19 -0
  8. data/config/settings/test.yml~ +3 -0
  9. data/lib/aggregation.rb~ +4 -0
  10. data/lib/blacklight.rb~ +8 -0
  11. data/lib/krikri/engine.rb +29 -2
  12. data/lib/krikri/enrichment.rb~ +5 -0
  13. data/lib/krikri/enrichment_agent.rb~ +11 -0
  14. data/lib/krikri/enrichment_agent_spec.rb~ +2 -0
  15. data/lib/krikri/enrichment_job.rb~ +13 -0
  16. data/lib/krikri/enrichments.rb~ +4 -0
  17. data/lib/krikri/enrichments/capitalize.rb~ +24 -0
  18. data/lib/krikri/enrichments/deduplication.rb~ +10 -0
  19. data/lib/krikri/enrichments/genre_filter.rb~ +9 -0
  20. data/lib/krikri/enrichments/iso_enrcich.rb~ +8 -0
  21. data/lib/krikri/enrichments/iso_enrich.rb~ +13 -0
  22. data/lib/krikri/enrichments/parse_date.rb~ +10 -0
  23. data/lib/krikri/enrichments/strip_html.rb~ +16 -0
  24. data/lib/krikri/enrichments/timespan.rb~ +6 -0
  25. data/lib/krikri/enrichments/timespan_split.rb~ +83 -0
  26. data/lib/krikri/field_enrichment.rb~ +3 -0
  27. data/lib/krikri/harvester.rb +19 -7
  28. data/lib/krikri/harvesters/basic_save_behavior.rb +9 -0
  29. data/lib/krikri/harvesters/basic_save_behavior.rb~ +1 -0
  30. data/lib/krikri/harvesters/harvest_behavior.rb +40 -0
  31. data/lib/krikri/harvesters/harvest_behavior.rb~ +14 -0
  32. data/lib/krikri/harvesters/oai_harvester.rb +110 -12
  33. data/lib/krikri/harvesters/oai_skip_deleted_behavior.rb +20 -0
  34. data/lib/krikri/harvesters/oai_skip_deleted_behavior.rb~ +17 -0
  35. data/lib/krikri/id_minter.rb~ +8 -0
  36. data/lib/krikri/id_service.rb~ +4 -0
  37. data/lib/krikri/index_service.rb +40 -24
  38. data/lib/krikri/ldp/container.rb~ +22 -0
  39. data/lib/krikri/ldp/nr_source.rb~ +4 -0
  40. data/lib/krikri/ldp/rdf_source.rb~ +24 -0
  41. data/lib/krikri/ldp/resource.rb~ +49 -0
  42. data/lib/krikri/mapping_dsl.rb~ +4 -0
  43. data/lib/krikri/mapping_dsl/parser_methods.rb +13 -9
  44. data/lib/krikri/mapping_job.rb~ +13 -0
  45. data/lib/krikri/md5_minter.rb~ +8 -0
  46. data/lib/krikri/parsers/json_parser.rb~ +17 -0
  47. data/lib/krikri/parsers/mods_parser.rb +2 -0
  48. data/lib/krikri/parsers/oai_headers.rb~ +4 -0
  49. data/lib/krikri/parsers/oai_parser.rb~ +2 -0
  50. data/lib/krikri/parsers/oai_parser_headers.rb~ +4 -0
  51. data/lib/krikri/parsers/qdc_parser.rb +2 -0
  52. data/lib/krikri/parsers/xml_parser.rb~ +61 -0
  53. data/lib/krikri/provenance_query.rb~ +4 -0
  54. data/lib/krikri/provenance_query_client.rb~ +11 -0
  55. data/lib/krikri/util/edtf_converter.rb~ +26 -0
  56. data/lib/krikri/util/extended_date_parser.rb~ +70 -0
  57. data/lib/krikri/version.rb +1 -1
  58. data/lib/tasks/jetty.rake +1 -1
  59. data/lib/tasks/jetty.rake~ +12 -0
  60. data/lib/tasks/krikri.rake +13 -10
  61. data/lib/tasks/krikri.rake~ +20 -0
  62. data/spec/factories/krikri_original_record.rb +22 -0
  63. data/spec/factories/krikri_original_record.rb~ +5 -0
  64. data/spec/internal/Gemfile +3 -2
  65. data/spec/internal/Gemfile.lock +39 -41
  66. data/spec/internal/config/initializers/blacklight_initializer.rb +1 -1
  67. data/spec/internal/config/initializers/devise.rb +2 -2
  68. data/spec/internal/config/secrets.yml +2 -2
  69. data/spec/internal/db/development.sqlite3 +0 -0
  70. data/spec/internal/db/migrate/{20150224000601_devise_create_users.rb → 20150305160911_devise_create_users.rb} +0 -0
  71. data/spec/internal/db/migrate/{20150224000620_create_searches.blacklight.rb → 20150305160928_create_searches.blacklight.rb} +0 -0
  72. data/spec/internal/db/migrate/{20150224000621_create_bookmarks.blacklight.rb → 20150305160929_create_bookmarks.blacklight.rb} +0 -0
  73. data/spec/internal/db/migrate/{20150224000622_add_polymorphic_type_to_bookmarks.blacklight.rb → 20150305160930_add_polymorphic_type_to_bookmarks.blacklight.rb} +0 -0
  74. data/spec/internal/db/schema.rb +1 -1
  75. data/spec/internal/db/test.sqlite3 +0 -0
  76. data/spec/internal/lib/generators/test_app_generator.rb~ +14 -0
  77. data/spec/internal/log/development.log +67 -67
  78. data/spec/internal/log/test.log +60918 -3966
  79. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_alerts.scssc +0 -0
  80. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_background-variant.scssc +0 -0
  81. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_border-radius.scssc +0 -0
  82. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_buttons.scssc +0 -0
  83. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_center-block.scssc +0 -0
  84. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_clearfix.scssc +0 -0
  85. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_forms.scssc +0 -0
  86. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_gradients.scssc +0 -0
  87. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_grid-framework.scssc +0 -0
  88. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_grid.scssc +0 -0
  89. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_hide-text.scssc +0 -0
  90. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_image.scssc +0 -0
  91. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_labels.scssc +0 -0
  92. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_list-group.scssc +0 -0
  93. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_nav-divider.scssc +0 -0
  94. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_nav-vertical-align.scssc +0 -0
  95. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_opacity.scssc +0 -0
  96. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_pagination.scssc +0 -0
  97. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_panels.scssc +0 -0
  98. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_progress-bar.scssc +0 -0
  99. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_reset-filter.scssc +0 -0
  100. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_resize.scssc +0 -0
  101. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_responsive-visibility.scssc +0 -0
  102. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_size.scssc +0 -0
  103. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_tab-focus.scssc +0 -0
  104. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_table-row.scssc +0 -0
  105. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_text-emphasis.scssc +0 -0
  106. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_text-overflow.scssc +0 -0
  107. data/spec/internal/tmp/cache/assets/test/sass/{b0e4dc91d58228c3adf15cb753bdeb4e4010a333 → 6150801e42e33a1ef8211bc5bd57210113efb322}/_vendor-prefixes.scssc +0 -0
  108. data/spec/internal/tmp/cache/assets/test/sass/{71fba6bdfa89d88fe8a72b36eafd3b91cf10a6d0 → 93e201cf4a11978a1f491a057a3bd569c3825210}/blacklight.css.scssc +0 -0
  109. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_blacklight_base.scssc +0 -0
  110. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_bookmark.scssc +0 -0
  111. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_catalog.scssc +0 -0
  112. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_facets.scssc +0 -0
  113. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_group.scssc +0 -0
  114. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_header.scssc +0 -0
  115. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_layout.scssc +0 -0
  116. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_modal.scssc +0 -0
  117. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/_search_history.scssc +0 -0
  118. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/blacklight.scssc +0 -0
  119. data/spec/internal/tmp/cache/assets/test/sass/{78e0580c292179fc5fdd7b74b703dad1702b4176 → ca8c12d03785e0d6cd4554f4d3939e7836d38282}/blacklight_defaults.scssc +0 -0
  120. data/spec/internal/tmp/cache/assets/test/sass/{e2a3786e4ebe66d44f7faa2a5c1fde6ac88e9913 → f4c2e42bd47363124f382d6b3accf5b68bede368}/_bootstrap-sprockets.scssc +0 -0
  121. data/spec/internal/tmp/cache/assets/test/sass/{e2a3786e4ebe66d44f7faa2a5c1fde6ac88e9913 → f4c2e42bd47363124f382d6b3accf5b68bede368}/_bootstrap.scssc +0 -0
  122. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_alerts.scssc +0 -0
  123. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_badges.scssc +0 -0
  124. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_breadcrumbs.scssc +0 -0
  125. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_button-groups.scssc +0 -0
  126. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_buttons.scssc +0 -0
  127. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_carousel.scssc +0 -0
  128. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_close.scssc +0 -0
  129. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_code.scssc +0 -0
  130. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_component-animations.scssc +0 -0
  131. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_dropdowns.scssc +0 -0
  132. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_forms.scssc +0 -0
  133. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_glyphicons.scssc +0 -0
  134. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_grid.scssc +0 -0
  135. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_input-groups.scssc +0 -0
  136. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_jumbotron.scssc +0 -0
  137. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_labels.scssc +0 -0
  138. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_list-group.scssc +0 -0
  139. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_media.scssc +0 -0
  140. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_mixins.scssc +0 -0
  141. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_modals.scssc +0 -0
  142. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_navbar.scssc +0 -0
  143. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_navs.scssc +0 -0
  144. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_normalize.scssc +0 -0
  145. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_pager.scssc +0 -0
  146. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_pagination.scssc +0 -0
  147. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_panels.scssc +0 -0
  148. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_popovers.scssc +0 -0
  149. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_print.scssc +0 -0
  150. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_progress-bars.scssc +0 -0
  151. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_responsive-embed.scssc +0 -0
  152. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_responsive-utilities.scssc +0 -0
  153. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_scaffolding.scssc +0 -0
  154. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_tables.scssc +0 -0
  155. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_thumbnails.scssc +0 -0
  156. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_tooltip.scssc +0 -0
  157. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_type.scssc +0 -0
  158. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_utilities.scssc +0 -0
  159. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_variables.scssc +0 -0
  160. data/spec/internal/tmp/cache/assets/test/sass/{86c40011646adf02115c5f9a86cbbbe78771a7f9 → f65d96a170ed1d9ac890c97fabbd2605e6dd83f7}/_wells.scssc +0 -0
  161. data/spec/internal/tmp/cache/assets/test/sprockets/{8ef9e7d38c0b792a85f86f7b5e764d33 → 02bee7ecb2697ab24c566acc29e23717} +0 -0
  162. data/spec/internal/tmp/cache/assets/test/sprockets/03126075e92026e5dd05f2c577bd4730 +0 -0
  163. data/spec/internal/tmp/cache/assets/test/sprockets/04a0815eb41346be1a815741677d9d46 +0 -0
  164. data/spec/internal/tmp/cache/assets/test/sprockets/059eceaa18e2eaee3d5168f3949f4957 +0 -0
  165. data/spec/internal/tmp/cache/assets/test/sprockets/093d898bf3f20b26b13c82714a77c040 +0 -0
  166. data/spec/internal/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  167. data/spec/internal/tmp/cache/assets/test/sprockets/{8c1af1f5b9a42448f4b8ff3dc1c1b81b → 24c91d512c7cc64c22aeb15a7e6cb7a2} +0 -0
  168. data/spec/internal/tmp/cache/assets/test/sprockets/2665fe64198bd4c9fec4c5ab52bea19e +0 -0
  169. data/spec/internal/tmp/cache/assets/test/sprockets/2bea755b15e0adfa7c25ed3d0ede78ae +0 -0
  170. data/spec/internal/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  171. data/spec/internal/tmp/cache/assets/test/sprockets/{4873ea32d49c588483b701fcd571786b → 308dc75487b2e4133c218761921cbba0} +0 -0
  172. data/spec/internal/tmp/cache/assets/test/sprockets/{7f804c48c333d9758fa49ff9331b78e2 → 350a65d446eb7398f96d102f7a1a6d69} +0 -0
  173. data/spec/internal/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  174. data/spec/internal/tmp/cache/assets/test/sprockets/37ad484f356c918e56ba82f60caf9521 +0 -0
  175. data/spec/internal/tmp/cache/assets/test/sprockets/{e451ef2f153fc084065cf4f66d62a912 → 3ca413a5a67acfa5c4adb491faec270e} +0 -0
  176. data/spec/internal/tmp/cache/assets/test/sprockets/{39329b3558b9f58b0d4e43621aeaa8c2 → 3cc20a63495e66e9251101ccfb0d389c} +0 -0
  177. data/spec/internal/tmp/cache/assets/test/sprockets/41b62fb10530766b5b9fef3338f5f30b +0 -0
  178. data/spec/internal/tmp/cache/assets/test/sprockets/421c89c58d3e76046a0294dae1f731ff +0 -0
  179. data/spec/internal/tmp/cache/assets/test/sprockets/43da966542fafc2a4c768be78527391c +0 -0
  180. data/spec/internal/tmp/cache/assets/test/sprockets/496a0d7dce1ff6bf4a9c3a089ea3a635 +0 -0
  181. data/spec/internal/tmp/cache/assets/test/sprockets/{ecb21744c6c865116bfaa342d4cc373d → 4ed1f0897f5818a8af48b809981f38f2} +0 -0
  182. data/spec/internal/tmp/cache/assets/test/sprockets/5d9772b2d3ee4527f6669b3187f91bf2 +0 -0
  183. data/spec/internal/tmp/cache/assets/test/sprockets/{a66ba1ae2ecf53099b8c240249aaccaa → 6ca71451ade728977ed02cea06e07914} +0 -0
  184. data/spec/internal/tmp/cache/assets/test/sprockets/6df5b5c0a8e6d87ced9504a460df875e +0 -0
  185. data/spec/internal/tmp/cache/assets/test/sprockets/6eefd2765a716d66ff857cfcda69a119 +0 -0
  186. data/spec/internal/tmp/cache/assets/test/sprockets/{c19459bc1eff0b0133093c0473f47c04 → 75da31aa64ac2526ffbe396852663999} +0 -0
  187. data/spec/internal/tmp/cache/assets/test/sprockets/{cb74a43b2a6abc262abfed639df77470 → 7a841c591675a2dafb8b859ca4014f1c} +0 -0
  188. data/spec/internal/tmp/cache/assets/test/sprockets/{853ad370adfaa0da7ec26f51b89421f1 → 813e23719129cf9f19349f720bebdf70} +0 -0
  189. data/spec/internal/tmp/cache/assets/test/sprockets/8297d7100b7c4e6115a7e6408f2fced5 +0 -0
  190. data/spec/internal/tmp/cache/assets/test/sprockets/86b7795bee54d7ffa2ff30e867aff344 +0 -0
  191. data/spec/internal/tmp/cache/assets/test/sprockets/88ded10f28177bec1bddb0d72d6b1cd2 +0 -0
  192. data/spec/internal/tmp/cache/assets/test/sprockets/{93c6b8da8f3373c42510a25694457483 → 8ad5c3dc0f5fcc5d7a775d6294dda9f5} +0 -0
  193. data/spec/internal/tmp/cache/assets/test/sprockets/93aaa9231a32901266b05632f3d35ecd +0 -0
  194. data/spec/internal/tmp/cache/assets/test/sprockets/{4a9e62d054a09c7c8e486f73bd032bdc → 9f68eb44ffcb9dd95623c179300414fd} +0 -0
  195. data/spec/internal/tmp/cache/assets/test/sprockets/{11b7eeb5da37de1c315d886349adbc98 → ab2a05b91d7d316d4ceb47ce067006fb} +0 -0
  196. data/spec/internal/tmp/cache/assets/test/sprockets/ad4a54c43c2a4c3874bfde1c9f08c248 +0 -0
  197. data/spec/internal/tmp/cache/assets/test/sprockets/b0423ae95a661f086b7766d7573885f9 +0 -0
  198. data/spec/internal/tmp/cache/assets/test/sprockets/{f7a87683461c3a58ee9b6e9546473c4e → b1a42de74c934edd0e5eed0f98a23597} +0 -0
  199. data/spec/internal/tmp/cache/assets/test/sprockets/b1c03c36188b4f58f819510adb9a7e9c +0 -0
  200. data/spec/internal/tmp/cache/assets/test/sprockets/{cd59839c2fc0d494ffa76ef4c4dbfa42 → b225d67626669cb154cbe08a3c439d48} +0 -0
  201. data/spec/internal/tmp/cache/assets/test/sprockets/b42c247628daaf44109584724682a6ad +0 -0
  202. data/spec/internal/tmp/cache/assets/test/sprockets/{92c82efebbff4c3a9f96e08b308e92dd → b660ec1ede271559cfd0259eed96ae9c} +0 -0
  203. data/spec/internal/tmp/cache/assets/test/sprockets/bb1a549778011fb037836e1fa6a80ba6 +0 -0
  204. data/spec/internal/tmp/cache/assets/test/sprockets/be8a6d8dc481c07c86bdf541e15c4634 +0 -0
  205. data/spec/internal/tmp/cache/assets/test/sprockets/{6b20592285155ef367334915b33781ea → c5b703cc22fc68aa8cf29fb7af16cf71} +0 -0
  206. data/spec/internal/tmp/cache/assets/test/sprockets/c644ecad928e076f999e9c9a3bc350c9 +0 -0
  207. data/spec/internal/tmp/cache/assets/test/sprockets/c78dd20a0df27e9394a413bf2e4abf92 +0 -0
  208. data/spec/internal/tmp/cache/assets/test/sprockets/{59b1fd64c6fc18a82465ad6fdc7094fa → c9efce42580b0ad0374a052aa61f2a07} +0 -0
  209. data/spec/internal/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  210. data/spec/internal/tmp/cache/assets/test/sprockets/{47defd1245e87ed8558af57fa5f03bef → d0862d2af3fe93a869e9ecfdb9d89e23} +0 -0
  211. data/spec/internal/tmp/cache/assets/test/sprockets/d24a7c4b8ac71a90e809881a64970898 +0 -0
  212. data/spec/internal/tmp/cache/assets/test/sprockets/d5415d1f2b4a2672355dd988eb332d0b +0 -0
  213. data/spec/internal/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  214. data/spec/internal/tmp/cache/assets/test/sprockets/dbba4bbc32c17ade3d618c5d0baeb371 +0 -0
  215. data/spec/internal/tmp/cache/assets/test/sprockets/dfdda7a36a1428f72947384938d105a2 +0 -0
  216. data/spec/internal/tmp/cache/assets/test/sprockets/e40f087f7b8b59f85a4811f715e5e35a +0 -0
  217. data/spec/internal/tmp/cache/assets/test/sprockets/e8276b98892dcac8285a592bb63fe75b +0 -0
  218. data/spec/internal/tmp/cache/assets/test/sprockets/{d7bf17ad1471147b5314b4dda0bad9fe → ecfc314951b349e27742c1b26880619e} +0 -0
  219. data/spec/internal/tmp/cache/assets/test/sprockets/eddae0741d973a8ab3df27c1ea5b635e +0 -0
  220. data/spec/internal/tmp/cache/assets/test/sprockets/{53329c49c9b4ba25d31c73c9b98260b0 → f3935581a84aba9a499005ed6a8e18be} +0 -0
  221. data/spec/internal/tmp/cache/assets/test/sprockets/{82dd05a187bccd30f62fabb16491fe03 → f3e7729c53b8a2c408086a61b58922ae} +0 -0
  222. data/spec/internal/tmp/cache/assets/test/sprockets/f45dfdb34e84d3c72a3319399a7316a3 +0 -0
  223. data/spec/internal/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  224. data/spec/internal/tmp/cache/assets/test/sprockets/{8ea9ff17090b736331312d04c8036810 → fa11f1beb15b0f04503ce1f06701a8bf} +0 -0
  225. data/spec/internal/tmp/cache/assets/test/sprockets/faac2909046aa87e1f1f08b2bf0ad2b2 +0 -0
  226. data/spec/internal/tmp/cache/assets/test/sprockets/faef697283f2f0627727a5f856242651 +0 -0
  227. data/spec/krikri_spec.rb +15 -0
  228. data/spec/krikri_spec.rb~ +30 -0
  229. data/spec/ldp/active_triples_spec.rb~ +15 -0
  230. data/spec/ldp/at_resource_spec.rb~ +41 -0
  231. data/spec/ldp/nr_source_spec.rb~ +3 -0
  232. data/spec/ldp/rdf_source_spec.rb~ +4 -0
  233. data/spec/ldp/resource_spec.rb~ +49 -0
  234. data/spec/lib/krikri/enrichment_agent_spec.rb~ +4 -0
  235. data/spec/lib/krikri/enrichments/capitalize_spec.rb~ +24 -0
  236. data/spec/lib/krikri/enrichments/deduplication_spec.rb~ +5 -0
  237. data/spec/lib/krikri/enrichments/genre_filter_spec.rb~ +19 -0
  238. data/spec/lib/krikri/enrichments/iso_enrich_spec.rb~ +5 -0
  239. data/spec/lib/krikri/enrichments/parse_date_spec.rb~ +16 -0
  240. data/spec/lib/krikri/enrichments/timespan_spec.rb~ +10 -0
  241. data/spec/lib/krikri/enrichments/timespan_split_spec.rb~ +59 -0
  242. data/spec/lib/krikri/harvester_spec.rb +38 -2
  243. data/spec/lib/krikri/harvesters/basic_save_behavior_spec.rb +16 -0
  244. data/spec/lib/krikri/harvesters/basic_save_behavior_spec.rb~ +12 -0
  245. data/spec/lib/krikri/harvesters/harvest_behavior_spec.rb +5 -0
  246. data/spec/lib/krikri/harvesters/harvest_behavior_spec.rb~ +5 -0
  247. data/spec/lib/krikri/harvesters/oai_harvester_spec.rb +170 -2
  248. data/spec/lib/krikri/harvesters/oai_skip_deleted_behavior.rb~ +7 -0
  249. data/spec/lib/krikri/harvesters/oai_skip_deleted_behavior_spec.rb +25 -0
  250. data/spec/lib/krikri/harvesters/oai_skip_deleted_behavior_spec.rb~ +15 -0
  251. data/spec/lib/krikri/id_service_spec.rb~ +3 -0
  252. data/spec/lib/krikri/index_service_spec.rb +25 -14
  253. data/spec/lib/krikri/job_spec.rb~ +13 -0
  254. data/spec/lib/krikri/mapper_agent_spec.rb~ +64 -0
  255. data/spec/lib/krikri/mapper_spec.rb +12 -0
  256. data/spec/lib/krikri/mapper_spec.rb~ +5 -0
  257. data/spec/lib/krikri/mapping_dsl/parser_methods_spec.rb +38 -14
  258. data/spec/lib/krikri/mapping_dsl/parser_methods_spec.rb~ +65 -0
  259. data/spec/lib/krikri/mapping_dsl/property_declaration_spec.rb~ +87 -0
  260. data/spec/lib/krikri/mapping_dsl/rdf_subjects_spec.rb~ +16 -0
  261. data/spec/lib/krikri/mapping_dsl_spec.rb~ +10 -0
  262. data/spec/lib/krikri/mapping_job.rb~ +12 -0
  263. data/spec/lib/krikri/mapping_job_spec.rb~ +11 -0
  264. data/spec/lib/krikri/mapping_spec.rb~ +5 -0
  265. data/spec/lib/krikri/md5_minter_spec.rb~ +5 -0
  266. data/spec/lib/krikri/parser_value_array.rb~ +5 -0
  267. data/spec/lib/krikri/parsers/json_parser_spec.rb~ +17 -0
  268. data/spec/lib/krikri/parsers/mods_parser_spec.rb +1 -0
  269. data/spec/lib/krikri/parsers/qdc_parser_spec.rb +1 -0
  270. data/spec/lib/krikri/parsers/xml_parser_spec.rb~ +21 -0
  271. data/spec/lib/krikri/provenance_query_client.rb~ +5 -0
  272. data/spec/lib/krikri/provenance_query_client_spec.rb~ +8 -0
  273. data/spec/lib/krikri/util/edtf_converter_spec.rb~ +17 -0
  274. data/spec/lib/krikri/util/extended_date_parser_spec.rb~ +102 -0
  275. data/spec/models/activity_spec.rb~ +41 -0
  276. data/spec/models/dpla/map/aggregation_spec.rb~ +67 -0
  277. data/spec/models/harvesters/oai_harvester_spec.rb~ +15 -0
  278. data/spec/models/mapper_spec.rb~ +5 -0
  279. data/spec/models/original_record_metadata_spec.rb~ +5 -0
  280. data/spec/models/original_record_spec.rb~ +5 -0
  281. data/spec/support/shared_contexts/mapping_dsl.rb~ +12 -0
  282. data/spec/support/shared_contexts/provenance_query_client.rb~ +6 -0
  283. data/spec/support/shared_examples/enrichment.rb~ +5 -0
  284. data/spec/support/shared_examples/harvest_behavior.rb +21 -0
  285. data/spec/support/shared_examples/harvest_behavior.rb~ +13 -0
  286. data/spec/support/shared_examples/harvester.rb +5 -3
  287. data/spec/support/shared_examples/job.rb~ +20 -0
  288. data/spec/support/shared_examples/ldp_resource.rb~ +4 -0
  289. data/spec/support/shared_examples/oai_parser_headers.rb~ +12 -0
  290. data/spec/support/shared_examples/rdf_source.rb~ +1 -0
  291. data/spec/support/shared_examples/software_agent.rb~ +5 -0
  292. data/spec/support/shared_examples/string_enrichment.rb~ +12 -0
  293. data/spec/test_app_templates/lib/generators/test_app_generator.rb~ +14 -0
  294. data/spec/webmocks/oai.rb~ +13 -0
  295. metadata +566 -400
  296. data/spec/dummy/db/development.sqlite3 +0 -0
  297. data/spec/dummy/db/test.sqlite3 +0 -0
  298. data/spec/dummy/log/development.log +0 -207
  299. data/spec/internal/tmp/cache/assets/test/sprockets/0b3850cd2568d76d8583e8e6bffa44d9 +0 -0
  300. data/spec/internal/tmp/cache/assets/test/sprockets/0dffbe192bade10cf2b568c73695e96e +0 -0
  301. data/spec/internal/tmp/cache/assets/test/sprockets/12fe6051fca3506bae2d3a3452d89b8a +0 -0
  302. data/spec/internal/tmp/cache/assets/test/sprockets/16648e86ab6ef2950f3630ff0d566409 +0 -0
  303. data/spec/internal/tmp/cache/assets/test/sprockets/1877c8233ee501d08788d7324a70bd70 +0 -0
  304. data/spec/internal/tmp/cache/assets/test/sprockets/2338a6f943deb78d21f2acca84ab4f2b +0 -0
  305. data/spec/internal/tmp/cache/assets/test/sprockets/2c58fb6a2406edc8067b46ee33af7262 +0 -0
  306. data/spec/internal/tmp/cache/assets/test/sprockets/2d0220441d85355dcd9ade523f95c048 +0 -0
  307. data/spec/internal/tmp/cache/assets/test/sprockets/339e294297aa1a0070e702f9b1d6a138 +0 -0
  308. data/spec/internal/tmp/cache/assets/test/sprockets/39ed74e4d194593ec48c481d0fd76007 +0 -0
  309. data/spec/internal/tmp/cache/assets/test/sprockets/3cdc19003f073eb3b9f3a080ffdcba4b +0 -0
  310. data/spec/internal/tmp/cache/assets/test/sprockets/40271adcb3c4654dcb20b55abc2505c9 +0 -0
  311. data/spec/internal/tmp/cache/assets/test/sprockets/43f0a87eb2c9be2e37129f0a869756fa +0 -0
  312. data/spec/internal/tmp/cache/assets/test/sprockets/46ec3d34d3576e4452b0a95b87176996 +0 -0
  313. data/spec/internal/tmp/cache/assets/test/sprockets/52ce034583a746333fd7b8aa3916b8e1 +0 -0
  314. data/spec/internal/tmp/cache/assets/test/sprockets/677fd27eda24da657f51d725742582f3 +0 -0
  315. data/spec/internal/tmp/cache/assets/test/sprockets/735621cd88de5e37980cced4fb13ded9 +0 -0
  316. data/spec/internal/tmp/cache/assets/test/sprockets/7de1f4ba8418fc9219f44e125c429b39 +0 -0
  317. data/spec/internal/tmp/cache/assets/test/sprockets/7e4f29f7a7327f10677cd047be78cf8a +0 -0
  318. data/spec/internal/tmp/cache/assets/test/sprockets/806c560c2f6e89ba0ad39561804ff79c +0 -0
  319. data/spec/internal/tmp/cache/assets/test/sprockets/9443255223294f7ad9ad6daba446afc3 +0 -0
  320. data/spec/internal/tmp/cache/assets/test/sprockets/9aae694d5c7713a4666814ecfd04bc8e +0 -0
  321. data/spec/internal/tmp/cache/assets/test/sprockets/9ca9885875e2e0ab4e531cba60aa03e5 +0 -0
  322. data/spec/internal/tmp/cache/assets/test/sprockets/9e91dee79db70af8ab4149b9698a12a5 +0 -0
  323. data/spec/internal/tmp/cache/assets/test/sprockets/a13d3a27038cf6570d22b54c54442642 +0 -0
  324. data/spec/internal/tmp/cache/assets/test/sprockets/a62c05e92bbbd1d49540b17c1a17982f +0 -0
  325. data/spec/internal/tmp/cache/assets/test/sprockets/acc90134230a954a6983332d94303e66 +0 -0
  326. data/spec/internal/tmp/cache/assets/test/sprockets/b2b550f46801c5fb416302ef0737a62d +0 -0
  327. data/spec/internal/tmp/cache/assets/test/sprockets/b37776526b5809e55fbb0add6d059127 +0 -0
  328. data/spec/internal/tmp/cache/assets/test/sprockets/b7136d57967d58d8247f9168a681ce01 +0 -0
  329. data/spec/internal/tmp/cache/assets/test/sprockets/d6995317fba3b6344c75db70b8c997e2 +0 -0
  330. data/spec/internal/tmp/cache/assets/test/sprockets/e3f7abb4568acd320b05e7765b31412f +0 -0
  331. data/spec/internal/tmp/cache/assets/test/sprockets/e802e3ce42ea0c2e35ccfd33f3b8caad +0 -0
  332. data/spec/internal/tmp/cache/assets/test/sprockets/ef1d076b51c3ce03aa1e754fb8f0457e +0 -0
@@ -0,0 +1,9 @@
1
+ module Krikri::Harvesters
2
+ ##
3
+ # Harvest behavior that call a simple save on a record
4
+ class BasicSaveBehavior < HarvestBehavior
5
+ def process_record
6
+ record.save(activity_uri)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ module Krikri
@@ -0,0 +1,40 @@
1
+ module Krikri::Harvesters
2
+ ##
3
+ # Defines an interface for handling records during the harvest process.
4
+ # Subclasses specify behavior by implementing `#process_record`.
5
+ #
6
+ # Behaviors should be implemented idempotently so they can be safely
7
+ # retried on errors.
8
+ #
9
+ # @example
10
+ # behavior = MyHarvestBehavior.new(record, activity_uri)
11
+ # behavior.process_record
12
+ #
13
+ # @example
14
+ # MyHarvestBehavior.process_record(record, activity_uri)
15
+ #
16
+ # @see Krirki::Harvester#run
17
+ class HarvestBehavior
18
+ # @!attribute activity_uri [r]
19
+ # a URI identifying the activity responsible for invoking the behavior
20
+ # @!attribute record [r]
21
+ # the record to process with this behavior
22
+ attr_reader :activity_uri, :record
23
+
24
+ def initialize(record, activity_uri)
25
+ @record = record
26
+ @activity_uri = activity_uri
27
+ end
28
+
29
+ ##
30
+ # Creates a new instance of this behavior with the given arguments
31
+ # and calls `#process_record`.
32
+ #
33
+ # @param activity_uri
34
+ # @param record
35
+ # @see self#record, self#activity_uri for parameter usage
36
+ def self.process_record(record, activity_uri)
37
+ new(record, activity_uri).process_record
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,14 @@
1
+ module Krikri::Harvesters
2
+ class HarvestBehavior
3
+ attr_reader :activity_uri, :record
4
+
5
+ def initialize(record, activity_uri)
6
+ @record = record
7
+ @activity_uri = activity_uri
8
+ end
9
+
10
+ def self.process_record(record, activity_uri)
11
+ new(record, activity_uri).process_record
12
+ end
13
+ end
14
+ end
@@ -1,6 +1,29 @@
1
1
  module Krikri::Harvesters
2
2
  ##
3
3
  # A harvester implementation for OAI-PMH
4
+ #
5
+ # Accepts options to pass to OAI client as `:oai => opts`
6
+ #
7
+ # @example
8
+ #
9
+ # OAIHarvester.new(:uri => endpoint,
10
+ # :oai => { :set => 'my_set', :metadata_prefix => 'oai_dc' }
11
+ #
12
+ # Options allowed are:
13
+ #
14
+ # - set: A string or array of strings specifying the sets to harvest.
15
+ # If multiple sets are given, they will be lazily requested from
16
+ # `OAI::Client#list_records` in turn and combined into a single
17
+ # enumerator.
18
+ # - skip_set: A string or array of strings specifying the sets to skip.
19
+ # If both `set` and `skip_set` are given, sets specified as
20
+ # skip are excluded from the harvest. Otherwise, all sets
21
+ # returned by `#set` except those skipped will be harvested.
22
+ # - metadata_prefix: A string specifying the metadata prefix. e.g. 'oai_dc'.
23
+ # - from: The begin date for the harvest.
24
+ # - until: The end date for the harvest.
25
+ #
26
+ # @see http://www.rubydoc.info/gems/oai/OAI/Client
4
27
  class OAIHarvester
5
28
  include Krikri::Harvester
6
29
  attr_accessor :client
@@ -12,6 +35,7 @@ module Krikri::Harvesters
12
35
  # @see OAI::Client
13
36
  # @see #expected_opts
14
37
  def initialize(opts = {})
38
+ opts[:harvest_behavior] ||= OAISkipDeletedBehavior
15
39
  super
16
40
  @opts = opts.fetch(:oai, {})
17
41
 
@@ -32,9 +56,13 @@ module Krikri::Harvesters
32
56
  #
33
57
  # record_ids.take(1000)
34
58
  #
59
+ # @param opts [Hash] opts to pass to OAI::Client
60
+ # @see #expected_opts
35
61
  def record_ids(opts = {})
36
- opts = opts.merge(@opts)
37
- client.list_identifiers(opts).full.lazy.flat_map(&:identifier)
62
+ opts = @opts.merge(opts)
63
+ request_with_sets(opts) do |set_opts|
64
+ client.list_identifiers(set_opts).full.lazy.flat_map(&:identifier)
65
+ end
38
66
  end
39
67
 
40
68
  # Count on record_ids will request all ids and load them into memory
@@ -51,38 +79,106 @@ module Krikri::Harvesters
51
79
  #
52
80
  # records.take(1000)
53
81
  #
82
+ # @param opts [Hash] opts to pass to OAI::Client
83
+ # @see #expected_opts
54
84
  def records(opts = {})
55
- opts = opts.merge(@opts)
56
- client.list_records(opts).full.lazy.flat_map do |rec|
57
- @record_class.build(mint_id(rec.header.identifier),
58
- record_xml(rec))
59
-
85
+ opts = @opts.merge(opts)
86
+ request_with_sets(opts) do |set_opts|
87
+ client.list_records(set_opts).full.lazy.flat_map do |rec|
88
+ @record_class.build(mint_id(rec.header.identifier),
89
+ record_xml(rec))
90
+ end
60
91
  end
61
92
  end
62
93
 
63
- # TODO: normalize records; there will be differences in XML
64
- # for different requests
94
+ ##
95
+ # Gets a single record with the given identifier from the OAI endpoint
96
+ #
97
+ # @param identifier [#to_s] the identifier of the record to get
98
+ # @param opts [Hash] options to pass to the OAI client
65
99
  def get_record(identifier, opts = {})
66
100
  opts[:identifier] = identifier
67
- opts = opts.merge(@opts)
101
+ opts = @opts.merge(opts)
68
102
  @record_class.build(mint_id(identifier),
69
103
  record_xml(client.get_record(opts).record))
70
104
  end
71
105
 
72
106
  ##
107
+ # Lists the sets available from the OAI endpoint. Accepts a block to
108
+ # pass to `#map` on the resulting array.
109
+ #
110
+ # @example:
111
+ #
112
+ # sets(&:spec)
113
+ #
114
+ # @param opts [Hash] options to pass to the OAI client
115
+ # @return [Array<OAI::Set>] an array of sets.
116
+ #
117
+ # @see OAI::Set
118
+ def sets(opts = {}, &block)
119
+ arry = client.list_sets.full.to_a
120
+ return arry unless block_given?
121
+ arry.map(&block)
122
+ end
123
+
124
+ ##
125
+ # @return [Hash] A hash documenting the allowable options to pass to
126
+ # initializers.
127
+ #
73
128
  # @see Krikri::Harvester::expected_opts
74
129
  def self.expected_opts
75
130
  {
76
131
  key: :oai,
77
132
  opts: {
78
133
  set: {type: :string, required: false, multiple_ok: true},
79
- metadata_prefix: {type: :string, required: true}
134
+ skip_set: {type: :string, required: false, multiple_ok: true},
135
+ metadata_prefix: {type: :string, required: false},
136
+ from: {type: :string, required: false},
137
+ until: {type: :string, required: false}
80
138
  }
81
139
  }
82
140
  end
83
141
 
142
+ ##
143
+ # Concatinates two enumerators
144
+ # @todo find a better home for this. Reopen Enumerable? or use the
145
+ # `Enumerating` gem: https://github.com/mdub/enumerating
146
+ def concat_enum(*enums)
147
+ Enumerator.new do |yielder|
148
+ enums.each do |enum|
149
+ enum.each { |i| yielder << i }
150
+ end
151
+ end
152
+ end
153
+
84
154
  private
85
155
 
156
+ ##
157
+ # Runs the request in the given block against the sets specified in `opts`.
158
+ # Results are concatenated into a single enumerator
159
+ def request_with_sets(opts, &block)
160
+ sets = Array(opts.delete(:set))
161
+ if opts[:skip_set]
162
+ sets = self.sets(&:spec) if sets.empty?
163
+ skips = Array(opts.delete(:skip_set))
164
+ sets.reject! { |s| skips.include? s }
165
+ end
166
+ sets = [nil] if sets.empty?
167
+
168
+ set_enums = sets.map do |set|
169
+ set_opts = opts.dup
170
+ set_opts[:set] = set unless set.nil?
171
+ yield(set_opts) if block_given?
172
+ end
173
+ concat_enum(*set_enums).lazy
174
+ end
175
+
176
+ ##
177
+ # Transforms an OAI::Record to xml suitable for saving with the
178
+ # OriginalRecord
179
+ #
180
+ # @param rec [OAI::Record]
181
+ # @return [String] an xml string
86
182
  def record_xml(rec)
87
183
  doc = Nokogiri::XML::Builder.new do |xml|
88
184
  xml.record('xmlns' => 'http://www.openarchives.org/OAI/2.0/') {
@@ -93,10 +189,12 @@ module Krikri::Harvesters
93
189
  xml.set_spec set.text
94
190
  end
95
191
  }
96
- xml << rec.metadata.to_s
192
+ xml << rec.metadata.to_s unless rec.metadata.nil?
97
193
  xml << rec.about.to_s unless rec.about.nil?
98
194
  }
99
195
  end
196
+ doc.doc.at_css('header')['status'] = rec.header.status if
197
+ rec.header.status
100
198
  doc.to_xml
101
199
  end
102
200
  end
@@ -0,0 +1,20 @@
1
+ module Krikri::Harvesters
2
+ ##
3
+ # Harvest behavior that skips OAI records marked as deleted
4
+ class OAISkipDeletedBehavior < BasicSaveBehavior
5
+ def process_record
6
+ return if deleted?(record)
7
+ super
8
+ end
9
+
10
+ private
11
+
12
+ def deleted?(record)
13
+ header = Nokogiri::XML(record.content).xpath('//xmlns:header')
14
+ return false if header.empty?
15
+ status = header.first['status']
16
+ return true if status.to_s.downcase.include? 'deleted'
17
+ false
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module Krikri::Harvesters
2
+ ##
3
+ # Harvest behavior that skips OAI records marked as deleted
4
+ class OAISkipDeletedBehavior < BasicSaveBehavior
5
+ def process_record
6
+ return if deleted?(record)
7
+ super
8
+ end
9
+
10
+ private
11
+
12
+ def deleted?(record)
13
+ require 'pry'
14
+ binding.pry
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ module Krikri
2
+ class IdMinter
3
+ class << self
4
+ def mint
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Krikri
2
+ module IdService
3
+ end
4
+ end
@@ -4,8 +4,25 @@ require 'rsolr'
4
4
  module Krikri
5
5
  ##
6
6
  # Generates flattened Solr documents and manages indexing of DPLA MAP models.
7
+ #
8
+ # @example
9
+ #
10
+ # indexer = Krikri::IndexService.new
11
+ # agg = Krikri::Aggregation.new
12
+ # json_doc = agg.to_jsonld['@graph'].first.to_json
13
+ #
14
+ # indexer.add(json_doc)
15
+ # indexer.commit
16
+ #
7
17
  class IndexService
8
- @solr = RSolr.connect
18
+ attr_reader :solr
19
+
20
+ ##
21
+ # @param opts [Hash] options to pass to RSolr
22
+ # @see RSolr.connect
23
+ def initialize(opts = Krikri::Settings.solr.to_h)
24
+ @solr = RSolr.connect(opts)
25
+ end
9
26
 
10
27
  # TODO: Assure that the following metacharacters are escaped:
11
28
  # + - && || ! ( ) { } [ ] ^ " ~ * ? : \
@@ -13,22 +30,22 @@ module Krikri
13
30
  ##
14
31
  # Adds a single JSON document to Solr
15
32
  # @param JSON
16
- def self.add(doc)
17
- @solr.add solr_doc(doc)
33
+ def add(doc)
34
+ solr.add solr_doc(doc)
18
35
  end
19
36
 
20
37
  ##
21
38
  # Deletes an item from Solr
22
39
  # @param String or Array
23
- def self.delete_by_id(id)
24
- @solr.delete_by_id id
40
+ def delete_by_id(id)
41
+ solr.delete_by_id id
25
42
  end
26
43
 
27
44
  ##
28
45
  # Deletes items from Solr that match query
29
46
  # @param String or Array
30
- def self.delete_by_query(query)
31
- @solr.delete_by_query query
47
+ def delete_by_query(query)
48
+ solr.delete_by_query query
32
49
  end
33
50
 
34
51
  ##
@@ -36,32 +53,23 @@ module Krikri
36
53
  # Should be run after self.add and self.delete
37
54
  # Okay to add or delete multiple docs and commit them all with
38
55
  # a single self.commit
39
- def self.commit
40
- @solr.commit
56
+ def commit
57
+ solr.commit
41
58
  end
42
59
 
43
60
  ##
44
61
  # Converts JSON document into a Hash that complies with Solr schema
45
62
  # @param [JSON]
46
63
  # @return [Hash]
47
- def self.solr_doc(doc)
64
+ def solr_doc(doc)
48
65
  remove_invalid_keys(flat_hash(JSON.parse(doc)))
49
66
  end
50
67
 
51
- ##
52
- # Remove keys (ie. fields) that are not in the Solr schema.
53
- # @param [Hash]
54
- # @return [Hash]
55
- def self.remove_invalid_keys(solr_doc)
56
- valid_keys = schema_keys
57
- solr_doc.delete_if { |key, _| !key.in? valid_keys }
58
- end
59
-
60
68
  ##
61
69
  # Get field names from Solr schema in host application.
62
70
  # Will raise exception if file not found.
63
71
  # @return [Array]
64
- def self.schema_keys
72
+ def schema_keys
65
73
  schema_file = File.join(Rails.root, 'solr_conf', 'schema.xml')
66
74
  file = File.open(schema_file)
67
75
  doc = Nokogiri::XML(file)
@@ -69,13 +77,15 @@ module Krikri
69
77
  doc.xpath('//fields/field').map { |f| f.attr('name') }
70
78
  end
71
79
 
80
+ private
81
+
72
82
  ##
73
83
  # Flattens a nested hash
74
84
  # Joins keys with "_" and removes "@" symbols
75
85
  # Example:
76
86
  # flat_hash( {"a"=>"1", "b"=>{"c"=>"2", "d"=>"3"} )
77
87
  # => {"a"=>"1", "b_c"=>"2", "b_d"=>"3"}
78
- def self.flat_hash(hash, keys = [])
88
+ def flat_hash(hash, keys = [])
79
89
  new_hash = {}
80
90
 
81
91
  hash.each do |key, val|
@@ -99,14 +109,20 @@ module Krikri
99
109
  # @param Array
100
110
  #
101
111
  # TODO: Revisit this to make it more generalizable
102
- def self.format_key(keys)
112
+ def format_key(keys)
103
113
  keys.join('_')
104
114
  .gsub('@', '')
105
115
  .gsub('http://www.geonames.org/ontology#', '')
106
116
  .gsub('http://www.w3.org/2003/01/geo/wgs84_pos#', '')
107
117
  end
108
118
 
109
- private_class_method(:solr_doc, :remove_invalid_keys, :flat_hash,
110
- :format_key)
119
+ ##
120
+ # Remove keys (ie. fields) that are not in the Solr schema.
121
+ # @param [Hash]
122
+ # @return [Hash]
123
+ def remove_invalid_keys(solr_doc)
124
+ valid_keys = schema_keys
125
+ solr_doc.delete_if { |key, _| !key.in? valid_keys }
126
+ end
111
127
  end
112
128
  end
@@ -0,0 +1,22 @@
1
+ module Krikri::LDP
2
+ class Container < ActiveTriples::Resource
3
+ include Krikri::LDP::Resource
4
+
5
+ configure :type => RDF::URI('http://www.w3.org/ns/ldp#Container')
6
+
7
+ def initialize(uri, slug)
8
+ @ldp_uri = uri
9
+ @container_slug = slug
10
+ super("#{uri}/#{slug}")
11
+ end
12
+
13
+ def save(body = nil, opts = {})
14
+ opts[:Link] = "<#{type.first.to_s}>; rel='type'"
15
+ opts[:Slug] = @container_slug
16
+ opts[:method] = :post unless exists?
17
+ body ||= (dump :ttl)
18
+ opts['Content-Type'] ||= 'text/turtle'
19
+ super(body, opts)
20
+ end
21
+ end
22
+ end