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 +8 -8
- data/README.markdown +3 -1
- data/VERSION +1 -1
- data/lib/generators/purgatory/purgatory_generator.rb +10 -0
- data/lib/purgatory.rb +0 -1
- data/lib/purgatory/purgatory.rb +4 -2
- data/lib/purgatory/purgatory_module.rb +15 -0
- data/purgatory.gemspec +2 -2
- data/spec/purgatory_spec.rb +1 -1
- data/spec/support/active_record.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmFiMzhlMmYwYjI4ZGVlMWM3N2E1MTFjZjc0YmU1YzU5MGI3MDc2ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGFlYjYxM2IxMWIzMjU0ZWI1MTNmN2ViZjgzMGYxZGE5OWYxNGE4Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2NjNTkxYjgzZTk1ZmNlOGE4YWUxZmE2MzZjOGFlYmJhMWZjNmQ5ODk1ZTJh
|
10
|
+
NWU1MWIzYTZmNGRjZDM2YzE1ZDYyMmQ4NWIzZWY0NjRiNTc3ZDlhZWM5MTI4
|
11
|
+
MTJhNzk5ZDgzMzM4MTFiN2I0ZTMxMjMxOGI0ZTg5NWIxMmU1M2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
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.
|
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
data/lib/purgatory/purgatory.rb
CHANGED
@@ -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:
|
4
|
-
belongs_to :approver, class_name:
|
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.
|
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.
|
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"]
|
data/spec/purgatory_spec.rb
CHANGED
@@ -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
|