purgatory 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/Gemfile +1 -2
- data/Gemfile.lock +22 -20
- data/README.markdown +1 -1
- data/VERSION +1 -1
- data/lib/generators/purgatory/templates/create_purgatories.rb +1 -1
- data/lib/purgatory/purgatory.rb +4 -6
- data/purgatory.gemspec +4 -6
- data/spec/purgatory_spec.rb +8 -8
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZThjNmYwNzUxOTAyNWY4Nzg5YjViOGViMmU0NTE5ZTg4MmJhZWQ2Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
NzE1MmNmNzkzZTgxZDY2Y2IxNTgzZmQ1YmI3NjRhYjBhMTY4Nzk1Nw==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTE1N2FiNmUwMjEzYTFlNWU3M2M3MmZiYmRiOTU2MzIzODQ4NjNlMjI5ZTFm
|
10
|
+
YzkxZjc4ZWI1OWFhZWQ3NThhY2EzZTM5ZGI4M2NlN2JjMWQ3MjA5YTEwMTQy
|
11
|
+
MDdmNmFmNzYwMDE2YzEzODU3ZTU1N2RiZDMzZDU5NjNjNTRlMzQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDg5MjZlYTA3ZDY1NTQyOTE3MDE4MzczMjNlNGE5NWVhMTRmMzMxYzU4ZmEz
|
14
|
+
ZjQyOGFkYTE0N2RlOWM0MmU5NzI0NmFmNmNlYTAzMDRhOWU0M2JkYWE1MjY4
|
15
|
+
YTg3NjNmOGI0NTcxNmM5YjY0YTE3MWI0M2EyODM5Mjk1MTk3ODU=
|
data/Gemfile
CHANGED
@@ -6,14 +6,13 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "shoulda", ">= 0"
|
10
9
|
gem "rdoc", "~> 3.12"
|
11
10
|
gem "bundler", "~> 1.0"
|
12
11
|
gem "jeweler", "~> 1.8.7"
|
13
12
|
end
|
14
13
|
|
15
14
|
group :test do
|
16
|
-
gem "activerecord"
|
15
|
+
gem "activerecord", ">= 4"
|
17
16
|
gem "rspec"
|
18
17
|
gem "sqlite3"
|
19
18
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
4
|
+
activemodel (4.0.1)
|
5
|
+
activesupport (= 4.0.1)
|
6
|
+
builder (~> 3.1.0)
|
7
|
+
activerecord (4.0.1)
|
8
|
+
activemodel (= 4.0.1)
|
9
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
10
|
+
activesupport (= 4.0.1)
|
11
|
+
arel (~> 4.0.0)
|
12
|
+
activerecord-deprecated_finders (1.0.3)
|
5
13
|
activesupport (4.0.1)
|
6
14
|
i18n (~> 0.6, >= 0.6.4)
|
7
15
|
minitest (~> 4.2)
|
@@ -9,9 +17,10 @@ GEM
|
|
9
17
|
thread_safe (~> 0.1)
|
10
18
|
tzinfo (~> 0.3.37)
|
11
19
|
addressable (2.3.5)
|
20
|
+
arel (4.0.1)
|
12
21
|
atomic (1.1.14)
|
13
|
-
builder (3.
|
14
|
-
diff-lcs (1.
|
22
|
+
builder (3.1.4)
|
23
|
+
diff-lcs (1.2.5)
|
15
24
|
faraday (0.8.8)
|
16
25
|
multipart-post (~> 1.2.0)
|
17
26
|
git (1.2.6)
|
@@ -54,21 +63,15 @@ GEM
|
|
54
63
|
rake (10.1.0)
|
55
64
|
rdoc (3.12.2)
|
56
65
|
json (~> 1.4)
|
57
|
-
rspec (2.
|
58
|
-
rspec-core (~> 2.
|
59
|
-
rspec-expectations (~> 2.
|
60
|
-
rspec-mocks (~> 2.
|
61
|
-
rspec-core (2.
|
62
|
-
rspec-expectations (2.
|
63
|
-
diff-lcs (
|
64
|
-
rspec-mocks (2.
|
65
|
-
|
66
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
67
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
68
|
-
shoulda-context (1.1.6)
|
69
|
-
shoulda-matchers (2.4.0)
|
70
|
-
activesupport (>= 3.0.0)
|
71
|
-
sqlite3 (1.3.7)
|
66
|
+
rspec (2.14.1)
|
67
|
+
rspec-core (~> 2.14.0)
|
68
|
+
rspec-expectations (~> 2.14.0)
|
69
|
+
rspec-mocks (~> 2.14.0)
|
70
|
+
rspec-core (2.14.7)
|
71
|
+
rspec-expectations (2.14.4)
|
72
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
73
|
+
rspec-mocks (2.14.4)
|
74
|
+
sqlite3 (1.3.8)
|
72
75
|
thread_safe (0.1.3)
|
73
76
|
atomic
|
74
77
|
tzinfo (0.3.38)
|
@@ -77,10 +80,9 @@ PLATFORMS
|
|
77
80
|
ruby
|
78
81
|
|
79
82
|
DEPENDENCIES
|
80
|
-
activerecord
|
83
|
+
activerecord (>= 4)
|
81
84
|
bundler (~> 1.0)
|
82
85
|
jeweler (~> 1.8.7)
|
83
86
|
rdoc (~> 3.12)
|
84
87
|
rspec
|
85
|
-
shoulda
|
86
88
|
sqlite3
|
data/README.markdown
CHANGED
@@ -37,6 +37,7 @@ The following are some attributes of a purgatory:
|
|
37
37
|
purgatory.soul # The ActiveRecord model instance whose changes are in purgatory
|
38
38
|
purgatory.requester # The user who created the purgatory
|
39
39
|
purgatory.created_at # The time when the purgatory was created
|
40
|
+
purgatory.requested_changes # A hash of the proposed changes. The keys are the attribute names and the values are 2-element arrays where the 1st element is the old value and the 2nd element is the new value
|
40
41
|
purgatory.approver # The user who approved the purgatory
|
41
42
|
purgatory.approved_at # The time when the purgatory was approved
|
42
43
|
|
@@ -49,7 +50,6 @@ Here are some handy scopes and methods available to you:
|
|
49
50
|
### Methods
|
50
51
|
purgatory.pending? # Returns true if the purgatory is pending, false otherwise
|
51
52
|
purgatory.approved? # Returns true if the purgatory has been approved, false otherwise
|
52
|
-
purgatory.changes_hash # Returns a hash of the proposed changes. The keys are the attribute names and the values are 2-element arrays where the 1st element is the old value and the 2nd element is the new value
|
53
53
|
|
54
54
|
## Contributing to Purgatory
|
55
55
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/lib/purgatory/purgatory.rb
CHANGED
@@ -6,6 +6,8 @@ class Purgatory < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
validates :soul_type, presence: true
|
8
8
|
|
9
|
+
serialize :requested_changes
|
10
|
+
|
9
11
|
def self.pending
|
10
12
|
where(approved_at: nil)
|
11
13
|
end
|
@@ -22,17 +24,13 @@ class Purgatory < ActiveRecord::Base
|
|
22
24
|
approved_at.nil?
|
23
25
|
end
|
24
26
|
|
25
|
-
def changes_hash
|
26
|
-
ActiveSupport::JSON.decode(changes_json)
|
27
|
-
end
|
28
|
-
|
29
27
|
def soul
|
30
28
|
@soul ||= (super || soul_type.constantize.new)
|
31
29
|
end
|
32
30
|
|
33
31
|
def approve!(approver = nil)
|
34
32
|
return false if approved?
|
35
|
-
|
33
|
+
requested_changes.each{|k,v| soul.send "#{k}=", v[1]}
|
36
34
|
if soul.save
|
37
35
|
self.approver = approver
|
38
36
|
self.approved_at = Time.now
|
@@ -45,6 +43,6 @@ class Purgatory < ActiveRecord::Base
|
|
45
43
|
private
|
46
44
|
|
47
45
|
def store_changes
|
48
|
-
self.
|
46
|
+
self.requested_changes = soul.changes
|
49
47
|
end
|
50
48
|
end
|
data/purgatory.gemspec
CHANGED
@@ -2,14 +2,15 @@
|
|
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
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "purgatory"
|
8
|
-
s.version = "2.
|
9
|
+
s.version = "2.2.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
12
|
s.authors = ["Elan Dubrofsky"]
|
12
|
-
s.date = "2013-11-
|
13
|
+
s.date = "2013-11-25"
|
13
14
|
s.description = "Put your model changes in purgatory and allow them to remain lost souls until they are approved"
|
14
15
|
s.email = "elan.dubrofsky@gmail.com"
|
15
16
|
s.extra_rdoc_files = [
|
@@ -39,25 +40,22 @@ Gem::Specification.new do |s|
|
|
39
40
|
s.homepage = "http://github.com/financeit/purgatory"
|
40
41
|
s.licenses = ["MIT"]
|
41
42
|
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = "2.
|
43
|
+
s.rubygems_version = "2.1.11"
|
43
44
|
s.summary = "Allow changes to a model to be put in purgatory until they are approved"
|
44
45
|
|
45
46
|
if s.respond_to? :specification_version then
|
46
47
|
s.specification_version = 4
|
47
48
|
|
48
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
50
50
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
51
51
|
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
52
52
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
53
53
|
else
|
54
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
54
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
56
55
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
57
56
|
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
58
57
|
end
|
59
58
|
else
|
60
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
61
59
|
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
60
|
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
63
61
|
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
data/spec/purgatory_spec.rb
CHANGED
@@ -23,10 +23,10 @@ describe Purgatory do
|
|
23
23
|
it "should store the soul, requester and requested changes" do
|
24
24
|
@purgatory.soul.should == @widget
|
25
25
|
@purgatory.requester.should == user1
|
26
|
-
@purgatory.
|
27
|
-
@purgatory.
|
28
|
-
@purgatory.
|
29
|
-
@purgatory.
|
26
|
+
@purgatory.requested_changes['name'].first.should == 'foo'
|
27
|
+
@purgatory.requested_changes['name'].last.should == 'bar'
|
28
|
+
@purgatory.requested_changes['price'].first.should == 100
|
29
|
+
@purgatory.requested_changes['price'].last.should == 200
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not change the widget" do
|
@@ -71,10 +71,10 @@ describe Purgatory do
|
|
71
71
|
|
72
72
|
it "should store the requester and requested changes" do
|
73
73
|
@purgatory.requester.should == user1
|
74
|
-
@purgatory.
|
75
|
-
@purgatory.
|
76
|
-
@purgatory.
|
77
|
-
@purgatory.
|
74
|
+
@purgatory.requested_changes['name'].first.should == nil
|
75
|
+
@purgatory.requested_changes['name'].last.should == 'foo'
|
76
|
+
@purgatory.requested_changes['price'].first.should == nil
|
77
|
+
@purgatory.requested_changes['price'].last.should == 100
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should not create a widget" do
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purgatory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elan Dubrofsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: shoulda
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rdoc
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
99
|
version: '0'
|
114
100
|
requirements: []
|
115
101
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.1.11
|
117
103
|
signing_key:
|
118
104
|
specification_version: 4
|
119
105
|
summary: Allow changes to a model to be put in purgatory until they are approved
|