hydra-access-controls 7.0.0.rc1 → 7.0.0

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
  SHA1:
3
- metadata.gz: 58a77fa2bd284c19512fb6e9267dde6555b9ccf0
4
- data.tar.gz: 6913b984630dd75785b575040b7e5bbd1da5447a
3
+ metadata.gz: eca7a77f8cb4ea32d7c4915e35a9da69cb3e109b
4
+ data.tar.gz: 27f3c6ae86554fffe20aa0befd33b5850cfb5391
5
5
  SHA512:
6
- metadata.gz: ab4a35778989b898e957debeee6523f009ad0d7cb660545d8f9f194cde8f4f862b64d72d94f1641e6bbe0158b9280d1d9c44935d0803a1031970f316f096e3d8
7
- data.tar.gz: 8fc2c4dbd5a58ac0ca82288e6e42904a930a3a432188635747147294959773a372a6f81627809e74a8f0c0aa766631bb58cd6916480182dbbcfc5ed66e89f162
6
+ metadata.gz: 16d9138368be86ed0307539b68f935d3dfb9533c050e78a13b2c8f90f9eb29f16e04bd3d33d01e29b3265648f5ef8959cd398bb1fa134d59f281d543fef308e9
7
+ data.tar.gz: a86f237e7f52ad1e88187ebb463db7e6c4daaf77f43421f7f8113a3fed8eb20e50cf6984a9fe2d2eba64e1e6a0621903130081aa0d9bde66dec1be181a312814
@@ -19,14 +19,14 @@ Gem::Specification.new do |gem|
19
19
  gem.required_ruby_version = '>= 1.9.3'
20
20
 
21
21
  gem.add_dependency 'activesupport'
22
- gem.add_dependency "active-fedora", '~> 7.0.0.rc3'
22
+ gem.add_dependency "active-fedora", '~> 7.0.0'
23
23
  gem.add_dependency 'cancancan'
24
24
  gem.add_dependency 'deprecation'
25
- gem.add_dependency "blacklight", '~> 5.0'
25
+ gem.add_dependency "blacklight", '~> 5.3'
26
26
 
27
27
  # sass-rails is typically generated into the app's gemfile by `rails new`
28
28
  # In rails 3 it's put into the "assets" group and thus not available to the
29
- # app. Blacklight 5.2 requires bootstrap-sass which requires (but does not
29
+ # app. Blacklight 5.3 requires bootstrap-sass which requires (but does not
30
30
  # declare a dependency on) sass-rails
31
31
  gem.add_dependency 'sass-rails'
32
32
 
@@ -130,12 +130,4 @@ module Hydra::AccessControlsEnforcement
130
130
  def apply_superuser_permissions(permission_types, ability = current_ability)
131
131
  []
132
132
  end
133
-
134
- # This filters out objects that you want to exclude from search results. By default it only excludes FileAssets
135
- # @param solr_parameters the current solr parameters
136
- # @param user_parameters the current user-subitted parameters
137
- def exclude_unwanted_models(solr_parameters, user_parameters)
138
- solr_parameters[:fq] ||= []
139
- solr_parameters[:fq] << "-#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:\"info:fedora/afmodel:FileAsset\""
140
- end
141
133
  end
@@ -1,5 +1,3 @@
1
- # this code will be moved/renamed to Hydra::AccessControl::RoleMapperBehavior (with the appropriate namespace changes) in Hydra 5.0
2
- require 'yaml'
3
1
  module Hydra::RoleMapperBehavior
4
2
  extend ActiveSupport::Concern
5
3
 
@@ -25,23 +23,47 @@ module Hydra::RoleMapperBehavior
25
23
  end
26
24
 
27
25
  def whois(r)
28
- map[r]||[]
26
+ map[r] || []
29
27
  end
30
28
 
31
29
  def map
32
- @map ||= YAML.load(File.open(File.join(Rails.root, "config/role_map_#{Rails.env}.yml")))
30
+ @map ||= load_role_map
33
31
  end
34
32
 
35
33
 
36
34
  def byname
37
- return @byname if @byname
38
- m = Hash.new{|h,k| h[k]=[]}
39
- @byname = map.inject(m) do|memo, (role,usernames)|
40
- ((usernames if usernames.respond_to?(:each)) || [usernames]).each { |x| memo[x]<<role}
41
- memo
35
+ @byname ||= map.each_with_object(Hash.new{ |h,k| h[k] = [] }) do |(role, usernames), memo|
36
+ Array(usernames).each { |x| memo[x] << role}
42
37
  end
43
38
  end
44
-
39
+
40
+ private
41
+ def load_role_map
42
+ require 'erb'
43
+ require 'yaml'
44
+
45
+ filename = 'config/role_map.yml'
46
+ file = File.join(Rails.root, filename)
47
+
48
+ unless File.exists?(file)
49
+ raise "You are missing a role map configuration file: #{filename}. Have you run \"rails generate hydra:head\"?"
50
+ end
51
+
52
+ begin
53
+ erb = ERB.new(IO.read(file)).result(binding)
54
+ rescue
55
+ raise("#{file} was found, but could not be parsed with ERB. \n#{$!.inspect}")
56
+ end
57
+
58
+ begin
59
+ yml = YAML::load(erb)
60
+ rescue
61
+ raise("#{filename} was found, but could not be parsed.\n")
62
+ end
63
+ return yml[Rails.env] if yml.is_a? Hash
64
+
65
+ raise("#{filename} was found, but was blank or malformed.\n")
66
+ end
45
67
  end
46
68
  end
47
69
 
@@ -22,7 +22,6 @@ require "support/user"
22
22
  require "factory_girl"
23
23
  require "factories"
24
24
 
25
- require 'support/blacklight'
26
25
  require 'support/rails'
27
26
  Object.logger = Logger.new(File.expand_path('../test.log', __FILE__))
28
27
 
@@ -0,0 +1,15 @@
1
+ test:
2
+ archivist:
3
+ - archivist1@example.com
4
+ - archivist2@example.com
5
+ - leland_himself@example.com
6
+ admin_policy_object_editor:
7
+ - archivist1@example.com
8
+ donor:
9
+ - donor1@example.com
10
+ - leland_himself@example.com
11
+ researcher:
12
+ - researcher1@example.com
13
+ patron:
14
+ - patron1@example.com
15
+ - leland_himself@example.com
@@ -155,19 +155,6 @@ describe Hydra::AccessControlsEnforcement do
155
155
  end
156
156
  end
157
157
  end
158
-
159
- describe "exclude_unwanted_models" do
160
- before(:each) do
161
- stub_user = User.new :uid=>'archivist1@example.com'
162
- subject.stub(:current_user).and_return(stub_user)
163
- @solr_parameters = {}
164
- @user_parameters = {}
165
- end
166
- it "should set solr query parameters to filter out FileAssets" do
167
- subject.send(:exclude_unwanted_models, @solr_parameters, @user_parameters)
168
- @solr_parameters[:fq].should include("-#{ActiveFedora::SolrService.solr_name("has_model", :symbol)}:\"info:fedora/afmodel:FileAsset\"")
169
- end
170
- end
171
158
 
172
159
  describe "apply_user_permissions" do
173
160
  describe "when the user is a guest user (user key nil)" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-access-controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.rc1
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-18 00:00:00.000000000 Z
13
+ date: 2014-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 7.0.0.rc3
35
+ version: 7.0.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 7.0.0.rc3
42
+ version: 7.0.0
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: cancancan
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '5.0'
77
+ version: '5.3'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '5.0'
84
+ version: '5.3'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: sass-rails
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -163,8 +163,7 @@ files:
163
163
  - lib/hydra/user.rb
164
164
  - spec/factories.rb
165
165
  - spec/spec_helper.rb
166
- - spec/support/blacklight.rb
167
- - spec/support/config/role_map_test.yml
166
+ - spec/support/config/role_map.yml
168
167
  - spec/support/config/solr.yml
169
168
  - spec/support/mods_asset.rb
170
169
  - spec/support/rails.rb
@@ -202,9 +201,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
201
  version: 1.9.3
203
202
  required_rubygems_version: !ruby/object:Gem::Requirement
204
203
  requirements:
205
- - - ">"
204
+ - - ">="
206
205
  - !ruby/object:Gem::Version
207
- version: 1.3.1
206
+ version: '0'
208
207
  requirements: []
209
208
  rubyforge_project:
210
209
  rubygems_version: 2.2.2
@@ -214,8 +213,7 @@ summary: Access controls for project hydra
214
213
  test_files:
215
214
  - spec/factories.rb
216
215
  - spec/spec_helper.rb
217
- - spec/support/blacklight.rb
218
- - spec/support/config/role_map_test.yml
216
+ - spec/support/config/role_map.yml
219
217
  - spec/support/config/solr.yml
220
218
  - spec/support/mods_asset.rb
221
219
  - spec/support/rails.rb
@@ -1,7 +0,0 @@
1
- require 'blacklight'
2
-
3
- module Blacklight
4
- def self.solr_file
5
- File.expand_path(File.join(File.dirname(__FILE__), "config", "solr.yml"))
6
- end
7
- end
@@ -1,14 +0,0 @@
1
- archivist:
2
- - archivist1@example.com
3
- - archivist2@example.com
4
- - leland_himself@example.com
5
- admin_policy_object_editor:
6
- - archivist1@example.com
7
- donor:
8
- - donor1@example.com
9
- - leland_himself@example.com
10
- researcher:
11
- - researcher1@example.com
12
- patron:
13
- - patron1@example.com
14
- - leland_himself@example.com