purgatory 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZThjNmYwNzUxOTAyNWY4Nzg5YjViOGViMmU0NTE5ZTg4MmJhZWQ2Mw==
4
+ MmFiMzhlMmYwYjI4ZGVlMWM3N2E1MTFjZjc0YmU1YzU5MGI3MDc2ZA==
5
5
  data.tar.gz: !binary |-
6
- NzE1MmNmNzkzZTgxZDY2Y2IxNTgzZmQ1YmI3NjRhYjBhMTY4Nzk1Nw==
6
+ ZGFlYjYxM2IxMWIzMjU0ZWI1MTNmN2ViZjgzMGYxZGE5OWYxNGE4Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTE1N2FiNmUwMjEzYTFlNWU3M2M3MmZiYmRiOTU2MzIzODQ4NjNlMjI5ZTFm
10
- YzkxZjc4ZWI1OWFhZWQ3NThhY2EzZTM5ZGI4M2NlN2JjMWQ3MjA5YTEwMTQy
11
- MDdmNmFmNzYwMDE2YzEzODU3ZTU1N2RiZDMzZDU5NjNjNTRlMzQ=
9
+ N2NjNTkxYjgzZTk1ZmNlOGE4YWUxZmE2MzZjOGFlYmJhMWZjNmQ5ODk1ZTJh
10
+ NWU1MWIzYTZmNGRjZDM2YzE1ZDYyMmQ4NWIzZWY0NjRiNTc3ZDlhZWM5MTI4
11
+ MTJhNzk5ZDgzMzM4MTFiN2I0ZTMxMjMxOGI0ZTg5NWIxMmU1M2Y=
12
12
  data.tar.gz: !binary |-
13
- NDg5MjZlYTA3ZDY1NTQyOTE3MDE4MzczMjNlNGE5NWVhMTRmMzMxYzU4ZmEz
14
- ZjQyOGFkYTE0N2RlOWM0MmU5NzI0NmFmNmNlYTAzMDRhOWU0M2JkYWE1MjY4
15
- YTg3NjNmOGI0NTcxNmM5YjY0YTE3MWI0M2EyODM5Mjk1MTk3ODU=
13
+ OTZjNDRkYWYyZWRmODMxMmExODRlMjMxY2UxMDQwN2MxODc2YjJlMGRhZDAz
14
+ NzI1ZjM0NDJmYTNkMzIxMzA5MTViNGUyM2EzZTQ4ZmViN2E1MDUyZmViZjlj
15
+ YjdlMDg1MmM5ZDI0ODJjODI2ZjlmYmZlYmQxZjk3OTFmMTA0ZTA=
data/README.markdown CHANGED
@@ -4,7 +4,7 @@ Purgatory allows you to put changes to an ActiveRecord model into purgatory unti
4
4
 
5
5
  ## How to Use
6
6
 
7
- First run the generator the create the required migrations:
7
+ First run the generator the create the required migration and initializer file:
8
8
 
9
9
  $ rails generate purgatory
10
10
 
@@ -12,6 +12,8 @@ Then migrate the database:
12
12
 
13
13
  $ rake db:migrate
14
14
 
15
+ By default the class of a purgatory's requester and approver is assumed to be 'User'. You can configure this in the config/initializers/purgatory file.
16
+
15
17
  To enable Purgatory functionality in a class, add the following line to the class:
16
18
 
17
19
  use_purgatory
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.3.0
@@ -19,4 +19,14 @@ class PurgatoryGenerator < Rails::Generators::Base
19
19
  def create_migration_file
20
20
  migration_template 'create_purgatories.rb', 'db/migrate/create_purgatories.rb'
21
21
  end
22
+
23
+ def create_initializer_file
24
+ create_file 'config/initializers/purgatory.rb', <<-eos
25
+ PurgatoryModule.configure do |config|
26
+ config.user_class_name = 'User'
27
+ end
28
+
29
+ require 'purgatory/purgatory'
30
+ eos
31
+ end
22
32
  end
data/lib/purgatory.rb CHANGED
@@ -1,3 +1,2 @@
1
- require 'purgatory/purgatory'
2
1
  require 'purgatory/purgatory_module'
3
2
  ActiveRecord::Base.send(:include, PurgatoryModule)
@@ -1,7 +1,9 @@
1
+ require 'purgatory/purgatory_module'
2
+
1
3
  class Purgatory < ActiveRecord::Base
2
4
  belongs_to :soul, polymorphic: true, autosave: false
3
- belongs_to :requester, class_name: 'User'
4
- belongs_to :approver, class_name: 'User'
5
+ belongs_to :requester, class_name: PurgatoryModule.configuration.user_class_name
6
+ belongs_to :approver, class_name: PurgatoryModule.configuration.user_class_name
5
7
  before_create :store_changes
6
8
 
7
9
  validates :soul_type, presence: true
@@ -11,4 +11,19 @@ module PurgatoryModule
11
11
  return nil if self.invalid?
12
12
  Purgatory.create soul: self, requester: requester
13
13
  end
14
+
15
+ class Configuration
16
+ attr_accessor :user_class_name
17
+ end
18
+
19
+ class << self
20
+ def configure(&block)
21
+ yield(configuration)
22
+ configuration
23
+ end
24
+
25
+ def configuration
26
+ @_configuration ||= Configuration.new
27
+ end
28
+ end
14
29
  end
data/purgatory.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: purgatory 2.2.0 ruby lib
5
+ # stub: purgatory 2.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "purgatory"
9
- s.version = "2.2.0"
9
+ s.version = "2.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Elan Dubrofsky"]
@@ -1,7 +1,7 @@
1
1
  require 'support/active_record'
2
2
  require 'support/widget'
3
3
  require 'support/user'
4
- require 'purgatory'
4
+ require 'purgatory/purgatory'
5
5
 
6
6
  describe Purgatory do
7
7
  let(:user1) {User.create name: 'Elan'}
@@ -1,5 +1,6 @@
1
1
  require 'active_record'
2
2
  require 'generators/purgatory/templates/create_purgatories'
3
+ require 'purgatory/purgatory_module'
3
4
 
4
5
  ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
5
6
 
@@ -17,6 +18,10 @@ end
17
18
 
18
19
  CreatePurgatories.new.migrate(:up)
19
20
 
21
+ PurgatoryModule.configure do |config|
22
+ config.user_class_name = 'User'
23
+ end
24
+
20
25
  RSpec.configure do |config|
21
26
  config.around do |example|
22
27
  ActiveRecord::Base.transaction do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purgatory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elan Dubrofsky