dm-is-published 0.0.1 → 0.0.2

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