has_draft 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +1 -1
- data/lib/has_draft/version.rb +2 -2
- data/lib/has_draft.rb +5 -5
- data/spec/db/test.sqlite3 +0 -0
- data/spec/spec_helper.rb +0 -1
- metadata +69 -5
- data/CHANGELOG.rdoc +0 -10
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
has_draft (1.0.1)
|
5
|
+
activerecord (>= 3.0.0)
|
6
|
+
activesupport (>= 3.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.0.6)
|
12
|
+
activesupport (= 3.0.6)
|
13
|
+
builder (~> 2.1.2)
|
14
|
+
i18n (~> 0.5.0)
|
15
|
+
activerecord (3.0.6)
|
16
|
+
activemodel (= 3.0.6)
|
17
|
+
activesupport (= 3.0.6)
|
18
|
+
arel (~> 2.0.2)
|
19
|
+
tzinfo (~> 0.3.23)
|
20
|
+
activesupport (3.0.6)
|
21
|
+
arel (2.0.9)
|
22
|
+
builder (2.1.2)
|
23
|
+
diff-lcs (1.1.2)
|
24
|
+
factory_girl (1.3.3)
|
25
|
+
faker (0.9.5)
|
26
|
+
i18n (~> 0.4)
|
27
|
+
i18n (0.5.0)
|
28
|
+
rspec (2.5.0)
|
29
|
+
rspec-core (~> 2.5.0)
|
30
|
+
rspec-expectations (~> 2.5.0)
|
31
|
+
rspec-mocks (~> 2.5.0)
|
32
|
+
rspec-core (2.5.1)
|
33
|
+
rspec-expectations (2.5.0)
|
34
|
+
diff-lcs (~> 1.1.2)
|
35
|
+
rspec-mocks (2.5.0)
|
36
|
+
sqlite3 (1.3.3)
|
37
|
+
sqlite3-ruby (1.3.3)
|
38
|
+
sqlite3 (>= 1.3.3)
|
39
|
+
tzinfo (0.3.26)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
activerecord (>= 3.0.0)
|
46
|
+
activesupport (>= 3.0.0)
|
47
|
+
factory_girl (~> 1.3.1)
|
48
|
+
faker (~> 0.9.1)
|
49
|
+
has_draft!
|
50
|
+
rspec (~> 2.0)
|
51
|
+
sqlite3-ruby (~> 1.3.1)
|
data/LICENSE
CHANGED
data/lib/has_draft/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module HasDraft
|
2
|
-
VERSION = "1.0.
|
3
|
-
end
|
2
|
+
VERSION = "1.0.2"
|
3
|
+
end
|
data/lib/has_draft.rb
CHANGED
@@ -20,8 +20,8 @@ module HasDraft
|
|
20
20
|
:foreign_key => draft_foreign_key,
|
21
21
|
:dependent => :destroy
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
scope :with_draft, includes(:draft).where("#{draft_table_name}.id IS NOT NULL")
|
24
|
+
scope :without_draft, includes(:draft).where("#{draft_table_name}.id IS NULL")
|
25
25
|
end
|
26
26
|
|
27
27
|
# Dynamically Create Model::Draft Class
|
@@ -62,16 +62,16 @@ module HasDraft
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def instantiate_draft
|
65
|
-
self.
|
65
|
+
self.build_draft
|
66
66
|
|
67
67
|
copy_attributes_to_draft
|
68
68
|
before_instantiate_draft
|
69
69
|
|
70
|
-
self.draft
|
70
|
+
self.draft.tap(&:save)
|
71
71
|
end
|
72
72
|
|
73
73
|
def instantiate_draft!
|
74
|
-
|
74
|
+
instantiate_draft do |draft|
|
75
75
|
draft.save unless self.new_record?
|
76
76
|
end
|
77
77
|
end
|
data/spec/db/test.sqlite3
CHANGED
Binary file
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_draft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Hughes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-04-15 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,69 @@ dependencies:
|
|
50
50
|
version: 3.0.0
|
51
51
|
type: :runtime
|
52
52
|
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 0
|
65
|
+
version: "2.0"
|
66
|
+
type: :development
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: factory_girl
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 25
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 3
|
80
|
+
- 1
|
81
|
+
version: 1.3.1
|
82
|
+
type: :development
|
83
|
+
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: faker
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 57
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
- 9
|
96
|
+
- 1
|
97
|
+
version: 0.9.1
|
98
|
+
type: :development
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: sqlite3-ruby
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ~>
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 25
|
109
|
+
segments:
|
110
|
+
- 1
|
111
|
+
- 3
|
112
|
+
- 1
|
113
|
+
version: 1.3.1
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id006
|
53
116
|
description: Allows for your ActiveRecord models to have drafts which are stored in a separate duplicate table.
|
54
117
|
email: ben@railsgarden.com
|
55
118
|
executables: []
|
@@ -68,7 +131,8 @@ files:
|
|
68
131
|
- spec/factories/article.rb
|
69
132
|
- spec/has_draft_spec.rb
|
70
133
|
- spec/spec_helper.rb
|
71
|
-
-
|
134
|
+
- Gemfile
|
135
|
+
- Gemfile.lock
|
72
136
|
- LICENSE
|
73
137
|
- Rakefile
|
74
138
|
- README.rdoc
|
data/CHANGELOG.rdoc
DELETED