valkyrie_active_fedora 0.0.1 → 0.0.2

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: bb3204d5ea81515a5c5d414acc6b5413dfa2f80f793abab6f05b607771968c24
4
- data.tar.gz: 6544d26ef4518f6f9f97282fad146cf6b392257eea6a915f1115fc31184208b5
3
+ metadata.gz: 5e709de85b0b59a24e41e32aee09d7e9f74bcd2f2659e3d0f65f0df7101e55b9
4
+ data.tar.gz: 040bf354db71abc71e9642ed0a32706dbc356c1e745c50853920f68459768838
5
5
  SHA512:
6
- metadata.gz: 8989d36fef448474e3de820eb6bb6aad5f9bada51ccb9663ebc349ae138b05252e4c30da8ed22b7cd56156a1ac8658b79fbe61d4084ec39b699b2182afe275a3
7
- data.tar.gz: 1e3da26fff5f7a745b78888dc58a6090a25c2eddbd96c8f2cd0b9257fb3f5edb0241fe2d5362734602adb5eb5311ecf8ea65d956b9bfbd693921034533291d24
6
+ metadata.gz: acb5eb00f9d1601967c49f883390478d09c57a050b304cee177904d3c821416be8b010fa2aa508e12d7296724db79fc928377cbd9308f2cc63ab8d40ac0a7038
7
+ data.tar.gz: cd95a1245819eb9d05c624d8568b2d8a3d0dba6c44bc763ddae70be25f5518a56512f87ec6e766f9ac29e8810ff6171df83f73a31f01eb29c1be16c852be34bb
data/.rubocop.yml CHANGED
@@ -19,8 +19,6 @@ Lint/HandleExceptions:
19
19
  Exclude:
20
20
  - 'spec/unit/**/*'
21
21
  - 'spec/integration/**/*'
22
- - 'lib/active_fedora/cleaner.rb'
23
- - 'lib/active_fedora/associations/builder/has_subresource.rb'
24
22
 
25
23
  Lint/AssignmentInCondition:
26
24
  Enabled: false
@@ -31,130 +29,9 @@ Metrics/LineLength:
31
29
  Metrics/AbcSize:
32
30
  Enabled: false
33
31
 
34
- Metrics/BlockNesting:
35
- Exclude:
36
- - 'lib/active_fedora/autosave_association.rb'
37
- - 'lib/active_fedora/associations/has_many_association.rb'
38
-
39
- Metrics/CyclomaticComplexity:
40
- Exclude:
41
- - 'lib/active_fedora.rb'
42
- - 'lib/active_fedora/core.rb'
43
- - 'lib/active_fedora/reflection.rb'
44
- - 'lib/active_fedora/relation/finder_methods.rb'
45
- - 'lib/active_fedora/query_result_builder.rb'
46
- - 'lib/active_fedora/nested_attributes.rb'
47
- - 'lib/active_fedora/autosave_association.rb'
48
- - 'lib/active_fedora/associations/has_many_association.rb'
49
- - 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
50
- - 'lib/active_fedora/associations/builder/indirectly_contains.rb'
51
- - 'lib/active_fedora/associations/builder/directly_contains_one.rb'
52
- - 'lib/active_fedora/file_configurator.rb'
53
- - 'lib/active_fedora/file.rb'
54
- - 'lib/active_fedora/attribute_methods.rb'
55
- - 'lib/active_fedora/scoping/named.rb'
56
- - 'lib/active_fedora/indexing/field_mapper.rb'
57
- - 'lib/active_fedora/indexing/suffix.rb'
58
- - 'lib/active_fedora/inheritance.rb'
59
-
60
- Metrics/PerceivedComplexity:
61
- Exclude:
62
- - 'lib/active_fedora.rb'
63
- - 'lib/active_fedora/relation/finder_methods.rb'
64
- - 'lib/active_fedora/nested_attributes.rb'
65
- - 'lib/active_fedora/file_configurator.rb'
66
- - 'lib/active_fedora/autosave_association.rb'
67
- - 'lib/active_fedora/associations/has_many_association.rb'
68
- - 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
69
- - 'lib/active_fedora/associations/builder/indirectly_contains.rb'
70
- - 'lib/active_fedora/associations/builder/directly_contains_one.rb'
71
- - 'lib/active_fedora/associations/collection_association.rb'
72
- - 'lib/active_fedora/attribute_methods.rb'
73
- - 'lib/active_fedora/scoping/named.rb'
74
- - 'lib/active_fedora/indexing/field_mapper.rb'
75
- - 'lib/active_fedora/inheritance.rb'
76
-
77
- Metrics/ModuleLength:
78
- Exclude:
79
- - 'lib/active_fedora.rb'
80
- - 'lib/active_fedora/relation/finder_methods.rb'
81
- - 'lib/active_fedora/persistence.rb'
82
- - 'lib/active_fedora/attributes.rb'
83
- - 'lib/active_fedora/autosave_association.rb'
84
- - 'lib/active_fedora/attached_files.rb'
85
- - 'lib/active_fedora/nested_attributes.rb'
86
-
87
- Metrics/ClassLength:
88
- Exclude:
89
- - 'lib/active_fedora/rdf/fcrepo.rb'
90
- - 'lib/active_fedora/file_configurator.rb'
91
- - 'lib/active_fedora/file.rb'
92
- - 'lib/active_fedora/associations/association.rb'
93
- - 'lib/active_fedora/associations/builder/association.rb'
94
- - 'lib/active_fedora/associations/collection_proxy.rb'
95
- - 'lib/active_fedora/associations/collection_association.rb'
96
- - 'lib/active_fedora/reflection.rb'
97
- - 'lib/active_fedora/orders/ordered_list.rb'
98
- - 'lib/active_fedora/solr_service.rb'
99
- - 'lib/active_fedora/associations/orders_association.rb'
100
-
101
32
  Metrics/MethodLength:
102
33
  Enabled: false
103
34
 
104
- Naming/MethodName:
105
- Exclude:
106
- - 'lib/active_fedora/with_metadata.rb'
107
-
108
- Style/AndOr:
109
- Exclude:
110
- - 'lib/active_fedora/associations/has_many_association.rb'
111
-
112
- Naming/AccessorMethodName:
113
- Exclude:
114
- - 'lib/active_fedora/with_metadata/metadata_node.rb'
115
- - 'lib/active_fedora/fedora_attributes.rb'
116
- - 'lib/active_fedora/attribute_methods/dirty.rb'
117
- - 'lib/active_fedora/associations/has_many_association.rb'
118
- - 'lib/active_fedora/associations/association.rb'
119
-
120
- Naming/PredicateName:
121
- Exclude:
122
- - 'lib/active_fedora/attribute_methods.rb'
123
- - 'lib/active_fedora/relation/finder_methods.rb'
124
- - 'lib/active_fedora/versionable.rb'
125
- - 'lib/active_fedora/reflection.rb'
126
- - 'lib/active_fedora/pathing.rb'
127
- - 'lib/active_fedora/nested_attributes.rb'
128
- - 'lib/active_fedora/clean_connection.rb'
129
- - 'lib/active_fedora/attributes.rb'
130
- - 'lib/active_fedora/file/attributes.rb'
131
- - 'lib/active_fedora/attached_files.rb'
132
- - 'lib/active_fedora/associations.rb'
133
- - 'lib/active_fedora/association_hash.rb'
134
- - 'lib/active_fedora/aggregation/list_source.rb'
135
- - 'lib/active_fedora/associations/builder/aggregation.rb'
136
- - 'lib/active_fedora/indexing/suffix.rb'
137
-
138
- Style/GuardClause:
139
- Exclude:
140
- - 'lib/active_fedora/autosave_association.rb'
141
-
142
- Style/TrivialAccessors:
143
- Exclude:
144
- - 'lib/active_fedora/reflection.rb'
145
- - 'lib/active_fedora/attributes/node_config.rb'
146
- - 'lib/active_fedora/associations/directly_contains_one_association.rb'
147
- - 'lib/active_fedora/associations/belongs_to_association.rb'
148
- - 'lib/active_fedora/associations/association.rb'
149
-
150
- Style/EachWithObject:
151
- Exclude:
152
- - 'lib/active_fedora/relation/finder_methods.rb'
153
-
154
- Style/CaseEquality:
155
- Exclude:
156
- - 'lib/active_fedora/relation/finder_methods.rb'
157
-
158
35
  Style/BlockDelimiters:
159
36
  Exclude:
160
37
  - 'spec/**/*'
@@ -210,26 +87,11 @@ Style/SingleLineBlockParams:
210
87
 
211
88
  Style/ClassVars:
212
89
  Exclude:
213
- - 'spec/unit/finder_methods_spec.rb'
214
90
  - 'spec/unit/base_spec.rb'
215
- - 'spec/integration/indexing_spec.rb'
216
- - 'lib/active_fedora/identifiable.rb'
217
91
 
218
92
  Style/SignalException:
219
93
  Enabled: false
220
94
 
221
- Naming/FileName:
222
- Exclude:
223
- - 'lib/active-fedora.rb'
224
-
225
- Style/ZeroLengthPredicate:
226
- Exclude:
227
- - 'lib/active_fedora/file/attributes.rb'
228
-
229
- Performance/RedundantMerge:
230
- Exclude:
231
- - 'lib/active_fedora/railtie.rb'
232
-
233
95
  Rails:
234
96
  Enabled: true
235
97
 
@@ -265,10 +127,6 @@ RSpec/DescribeClass:
265
127
  Exclude:
266
128
  - 'spec/integration/**/*'
267
129
 
268
- RSpec/DescribedClass:
269
- Exclude:
270
- - 'spec/unit/finder_methods_spec.rb'
271
-
272
130
  RSpec/NotToNot:
273
131
  Enabled: false
274
132
 
data/.solr_wrapper CHANGED
@@ -2,5 +2,5 @@
2
2
  # version: 6.1.0
3
3
  port: 8985
4
4
  collection:
5
- dir: lib/generators/active_fedora/config/solr/templates/solr/config/
5
+ dir: lib/generators/valkyrie_active_fedora/config/solr/templates/solr/config/
6
6
  name: hydra-test
@@ -2,7 +2,7 @@ Description:
2
2
  Generate ActiveFedora config files
3
3
 
4
4
  Example:
5
- rails generate active_fedora:config
5
+ rails generate valkyrie_active_fedora:config
6
6
 
7
7
  This will create:
8
8
  config/fedora.yml
@@ -1,10 +1,10 @@
1
1
  require 'rails/generators'
2
2
 
3
- module ActiveFedora
3
+ module ValkyrieActiveFedora
4
4
  class ConfigGenerator < Rails::Generators::Base
5
5
  def generate_configs
6
- generate('active_fedora:config:fedora')
7
- generate('active_fedora:config:solr')
6
+ generate('valkyrie_active_fedora:config:fedora')
7
+ generate('valkyrie_active_fedora:config:solr')
8
8
  end
9
9
  end
10
10
  end
@@ -2,7 +2,7 @@ Description:
2
2
  Generate a class that inherits from ActiveFedora::Base
3
3
 
4
4
  Example:
5
- rails generate active_fedora:model Journal
5
+ rails generate valkyrie_active_fedora:model Journal
6
6
 
7
7
  This will create:
8
8
  app/models/journal.rb
@@ -1,6 +1,6 @@
1
1
  # Generated via
2
- # `rails generate active_fedora:model <%= class_name %>`
3
- class <%= class_name %>Metadata < ActiveFedora::OmDatastream
2
+ # `rails generate valkyrie_active_fedora:model <%= class_name %>`
3
+ class <%= class_name %>Metadata < ValkyrieActiveFedora::OmDatastream
4
4
 
5
5
  # Define a terminology for parsing this XML document
6
6
  # See: https://github.com/samvera/om/wiki/Tame-your-XML-with-OM
@@ -1,5 +1,5 @@
1
1
  # Generated via
2
- # `rails generate active_fedora:model <%= class_name %>`
2
+ # `rails generate valkyrie_active_fedora:model <%= class_name %>`
3
3
  require 'rails_helper'
4
4
 
5
5
  describe <%= class_name %>Metadata do
@@ -1,6 +1,6 @@
1
1
  # Generated via
2
- # `rails generate active_fedora:model <%= class_name %>`
3
- class <%= class_name %> < ActiveFedora::Base
2
+ # `rails generate valkyrie_active_fedora:model <%= class_name %>`
3
+ class <%= class_name %> < ValkyrieActiveFedora::Base
4
4
  <% if options['datastream'] %>
5
5
  has_subresource :descMetadata, class_name: "<%= options['datastream'] %>"
6
6
  <% else %>
@@ -1,7 +1,7 @@
1
1
  # Generated via
2
- # `rails generate active_fedora:model <%= class_name %>`
2
+ # `rails generate valkyrie_active_fedora:model <%= class_name %>`
3
3
  require 'rails_helper'
4
- require 'active_fedora/test_support'
4
+ require 'valkyrie_active_fedora/test_support'
5
5
 
6
6
  describe <%= class_name %> do
7
7
  it_behaves_like 'An ActiveModel'
@@ -2,7 +2,7 @@ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
2
2
 
3
3
  require 'solr_wrapper'
4
4
  require 'fcrepo_wrapper'
5
- require 'active_fedora/rake_support'
5
+ require 'valkyrie_active_fedora/rake_support'
6
6
 
7
7
  namespace :valkyrie_active_fedora do
8
8
  # Use yard to build docs
@@ -41,12 +41,23 @@ namespace :valkyrie_active_fedora do
41
41
  spec.rcov = true
42
42
  end
43
43
 
44
- desc "CI build"
45
- task :ci do
46
- Rake::Task['valkyrie_active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
44
+ # desc "CI build"
45
+ # task :ci do
46
+ # Rake::Task['valkyrie_active_fedora:rubocop'].invoke unless ENV['NO_RUBOCOP']
47
+ # ENV['environment'] = "test"
48
+ # with_test_server do
49
+ # Rake::Task['valkyrie_active_fedora:coverage'].invoke
50
+ # end
51
+ # end
52
+
53
+ task ci: [:rubocop] do
54
+ require 'solr_wrapper' # necessary for rake_support to work
55
+ require 'fcrepo_wrapper' # necessary for rake_support to work
56
+ require 'active_fedora/rake_support'
57
+
47
58
  ENV['environment'] = "test"
48
59
  with_test_server do
49
- Rake::Task['valkyrie_active_fedora:coverage'].invoke
60
+ Rake::Task['spec'].invoke
50
61
  end
51
62
  end
52
63
 
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'valkyrie_active_fedora/engine'
3
2
  require 'valkyrie_active_fedora/version'
4
3
 
5
4
  module ValkyrieActiveFedora
@@ -0,0 +1,45 @@
1
+ require 'byebug'
2
+
3
+ # Starts a fedora server and a solr server on a random port and then
4
+ # yields the passed block
5
+ def with_test_server(&block)
6
+ with_server('test', &block)
7
+ end
8
+
9
+ def with_server(environment)
10
+ return yield if ENV["#{environment}_SERVER_STARTED"]
11
+
12
+ ENV["#{environment}_SERVER_STARTED"] = 'true'
13
+
14
+ # setting port: nil assigns a random port.
15
+ solr_defaults = { port: nil, verbose: true, managed: true }
16
+ fcrepo_defaults = { port: nil, verbose: true, managed: true,
17
+ enable_jms: false, fcrepo_home_dir: "tmp/fcrepo4-#{environment}-data" }
18
+
19
+ SolrWrapper.wrap(load_config(:solr, environment, solr_defaults)) do |solr|
20
+ ENV["SOLR_#{environment.upcase}_PORT"] = solr.port.to_s
21
+ solr_config_path = File.join('solr', 'config')
22
+ # Check to see if configs exist in a path relative to the working directory
23
+ unless Dir.exist?(solr_config_path)
24
+ $stderr.puts "Solr configuration not found at #{solr_config_path}. Using ValkyrieActiveFedora defaults"
25
+ # Otherwise use the configs delivered with ValkyrieActiveFedora.
26
+ byebug
27
+ solr_config_path = File.join(File.expand_path("../..", File.dirname(__FILE__)), 'lib', 'generators', 'valkyrie_active_fedora', 'config', 'solr', 'templates', 'solr', 'config')
28
+ end
29
+ solr.with_collection(name: "hydra-#{environment}", dir: solr_config_path) do
30
+ FcrepoWrapper.wrap(load_config(:fcrepo, environment, fcrepo_defaults)) do |fcrepo|
31
+ ENV["FCREPO_#{environment.upcase}_PORT"] = fcrepo.port.to_s
32
+ yield
33
+ end
34
+ end
35
+ end
36
+ ENV["#{environment}_SERVER_STARTED"] = 'false'
37
+ end
38
+
39
+ private
40
+
41
+ def load_config(service, environment, defaults)
42
+ config_file = environment == 'test' ? "config/#{service}_wrapper_test.yml" : ".#{service}_wrapper"
43
+ return { config: config_file } if File.exist?(config_file)
44
+ defaults
45
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ValkyrieActiveFedora
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  ENV["environment"] ||= "test"
2
+ ENV["RAILS_ENV"] ||= "test"
2
3
 
3
4
  require "bundler/setup"
4
5
  require 'simplecov'
@@ -33,4 +33,42 @@ describe ValkyrieActiveFedora::Base do
33
33
  expect(foo_history.valkyrie_resource).to eq nil
34
34
  end
35
35
  end
36
+
37
+ describe '#attributes_including_linked_ids' do
38
+ context 'for has_many and belongs_to relationships' do
39
+ before :all do
40
+ class Library < ValkyrieActiveFedora::Base
41
+ has_many :books
42
+ end
43
+ class Book < ValkyrieActiveFedora::Base
44
+ belongs_to :library, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf
45
+ end
46
+ end
47
+
48
+ after :all do
49
+ Object.send(:remove_const, :Library)
50
+ Object.send(:remove_const, :Book)
51
+ end
52
+
53
+ let(:library1) { Library.create(id: 'lib1', books: [book1]) }
54
+ # let(:book1) { Book.create(id: 'bk1', library: library1) }
55
+ let(:book1) { Book.create(id: 'bk1') }
56
+
57
+ before do
58
+ book1.library = library1
59
+ book1.save
60
+ end
61
+
62
+ it "inserts ids of child objects into parent's attributes" do
63
+ expected_results = { "id"=>"lib1", "book_ids"=>["bk1"] }
64
+ # expect(library1.attributes_including_linked_ids).to eq expected_results
65
+ expect(library1.reload.attributes_including_linked_ids).to eq expected_results
66
+ end
67
+
68
+ it "inserts ids of parent objects into child's attributes" do
69
+ expected_results = { "id"=>"bk1", "library_id"=>"lib1" }
70
+ expect(book1.reload.attributes_including_linked_ids).to eq expected_results
71
+ end
72
+ end
73
+ end
36
74
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  # http://guides.rubyonrails.org/maintenance_policy.html
20
20
  s.add_dependency 'rails', '~> 5.0' # Keep in sync with version supported by Hyrax
21
21
 
22
- s.add_development_dependency 'active-fedora'
22
+ s.add_development_dependency 'active-fedora', '~> 11.0'
23
23
  s.add_development_dependency 'valkyrie'
24
24
 
25
25
  # s.add_development_dependency 'bixby', '~> 1.0.0' # rubocop styleguide
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valkyrie_active_fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: active-fedora
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '11.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '11.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: valkyrie
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -278,13 +278,12 @@ files:
278
278
  - lib/tasks/valkyrie_active_fedora_dev.rake
279
279
  - lib/valkyrie_active_fedora.rb
280
280
  - lib/valkyrie_active_fedora/base.rb
281
- - lib/valkyrie_active_fedora/engine.rb
281
+ - lib/valkyrie_active_fedora/rake_support.rb
282
282
  - lib/valkyrie_active_fedora/version.rb
283
283
  - spec/.gitignore
284
284
  - spec/rails_helper.rb
285
285
  - spec/spec_helper.rb
286
286
  - spec/unit/base_spec.rb
287
- - tasks/valkyrie_active_fedora_dev.rake
288
287
  - valkyrie_active_fedora.gemspec
289
288
  homepage: http://github.com/samvera-labs/valkyrie_active_fedora
290
289
  licenses:
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- module ValkyrieActiveFedora
3
- class Engine < ::Rails::Engine
4
- isolate_namespace ValkyrieActiveFedora
5
-
6
- require 'valkyrie_active_fedora'
7
-
8
- # def self.engine_mount
9
- # ValkyrieActiveFedora::Engine.routes.find_script_name({})
10
- # end
11
- end
12
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'rspec/core/rake_task'
3
- require 'engine_cart/rake_task'
4
- require 'rubocop/rake_task'
5
-
6
- desc 'Run style checker'
7
- RuboCop::RakeTask.new(:rubocop) do |task|
8
- task.fail_on_error = true
9
- end
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
-
13
- desc 'Generate the engine_cart and spin up test servers and run specs'
14
- task ci: ['rubocop', 'engine_cart:generate'] do
15
- puts 'running continuous integration'
16
- Rake::Task['spec_with_app_load'].invoke
17
- end