publishus 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +96 -10
- data/VERSION +1 -1
- data/lib/publishus.rb +1 -1
- data/publishus.gemspec +5 -5
- metadata +13 -4
data/README.rdoc
CHANGED
@@ -1,17 +1,103 @@
|
|
1
1
|
= publishus
|
2
2
|
|
3
|
-
|
3
|
+
== Introduction
|
4
4
|
|
5
|
-
|
5
|
+
At this stage this is purely an experimental piece of work to help me understand more of everything. It came about because of our need for a generic publishing framework to support the following needs:
|
6
|
+
|
7
|
+
* Allow for editing of generic content whilst retaining all the revision history
|
8
|
+
* Allow for publishing individual content items when theyre ready to go live
|
9
|
+
* Allow publishing of all unpublished content at once
|
10
|
+
|
11
|
+
== Implementation
|
12
|
+
|
13
|
+
We looked at some of the versioning frameworks, all of them seemed capable but we saw none that really addressed publishing as such. The one that stood out was <tt>vestal_versions</tt>[http://github.com/laserlemon/vestal_versions] so we used that as our starting point. This is an extremely thin layer on top of the excellent <tt>vestal_versions</tt>[http://github.com/laserlemon/vestal_versions]. Vestal versions handles all of the revisioning off to another table and some really nice features but we needed a way to track publishing itself hence some additional attributes on our models and some extra methods. The basic idea is that all publishable items gain a <tt>named_scope</tt> called <tt>published</tt> which will filter down the results to only include items that are currently considered "live". Each instance gains a <tt>live</tt> method that will return the current live version of that object. For now when using the named_scope you've got to call a proxy extension called <tt></tt> live. The named_scope returns items that have a published version and the live method actually reverts the items to those versions.
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
|
17
|
+
Prerequisites:
|
18
|
+
|
19
|
+
publishus requires vestal_versions by laserlemon
|
20
|
+
Follow instructions on installing <tt>vestal_versions</tt>[http://github.com/laserlemon/vestal_versions] first
|
21
|
+
|
22
|
+
Install the gem:
|
23
|
+
|
24
|
+
gem install publishus
|
25
|
+
|
26
|
+
In <tt>environment.rb</tt>:
|
27
|
+
|
28
|
+
Rails::Initializer.run do |config|
|
29
|
+
...
|
30
|
+
config.gem 'publishus'
|
31
|
+
...
|
32
|
+
end
|
33
|
+
|
34
|
+
At your application root, run:
|
35
|
+
|
36
|
+
$ sudo rake gems:install
|
37
|
+
|
38
|
+
== Example
|
39
|
+
|
40
|
+
To version and activate publishing add this to your models:
|
41
|
+
|
42
|
+
class Post < ActiveRecord::Base
|
43
|
+
publishable
|
44
|
+
has_many :comments
|
45
|
+
end
|
46
|
+
|
47
|
+
class Comment < ActiveRecord::Base
|
48
|
+
publishable
|
49
|
+
belongs_to :page
|
50
|
+
end
|
51
|
+
|
52
|
+
And add some fields to your tables in a migration (hopefully we'll automate this stuff later):
|
53
|
+
|
54
|
+
add_column :posts, :published_at, :datetime
|
55
|
+
add_column :posts, :deleted_at, :datetime
|
56
|
+
add_column :comments, :published_at, :datetime
|
57
|
+
add_column :comments, :deleted_at, :datetime
|
58
|
+
|
59
|
+
Using it:
|
60
|
+
|
61
|
+
>> page = Page.create(:name => "Page 1")
|
62
|
+
=> #<Page id: 1, name: "Page 1">
|
63
|
+
>> page.version
|
64
|
+
=> 1 (this bit is vestal versions magic)
|
65
|
+
>> page.publish!
|
66
|
+
=> true
|
67
|
+
>> page.update_attribute(:name, "Page 2")
|
68
|
+
=> true
|
69
|
+
>> page
|
70
|
+
=> #<Page id: 1, name: "Page 2">
|
71
|
+
>> page.live
|
72
|
+
=> #<Page id: 1, name: "Page 1">
|
73
|
+
>> Page.published.live
|
74
|
+
=> [#<Page id: 1, name: "Page 1">]
|
75
|
+
|
76
|
+
And for associations
|
77
|
+
|
78
|
+
>> page.comments.create(:body => "Great page")
|
79
|
+
=> #<Comment id: 1, body: "Great page">
|
80
|
+
>> page.comments.published
|
81
|
+
=> []
|
82
|
+
>> page.comments.first.publish!
|
83
|
+
=> true
|
84
|
+
>> page.comments.published.live
|
85
|
+
=> [#<Comment id: 1, body: "Great page">]
|
86
|
+
>> page.comments.first.update_attribute(:body, "Just an ok page")
|
87
|
+
=> true
|
88
|
+
>> page.comments.create(:body => "Another comment")
|
89
|
+
=> #<Comment id: 2, body: "Another comment">
|
90
|
+
>> page.comments
|
91
|
+
=> [#<Comment id: 1, body: "Just an ok page">, #<Comment id: 2, body: "Another comment">]
|
92
|
+
>> page.comments.published.live
|
93
|
+
=> [#<Comment id: 1, body: "Great page">]
|
94
|
+
|
95
|
+
|
96
|
+
== Notes
|
6
97
|
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
98
|
+
* I really would't use this, its not tested and its not finished
|
99
|
+
* If you're interested in helping out or know of something that already does this then let me know
|
14
100
|
|
15
101
|
== Copyright
|
16
102
|
|
17
|
-
Copyright (c) 2010 lostboy. See LICENSE for details.
|
103
|
+
Copyright (c) 2010 lostboy. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/publishus.rb
CHANGED
data/publishus.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{publishus}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["lostboy"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-18}
|
13
13
|
s.description = %q{Publishus allows active record models and associations to be published and exist both in a 'current' and 'live' state}
|
14
14
|
s.email = %q{paul.crabtree@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.homepage = %q{http://github.com/lostboy/publishus}
|
32
32
|
s.rdoc_options = ["--charset=UTF-8"]
|
33
33
|
s.require_paths = ["lib"]
|
34
|
-
s.rubygems_version = %q{1.3.
|
34
|
+
s.rubygems_version = %q{1.3.7}
|
35
35
|
s.summary = %q{An experimental publishing structure on top of vestal versions}
|
36
36
|
s.test_files = [
|
37
37
|
"test/helper.rb",
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
43
|
s.specification_version = 3
|
44
44
|
|
45
|
-
if Gem::Version.new(Gem::
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
46
|
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
47
47
|
s.add_runtime_dependency(%q<vestal_versions>, ["= 1.0.2"])
|
48
48
|
else
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- lostboy
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-05-18 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: thoughtbot-shoulda
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: vestal_versions
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - "="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 19
|
39
44
|
segments:
|
40
45
|
- 1
|
41
46
|
- 0
|
@@ -73,23 +78,27 @@ rdoc_options:
|
|
73
78
|
require_paths:
|
74
79
|
- lib
|
75
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
76
82
|
requirements:
|
77
83
|
- - ">="
|
78
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
79
86
|
segments:
|
80
87
|
- 0
|
81
88
|
version: "0"
|
82
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
83
91
|
requirements:
|
84
92
|
- - ">="
|
85
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
86
95
|
segments:
|
87
96
|
- 0
|
88
97
|
version: "0"
|
89
98
|
requirements: []
|
90
99
|
|
91
100
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.3.
|
101
|
+
rubygems_version: 1.3.7
|
93
102
|
signing_key:
|
94
103
|
specification_version: 3
|
95
104
|
summary: An experimental publishing structure on top of vestal versions
|