curation_concerns 0.12.0.pre1 → 0.12.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +24 -16
  3. data/Gemfile +0 -4
  4. data/README.md +14 -0
  5. data/RELEASING.md +2 -2
  6. data/Rakefile +2 -0
  7. data/app/actors/concerns/curation_concerns/manages_embargoes_actor.rb +28 -0
  8. data/app/actors/curation_concerns/abstract_actor.rb +28 -0
  9. data/app/actors/curation_concerns/add_to_collection_actor.rb +38 -0
  10. data/app/actors/curation_concerns/apply_order_actor.rb +24 -0
  11. data/app/actors/curation_concerns/assign_identifier_actor.rb +7 -0
  12. data/app/actors/curation_concerns/assign_representative_actor.rb +18 -0
  13. data/app/actors/curation_concerns/attach_files_actor.rb +39 -0
  14. data/app/actors/curation_concerns/base_actor.rb +71 -0
  15. data/app/actors/curation_concerns/embargo_actor.rb +19 -0
  16. data/app/actors/curation_concerns/file_actor.rb +79 -0
  17. data/app/actors/curation_concerns/file_set_actor.rb +146 -0
  18. data/app/actors/curation_concerns/interpret_visibility_actor.rb +123 -0
  19. data/app/actors/curation_concerns/lease_actor.rb +19 -0
  20. data/app/actors/curation_concerns/root_actor.rb +17 -0
  21. data/app/actors/curation_concerns/work_actor_behavior.rb +8 -0
  22. data/app/assets/javascripts/curation_concerns/batch_select.js +42 -0
  23. data/app/assets/javascripts/curation_concerns/collections.js +13 -0
  24. data/app/assets/javascripts/curation_concerns/curation_concerns.js +2 -0
  25. data/app/assets/stylesheets/curation_concerns/_curation_concerns.scss +0 -3
  26. data/app/assets/stylesheets/curation_concerns/_modules.scss +1 -1
  27. data/app/assets/stylesheets/curation_concerns/_positioning.scss +3 -6
  28. data/app/assets/stylesheets/curation_concerns/_theme.scss +0 -39
  29. data/app/assets/stylesheets/curation_concerns/_typography.scss +0 -69
  30. data/app/assets/stylesheets/curation_concerns/modules/classify_work.scss +0 -2
  31. data/app/assets/stylesheets/curation_concerns/modules/collections.scss +4 -0
  32. data/app/assets/stylesheets/curation_concerns/modules/forms.scss +0 -4
  33. data/app/assets/stylesheets/curation_concerns/modules/site_actions.scss +34 -29
  34. data/app/assets/stylesheets/curation_concerns/modules/site_search.scss +0 -46
  35. data/app/assets/stylesheets/curation_concerns.scss +4 -0
  36. data/app/controllers/concerns/curation_concerns/collections_controller_behavior.rb +166 -21
  37. data/app/controllers/concerns/curation_concerns/embargoes_controller_behavior.rb +1 -1
  38. data/app/controllers/concerns/curation_concerns/leases_controller_behavior.rb +1 -1
  39. data/app/controllers/concerns/curation_concerns/selects_collections.rb +65 -0
  40. data/app/forms/curation_concerns/forms/collection_edit_form.rb +0 -29
  41. data/app/forms/curation_concerns/forms/work_form.rb +2 -1
  42. data/app/helpers/batch_select_helper.rb +23 -0
  43. data/app/helpers/collections_helper.rb +4 -0
  44. data/app/helpers/curation_concerns/collections_helper.rb +2 -2
  45. data/app/helpers/curation_concerns/collections_helper_behavior.rb +56 -0
  46. data/app/helpers/curation_concerns/render_constraints_helper.rb +14 -35
  47. data/app/helpers/curation_concerns/title_helper.rb +4 -0
  48. data/app/indexers/curation_concerns/collection_indexer.rb +16 -0
  49. data/app/indexers/curation_concerns/file_set_indexer.rb +46 -0
  50. data/app/indexers/curation_concerns/work_indexer.rb +15 -0
  51. data/app/jobs/audit_job.rb +49 -0
  52. data/app/jobs/characterize_job.rb +11 -0
  53. data/app/jobs/create_derivatives_job.rb +21 -0
  54. data/app/jobs/import_url_job.rb +48 -0
  55. data/app/jobs/ingest_file_job.rb +30 -0
  56. data/app/jobs/ingest_local_file_job.rb +20 -0
  57. data/app/jobs/resolrize_job.rb +7 -0
  58. data/app/models/checksum_audit_log.rb +20 -0
  59. data/app/models/collection.rb +6 -0
  60. data/app/models/concerns/curation_concerns/ability.rb +49 -0
  61. data/app/models/concerns/curation_concerns/basic_metadata.rb +64 -0
  62. data/app/models/concerns/curation_concerns/collection.rb +16 -0
  63. data/app/models/concerns/curation_concerns/collection_behavior.rb +62 -0
  64. data/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb +47 -0
  65. data/app/models/concerns/curation_concerns/file_set/derivatives.rb +65 -0
  66. data/app/models/concerns/curation_concerns/file_set/full_text_indexing.rb +11 -0
  67. data/app/models/concerns/curation_concerns/file_set/indexing.rb +14 -0
  68. data/app/models/concerns/curation_concerns/file_set/querying.rb +17 -0
  69. data/app/models/concerns/curation_concerns/file_set_behavior.rb +36 -0
  70. data/app/models/concerns/curation_concerns/has_representative.rb +13 -0
  71. data/app/models/concerns/curation_concerns/human_readable_type.rb +17 -0
  72. data/app/models/concerns/curation_concerns/naming.rb +17 -0
  73. data/app/models/concerns/curation_concerns/permissions/readable.rb +18 -0
  74. data/app/models/concerns/curation_concerns/permissions/writable.rb +34 -0
  75. data/app/models/concerns/curation_concerns/permissions.rb +7 -0
  76. data/app/models/concerns/curation_concerns/required_metadata.rb +30 -0
  77. data/app/models/concerns/curation_concerns/serializers.rb +13 -0
  78. data/app/models/concerns/curation_concerns/solr_document_behavior.rb +147 -0
  79. data/app/models/concerns/curation_concerns/user.rb +18 -0
  80. data/app/models/concerns/curation_concerns/with_file_sets.rb +37 -0
  81. data/app/models/concerns/curation_concerns/work_behavior.rb +45 -0
  82. data/app/models/curation_concerns/classify_concern.rb +49 -0
  83. data/app/models/curation_concerns/quick_classification_query.rb +38 -0
  84. data/app/models/single_use_link.rb +34 -0
  85. data/app/models/version_committer.rb +2 -0
  86. data/app/search_builders/curation_concerns/collection_member_search_builder.rb +1 -1
  87. data/app/search_builders/curation_concerns/collection_search_builder.rb +33 -0
  88. data/app/search_builders/curation_concerns/member_search_builder.rb +17 -0
  89. data/app/services/curation_concerns/derivative_path.rb +49 -0
  90. data/app/services/curation_concerns/file_set_audit_service.rb +105 -0
  91. data/app/services/curation_concerns/indexes_thumbnails.rb +30 -0
  92. data/app/services/curation_concerns/local_file_service.rb +10 -0
  93. data/app/services/curation_concerns/lock_manager.rb +39 -0
  94. data/app/services/curation_concerns/lockable.rb +16 -0
  95. data/app/services/curation_concerns/noid.rb +23 -0
  96. data/app/services/curation_concerns/persist_derivatives.rb +33 -0
  97. data/app/services/curation_concerns/persist_directly_contained_output_file_service.rb +26 -0
  98. data/app/services/curation_concerns/repository_audit_service.rb +7 -0
  99. data/app/services/curation_concerns/thumbnail_path_service.rb +46 -0
  100. data/app/services/curation_concerns/time_service.rb +7 -0
  101. data/app/services/curation_concerns/versioning_service.rb +26 -0
  102. data/app/validators/has_one_title_validator.rb +8 -0
  103. data/app/views/batch_select/_add_button.html.erb +3 -0
  104. data/app/views/batch_select/_check_all.html.erb +4 -0
  105. data/app/views/batch_select/_tools.html.erb +10 -0
  106. data/app/views/catalog/_action_menu_partials/_collection.html.erb +3 -3
  107. data/app/views/catalog/_action_menu_partials/_default.html.erb +1 -1
  108. data/app/views/catalog/_document_list.html.erb +1 -1
  109. data/app/views/collections/_bookmark_control.html.erb +2 -0
  110. data/app/views/collections/_button_create_collection.html.erb +2 -0
  111. data/app/views/collections/_button_for_creating_empty_collection.html.erb +1 -1
  112. data/app/views/collections/_button_for_delete_collection.html.erb +4 -0
  113. data/app/views/collections/_button_for_remove_selected_from_collection.html.erb +8 -0
  114. data/app/views/collections/_button_for_update_collection.html.erb +4 -0
  115. data/app/views/collections/_button_remove_from_collection.html.erb +4 -0
  116. data/app/views/collections/_document_header.html.erb +9 -0
  117. data/app/views/collections/_edit_actions.html.erb +1 -1
  118. data/app/views/collections/_edit_descriptions.html.erb +1 -1
  119. data/app/views/collections/_form.html.erb +2 -2
  120. data/app/views/collections/_form_for_select_destination_collection.html.erb +21 -0
  121. data/app/views/collections/_form_to_add_member.html.erb +1 -1
  122. data/app/views/collections/_index_default.html.erb +2 -0
  123. data/app/views/collections/_index_header_default.html.erb +2 -0
  124. data/app/views/collections/_media_display.html.erb +1 -1
  125. data/app/views/collections/_paginate.html.erb +1 -1
  126. data/app/views/collections/_paginate_compact.html.erb +1 -0
  127. data/app/views/collections/_results_pagination.html.erb +9 -0
  128. data/app/views/collections/_search_collection_dashboard_form.html.erb +1 -1
  129. data/app/views/collections/_search_form.html.erb +1 -1
  130. data/app/views/collections/_search_results.html.erb +23 -0
  131. data/app/views/collections/_show_actions.html.erb +1 -1
  132. data/app/views/collections/_sort_and_per_page.html.erb +1 -1
  133. data/app/views/collections/_view_type_group.html.erb +1 -1
  134. data/app/views/collections/index.html.erb +9 -0
  135. data/app/views/collections/new.html.erb +3 -0
  136. data/app/views/curation_concerns/base/_form_permission.html.erb +10 -11
  137. data/app/views/curation_concerns/base/_form_permission_embargo.html.erb +1 -1
  138. data/app/views/curation_concerns/base/_form_permission_lease.html.erb +1 -1
  139. data/app/views/curation_concerns/base/_legally_binding_text.html.erb +7 -7
  140. data/app/views/curation_concerns/base/_related_files.html.erb +1 -1
  141. data/app/views/curation_concerns/base/_visibility.html.erb +2 -2
  142. data/app/views/curation_concerns/file_sets/_actions.html.erb +1 -1
  143. data/app/views/embargoes/_list_expired_active_embargoes.html.erb +1 -1
  144. data/app/views/error/single_use_error.html.erb +1 -1
  145. data/app/views/shared/_add_content.html.erb +17 -15
  146. data/app/views/shared/_brand_bar.html.erb +19 -10
  147. data/app/views/shared/_header.html.erb +2 -6
  148. data/app/views/shared/_my_actions.html.erb +28 -27
  149. data/app/views/shared/_site_actions.html.erb +5 -1
  150. data/app/views/shared/_site_search.html.erb +3 -2
  151. data/app/views/shared/_title_bar.html.erb +7 -16
  152. data/app/views/welcome/index.html.erb +2 -2
  153. data/config/locales/curation_concerns.en.yml +25 -1
  154. data/curation_concerns.gemspec +21 -5
  155. data/lib/curation_concerns/collections/accepts_batches.rb +53 -0
  156. data/lib/curation_concerns/collections/search_service.rb +57 -0
  157. data/lib/curation_concerns/collections.rb +10 -0
  158. data/lib/curation_concerns/configuration.rb +167 -0
  159. data/lib/curation_concerns/engine.rb +22 -1
  160. data/lib/curation_concerns/messages.rb +68 -0
  161. data/lib/curation_concerns/models.rb +42 -0
  162. data/lib/curation_concerns/name.rb +20 -0
  163. data/lib/curation_concerns/null_logger.rb +10 -0
  164. data/lib/curation_concerns/rails/routes.rb +1 -3
  165. data/lib/curation_concerns/version.rb +1 -1
  166. data/lib/curation_concerns.rb +2 -0
  167. data/lib/generators/curation_concerns/abstract_migration_generator.rb +31 -0
  168. data/lib/generators/curation_concerns/clamav_generator.rb +19 -0
  169. data/lib/generators/curation_concerns/collection_generator.rb +15 -0
  170. data/lib/generators/curation_concerns/install_generator.rb +1 -2
  171. data/lib/generators/curation_concerns/models_generator.rb +62 -0
  172. data/lib/generators/curation_concerns/templates/app/models/collection.rb +6 -0
  173. data/lib/generators/curation_concerns/templates/app/models/file_set.rb +4 -0
  174. data/lib/generators/curation_concerns/templates/config/clamav.rb +1 -0
  175. data/lib/generators/curation_concerns/templates/config/curation_concerns.rb +61 -0
  176. data/lib/generators/curation_concerns/templates/config/mime_types.rb +6 -0
  177. data/lib/generators/curation_concerns/templates/config/redis.yml +9 -0
  178. data/lib/generators/curation_concerns/templates/config/redis_config.rb +29 -0
  179. data/lib/generators/curation_concerns/templates/config/resque-pool.yml +1 -0
  180. data/lib/generators/curation_concerns/templates/config/resque_config.rb +6 -0
  181. data/lib/generators/curation_concerns/templates/curation_concerns.scss +3 -2
  182. data/lib/generators/curation_concerns/templates/migrations/create_checksum_audit_logs.rb +19 -0
  183. data/lib/generators/curation_concerns/templates/migrations/create_single_use_links.rb +12 -0
  184. data/lib/generators/curation_concerns/templates/migrations/create_version_committers.rb +15 -0
  185. data/lib/tasks/migrate.rake +11 -0
  186. data/lib/tasks/resque.rake +14 -0
  187. data/lib/tasks/solr_reindex.rake +8 -0
  188. data/spec/actors/curation_concerns/file_set_actor_spec.rb +31 -0
  189. data/spec/controllers/accepts_batches_controller_spec.rb +65 -0
  190. data/spec/controllers/collections_controller_spec.rb +272 -0
  191. data/spec/controllers/curation_concerns/collections_controller_spec.rb +1 -2
  192. data/spec/controllers/selects_collections_controller_spec.rb +109 -0
  193. data/spec/features/create_work_spec.rb +1 -1
  194. data/spec/features/work_generator_spec.rb +1 -1
  195. data/spec/forms/collection_edit_form_spec.rb +2 -9
  196. data/spec/forms/work_form_spec.rb +5 -0
  197. data/spec/helpers/collections_helper_spec.rb +129 -0
  198. data/spec/helpers/curation_concerns/collections_helper_spec.rb +2 -2
  199. data/spec/helpers/render_constraints_helper_spec.rb +23 -1
  200. data/spec/lib/curation_concerns/collections/search_service_spec.rb +33 -0
  201. data/spec/models/collection_spec.rb +165 -0
  202. data/spec/tasks/rake_spec.rb +1 -1
  203. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  204. data/spec/views/curation_concerns/base/_form_permission.html.erb_spec.rb +4 -1
  205. data/spec/views/curation_concerns/file_sets/show.html.erb_spec.rb +1 -0
  206. data/spec/views/shared/_add_content.html.erb_spec.rb +3 -3
  207. metadata +341 -24
  208. data/VERSION +0 -1
  209. data/app/assets/stylesheets/curation_concerns/_global-variables.scss +0 -5
  210. data/app/assets/stylesheets/curation_concerns/modules/multi_value_fields.scss +0 -52
  211. data/app/views/collections/_form_required_information.html.erb +0 -11
  212. data/tasks/release.rake +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e539e04a127fef5b331cbc4b51495b386f473ab8
4
- data.tar.gz: 2706ea39d092ae8ae4e7a969ec5f0d6ac40e8f75
3
+ metadata.gz: 127203132df29eed98a348c7ca741685e62793e0
4
+ data.tar.gz: 0e4704e41785f9eaf7a062f2ff5d7c8c34c9326b
5
5
  SHA512:
6
- metadata.gz: 4cb327b7af8c5e54d1b42ce2fc0784541e8f1aaaea7b19b172cc77615bec6ea8f7ffd49fa059e38a8132d6f759dcac3aca1c220d72b2ae5aedb65abc55e78f47
7
- data.tar.gz: 806dad8e1e5ed014956c1c9df81eaf3c7f43117081b9877a017e08509988ae5c2eeaf038dd5220fabc14c8e8a6e27ef8dd113a3025ab2c7f02791dbe19fd32b1
6
+ metadata.gz: abe17e8e0e63eb6b67adfd7606cef6e199d5b981d384a10615e59183764373dfd29f2b4655e6202e4d4bdcfca8db3e2dfa327a32213ee85e40c2f78955617bd1
7
+ data.tar.gz: 77bebf157e28c363c6025e2d35046a0e825de606e963dc7c22029f157c2a9c3703f1c09b9ebe413dff320c7dd072a678126db11748588cadaefa3bf409bfb0d5
data/.rubocop.yml CHANGED
@@ -9,7 +9,7 @@ AllCops:
9
9
  - 'script/**/*'
10
10
  - 'vendor/**/*'
11
11
  - '.internal_test_app/**/*'
12
- - 'curation_concerns-models/app/models/concerns/curation_concerns/file_set/export.rb'
12
+ - 'app/models/concerns/curation_concerns/file_set/export.rb'
13
13
 
14
14
  Rails:
15
15
  Enabled: true
@@ -18,15 +18,15 @@ Performance/RedundantBlockCall:
18
18
  # We can remove this exclusion when this commit is released:
19
19
  # https://github.com/bbatsov/rubocop/commit/7df382531db4f66cd9872a4f478bd486d6ce6712
20
20
  Exclude:
21
- - 'curation_concerns-models/lib/curation_concerns/null_logger.rb'
21
+ - 'lib/curation_concerns/null_logger.rb'
22
22
 
23
23
  Performance/RedundantMerge:
24
24
  Enabled: false
25
25
 
26
26
  Lint/AssignmentInCondition:
27
27
  Exclude:
28
- - 'curation_concerns-models/app/services/curation_concerns/persist_derivatives.rb'
29
- - 'curation_concerns-models/app/actors/curation_concerns/file_set_actor.rb'
28
+ - 'app/services/curation_concerns/persist_derivatives.rb'
29
+ - 'app/actors/curation_concerns/file_set_actor.rb'
30
30
 
31
31
  Metrics/LineLength:
32
32
  Enabled: false
@@ -36,29 +36,29 @@ Metrics/AbcSize:
36
36
 
37
37
  Metrics/CyclomaticComplexity:
38
38
  Exclude:
39
- - 'curation_concerns-models/app/services/curation_concerns/file_set_audit_service.rb'
39
+ - 'app/services/curation_concerns/file_set_audit_service.rb'
40
40
  - 'app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb'
41
41
  - 'app/helpers/curation_concerns/curation_concerns_helper_behavior.rb'
42
42
  - 'app/helpers/curation_concerns/attribute_helper.rb'
43
- - 'curation_concerns-models/app/actors/curation_concerns/file_set_actor.rb'
44
- - 'curation_concerns-models/app/actors/curation_concerns/work_actor_behavior.rb'
43
+ - 'app/actors/curation_concerns/file_set_actor.rb'
44
+ - 'app/actors/curation_concerns/work_actor_behavior.rb'
45
45
 
46
46
  Metrics/PerceivedComplexity:
47
47
  Exclude:
48
- - 'curation_concerns-models/app/services/curation_concerns/file_set_audit_service.rb'
48
+ - 'app/services/curation_concerns/file_set_audit_service.rb'
49
49
  - 'app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb'
50
50
  - 'app/helpers/curation_concerns/curation_concerns_helper_behavior.rb'
51
51
  - 'app/helpers/curation_concerns/attribute_helper.rb'
52
- - 'curation_concerns-models/app/actors/curation_concerns/file_set_actor.rb'
52
+ - 'app/actors/curation_concerns/file_set_actor.rb'
53
53
 
54
54
  Metrics/MethodLength:
55
55
  Enabled: false
56
56
 
57
57
  Metrics/ClassLength:
58
58
  Exclude:
59
- - curation_concerns-models/lib/curation_concerns/configuration.rb
59
+ - lib/curation_concerns/configuration.rb
60
60
  - 'lib/generators/curation_concerns/templates/catalog_controller.rb'
61
- - 'curation_concerns-models/app/actors/curation_concerns/file_set_actor.rb'
61
+ - 'app/actors/curation_concerns/file_set_actor.rb'
62
62
 
63
63
  Metrics/ModuleLength:
64
64
  Exclude:
@@ -67,7 +67,8 @@ Metrics/ModuleLength:
67
67
  - 'app/controllers/concerns/curation_concerns/catalog_controller.rb'
68
68
  - 'app/controllers/concerns/curation_concerns/file_sets_controller_behavior.rb'
69
69
  - 'app/helpers/curation_concerns/curation_concerns_helper_behavior.rb'
70
- - 'curation_concerns-models/app/models/concerns/curation_concerns/solr_document_behavior.rb'
70
+ - 'app/models/concerns/curation_concerns/solr_document_behavior.rb'
71
+ - 'app/controllers/concerns/curation_concerns/collections_controller_behavior.rb'
71
72
 
72
73
  Style/ZeroLengthPredicate:
73
74
  Enabled: false
@@ -131,6 +132,7 @@ Style/PredicateName:
131
132
  - 'app/helpers/curation_concerns/curation_concerns_helper_behavior.rb'
132
133
  - 'app/controllers/concerns/curation_concerns/controller.rb'
133
134
  - 'app/helpers/curation_concerns/collections_helper.rb'
135
+ - 'app/helpers/curation_concerns/collections_helper_behavior.rb'
134
136
 
135
137
  Style/GlobalVars:
136
138
  Exclude:
@@ -141,9 +143,9 @@ Style/SingleLineBlockParams:
141
143
 
142
144
  Style/ClassVars:
143
145
  Exclude:
144
- - 'curation_concerns-models/lib/curation_concerns/models.rb'
145
- - 'curation_concerns-models/lib/curation_concerns/models/engine.rb'
146
- - 'curation_concerns-models/app/models/concerns/curation_concerns/file_set/versions.rb'
146
+ - 'lib/curation_concerns/models.rb'
147
+ - 'lib/curation_concerns/models/engine.rb'
148
+ - 'app/models/concerns/curation_concerns/file_set/versions.rb'
147
149
 
148
150
  Style/SignalException:
149
151
  Enabled: false
@@ -151,7 +153,7 @@ Style/SignalException:
151
153
  Rails/Output:
152
154
  Exclude:
153
155
  - 'lib/generators/**/*'
154
- - 'curation_concerns-models/lib/generators/**/*'
156
+ - 'lib/generators/**/*'
155
157
 
156
158
  Rails/Date:
157
159
  Enabled: false
@@ -174,6 +176,12 @@ RSpec/FilePath:
174
176
  RSpec/InstanceVariable:
175
177
  Enabled: false
176
178
 
179
+ RSpec/AnyInstance:
180
+ Enabled: false
181
+
182
+ RSpec/NotToNot:
183
+ Enabled: false
184
+
177
185
  RSpec/DescribeClass:
178
186
  Exclude:
179
187
  - 'spec/javascripts/jasmine_spec.rb'
data/Gemfile CHANGED
@@ -3,11 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in curation_concerns.gemspec
4
4
  gemspec
5
5
 
6
- gem 'curation_concerns-models', path: './curation_concerns-models'
7
-
8
6
  group :development, :test do
9
- gem 'rubocop', '~> 0.37.0', require: false
10
- gem 'rubocop-rspec', '~> 1.3.1', require: false
11
7
  gem 'simplecov', '~> 0.9', require: false
12
8
  gem 'coveralls', require: false
13
9
  gem 'poltergeist'
data/README.md CHANGED
@@ -40,6 +40,20 @@ Then run the install generator. You will be prompted if you want to overwrite t
40
40
  $ rails generate curation_concerns:install
41
41
  $ rake db:migrate
42
42
 
43
+ ### FITS 0.6.2
44
+
45
+ To install FITS:
46
+ * Go to http://projects.iq.harvard.edu/fits/downloads, download __fits-0.6.2.zip__, and unpack it somewhere on your machine. You can also install FITS on OSX with homebrew: `brew install fits` (you may also have to create a symlink from fits.sh -> fits in the next step).
47
+ * Mark fits.sh as executable (chmod a+x fits.sh)
48
+ * Run "fits.sh -h" from the command line and see a help message to ensure FITS is properly installed
49
+ * Give your app access to FITS by:
50
+ * Adding the full fits.sh path to your PATH (e.g., in your .bash_profile), OR
51
+ * Changing config/initializers/sufia.rb to point to your FITS location: config.fits_path = "/<your full path>/fits.sh"
52
+
53
+ ### Redis 2.6
54
+
55
+ The redlock gem requires Redis >= 2.6.
56
+
43
57
  ## Usage
44
58
 
45
59
  ### Generator
data/RELEASING.md CHANGED
@@ -1,3 +1,3 @@
1
- * Bump version number in `VERSION`
2
- * Release the gem to rubygems.org: `rake all:release`
1
+ * Bump version number in `lib/curation_concerns/version.rb`
2
+ * Release the gem to rubygems.org: `rake build` then `rake release`
3
3
  * `git push`
data/Rakefile CHANGED
@@ -9,6 +9,8 @@ require 'active_fedora/rake_support'
9
9
 
10
10
  Dir.glob('tasks/*.rake').each { |r| import r }
11
11
 
12
+ Bundler::GemHelper.install_tasks
13
+
12
14
  namespace :curation_concerns do
13
15
  desc 'Run style checker'
14
16
  RuboCop::RakeTask.new(:rubocop) do |task|
@@ -0,0 +1,28 @@
1
+ module CurationConcerns
2
+ # To use this module, include it in your Actor class
3
+ # and then add its interpreters wherever you want them to run.
4
+ # They should be called _before_ apply_attributes is called because
5
+ # they intercept values in the attributes Hash.
6
+ #
7
+ # @example
8
+ # class MyActorClass < BaseActor
9
+ # include Worthwile::ManagesEmbargoesActor
10
+ #
11
+ # def create
12
+ # interpret_visibility && super
13
+ # end
14
+ #
15
+ # def update
16
+ # interpret_visibility && super
17
+ # end
18
+ # end
19
+ #
20
+ module ManagesEmbargoesActor
21
+ extend ActiveSupport::Concern
22
+ extend Deprecation
23
+
24
+ included do
25
+ Deprecation.warn(ManagesEmbargoesActor, "ManagesEmbargoesActor is deprecated and will be removed in CurationConcerns 1.0")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module CurationConcerns
2
+ # The CurationConcern Abstract actor responds to two primary actions:
3
+ # * #create
4
+ # * #update
5
+ #
6
+ # and the following attributes
7
+ #
8
+ # * next_actor
9
+ # * curation_concern
10
+ # * user
11
+ #
12
+ # it must instantiate the next actor in the chain and instantiate it.
13
+ # it should respond to curation_concern, user and attributes.
14
+ # it ha to next_actor
15
+ class AbstractActor
16
+ attr_reader :next_actor
17
+
18
+ def initialize(_curation_concern, _user, next_actor)
19
+ @next_actor = next_actor
20
+ end
21
+
22
+ delegate :curation_concern, :user, to: :next_actor
23
+
24
+ delegate :create, to: :next_actor
25
+
26
+ delegate :update, to: :next_actor
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ module CurationConcerns
2
+ class AddToCollectionActor < AbstractActor
3
+ def create(attributes)
4
+ collection_ids = attributes.delete(:collection_ids)
5
+ next_actor.create(attributes) && add_to_collections(collection_ids)
6
+ end
7
+
8
+ def update(attributes)
9
+ collection_ids = attributes.delete(:collection_ids)
10
+ add_to_collections(collection_ids) && next_actor.update(attributes)
11
+ end
12
+
13
+ private
14
+
15
+ # The default behavior of active_fedora's aggregates association,
16
+ # when assigning the id accessor (e.g. collection_ids = ['foo:1']) is to add
17
+ # to new collections, but not remove from old collections.
18
+ # This method ensures it's removed from the old collections.
19
+ def add_to_collections(new_collection_ids)
20
+ return true unless new_collection_ids
21
+ # remove from old collections
22
+ # TODO: Implement in_collection_ids https://github.com/projecthydra-labs/hydra-pcdm/issues/157
23
+ (curation_concern.in_collections.map(&:id) - new_collection_ids).each do |old_id|
24
+ collection = ::Collection.find(old_id)
25
+ collection.members.delete(curation_concern)
26
+ collection.save
27
+ end
28
+
29
+ # add to new
30
+ new_collection_ids.each do |coll_id|
31
+ collection = ::Collection.find(coll_id)
32
+ collection.members << curation_concern
33
+ collection.save
34
+ end
35
+ true
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ module CurationConcerns
2
+ class ApplyOrderActor < AbstractActor
3
+ def update(attributes)
4
+ ordered_member_ids = attributes.delete(:ordered_member_ids)
5
+ apply_order(ordered_member_ids) && next_actor.update(attributes)
6
+ end
7
+
8
+ private
9
+
10
+ def apply_order(new_order)
11
+ return true unless new_order
12
+ curation_concern.ordered_member_proxies.each_with_index do |proxy, index|
13
+ unless new_order[index]
14
+ proxy.prev.next = curation_concern.ordered_member_proxies.last.next
15
+ break
16
+ end
17
+ proxy.proxy_for = ActiveFedora::Base.id_to_uri(new_order[index])
18
+ proxy.target = nil
19
+ end
20
+ curation_concern.list_source.order_will_change!
21
+ true
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module CurationConcerns
2
+ class AssignIdentifierActor < AbstractActor
3
+ def create(attributes)
4
+ curation_concern.assign_id && next_actor.create(attributes)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ module CurationConcerns
2
+ class AssignRepresentativeActor < AbstractActor
3
+ def create(attributes)
4
+ next_actor.create(attributes) && assign_representative
5
+ end
6
+
7
+ private
8
+
9
+ def assign_representative
10
+ unless curation_concern.representative_id
11
+ # TODO: Possible optimization here. Does this cause a fetch of ordered_members if they're already loaded?
12
+ representative = nil # curation_concern.ordered_members.association.reader.first.target
13
+ curation_concern.representative = representative if representative
14
+ end
15
+ curation_concern.save
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ module CurationConcerns
2
+ class AttachFilesActor < AbstractActor
3
+ def create(attributes)
4
+ files = [attributes.delete(:files)].flatten.compact
5
+ attach_files(files, visibility_attributes(attributes)) &&
6
+ next_actor.create(attributes)
7
+ end
8
+
9
+ def update(attributes)
10
+ files = [attributes.delete(:files)].flatten.compact
11
+ next_actor.update(attributes) &&
12
+ attach_files(files, visibility_attributes(attributes))
13
+ end
14
+
15
+ private
16
+
17
+ def attach_files(files, visibility_attr)
18
+ files.all? do |file|
19
+ attach_file(file, visibility_attr)
20
+ end
21
+ end
22
+
23
+ def attach_file(file, visibility_attr)
24
+ file_set = ::FileSet.new
25
+ file_set_actor = CurationConcerns::FileSetActor.new(file_set, user)
26
+ file_set_actor.create_metadata(curation_concern, visibility_attr)
27
+ file_set_actor.create_content(file)
28
+ end
29
+
30
+ # The attributes used for visibility - used to send as initial params to
31
+ # created FileSets.
32
+ def visibility_attributes(attributes)
33
+ attributes.slice(:visibility, :visibility_during_lease,
34
+ :visibility_after_lease, :lease_expiration_date,
35
+ :embargo_release_date, :visibility_during_embargo,
36
+ :visibility_after_embargo)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,71 @@
1
+ module CurationConcerns
2
+ # The CurationConcern base actor responds to two primary actions:
3
+ # * #create
4
+ # * #update
5
+ # it must instantiate the next actor in the chain and instantiate it.
6
+ # it should respond to curation_concern, user and attributes.
7
+ class BaseActor < AbstractActor
8
+ attr_reader :cloud_resources
9
+
10
+ def create(attributes)
11
+ @cloud_resources = attributes.delete(:cloud_resources.to_s)
12
+ apply_creation_data_to_curation_concern
13
+ apply_save_data_to_curation_concern(attributes)
14
+ next_actor.create(attributes) && save
15
+ end
16
+
17
+ def update(attributes)
18
+ apply_update_data_to_curation_concern
19
+ apply_save_data_to_curation_concern(attributes)
20
+ next_actor.update(attributes) && save
21
+ end
22
+
23
+ protected
24
+
25
+ def apply_creation_data_to_curation_concern
26
+ apply_depositor_metadata
27
+ apply_deposit_date
28
+ end
29
+
30
+ def apply_update_data_to_curation_concern
31
+ true
32
+ end
33
+
34
+ def apply_depositor_metadata
35
+ curation_concern.apply_depositor_metadata(user.user_key)
36
+ curation_concern.edit_users += [user.user_key]
37
+ end
38
+
39
+ def apply_deposit_date
40
+ curation_concern.date_uploaded = CurationConcerns::TimeService.time_in_utc
41
+ end
42
+
43
+ def save
44
+ curation_concern.save
45
+ end
46
+
47
+ def apply_save_data_to_curation_concern(attributes)
48
+ attributes[:rights] = Array(attributes[:rights]) if attributes.key? :rights
49
+ remove_blank_attributes!(attributes)
50
+ curation_concern.attributes = attributes.symbolize_keys
51
+ curation_concern.date_modified = CurationConcerns::TimeService.time_in_utc
52
+ end
53
+
54
+ # If any attributes are blank remove them
55
+ # e.g.:
56
+ # self.attributes = { 'title' => ['first', 'second', ''] }
57
+ # remove_blank_attributes!
58
+ # self.attributes
59
+ # => { 'title' => ['first', 'second'] }
60
+ def remove_blank_attributes!(attributes)
61
+ multivalued_form_attributes(attributes).each_with_object(attributes) do |(k, v), h|
62
+ h[k] = v.instance_of?(Array) ? v.select(&:present?) : v
63
+ end
64
+ end
65
+
66
+ # Return the hash of attributes that are multivalued and not uploaded files
67
+ def multivalued_form_attributes(attributes)
68
+ attributes.select { |_, v| v.respond_to?(:select) && !v.respond_to?(:read) }
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,19 @@
1
+ module CurationConcerns
2
+ class EmbargoActor
3
+ attr_reader :work
4
+
5
+ # @param [Hydra::Works::Work] work
6
+ def initialize(work)
7
+ @work = work
8
+ end
9
+
10
+ # Update the visibility of the work to match the correct state of the embargo, then clear the embargo date, etc.
11
+ # Saves the embargo and the work
12
+ def destroy
13
+ work.embargo_visibility! # If the embargo has lapsed, update the current visibility.
14
+ work.deactivate_embargo!
15
+ work.embargo.save!
16
+ work.save!
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,79 @@
1
+ module CurationConcerns
2
+ # actions for a file identified by file_set and relation (maps to use predicate)
3
+ class FileActor
4
+ attr_reader :file_set, :relation, :user
5
+
6
+ # @param [FileSet] file_set the parent FileSet
7
+ # @param [String] relation the type/use for the file.
8
+ # @param [User] user the user to record as the Agent acting upon the file
9
+ def initialize(file_set, relation, user)
10
+ @file_set = file_set
11
+ @relation = relation
12
+ @user = user
13
+ end
14
+
15
+ # Puts the uploaded content into a staging directory. Then kicks off a
16
+ # job to characterize and create derivatives with this on disk variant.
17
+ # Simultaneously moving a preservation copy to the repostiory.
18
+ # TODO: create a job to monitor this directory and prune old files that
19
+ # have made it to the repo
20
+ # @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file to save in the repository
21
+ def ingest_file(file)
22
+ working_file = copy_file_to_working_directory(file, file_set.id)
23
+ mime_type = file.respond_to?(:content_type) ? file.content_type : nil
24
+ IngestFileJob.perform_later(file_set, working_file, mime_type, user.user_key, relation)
25
+ make_derivative(file_set, working_file)
26
+ true
27
+ end
28
+
29
+ def revert_to(revision_id)
30
+ repository_file = file_set.send(relation.to_sym)
31
+ repository_file.restore_version(revision_id)
32
+
33
+ return false unless file_set.save
34
+
35
+ CurationConcerns::VersioningService.create(repository_file, user)
36
+
37
+ # Retrieve a copy of the orginal file from the repository
38
+ working_file = copy_repository_resource_to_working_directory(repository_file)
39
+ make_derivative(file_set, working_file)
40
+ true
41
+ end
42
+
43
+ private
44
+
45
+ def make_derivative(file_set, working_file)
46
+ CharacterizeJob.perform_later(file_set, working_file)
47
+ end
48
+
49
+ # @param [File, ActionDispatch::Http::UploadedFile] file
50
+ # @param [String] id the identifer of the FileSet
51
+ # @return [String] path of the working file
52
+ def copy_file_to_working_directory(file, id)
53
+ file_name = file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
54
+ copy_stream_to_working_directory(id, file_name, file)
55
+ end
56
+
57
+ # @param [ActiveFedora::File] file the resource in the repo
58
+ # @return [String] path of the working file
59
+ def copy_repository_resource_to_working_directory(file)
60
+ copy_stream_to_working_directory(file_set.id, file.original_name, StringIO.new(file.content))
61
+ end
62
+
63
+ # @param [String] id the identifer
64
+ # @param [String] name the file name
65
+ # @param [#read] stream the stream to copy to the working directory
66
+ # @return [String] path of the working file
67
+ def copy_stream_to_working_directory(id, name, stream)
68
+ working_path = full_filename(id, name)
69
+ FileUtils.mkdir_p(File.dirname(working_path))
70
+ IO.copy_stream(stream, working_path)
71
+ working_path
72
+ end
73
+
74
+ def full_filename(id, original_name)
75
+ pair = id.scan(/..?/).first(4)
76
+ File.join(CurationConcerns.config.working_path, *pair, original_name)
77
+ end
78
+ end
79
+ end