valkyrie 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +33 -29
  3. data/.lando.yml +40 -0
  4. data/.rubocop.yml +4 -1
  5. data/.tool-versions +1 -1
  6. data/CHANGELOG.md +26 -0
  7. data/README.md +19 -47
  8. data/Rakefile +21 -20
  9. data/db/config.yml +3 -10
  10. data/lib/generators/valkyrie/resource_generator.rb +3 -3
  11. data/lib/valkyrie.rb +13 -13
  12. data/lib/valkyrie/change_set.rb +3 -3
  13. data/lib/valkyrie/id.rb +14 -14
  14. data/lib/valkyrie/indexers/access_controls_indexer.rb +17 -17
  15. data/lib/valkyrie/persistence/fedora/list_node.rb +43 -43
  16. data/lib/valkyrie/persistence/fedora/ordered_list.rb +90 -90
  17. data/lib/valkyrie/persistence/fedora/ordered_reader.rb +5 -5
  18. data/lib/valkyrie/persistence/fedora/permissive_schema.rb +1 -1
  19. data/lib/valkyrie/persistence/fedora/persister.rb +80 -82
  20. data/lib/valkyrie/persistence/fedora/persister/model_converter.rb +15 -15
  21. data/lib/valkyrie/persistence/fedora/persister/orm_converter.rb +38 -18
  22. data/lib/valkyrie/persistence/fedora/query_service.rb +38 -40
  23. data/lib/valkyrie/persistence/memory/persister.rb +33 -33
  24. data/lib/valkyrie/persistence/memory/query_service.rb +26 -30
  25. data/lib/valkyrie/persistence/postgres/orm_converter.rb +52 -52
  26. data/lib/valkyrie/persistence/postgres/query_service.rb +34 -34
  27. data/lib/valkyrie/persistence/shared/json_value_mapper.rb +1 -1
  28. data/lib/valkyrie/persistence/solr/model_converter.rb +337 -337
  29. data/lib/valkyrie/persistence/solr/orm_converter.rb +3 -3
  30. data/lib/valkyrie/persistence/solr/queries/find_members_query.rb +1 -1
  31. data/lib/valkyrie/persistence/solr/query_service.rb +12 -12
  32. data/lib/valkyrie/specs/shared_specs/persister.rb +2 -2
  33. data/lib/valkyrie/storage/fedora.rb +16 -16
  34. data/lib/valkyrie/storage_adapter.rb +11 -11
  35. data/lib/valkyrie/version.rb +1 -1
  36. data/tasks/dev.rake +14 -51
  37. data/valkyrie.gemspec +3 -4
  38. metadata +22 -33
  39. data/.docker-stack/valkyrie-development/docker-compose.yml +0 -53
  40. data/.docker-stack/valkyrie-test/docker-compose.yml +0 -53
  41. data/tasks/docker.rake +0 -31
@@ -48,7 +48,7 @@ module Valkyrie::Persistence::Solr
48
48
  # Construct a Time object from the datestamp for the resource creation date indexed in Solr
49
49
  # @return [Time]
50
50
  def created_at
51
- DateTime.parse(solr_document.fetch("created_at_dtsi").to_s).utc
51
+ DateTime.parse(solr_document.fetch("created_at_dtsi").to_s).new_offset(0)
52
52
  end
53
53
 
54
54
  # Construct a Time object from the datestamp for the date of the last resource update indexed in Solr
@@ -445,7 +445,7 @@ module Valkyrie::Persistence::Solr
445
445
  # @return [Boolean]
446
446
  def self.handles?(value)
447
447
  return false unless value.to_s.start_with?("datetime-")
448
- DateTime.iso8601(value.sub(/^datetime-/, '')).utc
448
+ DateTime.iso8601(value.sub(/^datetime-/, '')).new_offset(0)
449
449
  rescue
450
450
  false
451
451
  end
@@ -453,7 +453,7 @@ module Valkyrie::Persistence::Solr
453
453
  # Parses and casts the Solr field value into a UTC DateTime value
454
454
  # @return [Time]
455
455
  def result
456
- DateTime.parse(value.sub(/^datetime-/, '')).utc
456
+ DateTime.parse(value.sub(/^datetime-/, '')).new_offset(0)
457
457
  end
458
458
  end
459
459
  end
@@ -27,7 +27,7 @@ module Valkyrie::Persistence::Solr::Queries
27
27
  # Results are ordered by the member IDs specified in the Valkyrie Resource attribute
28
28
  # @yield [Valkyrie::Resource]
29
29
  def each
30
- return [] unless resource.id.present?
30
+ return [] if resource.id.blank?
31
31
  member_ids.map { |id| unordered_members.find { |member| member.id == id } }.reject(&:nil?).each do |member|
32
32
  yield member
33
33
  end
@@ -97,19 +97,19 @@ module Valkyrie::Persistence::Solr
97
97
 
98
98
  private
99
99
 
100
- # (see Valkyrie::Persistence::Memory::QueryService#validate_id)
101
- def validate_id(id)
102
- raise ArgumentError, 'id must be a Valkyrie::ID' unless id.is_a? Valkyrie::ID
103
- end
100
+ # (see Valkyrie::Persistence::Memory::QueryService#validate_id)
101
+ def validate_id(id)
102
+ raise ArgumentError, 'id must be a Valkyrie::ID' unless id.is_a? Valkyrie::ID
103
+ end
104
104
 
105
- # (see Valkyrie::Persistence::Memory::QueryService#ensure_persisted)
106
- def ensure_persisted(resource)
107
- raise ArgumentError, 'resource is not saved' unless resource.persisted?
108
- end
105
+ # (see Valkyrie::Persistence::Memory::QueryService#ensure_persisted)
106
+ def ensure_persisted(resource)
107
+ raise ArgumentError, 'resource is not saved' unless resource.persisted?
108
+ end
109
109
 
110
- # (see Valkyrie::Persistence::Memory::QueryService#ordered_property?)
111
- def ordered_property?(resource:, property:)
112
- resource.ordered_attribute?(property)
113
- end
110
+ # (see Valkyrie::Persistence::Memory::QueryService#ordered_property?)
111
+ def ordered_property?(resource:, property:)
112
+ resource.ordered_attribute?(property)
113
+ end
114
114
  end
115
115
  end
@@ -194,9 +194,9 @@ RSpec.shared_examples 'a Valkyrie::Persister' do |*flags|
194
194
  reloaded = query_service.find_by(id: book.id)
195
195
 
196
196
  expect(reloaded.title.first.to_i).to eq(time1.to_i)
197
- expect(reloaded.title.first.zone).to eq('UTC')
197
+ expect(reloaded.title.first.zone).to eq('+00:00')
198
198
  expect(reloaded.author.first.to_i).to eq(time2.to_i)
199
- expect(reloaded.author.first.zone).to eq('UTC')
199
+ expect(reloaded.author.first.zone).to eq('+00:00')
200
200
  expect(reloaded.other_author.first).to eq "2019-01"
201
201
  end
202
202
 
@@ -83,24 +83,24 @@ module Valkyrie::Storage
83
83
 
84
84
  private
85
85
 
86
- # @return [IOProxy]
87
- def response(id:)
88
- response = connection.http.get(fedora_identifier(id: id))
89
- raise Valkyrie::StorageAdapter::FileNotFound unless response.success?
90
- IOProxy.new(response.body)
91
- end
86
+ # @return [IOProxy]
87
+ def response(id:)
88
+ response = connection.http.get(fedora_identifier(id: id))
89
+ raise Valkyrie::StorageAdapter::FileNotFound unless response.success?
90
+ IOProxy.new(response.body)
91
+ end
92
92
 
93
- def default_resource_uri_transformer
94
- lambda do |resource, base_url|
95
- id = CGI.escape(resource.id.to_s)
96
- RDF::URI.new(base_url + id)
97
- end
93
+ def default_resource_uri_transformer
94
+ lambda do |resource, base_url|
95
+ id = CGI.escape(resource.id.to_s)
96
+ RDF::URI.new(base_url + id)
98
97
  end
98
+ end
99
99
 
100
- def base_url
101
- pre_divider = base_path.starts_with?(SLASH) ? '' : SLASH
102
- post_divider = base_path.ends_with?(SLASH) ? '' : SLASH
103
- "#{connection.http.url_prefix}#{pre_divider}#{base_path}#{post_divider}"
104
- end
100
+ def base_url
101
+ pre_divider = base_path.starts_with?(SLASH) ? '' : SLASH
102
+ post_divider = base_path.ends_with?(SLASH) ? '' : SLASH
103
+ "#{connection.http.url_prefix}#{pre_divider}#{base_path}#{post_divider}"
104
+ end
105
105
  end
106
106
  end
@@ -106,20 +106,20 @@ module Valkyrie
106
106
 
107
107
  private
108
108
 
109
- def tmp_file_name
110
- id.to_s.tr(':/', '__')
111
- end
109
+ def tmp_file_name
110
+ id.to_s.tr(':/', '__')
111
+ end
112
112
 
113
- def tmp_file_path
114
- ::File.join(Dir.tmpdir, tmp_file_name)
115
- end
113
+ def tmp_file_path
114
+ ::File.join(Dir.tmpdir, tmp_file_name)
115
+ end
116
116
 
117
- def tmp_file
118
- @tmp_file ||= ::File.open(tmp_file_path, 'w+b') do |f|
119
- IO.copy_stream(io, f)
120
- f
121
- end
117
+ def tmp_file
118
+ @tmp_file ||= ::File.open(tmp_file_path, 'w+b') do |f|
119
+ IO.copy_stream(io, f)
120
+ f
122
121
  end
122
+ end
123
123
  end
124
124
  end
125
125
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Valkyrie
3
- VERSION = "2.1.1"
3
+ VERSION = "2.1.2"
4
4
  end
data/tasks/dev.rake CHANGED
@@ -2,63 +2,26 @@
2
2
 
3
3
  namespace :server do
4
4
  desc "Start solr and fedora servers for testing"
5
- task :test do
5
+ task :start do
6
6
  require 'rails'
7
- require 'solr_wrapper'
8
- require 'fcrepo_wrapper'
9
- SolrWrapper.wrap(shared_solr_opts.merge(port: 8984, instance_dir: 'tmp/blacklight-core-test')) do |solr|
10
- solr.with_collection(name: "blacklight-core-test", dir: Pathname.new(__dir__).join("..", "solr", "config").to_s) do
11
- FcrepoWrapper.wrap(shared_fedora_opts.merge(port: 8988, fcrepo_home_dir: "tmp/fcrepo4-test-data", version: "4.7.5", instance_directory: "tmp/fcrepo4")) do |_fcrepo|
12
- FcrepoWrapper::Instance.new(shared_fedora_opts.merge(port: 8998, fcrepo_home_dir: "tmp/fcrepo5-test-data", version: "5.1.0", instance_directory: "tmp/fcrepo5")).wrap do |_other_repo|
13
- puts "Setup solr & Fedora"
14
- loop do
15
- sleep(1)
16
- end
17
- end
18
- end
19
- end
20
- end
7
+ `lando start`
8
+ `bundle exec rake db:create`
9
+ `bundle exec rake db:migrate`
10
+ puts "Started Solr/Fedora/Postgres"
21
11
  end
22
12
 
23
13
  desc "Cleanup test servers"
24
- task :clean_test do
14
+ task :clean do
25
15
  require 'rails'
26
- require 'solr_wrapper'
27
- require 'fcrepo_wrapper'
28
- SolrWrapper.instance(shared_solr_opts.merge(port: 8984, instance_dir: 'tmp/blacklight-core-test')).remove_instance_dir!
29
- FcrepoWrapper.default_instance(shared_fedora_opts.merge(port: 8988, fcrepo_home_dir: "tmp/fcrepo4-test-data", instance_directory: "tmp/fcrepo4")).remove_instance_dir!
30
- FcrepoWrapper::Instance.new(shared_fedora_opts.merge(port: 8998, fcrepo_home_dir: "tmp/fcrepo5-test-data", instance_directory: "tmp/fcrepo5")).remove_instance_dir!
31
- puts "Cleaned up test solr & fedora servers."
16
+ `lando destroy -y`
17
+ `lando start`
18
+ `bundle exec rake db:create`
19
+ `bundle exec rake db:migrate`
20
+ puts "Cleaned/Started Solr/Fedora/Postgres"
32
21
  end
33
22
 
34
- desc "Start solr and fedora servers for development"
35
- task :development do
36
- require 'rails'
37
- require 'solr_wrapper'
38
- require 'fcrepo_wrapper'
39
-
40
- SolrWrapper.wrap(shared_solr_opts.merge(port: 8983, instance_dir: 'tmp/blacklight-core')) do |solr|
41
- solr.with_collection(name: "blacklight-core", dir: Pathname.new(__dir__).join("..", "solr", "config").to_s) do
42
- FcrepoWrapper.wrap(shared_fedora_opts.merge(port: 8986, fcrepo_home_dir: "tmp/fcrepo4-dev-data", version: "4.7.5")) do |_fcrepo|
43
- FcrepoWrapper::Instance.new(shared_fedora_opts.merge(port: 8996, fcrepo_home_dir: "tmp/fcrepo5-dev-data", version: "5.1.0")).wrap do |_fcrepo|
44
- puts "Setup solr & Fedora"
45
- loop do
46
- sleep(1)
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
- def shared_solr_opts
55
- opts = { managed: true, verbose: true, persist: false, download_dir: "tmp" }
56
- opts[:version] = ENV['SOLR_VERSION'] if ENV['SOLR_VERSION']
57
- opts
58
- end
59
-
60
- def shared_fedora_opts
61
- opts = { managed: true, verbose: true, enable_jms: false, download_dir: "tmp" }
62
- opts
23
+ desc "Stop test servers"
24
+ task :stop do
25
+ `lando stop -y`
63
26
  end
64
27
  end
data/valkyrie.gemspec CHANGED
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'draper'
25
25
  spec.add_dependency 'activemodel'
26
26
  spec.add_dependency 'dry-types', '~> 1.0'
27
- spec.add_dependency 'rdf', '~> 3.0.10'
27
+ spec.add_dependency 'rdf', '~> 3.0', '>= 3.0.10'
28
28
  spec.add_dependency 'activesupport'
29
29
  spec.add_dependency 'railties' # To use generators and engines
30
- spec.add_dependency 'reform'
30
+ spec.add_dependency 'reform', '~> 2.2'
31
31
  spec.add_dependency 'reform-rails'
32
32
  spec.add_dependency 'json-ld'
33
33
  spec.add_dependency 'json'
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'faraday', '< 1.0'
37
37
 
38
38
  spec.add_development_dependency "bundler", "> 1.16.0", "< 3"
39
- spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rake", ">= 10"
40
40
  spec.add_development_dependency "rspec", "~> 3.0"
41
41
  spec.add_development_dependency "pry"
42
42
  spec.add_development_dependency "webmock"
@@ -47,7 +47,6 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency 'yard'
48
48
  spec.add_development_dependency 'solr_wrapper'
49
49
  spec.add_development_dependency 'fcrepo_wrapper'
50
- spec.add_development_dependency 'docker-stack', '~> 0.2.6'
51
50
  spec.add_development_dependency 'timecop'
52
51
  spec.add_development_dependency 'appraisal'
53
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkyrie
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trey Pendragon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -71,6 +71,9 @@ dependencies:
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ - - ">="
74
77
  - !ruby/object:Gem::Version
75
78
  version: 3.0.10
76
79
  type: :runtime
@@ -78,6 +81,9 @@ dependencies:
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
83
  - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '3.0'
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
88
  version: 3.0.10
83
89
  - !ruby/object:Gem::Dependency
@@ -112,16 +118,16 @@ dependencies:
112
118
  name: reform
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - ">="
121
+ - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: '0'
123
+ version: '2.2'
118
124
  type: :runtime
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - ">="
128
+ - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '0'
130
+ version: '2.2'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: reform-rails
127
133
  requirement: !ruby/object:Gem::Requirement
@@ -230,16 +236,16 @@ dependencies:
230
236
  name: rake
231
237
  requirement: !ruby/object:Gem::Requirement
232
238
  requirements:
233
- - - "~>"
239
+ - - ">="
234
240
  - !ruby/object:Gem::Version
235
- version: '10.0'
241
+ version: '10'
236
242
  type: :development
237
243
  prerelease: false
238
244
  version_requirements: !ruby/object:Gem::Requirement
239
245
  requirements:
240
- - - "~>"
246
+ - - ">="
241
247
  - !ruby/object:Gem::Version
242
- version: '10.0'
248
+ version: '10'
243
249
  - !ruby/object:Gem::Dependency
244
250
  name: rspec
245
251
  requirement: !ruby/object:Gem::Requirement
@@ -380,20 +386,6 @@ dependencies:
380
386
  - - ">="
381
387
  - !ruby/object:Gem::Version
382
388
  version: '0'
383
- - !ruby/object:Gem::Dependency
384
- name: docker-stack
385
- requirement: !ruby/object:Gem::Requirement
386
- requirements:
387
- - - "~>"
388
- - !ruby/object:Gem::Version
389
- version: 0.2.6
390
- type: :development
391
- prerelease: false
392
- version_requirements: !ruby/object:Gem::Requirement
393
- requirements:
394
- - - "~>"
395
- - !ruby/object:Gem::Version
396
- version: 0.2.6
397
389
  - !ruby/object:Gem::Dependency
398
390
  name: timecop
399
391
  requirement: !ruby/object:Gem::Requirement
@@ -422,7 +414,7 @@ dependencies:
422
414
  - - ">="
423
415
  - !ruby/object:Gem::Version
424
416
  version: '0'
425
- description:
417
+ description:
426
418
  email:
427
419
  - tpendragon@princeton.edu
428
420
  executables: []
@@ -431,9 +423,8 @@ extra_rdoc_files: []
431
423
  files:
432
424
  - ".circleci/config.yml"
433
425
  - ".ctags"
434
- - ".docker-stack/valkyrie-development/docker-compose.yml"
435
- - ".docker-stack/valkyrie-test/docker-compose.yml"
436
426
  - ".gitignore"
427
+ - ".lando.yml"
437
428
  - ".rspec"
438
429
  - ".rubocop.yml"
439
430
  - ".rubocop_todo.yml"
@@ -569,13 +560,12 @@ files:
569
560
  - solr/config/xslt/luke.xsl
570
561
  - solr/solr.xml
571
562
  - tasks/dev.rake
572
- - tasks/docker.rake
573
563
  - valkyrie.gemspec
574
564
  - valkyrie_logo.png
575
565
  homepage: https://github.com/samvera/valkyrie
576
566
  licenses: []
577
567
  metadata: {}
578
- post_install_message:
568
+ post_install_message:
579
569
  rdoc_options: []
580
570
  require_paths:
581
571
  - lib
@@ -590,9 +580,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
590
580
  - !ruby/object:Gem::Version
591
581
  version: '0'
592
582
  requirements: []
593
- rubyforge_project:
594
- rubygems_version: 2.7.6
595
- signing_key:
583
+ rubygems_version: 3.0.3
584
+ signing_key:
596
585
  specification_version: 4
597
586
  summary: An ORM using the Data Mapper pattern, specifically built to solve Digital
598
587
  Repository use cases.
@@ -1,53 +0,0 @@
1
- ---
2
- version: '3.4'
3
- volumes:
4
- fedora4:
5
- fedora5:
6
- db:
7
- solr_repo:
8
- solr_index:
9
- services:
10
- fedora4:
11
- image: samvera/fcrepo4:4.7.5
12
- volumes:
13
- - fedora4:/data
14
- ports:
15
- - 8986:8080
16
- fedora5:
17
- image: samvera/fcrepo4:5.1.0
18
- volumes:
19
- - fedora5:/data
20
- ports:
21
- - 8996:8080
22
- db:
23
- image: healthcheck/postgres:alpine
24
- volumes:
25
- - db:/data
26
- environment:
27
- - PGDATA=/data
28
- - POSTGRES_USER=docker
29
- - POSTGRES_PASSWORD=d0ck3r
30
- ports:
31
- - 5433:5432
32
- solr_repo:
33
- image: solr:7.2-alpine
34
- ports:
35
- - 8983:8983
36
- volumes:
37
- - solr_repo:/opt/solr/server/solr/mycores
38
- - "../../solr:/solr_config"
39
- entrypoint:
40
- - docker-entrypoint.sh
41
- - solr-precreate
42
- - blacklight-core
43
- - "/solr_config/config"
44
- healthcheck:
45
- test:
46
- - CMD
47
- - wget
48
- - "-O"
49
- - "/dev/null"
50
- - http://localhost:8983/solr/
51
- interval: 30s
52
- timeout: 5s
53
- retries: 3