kematzy-dm-is-published 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -10,6 +10,7 @@ tmtags
10
10
  coverage
11
11
  rdoc
12
12
  pkg
13
+ doc
13
14
 
14
15
  ## PROJECT::SPECIFIC
15
16
 
File without changes
data/README.rdoc CHANGED
@@ -100,9 +100,9 @@ As I said above, for a better understanding of this gem/plugin, make sure you st
100
100
  == Errors / Bugs
101
101
 
102
102
  If something is not behaving intuitively, it is a bug, and should be reported.
103
- Report it here: http://datamapper.lighthouseapp.com/
103
+ Report it here: http://github.com/kematzy/dm-is-published/issues
104
104
 
105
- === Credits
105
+ == Credits
106
106
 
107
107
  Copyright (c) 2009-07-11 [kematzy gmail com]
108
108
 
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ begin
12
12
  gem.email = "kematzy@gmail.com"
13
13
  gem.homepage = "http://github.com/kematzy/dm-is-published"
14
14
  gem.authors = ["kematzy"]
15
- gem.extra_rdoc_files = %w[ README.rdoc LICENSE TODO History.txt ]
15
+ gem.extra_rdoc_files = %w[ README.rdoc LICENSE TODO History.rdoc ]
16
16
  gem.add_dependency('dm-core', '>= 0.10.0')
17
17
  gem.add_dependency('dm-validations', '>= 0.10.0')
18
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -39,16 +39,37 @@ task :default => :spec
39
39
 
40
40
  require 'rake/rdoctask'
41
41
  Rake::RDocTask.new do |rdoc|
42
- if File.exist?('VERSION.yml')
43
- config = YAML.load(File.read('VERSION.yml'))
44
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
45
- else
46
- version = ""
47
- end
48
-
42
+ version = File.exist?('VERSION') ? IO.read('VERSION').chomp : "[Unknown]"
43
+
49
44
  rdoc.rdoc_dir = 'rdoc'
50
45
  rdoc.title = "dm-is-published #{version}"
51
46
  rdoc.rdoc_files.include('README*')
52
47
  rdoc.rdoc_files.include('lib/**/*.rb')
53
48
  end
54
49
 
50
+
51
+ desc 'Build the rdoc HTML Files'
52
+ task :docs do
53
+ version = File.exist?('VERSION') ? IO.read('VERSION').chomp : "[Unknown]"
54
+
55
+ sh "sdoc -N --title 'DM::Is::Published v#{version}' lib/dm-is-published README.rdoc"
56
+ end
57
+
58
+ namespace :docs do
59
+
60
+ desc 'Remove rdoc products'
61
+ task :remove => [:clobber_rdoc] do
62
+ sh "rm -rf doc"
63
+ end
64
+
65
+ desc 'Force a rebuild of the RDOC files'
66
+ task :rebuild => [:docs]
67
+
68
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
69
+ task :open => [:docs] do
70
+ browser = ENV["BROWSER"] || "safari"
71
+ sh "open -a #{browser} doc/index.html"
72
+ end
73
+
74
+ end
75
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{dm-is-published}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["kematzy"]
9
- s.date = %q{2009-07-12}
9
+ s.date = %q{2009-08-20}
10
10
  s.description = %q{= dm-is-published
11
11
 
12
12
  This plugin makes it very easy to add different states to your models, like 'draft' vs 'live'.
@@ -109,9 +109,9 @@ As I said above, for a better understanding of this gem/plugin, make sure you st
109
109
  == Errors / Bugs
110
110
 
111
111
  If something is not behaving intuitively, it is a bug, and should be reported.
112
- Report it here: http://datamapper.lighthouseapp.com/
112
+ Report it here: http://github.com/kematzy/dm-is-published/issues
113
113
 
114
- === Credits
114
+ == Credits
115
115
 
116
116
  Copyright (c) 2009-07-11 [kematzy gmail com]
117
117
 
@@ -123,14 +123,14 @@ Released under the MIT license.
123
123
  }
124
124
  s.email = %q{kematzy@gmail.com}
125
125
  s.extra_rdoc_files = [
126
- "History.txt",
126
+ "History.rdoc",
127
127
  "LICENSE",
128
128
  "README.rdoc",
129
129
  "TODO"
130
130
  ]
131
131
  s.files = [
132
132
  ".gitignore",
133
- "History.txt",
133
+ "History.rdoc",
134
134
  "LICENSE",
135
135
  "README.rdoc",
136
136
  "Rakefile",
@@ -99,9 +99,9 @@ module DataMapper
99
99
  # == Errors / Bugs
100
100
  #
101
101
  # If something is not behaving intuitively, it is a bug, and should be reported.
102
- # Report it here: http://datamapper.lighthouseapp.com/
102
+ # Report it here: http://github.com/kematzy/dm-is-published/issues
103
103
  #
104
- # === Credits
104
+ # == Credits
105
105
  #
106
106
  # Copyright (c) 2008-05-07 [Kematzy at gmail]
107
107
  #
@@ -203,18 +203,21 @@ module DataMapper
203
203
  # -- (Hash) => all(:key => "value") ( normal operations, so just pass on the Hash )
204
204
  # -- (Symbol) => all(:draft) ( just get the symbol, )
205
205
  # -- (Symbol, Hash ) => :draft, { extra options }
206
+ # -- (DataMapper somethings) => leave it alone
206
207
  if args.empty?
207
208
  return super
208
- elsif args.first.is_a?(Hash)
209
- return super(args.first)
210
- else
209
+ elsif args.first.is_a?(Symbol)
211
210
  # set the from args Array, remove first item if Symbol, and then check for 2nd item's presence
212
- state, options = args.shift.to_s, (args.blank? ? {} : args.first) if args.first.is_a?(Symbol)
211
+ state, options = args.shift.to_s, (args.blank? ? {} : args.first)
213
212
  # puts " and state=[#{state}] and options=[#{options.class}] options.inspect=[#{options.inspect}] [#{__FILE__}:#{__LINE__}]"
214
-
215
213
  return super({ :publish_status => state }.merge(options) )
214
+ elsif args.first.is_a?(Hash)
215
+ # puts "dm-is-published args.first was a HASH ] [#{__FILE__}:#{__LINE__}]"
216
+ return super(args.first)
217
+ else
218
+ # puts "dm-is-published (ELSE) [#{__FILE__}:#{__LINE__}]"
219
+ return super
216
220
  end
217
-
218
221
  end
219
222
 
220
223
  end # ClassMethods
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Is
3
3
  module Published
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  end
@@ -161,6 +161,15 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
161
161
 
162
162
  end #/ #self.all
163
163
 
164
+ describe "#first" do
165
+
166
+ it "should description" do
167
+ # Article.first.should == ''
168
+ # Article.first(:title => "Live Article").should == ''
169
+ end
170
+
171
+ end #/ #first
172
+
164
173
  end #/ Class Methods
165
174
 
166
175
  describe "Instance Methods" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kematzy-dm-is-published
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kematzy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-12 00:00:00 -07:00
12
+ date: 2009-08-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,20 +32,20 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.10.0
34
34
  version:
35
- description: "= dm-is-published This plugin makes it very easy to add different states to your models, like 'draft' vs 'live'. By default it also adds validations of the field value. Originally inspired by the Rails plugin +acts_as_publishable+ by <b>fr.ivolo.us</b>. == Installation # Add GitHub to your RubyGems sources $ gem sources -a http://gems.github.com $ (sudo)? gem install kematzy-dm-is-published <b>NB! Depends upon the whole DataMapper suite being installed, and has ONLY been tested with DM 0.10.0 (next branch).</b> == Getting Started First of all, for a better understanding of this gem, make sure you study the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file. ---- Require +dm-is-published+ in your app. require 'dm-core' # must be required first require 'dm-is-published' Lets say we have an Article class, and each Article can have a current state, ie: whether it's Live, Draft or an Obituary awaiting the death of someone famous (real or rumored) class Article include DataMapper::Resource property :id, Serial property :title, String ...<snip> is :published end Once you have your Article model we can create our Articles just as normal Article.create(:title => 'Example 1') The instance of <tt>Article.get(1)</tt> now has the following things for free: * a <tt>:publish_status</tt> attribute with the value <tt>'live'</tt>. Default choices are <tt>[ :live, :draft, :hidden ]</tt>. * <tt>:is_live?, :is_draft? or :is_hidden?</tt> methods that returns true/false based upon the state. * <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. * <tt>:publishable?</tt> method that returns true for models where <tt>is :published </tt> has been declared, but <b>false</b> for those where it has not been declared. The Article class also gets a bit of new functionality: Article.all(:draft) => finds all Articles with :publish_status = :draft Article.all(:draft, :author => @author_joe ) => finds all Articles with :publish_status = :draft and author == Joe Todo Need to write more documentation here.. == Usage Scenarios In a Blog/Publishing scenario you could use it like this: class Article ...<snip>... is :published :live, :draft, :hidden end Whereas in another scenario - like in a MenuItem model for a Restaurant - you could use it like this: class MenuItem ...<snip>... is :published :on, :off # the item is either on the menu or not end == RTFM 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. == Errors / Bugs If something is not behaving intuitively, it is a bug, and should be reported. Report it here: http://datamapper.lighthouseapp.com/ === Credits Copyright (c) 2009-07-11 [kematzy gmail com] Loosely based on the ActsAsPublishable plugin by [http://fr.ivolo.us/posts/acts-as-publishable] == Licence Released under the MIT license."
35
+ description: "= dm-is-published This plugin makes it very easy to add different states to your models, like 'draft' vs 'live'. By default it also adds validations of the field value. Originally inspired by the Rails plugin +acts_as_publishable+ by <b>fr.ivolo.us</b>. == Installation # Add GitHub to your RubyGems sources $ gem sources -a http://gems.github.com $ (sudo)? gem install kematzy-dm-is-published <b>NB! Depends upon the whole DataMapper suite being installed, and has ONLY been tested with DM 0.10.0 (next branch).</b> == Getting Started First of all, for a better understanding of this gem, make sure you study the '<tt>dm-is-published/spec/integration/published_spec.rb</tt>' file. ---- Require +dm-is-published+ in your app. require 'dm-core' # must be required first require 'dm-is-published' Lets say we have an Article class, and each Article can have a current state, ie: whether it's Live, Draft or an Obituary awaiting the death of someone famous (real or rumored) class Article include DataMapper::Resource property :id, Serial property :title, String ...<snip> is :published end Once you have your Article model we can create our Articles just as normal Article.create(:title => 'Example 1') The instance of <tt>Article.get(1)</tt> now has the following things for free: * a <tt>:publish_status</tt> attribute with the value <tt>'live'</tt>. Default choices are <tt>[ :live, :draft, :hidden ]</tt>. * <tt>:is_live?, :is_draft? or :is_hidden?</tt> methods that returns true/false based upon the state. * <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. * <tt>:publishable?</tt> method that returns true for models where <tt>is :published </tt> has been declared, but <b>false</b> for those where it has not been declared. The Article class also gets a bit of new functionality: Article.all(:draft) => finds all Articles with :publish_status = :draft Article.all(:draft, :author => @author_joe ) => finds all Articles with :publish_status = :draft and author == Joe Todo Need to write more documentation here.. == Usage Scenarios In a Blog/Publishing scenario you could use it like this: class Article ...<snip>... is :published :live, :draft, :hidden end Whereas in another scenario - like in a MenuItem model for a Restaurant - you could use it like this: class MenuItem ...<snip>... is :published :on, :off # the item is either on the menu or not end == RTFM 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. == Errors / Bugs If something is not behaving intuitively, it is a bug, and should be reported. Report it here: http://github.com/kematzy/dm-is-published/issues == Credits Copyright (c) 2009-07-11 [kematzy gmail com] Loosely based on the ActsAsPublishable plugin by [http://fr.ivolo.us/posts/acts-as-publishable] == Licence Released under the MIT license."
36
36
  email: kematzy@gmail.com
37
37
  executables: []
38
38
 
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - History.txt
42
+ - History.rdoc
43
43
  - LICENSE
44
44
  - README.rdoc
45
45
  - TODO
46
46
  files:
47
47
  - .gitignore
48
- - History.txt
48
+ - History.rdoc
49
49
  - LICENSE
50
50
  - README.rdoc
51
51
  - Rakefile
@@ -60,6 +60,7 @@ files:
60
60
  - spec/spec_helper.rb
61
61
  has_rdoc: false
62
62
  homepage: http://github.com/kematzy/dm-is-published
63
+ licenses:
63
64
  post_install_message:
64
65
  rdoc_options:
65
66
  - --charset=UTF-8
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  requirements: []
81
82
 
82
83
  rubyforge_project:
83
- rubygems_version: 1.2.0
84
+ rubygems_version: 1.3.5
84
85
  signing_key:
85
86
  specification_version: 3
86
87
  summary: A DataMapper plugin that provides an easy way to add different states to your models.