valkyrie 3.0.0.pre.beta.1 → 3.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 240eb74a4be15202ae2036ac9a0067b1aadc23e65ad583638b6cd2874540a845
4
- data.tar.gz: 65568d10c48dcadbee70bff7c23360a6e0b149f874b5ebe493b5770afb6e4362
3
+ metadata.gz: 987aae96fd21d248254a9957cc76686714c2f434b674c712130990a0943a3d88
4
+ data.tar.gz: edbd02182ed2f107bfdf2b4516663489bae7863a524d77b3147c9c6da6b1295b
5
5
  SHA512:
6
- metadata.gz: 29b4ebfb067823191dfb2ca74151765ad8157f2c4b7b89cbecaf882e8e6f32eded31fdfb326ca198192e50574a562f8582205bab921d248707f2993b31960528
7
- data.tar.gz: 1fc174038d3baac66d35e431211ed83e38d2531395f86ecfeee106a612631d42a1f2fa11fe55a561617d3a23561763707100c701a73a06147db11bb073a60636
6
+ metadata.gz: d955568572008da1a1e11b823e6b7c1da2732aa6bdd75619f337583c8741b83601cf3477dd04da1bad2d749c6c596ad484564eab6bbf466d53daa7b93f28fa0a
7
+ data.tar.gz: 88704affe5c5f2dd8d1f58d6901eefa3d72fc8d184098922e6125c1a9f61b2d4084bc1655926d18c1bbcb861ee71e4d3426778b724aa535ce00f4659aa625ac7
data/.circleci/config.yml CHANGED
@@ -12,7 +12,7 @@ jobs:
12
12
  default: "2.6.5"
13
13
  type: "string"
14
14
  docker:
15
- - image: circleci/ruby:<< parameters.ruby >>-node-browsers
15
+ - image: cimg/ruby:<< parameters.ruby >>
16
16
  environment:
17
17
  RAILS_ENV: test
18
18
  - image: postgres:10.6-alpine
@@ -98,6 +98,18 @@ workflows:
98
98
  gemfile: "gemfiles/activerecord_6_0.gemfile"
99
99
  ruby: 2.7.0
100
100
  name: "Ruby2-7_Rails6-0"
101
+ - build:
102
+ gemfile: "gemfiles/activerecord_7_0.gemfile"
103
+ ruby: 2.7.5
104
+ name: "Ruby2-7_rails7-0"
105
+ - build:
106
+ gemfile: "gemfiles/faraday_1.gemfile"
107
+ ruby: 2.7.0
108
+ name: "Faraday1"
109
+ - build:
110
+ gemfile: "gemfiles/faraday_0.gemfile"
111
+ ruby: 2.7.0
112
+ name: "Faraday0"
101
113
  - build:
102
114
  gemfile: "gemfiles/activerecord_6_0.gemfile"
103
115
  ruby: 2.6.5
@@ -127,6 +139,14 @@ workflows:
127
139
  gemfile: "gemfiles/activerecord_6_0.gemfile"
128
140
  ruby: 2.7.0
129
141
  name: "Ruby2-7_Rails6-0"
142
+ - build:
143
+ gemfile: "gemfiles/faraday_1.gemfile"
144
+ ruby: 2.7.0
145
+ name: "Faraday1"
146
+ - build:
147
+ gemfile: "gemfiles/faraday_0.gemfile"
148
+ ruby: 2.7.0
149
+ name: "Faraday0"
130
150
  - build:
131
151
  gemfile: "gemfiles/activerecord_6_0.gemfile"
132
152
  ruby: 2.6.5
data/.rubocop.yml CHANGED
@@ -46,3 +46,6 @@ Metrics/MethodLength:
46
46
  Metrics/CyclomaticComplexity:
47
47
  Exclude:
48
48
  - 'lib/valkyrie/persistence/postgres/persister.rb'
49
+ RSpec/VerifiedDoubles:
50
+ Exclude:
51
+ - 'spec/valkyrie/persistence/postgres/metadata_adapter_spec.rb'
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.6.6
1
+ ruby 2.7.5
data/Appraisals CHANGED
@@ -1,4 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
3
+ appraise "activerecord-7-0" do
4
+ gem "activerecord", "~> 7.0.0"
5
+ end
6
+
2
7
  appraise "activerecord-6-0" do
3
8
  gem "activerecord", "~> 6.0.0"
4
9
  end
@@ -6,3 +11,13 @@ end
6
11
  appraise "activerecord-5-2" do
7
12
  gem "activerecord", "~> 5.2.0"
8
13
  end
14
+
15
+ appraise "faraday-0" do
16
+ gem "faraday", "< 1"
17
+ gem "activerecord", "~> 6.0.0"
18
+ end
19
+
20
+ appraise "faraday-1" do
21
+ gem "faraday", "~> 1.0"
22
+ gem "activerecord", "~> 6.0.0"
23
+ end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ # v3.0.0.rc1 2022-08-09
2
+
3
+ ## Unchanged from 3.0.0.beta3
4
+
5
+ # v3.0.0.beta3 2022-08-09
6
+
7
+ ## Changes since last release
8
+
9
+ * Fix Ruby 3.0 support issues
10
+ [marrus-sh](https://github.com/marrus-sh)
11
+
12
+ # v3.0.0.beta2 2022-06-15
13
+
14
+ ## Changes since last release
15
+
16
+ * Update pcdm_use warning
17
+ [dchandekstark](https://github.com/dchandekstark)
18
+ * Add support for Faraday 2
19
+ [tpendragon](https://github.com/tpendragon)
20
+ * Rails 7 Support
21
+ [cgalarza](https://github.com/cgalarza)
22
+ [tpendragon](https://github.com/tpendragon)
23
+ * Support discovery of multiple disk adapters on different paths.
24
+ [no-reply](https://github.com/tpendragon)
25
+ * New Product Owner: Alexandra Dunn!
26
+ [dunn](https://github.com/dunn)
27
+
28
+ Additional thanks to the following for code review and issue reports leading to
29
+ this release:
30
+
31
+ [cjcolvar](https://github.com/cjcolvar)
32
+
1
33
  # v3.0.0.beta1 2021-10-18
2
34
 
3
35
  ## Changes since last release
data/README.md CHANGED
@@ -17,7 +17,7 @@ Jump in: [![Slack Status](http://slack.samvera.org/badge.svg)](http://slack.samv
17
17
  ## Primary Contacts
18
18
 
19
19
  ### Product Owner
20
- [Kate Lynch](https://github.com/kelynch)
20
+ [Alexandra Dunn](https://github.com/dunn)
21
21
 
22
22
  ### Technical Lead
23
23
  [Trey Pendragon](https://github.com/tpendragon)
@@ -180,21 +180,6 @@ attribute :authors, Valkyrie::Types::Array.meta(ordered: true)
180
180
  Defining resource attributes is explained in greater detail on the [Using Types Wiki
181
181
  page](https://github.com/samvera/valkyrie/wiki/Using-Types).
182
182
 
183
- #### Work Types Generator
184
-
185
- To create a custom Valkyrie model in your application, you can use the Rails generator. For example, to
186
- generate a model named `FooBar` with an unordered `title` field and an ordered `member_ids` field:
187
-
188
- ```
189
- rails generate valkyrie:resource FooBar title member_ids:array
190
- ```
191
-
192
- You can namespace your model class by including a slash in the model name:
193
-
194
- ```
195
- rails generate valkyrie:resource Foo/Bar title member_ids:array
196
- ```
197
-
198
183
  ### Read and Write Data
199
184
  ```
200
185
  # initialize a metadata adapter
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
4
  require 'yaml'
5
- require 'config/database_connection'
5
+ require_relative 'spec/support/database_connection.rb'
6
6
  require 'active_record'
7
7
  require 'rubocop/rake_task'
8
8
  load 'tasks/dev.rake'
data/db/config.yml CHANGED
@@ -5,7 +5,7 @@ default: &default
5
5
  pool: <%= Integer(ENV.fetch("DB_POOL", 5)) %>
6
6
  reaping_frequency: <%= Integer(ENV.fetch("DB_REAPING_FREQUENCY", 10)) %>
7
7
  timeout: 5000
8
- host: localhost
8
+ host: 127.0.0.1
9
9
  username: postgres
10
10
  password:
11
11
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  # This file was generated by Appraisal
4
3
 
5
4
  source "https://rubygems.org"
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  # This file was generated by Appraisal
4
3
 
5
4
  source "https://rubygems.org"
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ # This file was generated by Appraisal
3
+
4
+ source "https://rubygems.org"
5
+
6
+ gem "activerecord", "~> 7.0.0"
7
+ gem "ldp"
8
+ gem "pg"
9
+ gem "rsolr"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # This file was generated by Appraisal
3
+
4
+ source "https://rubygems.org"
5
+
6
+ gem "activerecord", "~> 6.0.0"
7
+ gem "ldp"
8
+ gem "pg"
9
+ gem "rsolr"
10
+ gem "faraday", "< 1"
11
+
12
+ gemspec path: "../"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # This file was generated by Appraisal
3
+
4
+ source "https://rubygems.org"
5
+
6
+ gem "activerecord", "~> 6.0.0"
7
+ gem "ldp"
8
+ gem "pg"
9
+ gem "rsolr"
10
+ gem "faraday", "~> 1.0"
11
+
12
+ gemspec path: "../"
@@ -46,8 +46,14 @@ module Valkyrie::Persistence
46
46
  query_handler.queries.each do |query|
47
47
  handler = query_handler.new(query_service: query_service)
48
48
  query_handlers[query.to_sym] = handler
49
- define_singleton_method query do |*args, &block|
50
- query_handlers[query.to_sym].__send__(query, *args, &block)
49
+ define_singleton_method query do |*args, **kwargs, &block|
50
+ if kwargs.empty?
51
+ # This case needs to be specially handled in Ruby 2.6, or else an
52
+ # empty hash will be passed as the final argument.
53
+ query_handlers[query.to_sym].__send__(query, *args, &block)
54
+ else
55
+ query_handlers[query.to_sym].__send__(query, *args, **kwargs, &block)
56
+ end
51
57
  end
52
58
  end
53
59
  end
@@ -33,12 +33,10 @@ module Valkyrie::Persistence::Fedora
33
33
  # empty, tail.prev is the first element.
34
34
  def tail
35
35
  @tail ||=
36
- begin
37
- if tail_subject
38
- TailSentinel.new(self, prev_node: build_node(tail_subject))
39
- else
40
- head.next
41
- end
36
+ if tail_subject
37
+ TailSentinel.new(self, prev_node: build_node(tail_subject))
38
+ else
39
+ head.next
42
40
  end
43
41
  end
44
42
 
@@ -31,9 +31,19 @@ module Valkyrie::Persistence::Postgres
31
31
  # @return [Valkyrie::ID]
32
32
  def id
33
33
  @id ||= begin
34
- to_hash = "#{resource_factory.orm_class.connection_config['host']}:#{resource_factory.orm_class.connection_config['database']}"
34
+ to_hash = "#{connection_configuration[:host]}:#{connection_configuration[:database]}"
35
35
  Valkyrie::ID.new(Digest::MD5.hexdigest(to_hash))
36
36
  end
37
37
  end
38
+
39
+ private
40
+
41
+ def connection_configuration
42
+ if resource_factory.orm_class.respond_to?(:connection_db_config)
43
+ resource_factory.orm_class.connection_db_config.configuration_hash
44
+ else
45
+ resource_factory.orm_class.connection_config
46
+ end
47
+ end
38
48
  end
39
49
  end
@@ -37,8 +37,10 @@ module Valkyrie
37
37
  autoload :Fedora, 'valkyrie/persistence/fedora'
38
38
  class ObjectNotFoundError < StandardError
39
39
  end
40
+
40
41
  class UnsupportedDatatype < StandardError
41
42
  end
43
+
42
44
  class StaleObjectError < StandardError
43
45
  end
44
46
 
@@ -9,6 +9,7 @@ module RDF
9
9
  ::JSON::LD::API.fromRdf([RDF::Statement.new(RDF::URI(""), RDF::URI(""), self)])[0][""][0]
10
10
  end
11
11
  end
12
+
12
13
  class URI
13
14
  def as_json(*_args)
14
15
  ::JSON::LD::API.fromRdf([RDF::Statement.new(RDF::URI(""), RDF::URI(""), self)])[0][""][0]
@@ -8,6 +8,7 @@ RSpec.shared_examples 'a Valkyrie::ChangeSetPersister' do |*_flags|
8
8
  attribute :member_ids
9
9
  attribute :nested_resource
10
10
  end
11
+
11
12
  class Valkyrie::Specs::CustomChangeSet < Valkyrie::ChangeSet
12
13
  self.fields = [:title]
13
14
  end
@@ -340,7 +340,7 @@ RSpec.shared_examples 'a Valkyrie::Persister' do |*flags|
340
340
  end
341
341
 
342
342
  after do
343
- ActiveSupport::Dependencies.remove_constant("MyLockingResource")
343
+ Object.send(:remove_const, :MyLockingResource)
344
344
  end
345
345
 
346
346
  describe "#save" do
@@ -10,8 +10,10 @@ RSpec.shared_examples 'a Valkyrie query provider' do
10
10
  attribute :a_member_of, Valkyrie::Types::Array
11
11
  attribute :an_ordered_member_of, Valkyrie::Types::Array.meta(ordered: true)
12
12
  end
13
+
13
14
  class Valkyrie::Specs::SecondResource < Valkyrie::Resource
14
15
  end
16
+
15
17
  class Valkyrie::Specs::ThirdResource < Valkyrie::Resource
16
18
  attribute :a_member_of, Valkyrie::Types::Array
17
19
  attribute :an_ordered_member_of, Valkyrie::Types::Array.meta(ordered: true)
@@ -353,9 +355,11 @@ RSpec.shared_examples 'a Valkyrie query provider' do
353
355
  context "when the property is ordered for one child but not the other" do
354
356
  before do
355
357
  class Valkyrie::Specs::Parent < Valkyrie::Resource; end
358
+
356
359
  class Valkyrie::Specs::ChildWithUnorderedParents < Valkyrie::Resource
357
360
  attribute :a_member_of, Valkyrie::Types::Array
358
361
  end
362
+
359
363
  class Valkyrie::Specs::ChildWithOrderedParents < Valkyrie::Resource
360
364
  attribute :a_member_of, Valkyrie::Types::Array.meta(ordered: true)
361
365
  end
@@ -491,6 +495,26 @@ RSpec.shared_examples 'a Valkyrie query provider' do
491
495
  expect(query_service.custom_queries).to respond_to :find_by_user_id
492
496
  expect(query_service.custom_queries.find_by_user_id).to eq 1
493
497
  end
498
+
499
+ it "can register a query handler which takes keyword arguments" do
500
+ class QueryHandler
501
+ def self.queries
502
+ [:identity]
503
+ end
504
+
505
+ attr_reader :query_service
506
+ def initialize(query_service:)
507
+ @query_service = query_service
508
+ end
509
+
510
+ def identity(term:)
511
+ term
512
+ end
513
+ end
514
+ query_service.custom_queries.register_query_handler(QueryHandler)
515
+ expect(query_service.custom_queries).to respond_to :identity
516
+ expect(query_service.custom_queries.identity(term: :x)).to eq :x
517
+ end
494
518
  end
495
519
 
496
520
  context "optimistic locking" do
@@ -24,7 +24,7 @@ module Valkyrie::Storage
24
24
  # @param id [Valkyrie::ID]
25
25
  # @return [Boolean] true if this adapter can handle this type of identifer
26
26
  def handles?(id:)
27
- id.to_s.start_with?("disk://")
27
+ id.to_s.start_with?("disk://#{base_path}")
28
28
  end
29
29
 
30
30
  def file_path(id)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Valkyrie
3
- VERSION = "3.0.0-beta.1"
3
+ VERSION = "3.0.0-rc.1"
4
4
  end
@@ -47,7 +47,8 @@ module Valkyrie::Vocab
47
47
  "rdf:subClassOf": %(http://pcdm.org/resources#File),
48
48
  "rdfs:isDefinedBy": %(pcdmuse:),
49
49
  type: "rdfs:Class"
50
- warn "[DEPRECATION] PCDM is deprecating '#{self.class}#PreservationMasterFile'. Use #{self.class}#PreservationFile instead."
50
+ warn "[DEPRECATION] PCDM is deprecating '#{name}#PreservationMasterFile'. Use '#{name}#PreservationFile' instead. " \
51
+ "This warning does *not* indicate that usage of the deprecated term has been detected."
51
52
  # @deprecated
52
53
  term :PreservationMasterFile,
53
54
  comment: %(Best quality representation of the Object appropriate for long-term
data/lib/valkyrie.rb CHANGED
@@ -27,7 +27,6 @@ module Valkyrie
27
27
  require 'valkyrie/indexers/access_controls_indexer'
28
28
  require 'valkyrie/storage'
29
29
  require 'valkyrie/vocab/pcdm_use'
30
- require 'generators/valkyrie/resource_generator'
31
30
  require 'valkyrie/engine' if defined?(Rails)
32
31
  def config
33
32
  @config ||= Config.new(
@@ -74,16 +73,20 @@ module Valkyrie
74
73
  end
75
74
 
76
75
  class Config < OpenStruct
76
+ # Method lookup with OpenStruct appears to have issues in Ruby 3, so we
77
+ # unfortunately can’t just call +super+ when accessing values in the
78
+ # following methods. Using brackets works fine, though.
79
+
77
80
  def initialize(hsh = {})
78
81
  super(defaults.merge(hsh))
79
82
  end
80
83
 
81
84
  def metadata_adapter
82
- Valkyrie::MetadataAdapter.find(super.to_sym)
85
+ Valkyrie::MetadataAdapter.find(self[:metadata_adapter].to_sym)
83
86
  end
84
87
 
85
88
  def storage_adapter
86
- Valkyrie::StorageAdapter.find(super.to_sym)
89
+ Valkyrie::StorageAdapter.find(self[:storage_adapter].to_sym)
87
90
  end
88
91
 
89
92
  # @api public
@@ -97,7 +100,7 @@ module Valkyrie
97
100
  #
98
101
  # @see #default_resource_class_resolver for full interface
99
102
  def resource_class_resolver
100
- super
103
+ self[:resource_class_resolver]
101
104
  end
102
105
 
103
106
  # @!attribute [w] resource_class_resolver=
data/valkyrie.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = 'An ORM using the Data Mapper pattern, specifically built to solve Digital Repository use cases.'
14
14
  spec.homepage = "https://github.com/samvera/valkyrie"
15
+ spec.metadata = { "rubygems_mfa_required" => "true" }
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
18
  f.match(%r{^(test|spec|features)/})
@@ -31,7 +32,8 @@ Gem::Specification.new do |spec|
31
32
  spec.add_dependency 'json-ld'
32
33
  spec.add_dependency 'json'
33
34
  spec.add_dependency 'rdf-vocab'
34
- spec.add_dependency 'faraday', '< 1.0'
35
+ spec.add_dependency 'faraday', '>= 0.9', '!= 2.0.0', '< 3'
36
+ spec.add_dependency 'faraday-multipart'
35
37
 
36
38
  spec.add_development_dependency "bundler", "> 1.16.0", "< 3"
37
39
  spec.add_development_dependency "rake", ">= 10"
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: 3.0.0.pre.beta.1
4
+ version: 3.0.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trey Pendragon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -174,16 +174,42 @@ dependencies:
174
174
  name: faraday
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0.9'
180
+ - - "!="
181
+ - !ruby/object:Gem::Version
182
+ version: 2.0.0
177
183
  - - "<"
178
184
  - !ruby/object:Gem::Version
179
- version: '1.0'
185
+ version: '3'
180
186
  type: :runtime
181
187
  prerelease: false
182
188
  version_requirements: !ruby/object:Gem::Requirement
183
189
  requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0.9'
193
+ - - "!="
194
+ - !ruby/object:Gem::Version
195
+ version: 2.0.0
184
196
  - - "<"
185
197
  - !ruby/object:Gem::Version
186
- version: '1.0'
198
+ version: '3'
199
+ - !ruby/object:Gem::Dependency
200
+ name: faraday-multipart
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ type: :runtime
207
+ prerelease: false
208
+ version_requirements: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
187
213
  - !ruby/object:Gem::Dependency
188
214
  name: bundler
189
215
  requirement: !ruby/object:Gem::Requirement
@@ -428,10 +454,9 @@ files:
428
454
  - db/schema.rb
429
455
  - gemfiles/activerecord_5_2.gemfile
430
456
  - gemfiles/activerecord_6_0.gemfile
431
- - lib/config/database_connection.rb
432
- - lib/generators/valkyrie/resource_generator.rb
433
- - lib/generators/valkyrie/templates/resource.rb.erb
434
- - lib/generators/valkyrie/templates/resource_spec.rb.erb
457
+ - gemfiles/activerecord_7_0.gemfile
458
+ - gemfiles/faraday_0.gemfile
459
+ - gemfiles/faraday_1.gemfile
435
460
  - lib/valkyrie.rb
436
461
  - lib/valkyrie/adapter_container.rb
437
462
  - lib/valkyrie/change_set.rb
@@ -537,7 +562,8 @@ files:
537
562
  - valkyrie_logo.png
538
563
  homepage: https://github.com/samvera/valkyrie
539
564
  licenses: []
540
- metadata: {}
565
+ metadata:
566
+ rubygems_mfa_required: 'true'
541
567
  post_install_message:
542
568
  rdoc_options: []
543
569
  require_paths:
@@ -553,7 +579,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
553
579
  - !ruby/object:Gem::Version
554
580
  version: 1.3.1
555
581
  requirements: []
556
- rubygems_version: 3.0.3
582
+ rubygems_version: 3.1.6
557
583
  signing_key:
558
584
  specification_version: 4
559
585
  summary: An ORM using the Data Mapper pattern, specifically built to solve Digital
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'active_record'
3
- require 'erb'
4
-
5
- module DatabaseConnection
6
- def self.connect!(env)
7
- # Ref https://github.com/puma/puma#clustered-mode
8
- ActiveSupport.on_load(:active_record) do
9
- ::ActiveRecord::Base.connection_pool.disconnect! if ::ActiveRecord::Base.connected?
10
- ::ActiveRecord::Base.configurations = YAML.safe_load(ERB.new(File.read("db/config.yml")).result, [], [], true) || {}
11
- config = ::ActiveRecord::Base.configurations[env.to_s]
12
- ::ActiveRecord::Base.establish_connection(config)
13
- end
14
- end
15
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rails/generators'
3
- require 'rails/generators/model_helpers'
4
-
5
- class Valkyrie::ResourceGenerator < Rails::Generators::NamedBase
6
- # Include ModelHelpers to warn about pluralization when generating new models or scaffolds
7
- include Rails::Generators::ModelHelpers
8
-
9
- source_root File.expand_path('../templates', __FILE__)
10
-
11
- argument :attributes, type: :array, default: [], banner: 'field:type field:type'
12
-
13
- def create_model
14
- template('resource.rb.erb', File.join('app/models', class_path, "#{file_name}.rb"))
15
- end
16
-
17
- def create_model_spec
18
- return unless rspec_installed?
19
- template('resource_spec.rb.erb', File.join('spec/models', class_path, "#{file_name}_spec.rb"))
20
- end
21
-
22
- private
23
-
24
- def rspec_installed?
25
- defined?(RSpec) && defined?(RSpec::Rails)
26
- end
27
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generated with `rails generate valkyrie:model <%= class_name %>`
3
- class <%= class_name %> < Valkyrie::Resource
4
- include Valkyrie::Resource::AccessControls
5
- <%- attributes.each do |att| -%>
6
- attribute :<%= att.name %>, Valkyrie::Types::<%= (att.type == :array) ? 'Array' : 'Set' %>
7
- <%- end -%>
8
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- # Generated with `rails generate valkyrie:model <%= class_name %>`
3
- require 'rails_helper'
4
- require 'valkyrie/specs/shared_specs'
5
-
6
- RSpec.describe <%= class_name %> do
7
- let(:resource_klass) { described_class }
8
- it_behaves_like "a Valkyrie::Resource"
9
-
10
- it "has tests" do
11
- skip "Add your tests here"
12
- end
13
- end