apollo 1.0.0

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.
@@ -0,0 +1,37 @@
1
+ require 'apollo'
2
+ class Article
3
+ include Apollo
4
+ apollo do
5
+ state :new do
6
+ event :submit, :to => :awaiting_review
7
+ end
8
+ state :awaiting_review do
9
+ event :review, :to => :being_reviewed
10
+ end
11
+ state :being_reviewed do
12
+ event :accept, :to => :accepted
13
+ event :reject, :to => :rejected
14
+ end
15
+ state :accepted
16
+ state :rejected
17
+ end
18
+ end
19
+
20
+ article = Article.new
21
+ article.accepted? # => false
22
+ article.new? # => true
23
+ article.submit!
24
+ article.review!
25
+
26
+ puts article.current_state # => being_reviewed
27
+
28
+
29
+ class Article
30
+ def reject
31
+ puts "send email to the author here explaining the reason for the rejection"
32
+ end
33
+ end
34
+
35
+ article.reject! # will cause a state transition, would persist the new
36
+ # state (if inherited from ActiveRecord), and invoke the callback -
37
+ # send email to the author.
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ class << Test::Unit::TestCase
5
+ def test(name, &block)
6
+ test_name = :"test_#{name.gsub(' ','_')}"
7
+ raise ArgumentError, "#{test_name} is already defined" if self.instance_methods.include? test_name.to_s
8
+ if block
9
+ define_method test_name, &block
10
+ else
11
+ puts "PENDING: #{name}"
12
+ end
13
+ end
14
+ end
15
+
16
+
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+ require 'apollo'
3
+
4
+ class WithoutApolloTest < Test::Unit::TestCase
5
+ class Article
6
+ include Apollo
7
+ apollo do
8
+ state :new do
9
+ event :submit, :to => :awaiting_review
10
+ end
11
+ state :awaiting_review do
12
+ event :review, :to => :being_reviewed
13
+ end
14
+ state :being_reviewed do
15
+ event :accept, :to => :accepted
16
+ event :reject, :to => :rejected
17
+ end
18
+ state :accepted
19
+ state :rejected
20
+ end
21
+ end
22
+
23
+ def test_readme_example_article
24
+ article = Article.new
25
+ assert article.new?
26
+ end
27
+
28
+ test 'better error message on to typo' do
29
+ assert_raise Apollo::ApolloDefinitionError do
30
+ Class.new do
31
+ include Apollo
32
+ apollo do
33
+ state :new do
34
+ event :event1, :transitionnn => :next # missing to target
35
+ end
36
+ state :next
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ test 'check transition_to alias' do
43
+ Class.new do
44
+ include Apollo
45
+ apollo do
46
+ state :new do
47
+ event :event1, :transition_to => :next
48
+ end
49
+ state :next
50
+ end
51
+ end
52
+ end
53
+ end
54
+
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apollo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Travis D. Warlick, Jr.
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-23 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: warlickt@operissystems.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.markdown
30
+ files:
31
+ - .gitignore
32
+ - LICENSE
33
+ - MIT-LICENSE
34
+ - README.markdown
35
+ - Rakefile
36
+ - VERSION
37
+ - apollo.gemspec
38
+ - lib/apollo.rb
39
+ - lib/apollo/active_record_instance_methods.rb
40
+ - lib/apollo/event.rb
41
+ - lib/apollo/specification.rb
42
+ - lib/apollo/state.rb
43
+ - test/couchtiny_example.rb
44
+ - test/main_test.rb
45
+ - test/readme_example.rb
46
+ - test/test_helper.rb
47
+ - test/without_active_record_test.rb
48
+ has_rdoc: true
49
+ homepage: http://github.com/tekwiz/apollo
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --charset=UTF-8
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.3.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: "A fork of workflow: a finite-state-machine-inspired API for modeling and interacting with what we tend to refer to as 'workflow'."
78
+ test_files:
79
+ - test/couchtiny_example.rb
80
+ - test/main_test.rb
81
+ - test/readme_example.rb
82
+ - test/test_helper.rb
83
+ - test/without_active_record_test.rb