Skip to content

Commit

Permalink
update engine name to samvera-persona
Browse files Browse the repository at this point in the history
  • Loading branch information
labradford committed Jun 13, 2019
1 parent f8fa4d5 commit b7241fe
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Declare your gem's dependencies in samvera_persona.gemspec.
# Declare your gem's dependencies in samvera-persona.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
user_management (0.1.0)
samvera-persona (0.1.0)
devise (~> 4.6)
devise_invitable (~> 1.7)
paranoia (~> 2.2)
Expand Down Expand Up @@ -185,7 +185,7 @@ DEPENDENCIES
factory_bot_rails
rspec-rails
sqlite3 (~> 1.3.6)
user_management!
samvera-persona!

BUNDLED WITH
2.0.1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SamveraPersona
# Samvera::Persona
Short description and motivation.

## Usage
Expand All @@ -8,7 +8,7 @@ How to use my plugin.
Add this line to your application's Gemfile:

```ruby
gem 'samvera_persona'
gem 'samvera-persona'
```

Then execute:
Expand All @@ -23,7 +23,7 @@ $ bundle exec rake db:migrate

Or install it yourself as:
```bash
$ gem install samvera_persona
$ gem install samvera-persona
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'SamveraPersona'
rdoc.title = 'Samvera::Persona'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions app/controllers/concerns/samvera/persona/becomes_behavior.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Samvera
module Persona
module BecomesBehavior
extend ActiveSupport::Concern
included do
impersonates :user
end
end
end
end
10 changes: 10 additions & 0 deletions app/controllers/concerns/samvera/persona/soft_delete_behavior.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Samvera
module Persona
module SoftDeleteBehavior
extend ActiveSupport::Concern
included do
acts_as_paranoid
end
end
end
end
26 changes: 26 additions & 0 deletions app/controllers/concerns/samvera/persona/username_behavior.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Samvera
module Persona
module SoftDeleteBehavior
extend ActiveSupport::Concern
included do
before_create :check_for_manditory
end

def check_for_manditory
if self.respond_to?(:username)
if self.email.present? && self.username.blank?
self.username = self.email
end
end

if self.respond_to?(:uid)
if self.email.present? && self.uid.blank?
self.uid = self.email
end
end

true
end
end
end
end
9 changes: 0 additions & 9 deletions app/controllers/concerns/user_management/becomes_behavior.rb

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions app/controllers/concerns/user_management/username_behavior.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/hyrax/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def load_user
end

def app_view_path
my_engine_root = SamveraPersona::Engine.root.to_s
my_engine_root = Samvera::Persona::Engine.root.to_s
prepend_view_path "#{my_engine_root}/app/views/#{Rails.application.class.parent_name.downcase}"
end

Expand Down
2 changes: 1 addition & 1 deletion bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/samvera_persoa/engine', __dir__)
ENGINE_PATH = File.expand_path('../lib/samvera-persona/engine', __dir__)
APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)

# Set up gems listed in the Gemfile.
Expand Down
11 changes: 11 additions & 0 deletions lib/samvera-persona.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# requires all dependencies
Gem.loaded_specs['samvera-persona'].dependencies.each do |d|
require d.name unless d.type == :development
end

require "samvera-persona/engine"

module Samvera
module Persona
end
end
51 changes: 51 additions & 0 deletions lib/samvera-persona/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
require 'rubygems'
require 'paranoia'
require 'pretender'

module Samvera
module Persona
class Engine < ::Rails::Engine
isolate_namespace Samvera::Persona

initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
end
end

config.generators do |g|
g.test_framework :rspec, :fixture => false
g.fixture_replacement :factory_bot, :dir => 'spec/factories'
g.assets false
g.helper false
end

config.before_initialize do
config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
end

config.after_initialize do
my_engine_root = Samvera::Persona::Engine.root.to_s
paths = ActionController::Base.view_paths.collect{|p| p.to_s}
hyrax_path = paths.detect { |path| path.match('/hyrax-') }
if hyrax_path
paths = paths.insert(paths.index(hyrax_path), my_engine_root + '/app/views')
else
paths = paths.insert(0, my_engine_root + '/app/views')
end
ActionController::Base.view_paths = paths
::ApplicationController.send :include, Samvera::Persona::BecomesBehavior
::Devise::InvitationsController.define_method :after_invite_path_for do |_resource|
admin_users_path
end
end

config.to_prepare do
User.send :include, Samvera::Persona::SoftDeleteBehavior
end

end
end
end
5 changes: 5 additions & 0 deletions lib/samvera-persona/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Samvera
module Persona
VERSION = '0.1.0'
end
end
10 changes: 0 additions & 10 deletions lib/samvera_persona.rb

This file was deleted.

49 changes: 0 additions & 49 deletions lib/samvera_persona/engine.rb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/samvera_persona/version.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# desc "Explaining what the task does"
# task :samvera_persona do
# task :samvera-persona do
# # Task goes here
# end
6 changes: 3 additions & 3 deletions samvera_persona.gemspec → samvera-persona.gemspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "samvera_persona/version"
require "samvera-persona/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "samvera_persona"
s.version = SamveraPersona::VERSION
s.name = "samvera-persona"
s.version = Samvera::Persona::VERSION
s.authors = ["Rob Kaufman", "Lea Ann Bradford"]
s.email = ["[email protected]"]
s.homepage = "https://gitlab.com/notch8/samvera-persona"
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rails/all'

Bundler.require(*Rails.groups)
require "samvera_persona"
require "samvera-persona"

module Dummy
class Application < Rails::Application
Expand Down
2 changes: 1 addition & 1 deletion spec/routing/admin_routes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails_helper'

RSpec.describe 'AdminController routes', type: :routing do
# routes { SamveraPersona::Engine.routes }
# routes { Samvera::Persona::Engine.routes }

it 'routes the admin users' do
expect(get: admin_users_path).to route_to(controller: 'hyrax/admin/users', action: 'index')
Expand Down

0 comments on commit b7241fe

Please sign in to comment.