workflow_on_mongoid 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT_LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Mani Tadayon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = Overview
2
+
3
+ == About workflow_on_mongoid
4
+
5
+ workflow_on_mongoid lets you use the {Workflow}[http://github.com/geekq/workflow] gem with your {Mongoid}[http://mongoid.org/] documents to add state machine functionality.
6
+
7
+ == How to use it
8
+
9
+ In your Gemfile, instead of
10
+ gem 'workflow'
11
+
12
+ do
13
+ gem 'workflow_on_mongoid'
14
+
15
+ That is all. Now you can use {Workflow}[http://github.com/geekq/workflow] with your {Mongoid}[http://mongoid.org/] documents. Of course, you can still continue to use {Workflow}[http://github.com/geekq/workflow] with ActiveRecord, Remodel and plain objects. All that workflow_on_mongoid does is to add {Mongoid}[http://mongoid.org/] support. You can use all the features of {Workflow}[http://github.com/geekq/workflow] with {Mongoid}[http://mongoid.org/] models, including reflection of events & states, transition hooks, support for inherited models, etc. Just refer to the {Workflow docs}[http://github.com/geekq/workflow].
16
+
17
+
18
+ == Versioning
19
+
20
+ The version numbers of workflow_on_mongoid match the latest supported version of {Workflow}[http://github.com/geekq/workflow] . The current version is 0.7.0 .
21
+
22
+ == Example
23
+ class MongoidImage
24
+ include Mongoid::Document
25
+
26
+ field :title
27
+ field :status
28
+
29
+ include Workflow
30
+
31
+ workflow_column :status
32
+
33
+ workflow do
34
+ state :unconverted do
35
+ event :convert, :transitions_to => :converted
36
+ end
37
+ state :converted
38
+ end
39
+ end
40
+
41
+ See the {tests for Mongoid}[http://github.com/bowsersenior/workflow_on_mongoid/blob/master/test/mongoid_test.rb] for more examples.
42
+
43
+ == Tests
44
+
45
+ I've included all the tests from the original workflow gem and added comprehensive tests for {Mongoid}[http://mongoid.org/] support. {Mongoid}[http://mongoid.org/] is now as well-tested as ActiveRecord. Including the existing tests ensures that workflow_on_mongoid implements support for {Mongoid}[http://mongoid.org/] documents without breaking anything.
46
+
47
+ = Project Info
48
+
49
+ workflow_on_mongoid is hosted on Github: http://github.com/bowsersenior/workflow_on_mongoid . It's a tiny project, but your contributions, forkings, comments and feedback are definitely appreciated.
50
+
51
+ Copyright (c) 2010 Mani Tadayon, released under the MIT License
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ module WorkflowOnMongoid #:nodoc
3
+ VERSION = "0.7.0" # version matches the latest supported version of the Workflow gem
4
+ end
@@ -0,0 +1,35 @@
1
+ require 'workflow'
2
+
3
+ module Workflow
4
+ module MongoidInstanceMethods
5
+ def load_workflow_state
6
+ send(self.class.workflow_column)
7
+ end
8
+
9
+ def persist_workflow_state(new_value)
10
+ self.update_attributes!(self.class.workflow_column => new_value)
11
+ end
12
+
13
+ private
14
+ def write_initial_state
15
+ update_attributes(self.class.workflow_column => current_state.to_s) if load_workflow_state.blank?
16
+ end
17
+ end
18
+
19
+ def self.included(klass)
20
+ klass.send :include, WorkflowInstanceMethods
21
+ klass.extend WorkflowClassMethods
22
+ if Object.const_defined?(:ActiveRecord) && klass < ActiveRecord::Base
23
+ klass.send :include, ActiveRecordInstanceMethods
24
+ klass.before_validation :write_initial_state
25
+ elsif Object.const_defined?(:Remodel) && klass < Remodel::Entity
26
+ klass.send :include, RemodelInstanceMethods
27
+ elsif Object.const_defined?(:Mongoid) && klass < Mongoid::Document
28
+ klass.class_eval do
29
+ klass.send :field, klass.workflow_column
30
+ klass.send :include, MongoidInstanceMethods
31
+ klass.before_validation :write_initial_state
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1 @@
1
+ require 'workflow_on_mongoid/workflow'
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workflow_on_mongoid
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
+ platform: ruby
12
+ authors:
13
+ - Mani Tadayon
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-11 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: workflow
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 7
33
+ version: "0.7"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: mongoid
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - "="
43
+ - !ruby/object:Gem::Version
44
+ hash: 62196421
45
+ segments:
46
+ - 2
47
+ - 0
48
+ - 0
49
+ - beta
50
+ - 19
51
+ version: 2.0.0.beta.19
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: bson_ext
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 13
63
+ segments:
64
+ - 1
65
+ - 1
66
+ version: "1.1"
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - "="
76
+ - !ruby/object:Gem::Version
77
+ hash: 49
78
+ segments:
79
+ - 0
80
+ - 8
81
+ - 7
82
+ version: 0.8.7
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 7712058
94
+ segments:
95
+ - 2
96
+ - 0
97
+ - 0
98
+ - rc
99
+ version: 2.0.0.rc
100
+ type: :development
101
+ version_requirements: *id005
102
+ - !ruby/object:Gem::Dependency
103
+ name: activerecord
104
+ prerelease: false
105
+ requirement: &id006 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ type: :development
115
+ version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
117
+ name: sqlite3-ruby
118
+ prerelease: false
119
+ requirement: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ type: :development
129
+ version_requirements: *id007
130
+ - !ruby/object:Gem::Dependency
131
+ name: mocha
132
+ prerelease: false
133
+ requirement: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ hash: 3
139
+ segments:
140
+ - 0
141
+ version: "0"
142
+ type: :development
143
+ version_requirements: *id008
144
+ - !ruby/object:Gem::Dependency
145
+ name: ruby-debug
146
+ prerelease: false
147
+ requirement: &id009 !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 3
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ type: :development
157
+ version_requirements: *id009
158
+ description: Lets you use the Workflow gem with your Mongoid documents to add state machine functionality.
159
+ email:
160
+ - bowsersenior@gmail.com
161
+ executables: []
162
+
163
+ extensions: []
164
+
165
+ extra_rdoc_files: []
166
+
167
+ files:
168
+ - lib/workflow_on_mongoid/version.rb
169
+ - lib/workflow_on_mongoid/workflow.rb
170
+ - lib/workflow_on_mongoid.rb
171
+ - MIT_LICENSE
172
+ - README.rdoc
173
+ has_rdoc: true
174
+ homepage: http://github.com/bowsersenior/workflow_on_mongoid
175
+ licenses: []
176
+
177
+ post_install_message:
178
+ rdoc_options: []
179
+
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 21
197
+ segments:
198
+ - 1
199
+ - 3
200
+ - 7
201
+ version: 1.3.7
202
+ requirements: []
203
+
204
+ rubyforge_project:
205
+ rubygems_version: 1.3.7
206
+ signing_key:
207
+ specification_version: 3
208
+ summary: Add Mongoid support to the Workflow gem.
209
+ test_files: []
210
+