dm-is-published 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -5
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/dm-is-published.gemspec +12 -126
- data/lib/dm-is-published/is/version.rb +1 -1
- metadata +7 -125
- data/spec/spec.opts +0 -1
data/README.rdoc
CHANGED
@@ -8,12 +8,8 @@ Originally inspired by the Rails plugin +acts_as_publishable+ by <b>fr.ivolo.us<
|
|
8
8
|
|
9
9
|
== Installation
|
10
10
|
|
11
|
-
|
12
|
-
$ gem sources -a http://gems.github.com
|
11
|
+
$ gem install dm-is-published
|
13
12
|
|
14
|
-
$ (sudo)? gem install kematzy-dm-is-published
|
15
|
-
|
16
|
-
<b>NB! Depends upon the whole DataMapper suite being installed, and has ONLY been tested with DM 0.10.0 (next branch).</b>
|
17
13
|
|
18
14
|
|
19
15
|
== Getting Started
|
data/Rakefile
CHANGED
@@ -8,17 +8,17 @@ begin
|
|
8
8
|
gem.name = "dm-is-published"
|
9
9
|
# gem.version = IO.read('VERSION') || '0.0.0'
|
10
10
|
gem.summary = %Q{A DataMapper plugin that provides an easy way to add different states to your models.}
|
11
|
-
gem.description =
|
11
|
+
gem.description = gem.summary
|
12
12
|
gem.email = "kematzy@gmail.com"
|
13
13
|
gem.homepage = 'http://github.com/kematzy/dm-is-published'
|
14
14
|
gem.authors = ["kematzy"]
|
15
15
|
gem.extra_rdoc_files = %w[ README.rdoc LICENSE TODO History.rdoc ]
|
16
16
|
|
17
|
-
gem.add_dependency 'dm-core', '~> 1.0.0
|
17
|
+
gem.add_dependency 'dm-core', '~> 1.0.0'
|
18
18
|
|
19
19
|
gem.add_development_dependency 'rspec', '~> 1.3'
|
20
|
-
gem.add_development_dependency 'dm-migrations', '~> 1.0.0
|
21
|
-
gem.add_development_dependency 'dm-validations', '~> 1.0.0
|
20
|
+
gem.add_development_dependency 'dm-migrations', '~> 1.0.0'
|
21
|
+
gem.add_development_dependency 'dm-validations', '~> 1.0.0'
|
22
22
|
end
|
23
23
|
|
24
24
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/dm-is-published.gemspec
CHANGED
@@ -5,125 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-is-published}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kematzy"]
|
12
|
-
s.date = %q{2010-06-
|
13
|
-
s.description = %q{
|
14
|
-
|
15
|
-
This plugin makes it very easy to add different states to your models, like 'draft' vs 'live'.
|
16
|
-
By default it also adds validations of the field value.
|
17
|
-
|
18
|
-
Originally inspired by the Rails plugin +acts_as_publishable+ by <b>fr.ivolo.us</b>.
|
19
|
-
|
20
|
-
|
21
|
-
== Installation
|
22
|
-
|
23
|
-
# Add GitHub to your RubyGems sources
|
24
|
-
$ gem sources -a http://gems.github.com
|
25
|
-
|
26
|
-
$ (sudo)? gem install kematzy-dm-is-published
|
27
|
-
|
28
|
-
<b>NB! Depends upon the whole DataMapper suite being installed, and has ONLY been tested with DM 0.10.0 (next branch).</b>
|
29
|
-
|
30
|
-
|
31
|
-
== Getting Started
|
32
|
-
|
33
|
-
First of all, for a better understanding of this gem, make sure you study
|
34
|
-
the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file.
|
35
|
-
|
36
|
-
----
|
37
|
-
|
38
|
-
Require +dm-is-published+ in your app.
|
39
|
-
|
40
|
-
require 'dm-core' # must be required first
|
41
|
-
require 'dm-is-published'
|
42
|
-
|
43
|
-
Lets say we have an Article class, and each Article can have a current state,
|
44
|
-
ie: whether it's Live, Draft or an Obituary awaiting the death of someone famous (real or rumored)
|
45
|
-
|
46
|
-
|
47
|
-
class Article
|
48
|
-
include DataMapper::Resource
|
49
|
-
property :id, Serial
|
50
|
-
property :title, String
|
51
|
-
...<snip>
|
52
|
-
|
53
|
-
is :published
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
Once you have your Article model we can create our Articles just as normal
|
58
|
-
|
59
|
-
Article.create(:title => 'Example 1')
|
60
|
-
|
61
|
-
|
62
|
-
The instance of <tt>Article.get(1)</tt> now has the following things for free:
|
63
|
-
|
64
|
-
* a <tt>:publish_status</tt> attribute with the value <tt>'live'</tt>. Default choices are <tt>[ :live, :draft, :hidden ]</tt>.
|
65
|
-
|
66
|
-
* <tt>:is_live?, :is_draft? or :is_hidden?</tt> methods that returns true/false based upon the state.
|
67
|
-
|
68
|
-
* <tt>:save_as_live</tt>, <tt>:save_as_draft</tt> or <tt>:save_as_hidden</tt> converts the instance to the state and saves it.
|
69
|
-
|
70
|
-
* <tt>:publishable?</tt> method that returns true for models where <tt>is :published </tt> has been declared,
|
71
|
-
but <b>false</b> for those where it has not been declared.
|
72
|
-
|
73
|
-
|
74
|
-
The Article class also gets a bit of new functionality:
|
75
|
-
|
76
|
-
Article.all(:draft) => finds all Articles with :publish_status = :draft
|
77
|
-
|
78
|
-
|
79
|
-
Article.all(:draft, :author => @author_joe ) => finds all Articles with :publish_status = :draft and author == Joe
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
Todo Need to write more documentation here..
|
84
|
-
|
85
|
-
|
86
|
-
== Usage Scenarios
|
87
|
-
|
88
|
-
In a Blog/Publishing scenario you could use it like this:
|
89
|
-
|
90
|
-
class Article
|
91
|
-
...<snip>...
|
92
|
-
|
93
|
-
is :published :live, :draft, :hidden
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
Whereas in another scenario - like in a MenuItem model for a Restaurant - you could use it like this:
|
98
|
-
|
99
|
-
class MenuItem
|
100
|
-
...<snip>...
|
101
|
-
|
102
|
-
is :published :on, :off # the item is either on the menu or not
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
== RTFM
|
108
|
-
|
109
|
-
As I said above, for a better understanding of this gem/plugin, make sure you study the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file.
|
110
|
-
|
111
|
-
|
112
|
-
== Errors / Bugs
|
113
|
-
|
114
|
-
If something is not behaving intuitively, it is a bug, and should be reported.
|
115
|
-
Report it here: http://github.com/kematzy/dm-is-published/issues
|
116
|
-
|
117
|
-
== Credits
|
118
|
-
|
119
|
-
Copyright (c) 2009-07-11 [kematzy gmail com]
|
120
|
-
|
121
|
-
Loosely based on the ActsAsPublishable plugin by [http://fr.ivolo.us/posts/acts-as-publishable]
|
122
|
-
|
123
|
-
== Licence
|
124
|
-
|
125
|
-
Released under the MIT license.
|
126
|
-
}
|
12
|
+
s.date = %q{2010-06-09}
|
13
|
+
s.description = %q{A DataMapper plugin that provides an easy way to add different states to your models.}
|
127
14
|
s.email = %q{kematzy@gmail.com}
|
128
15
|
s.extra_rdoc_files = [
|
129
16
|
"History.rdoc",
|
@@ -144,7 +31,6 @@ Released under the MIT license.
|
|
144
31
|
"lib/dm-is-published/is/published.rb",
|
145
32
|
"lib/dm-is-published/is/version.rb",
|
146
33
|
"spec/integration/published_spec.rb",
|
147
|
-
"spec/spec.opts",
|
148
34
|
"spec/spec_helper.rb"
|
149
35
|
]
|
150
36
|
s.homepage = %q{http://github.com/kematzy/dm-is-published}
|
@@ -162,21 +48,21 @@ Released under the MIT license.
|
|
162
48
|
s.specification_version = 3
|
163
49
|
|
164
50
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
165
|
-
s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0
|
51
|
+
s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0"])
|
166
52
|
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
167
|
-
s.add_development_dependency(%q<dm-migrations>, ["~> 1.0.0
|
168
|
-
s.add_development_dependency(%q<dm-validations>, ["~> 1.0.0
|
53
|
+
s.add_development_dependency(%q<dm-migrations>, ["~> 1.0.0"])
|
54
|
+
s.add_development_dependency(%q<dm-validations>, ["~> 1.0.0"])
|
169
55
|
else
|
170
|
-
s.add_dependency(%q<dm-core>, ["~> 1.0.0
|
56
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
|
171
57
|
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
172
|
-
s.add_dependency(%q<dm-migrations>, ["~> 1.0.0
|
173
|
-
s.add_dependency(%q<dm-validations>, ["~> 1.0.0
|
58
|
+
s.add_dependency(%q<dm-migrations>, ["~> 1.0.0"])
|
59
|
+
s.add_dependency(%q<dm-validations>, ["~> 1.0.0"])
|
174
60
|
end
|
175
61
|
else
|
176
|
-
s.add_dependency(%q<dm-core>, ["~> 1.0.0
|
62
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.0"])
|
177
63
|
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
178
|
-
s.add_dependency(%q<dm-migrations>, ["~> 1.0.0
|
179
|
-
s.add_dependency(%q<dm-validations>, ["~> 1.0.0
|
64
|
+
s.add_dependency(%q<dm-migrations>, ["~> 1.0.0"])
|
65
|
+
s.add_dependency(%q<dm-validations>, ["~> 1.0.0"])
|
180
66
|
end
|
181
67
|
end
|
182
68
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- kematzy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-09 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,7 @@ dependencies:
|
|
28
28
|
- 1
|
29
29
|
- 0
|
30
30
|
- 0
|
31
|
-
|
32
|
-
version: 1.0.0.rc3
|
31
|
+
version: 1.0.0
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
- !ruby/object:Gem::Dependency
|
@@ -56,8 +55,7 @@ dependencies:
|
|
56
55
|
- 1
|
57
56
|
- 0
|
58
57
|
- 0
|
59
|
-
|
60
|
-
version: 1.0.0.rc3
|
58
|
+
version: 1.0.0
|
61
59
|
type: :development
|
62
60
|
version_requirements: *id003
|
63
61
|
- !ruby/object:Gem::Dependency
|
@@ -71,125 +69,10 @@ dependencies:
|
|
71
69
|
- 1
|
72
70
|
- 0
|
73
71
|
- 0
|
74
|
-
|
75
|
-
version: 1.0.0.rc3
|
72
|
+
version: 1.0.0
|
76
73
|
type: :development
|
77
74
|
version_requirements: *id004
|
78
|
-
description:
|
79
|
-
= dm-is-published
|
80
|
-
|
81
|
-
This plugin makes it very easy to add different states to your models, like 'draft' vs 'live'.
|
82
|
-
By default it also adds validations of the field value.
|
83
|
-
|
84
|
-
Originally inspired by the Rails plugin +acts_as_publishable+ by <b>fr.ivolo.us</b>.
|
85
|
-
|
86
|
-
|
87
|
-
== Installation
|
88
|
-
|
89
|
-
# Add GitHub to your RubyGems sources
|
90
|
-
$ gem sources -a http://gems.github.com
|
91
|
-
|
92
|
-
$ (sudo)? gem install kematzy-dm-is-published
|
93
|
-
|
94
|
-
<b>NB! Depends upon the whole DataMapper suite being installed, and has ONLY been tested with DM 0.10.0 (next branch).</b>
|
95
|
-
|
96
|
-
|
97
|
-
== Getting Started
|
98
|
-
|
99
|
-
First of all, for a better understanding of this gem, make sure you study
|
100
|
-
the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file.
|
101
|
-
|
102
|
-
----
|
103
|
-
|
104
|
-
Require +dm-is-published+ in your app.
|
105
|
-
|
106
|
-
require 'dm-core' # must be required first
|
107
|
-
require 'dm-is-published'
|
108
|
-
|
109
|
-
Lets say we have an Article class, and each Article can have a current state,
|
110
|
-
ie: whether it's Live, Draft or an Obituary awaiting the death of someone famous (real or rumored)
|
111
|
-
|
112
|
-
|
113
|
-
class Article
|
114
|
-
include DataMapper::Resource
|
115
|
-
property :id, Serial
|
116
|
-
property :title, String
|
117
|
-
...<snip>
|
118
|
-
|
119
|
-
is :published
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
Once you have your Article model we can create our Articles just as normal
|
124
|
-
|
125
|
-
Article.create(:title => 'Example 1')
|
126
|
-
|
127
|
-
|
128
|
-
The instance of <tt>Article.get(1)</tt> now has the following things for free:
|
129
|
-
|
130
|
-
* a <tt>:publish_status</tt> attribute with the value <tt>'live'</tt>. Default choices are <tt>[ :live, :draft, :hidden ]</tt>.
|
131
|
-
|
132
|
-
* <tt>:is_live?, :is_draft? or :is_hidden?</tt> methods that returns true/false based upon the state.
|
133
|
-
|
134
|
-
* <tt>:save_as_live</tt>, <tt>:save_as_draft</tt> or <tt>:save_as_hidden</tt> converts the instance to the state and saves it.
|
135
|
-
|
136
|
-
* <tt>:publishable?</tt> method that returns true for models where <tt>is :published </tt> has been declared,
|
137
|
-
but <b>false</b> for those where it has not been declared.
|
138
|
-
|
139
|
-
|
140
|
-
The Article class also gets a bit of new functionality:
|
141
|
-
|
142
|
-
Article.all(:draft) => finds all Articles with :publish_status = :draft
|
143
|
-
|
144
|
-
|
145
|
-
Article.all(:draft, :author => @author_joe ) => finds all Articles with :publish_status = :draft and author == Joe
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
Todo Need to write more documentation here..
|
150
|
-
|
151
|
-
|
152
|
-
== Usage Scenarios
|
153
|
-
|
154
|
-
In a Blog/Publishing scenario you could use it like this:
|
155
|
-
|
156
|
-
class Article
|
157
|
-
...<snip>...
|
158
|
-
|
159
|
-
is :published :live, :draft, :hidden
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
Whereas in another scenario - like in a MenuItem model for a Restaurant - you could use it like this:
|
164
|
-
|
165
|
-
class MenuItem
|
166
|
-
...<snip>...
|
167
|
-
|
168
|
-
is :published :on, :off # the item is either on the menu or not
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
== RTFM
|
174
|
-
|
175
|
-
As I said above, for a better understanding of this gem/plugin, make sure you study the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file.
|
176
|
-
|
177
|
-
|
178
|
-
== Errors / Bugs
|
179
|
-
|
180
|
-
If something is not behaving intuitively, it is a bug, and should be reported.
|
181
|
-
Report it here: http://github.com/kematzy/dm-is-published/issues
|
182
|
-
|
183
|
-
== Credits
|
184
|
-
|
185
|
-
Copyright (c) 2009-07-11 [kematzy gmail com]
|
186
|
-
|
187
|
-
Loosely based on the ActsAsPublishable plugin by [http://fr.ivolo.us/posts/acts-as-publishable]
|
188
|
-
|
189
|
-
== Licence
|
190
|
-
|
191
|
-
Released under the MIT license.
|
192
|
-
|
75
|
+
description: A DataMapper plugin that provides an easy way to add different states to your models.
|
193
76
|
email: kematzy@gmail.com
|
194
77
|
executables: []
|
195
78
|
|
@@ -213,7 +96,6 @@ files:
|
|
213
96
|
- lib/dm-is-published/is/published.rb
|
214
97
|
- lib/dm-is-published/is/version.rb
|
215
98
|
- spec/integration/published_spec.rb
|
216
|
-
- spec/spec.opts
|
217
99
|
- spec/spec_helper.rb
|
218
100
|
has_rdoc: true
|
219
101
|
homepage: http://github.com/kematzy/dm-is-published
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|