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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1bbec50b7c38ae5d7237b14c02a79d642beeaf0c01c24584626ba2fc3c779b7
4
- data.tar.gz: 700e8fddc49bde6d7e7d02a0f22e23c2fd4ee7d2a349f35bfd27e83fc16a7bcf
3
+ metadata.gz: 2d82ceafa985dc327a594ad39da9f4feb343579e6330ae7f30a6fd7894471083
4
+ data.tar.gz: 56f54340890de9a799588b47eb4fb3ee6f400d598db03c7bf97d4163d128d831
5
5
  SHA512:
6
- metadata.gz: e4b898b35816e9a16e53fa2e8ecfb0ec239693a9f5806b9f56e32a4c129aab298faaa25dbea40d0ff57d98995a80d613d351953042721a450480871646bdaa14
7
- data.tar.gz: 1af95775fc3424cf09237045c2e26406ab0f4736a1ecfb4454f6628d329fd8743a9cad24179587e9212517c5839bd8eb28349e2cf668125efefc5485f72c1314
6
+ metadata.gz: 2676a955ae6333f4c9b82a4f2a0e131bb235e4cdef8b05951bdfb787ac1218a9e2da410a476928482824b909a12ade0f2d6e2074915c3738922ca4f3a8004337
7
+ data.tar.gz: 67a8b919a2ce033240db9d8b507140f84a8c49edfbf7283f205a41a7a09d2ba99940e5c465f0959cc27ce707e52d68b5e2d04a0f67376f482ae560c4713608ee
data/.circleci/config.yml CHANGED
@@ -2,7 +2,6 @@
2
2
  version: 2.1
3
3
  jobs:
4
4
  build:
5
- machine: true
6
5
  parameters:
7
6
  gemfile:
8
7
  description: "Gemfile to run"
@@ -12,32 +11,42 @@ jobs:
12
11
  description: "Ruby version"
13
12
  default: "2.6.5"
14
13
  type: "string"
14
+ docker:
15
+ - image: circleci/ruby:<< parameters.ruby >>-node-browsers
16
+ environment:
17
+ RAILS_ENV: test
18
+ - image: postgres:10.6-alpine
19
+ environment:
20
+ POSTGRES_USER: postgres
21
+ POSTGRES_DB: Valkyrie_gem_test
22
+ POSTGRES_HOST_AUTH_METHOD: trust
23
+ - image: samvera/fcrepo4:4.7.5
24
+ environment:
25
+ CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
26
+ JAVA_OPTIONS: "-Djetty.http.port=8988"
27
+ - image: samvera/fcrepo4:5.1.0
28
+ environment:
29
+ CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
30
+ JAVA_OPTIONS: "-Djetty.http.port=8998 -Dfcrepo.dynamic.jms.port=61618 -Dfcrepo.dynamic.stomp.port=61614"
31
+ - image: solr:7.7-alpine
32
+ command: bin/solr -cloud -noprompt -f -p 8994
15
33
  environment:
16
34
  BUNDLE_GEMFILE: << parameters.gemfile >>
35
+ POSTGRES_PORT: 5432
17
36
  steps:
18
37
  - checkout
19
38
  - run:
20
- name: Set ruby version to << parameters.ruby >>
21
- command: |
22
- rvm install << parameters.ruby >>
23
- echo . $(rvm << parameters.ruby >> do rvm env --path) >> $BASH_ENV
24
- - run:
25
- shell: /bin/bash -l
26
- name: Uninstall global Bundler
27
- command: |
28
- rvm use << parameters.ruby >>
29
- rvm gemset use global
30
- gem uninstall bundler -x
31
- echo Uninstalled
39
+ name: Wait for solr
40
+ command: dockerize -wait tcp://localhost:8994 -timeout 1m
32
41
  - run:
33
- name: Install Docker Compose
42
+ name: Load config into solr
34
43
  command: |
35
- curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
36
- chmod +x ~/docker-compose
37
- sudo mv ~/docker-compose /usr/local/bin/docker-compose
38
- - run:
39
- name: Update bundler
40
- command: gem install bundler -v 1.17.2
44
+ cd solr/config
45
+ zip -1 -r solr_config.zip ./*
46
+ curl -H "Content-type:application/octet-stream" --data-binary @solr_config.zip "http://localhost:8994/solr/admin/configs?action=UPLOAD&name=valkyrie"
47
+ curl -H 'Content-type: application/json' http://localhost:8994/api/collections/ -d '{create: {name: valkyrie-core-test, config: valkyrie, numShards: 1}}'
48
+ # Install Bundler
49
+ - run: gem install bundler -v '~> 2.0'
41
50
  - restore_cache:
42
51
  keys:
43
52
  - bundle-{{ checksum "<< parameters.gemfile >>" }}-{{ checksum "valkyrie.gemspec" }}-<< parameters.ruby >>-6
@@ -57,9 +66,12 @@ jobs:
57
66
  - run:
58
67
  name: Run Rubocop
59
68
  command: bundle exec rake rubocop
69
+ - run:
70
+ name: Set up database
71
+ command: bundle exec rake db:migrate
60
72
  - run:
61
73
  name: Run Specs
62
- command: bundle exec rake docker:spec
74
+ command: bundle exec rspec spec
63
75
  - store_artifacts:
64
76
  path: coverage
65
77
  destination: coverage
@@ -87,10 +99,6 @@ workflows:
87
99
  gemfile: "gemfiles/activerecord_5_2.gemfile"
88
100
  ruby: 2.5.7
89
101
  name: "Ruby2-5_Rails5-2"
90
- - build:
91
- gemfile: "gemfiles/activerecord_5_2.gemfile"
92
- ruby: 2.4.9
93
- name: "Ruby2-4_Rails5-2"
94
102
  nightly:
95
103
  triggers:
96
104
  - schedule:
@@ -120,7 +128,3 @@ workflows:
120
128
  gemfile: "gemfiles/activerecord_5_2.gemfile"
121
129
  ruby: 2.5.7
122
130
  name: "Ruby2-5_Rails5-2"
123
- - build:
124
- gemfile: "gemfiles/activerecord_5_2.gemfile"
125
- ruby: 2.4.9
126
- name: "Ruby2-4_Rails5-2"
data/.lando.yml ADDED
@@ -0,0 +1,40 @@
1
+ name: valkyrie
2
+ app_mount: false
3
+ services:
4
+ valkyrie_test_solr_7:
5
+ app_mount: false
6
+ type: solr:7
7
+ portforward: 8994
8
+ core: valkyrie-core-test
9
+ config:
10
+ dir: solr/config
11
+ valkyrie_database:
12
+ app_mount: false
13
+ type: postgres:10
14
+ portforward: 5433
15
+ valkyrie_fedora_4:
16
+ type: compose
17
+ app_mount: false
18
+ volumes:
19
+ fedora4:
20
+ services:
21
+ image: samvera/fcrepo4:4.7.5
22
+ command: /fedora-entrypoint.sh
23
+ volumes:
24
+ - fedora4:/data
25
+ ports:
26
+ - 8988:8080
27
+ portforward: true
28
+ valkyrie_fedora_5:
29
+ type: compose
30
+ app_mount: false
31
+ volumes:
32
+ fedora5:
33
+ services:
34
+ image: samvera/fcrepo4:5.1.0
35
+ command: /fedora-entrypoint.sh
36
+ volumes:
37
+ - fedora5:/data
38
+ ports:
39
+ - 8998:8080
40
+ portforward: true
data/.rubocop.yml CHANGED
@@ -4,7 +4,6 @@ inherit_gem:
4
4
  bixby: bixby_default.yml
5
5
  AllCops:
6
6
  DisplayCopNames: true
7
- TargetRubyVersion: 2.3
8
7
  Exclude:
9
8
  - 'bin/*'
10
9
  - 'db/schema.rb'
@@ -26,6 +25,10 @@ RSpec/MultipleExpectations:
26
25
  Enabled: false
27
26
  Rails/TimeZone:
28
27
  Enabled: false
28
+ Rails/RakeEnvironment:
29
+ Enabled: false
30
+ Rails/ApplicationRecord:
31
+ Enabled: false
29
32
  Naming/PredicateName:
30
33
  Exclude:
31
34
  - "lib/valkyrie/resource.rb"
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.5.1
1
+ ruby 2.6.6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # v2.1.2 2020-03-12
2
+
3
+ ## Changes since last release
4
+
5
+ * Tighten reform dependency
6
+ [tpendragon](https://github.com/tpendragon)
7
+ * Loosen RDF Dependency
8
+ [no-reply](https://github.com/no-reply)
9
+ * Update development ruby version in .tool-versions
10
+ [hackartisan](https://github.com/hackartisan)
11
+ * Use Lando for development
12
+ [tpendragon](https://github.com/tpendragon)
13
+ * Deprecate Blacklist in favor of Denylist.
14
+ [jeremyf](https://github.com/jeremyf)
15
+ * Make DateTime handling in Fedora/Solr persisters consistent with others.
16
+ [hcayless](https://github.com/hcayless)
17
+ * Add open-ended Rake support.
18
+ [no-reply](https://github.com/no-reply)
19
+
20
+ Additional thanks to the following for code review and issue reports leading to
21
+ this release:
22
+
23
+ [cjcolvar](https://github.com/cjcolvar)
24
+ [escowles](https://github.com/escowles)
25
+ [jeremyf](https://github.com/jeremyf)
26
+
1
27
  # v2.1.1 2020-03-12
2
28
 
3
29
  ## Changes since last release
data/README.md CHANGED
@@ -252,53 +252,25 @@ config. If Fedora requires auth, you can also include that in the URL, e.g.:
252
252
 
253
253
  ## Installing a Development environment
254
254
 
255
- ### With Docker
256
- The development and test stacks use fully contained virtual volumes and bind all services to different ports,
257
- so they can be running at the same time without issue.
258
-
259
- #### External Requirements
260
- * [Docker](https://store.docker.com/search?offering=community&type=edition) version >= 17.09.0
261
-
262
- ### Dependency Setup (Mac OSX)
263
- 1. `brew install docker`
264
- 1. `brew install docker-machine`
265
- 1. `brew install docker-compose`
266
-
267
- ### Starting Docker (Mac OSX)
268
- 1. `docker-machine create default`
269
- 1. `docker-machine start default`
270
- 1. `eval "$(docker-machine env)"`
271
-
272
- #### Starting the development mode dependencies
273
- 1. Start Solr, Fedora, and PostgreSQL with `rake docker:dev:daemon` (or `rake docker:dev:up` in a separate
274
- shell to run them in the foreground)
275
- 1. Run `rake db:create db:migrate` to initialize the database
276
- 1. Develop!
277
- 1. Run `rake docker:dev:down` to stop the server stack
278
- * Development servers maintain data between runs. To clean them out, run `rake docker:dev:clean`
279
-
280
- #### To run the test suite with all dependencies in one go
281
- 1. `rake docker:spec`
282
-
283
- #### To run the test suite manually
284
- 1. Start Solr, Fedora, and PostgreSQL with `rake docker:test:daemon` (or `rake docker:test:up` in a separate
285
- shell to run them in the foreground)
286
- 1. Run `rake db:create db:migrate` to initialize the database
287
- 1. Run the gem's RSpec test suite with `rspec spec` or `rake`
288
- 1. Run `rake docker:test:down` to stop the server stack
289
- * The test stack cleans up after itself on exit.
290
-
291
- ### Without Docker
292
-
293
- #### External Requirements
294
- * PostgreSQL with the uuid-ossp extension.
295
- * Note: Enabling uuid-ossp requires database superuser privileges.
296
- * From `psql`: `alter user [username] with superuser;`
297
-
298
- #### To run the test suite
299
- 1. Start Solr and Fedora servers for testing with `rake server:test`
300
- 1. Run `rake db:create` (First time only)
301
- 1. Run `rake db:migrate`
255
+ For ease of development we use Lando to abstract away some complications of
256
+ using Docker containers for development.
257
+
258
+ ### Running Tests
259
+
260
+ 1. Install the latest released > 3.0 version of Lando from [here](https://github.com/lando/lando/releases).
261
+ 2. `bundle install`
262
+ 3. `bundle exec rake server:start`
263
+ 4. `bundle exec rspec spec`
264
+
265
+ ### Cleaning Data
266
+
267
+ 1. `bundle exec rake server:clean`
268
+
269
+ ### Stopping Servers
270
+
271
+ 1. `bundle exec rake server:stop`
272
+
273
+ You can also run `lando poweroff` from anywhere.
302
274
 
303
275
  ## Acknowledgments
304
276
 
data/Rakefile CHANGED
@@ -6,7 +6,6 @@ require 'config/database_connection'
6
6
  require 'active_record'
7
7
  require 'rubocop/rake_task'
8
8
  load 'tasks/dev.rake'
9
- load 'tasks/docker.rake'
10
9
 
11
10
  RSpec::Core::RakeTask.new(:spec)
12
11
 
@@ -37,8 +36,12 @@ namespace :db do
37
36
 
38
37
  desc 'Create the database from db/config.yml for the current DATABASE_ENV'
39
38
  task create: :configure_connection do
40
- database = ActiveRecord::Tasks::PostgreSQLDatabaseTasks.new(@config)
41
- database.create
39
+ begin
40
+ database = ActiveRecord::Tasks::PostgreSQLDatabaseTasks.new(@config)
41
+ database.create
42
+ rescue
43
+ puts "Database already exists."
44
+ end
42
45
  puts "Database created"
43
46
  end
44
47
 
@@ -51,25 +54,23 @@ namespace :db do
51
54
 
52
55
  desc 'Migrate the database (options: VERSION=x, VERBOSE=false).'
53
56
  task migrate: :configure_connection do
54
- begin
55
- verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
56
- version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
57
- scope = ENV['SCOPE']
58
- verbose_was = ActiveRecord::Migration.verbose
59
- ActiveRecord::Migration.verbose = verbose
60
- if ActiveRecord::Migrator.respond_to?(:migrate)
61
- ActiveRecord::Migrator.migrate(MIGRATIONS_DIR, version) do |migration|
62
- scope.blank? || scope == migration.scope
63
- end
64
- else
65
- ActiveRecord::Base.connection.migration_context.migrate(version) do |migration|
66
- scope.blank? || scope == migration.scope
67
- end
57
+ verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
58
+ version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
59
+ scope = ENV['SCOPE']
60
+ verbose_was = ActiveRecord::Migration.verbose
61
+ ActiveRecord::Migration.verbose = verbose
62
+ if ActiveRecord::Migrator.respond_to?(:migrate)
63
+ ActiveRecord::Migrator.migrate(MIGRATIONS_DIR, version) do |migration|
64
+ scope.blank? || scope == migration.scope
65
+ end
66
+ else
67
+ ActiveRecord::Base.connection.migration_context.migrate(version) do |migration|
68
+ scope.blank? || scope == migration.scope
68
69
  end
69
- ActiveRecord::Base.clear_cache!
70
- ensure
71
- ActiveRecord::Migration.verbose = verbose_was
72
70
  end
71
+ ActiveRecord::Base.clear_cache!
72
+ ensure
73
+ ActiveRecord::Migration.verbose = verbose_was
73
74
  end
74
75
 
75
76
  namespace :schema do
data/db/config.yml CHANGED
@@ -1,4 +1,3 @@
1
- <% local = File.exist?('/tmp/.s.PGSQL.5432') && File.stat('/tmp/.s.PGSQL.5432').socket? %>
2
1
  default: &default
3
2
  adapter: postgresql
4
3
  encoding: utf8
@@ -6,22 +5,16 @@ default: &default
6
5
  pool: <%= Integer(ENV.fetch("DB_POOL", 5)) %>
7
6
  reaping_frequency: <%= Integer(ENV.fetch("DB_REAPING_FREQUENCY", 10)) %>
8
7
  timeout: 5000
9
- <% unless local %>
10
8
  host: localhost
11
- username: docker
12
- password: d0ck3r
13
- <% end %>
9
+ username: postgres
10
+ password:
14
11
 
15
12
  development:
16
13
  <<: *default
17
14
  database: Valkyrie_gem_development
18
- <% unless local %>
19
15
  port: 5433
20
- <% end %>
21
16
 
22
17
  test:
23
18
  <<: *default
24
19
  database: Valkyrie_gem_test
25
- <% unless local %>
26
- port: 5434
27
- <% end %>
20
+ port: <%= ENV["POSTGRES_PORT"] || 5433 %>
@@ -21,7 +21,7 @@ class Valkyrie::ResourceGenerator < Rails::Generators::NamedBase
21
21
 
22
22
  private
23
23
 
24
- def rspec_installed?
25
- defined?(RSpec) && defined?(RSpec::Rails)
26
- end
24
+ def rspec_installed?
25
+ defined?(RSpec) && defined?(RSpec::Rails)
26
+ end
27
27
  end
data/lib/valkyrie.rb CHANGED
@@ -119,19 +119,19 @@ module Valkyrie
119
119
 
120
120
  private
121
121
 
122
- def defaults
123
- {
124
- resource_class_resolver: method(:default_resource_class_resolver)
125
- }
126
- end
127
-
128
- # String constantize is a "by convention" factory. This works, but assumes
129
- # the ruby class once used to persist is the model used to now reify.
130
- #
131
- # @param [String] class_name
132
- def default_resource_class_resolver(class_name)
133
- class_name.constantize
134
- end
122
+ def defaults
123
+ {
124
+ resource_class_resolver: method(:default_resource_class_resolver)
125
+ }
126
+ end
127
+
128
+ # String constantize is a "by convention" factory. This works, but assumes
129
+ # the ruby class once used to persist is the model used to now reify.
130
+ #
131
+ # @param [String] class_name
132
+ def default_resource_class_resolver(class_name)
133
+ class_name.constantize
134
+ end
135
135
  end
136
136
 
137
137
  module_function :config, :logger, :logger=, :config_root_path, :environment, :config_file, :config_hash
@@ -104,8 +104,8 @@ module Valkyrie
104
104
 
105
105
  private
106
106
 
107
- def field(field_name)
108
- self.class.definitions.fetch(field_name.to_s)
109
- end
107
+ def field(field_name)
108
+ self.class.definitions.fetch(field_name.to_s)
109
+ end
110
110
  end
111
111
  end
data/lib/valkyrie/id.rb CHANGED
@@ -32,22 +32,22 @@ module Valkyrie
32
32
 
33
33
  protected
34
34
 
35
- def default_equality(other)
36
- output = (other.class == self.class && other.state == state)
37
- return output if output == true
38
- if output == false && string_equality(other) && Valkyrie.config.id_string_equality.nil?
39
- warn "[DEPRECATION] Valkyrie::IDs will always be equal to their string counterparts in 3.0.0. " \
40
- "To silence this message, please either compare IDs or set Valkyrie.config.id_string_equality = true."
41
- end
42
- false
35
+ def default_equality(other)
36
+ output = (other.class == self.class && other.state == state)
37
+ return output if output == true
38
+ if output == false && string_equality(other) && Valkyrie.config.id_string_equality.nil?
39
+ warn "[DEPRECATION] Valkyrie::IDs will always be equal to their string counterparts in 3.0.0. " \
40
+ "To silence this message, please either compare IDs or set Valkyrie.config.id_string_equality = true."
43
41
  end
42
+ false
43
+ end
44
44
 
45
- def string_equality(other)
46
- other == to_str
47
- end
45
+ def string_equality(other)
46
+ other == to_str
47
+ end
48
48
 
49
- def state
50
- [@id]
51
- end
49
+ def state
50
+ [@id]
51
+ end
52
52
  end
53
53
  end