simplificator-fsm 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,3 +1,8 @@
1
+ if RUBY_VERSION >= "1.9"
2
+ require 'psych'
3
+ end
4
+ require 'yaml'
5
+
1
6
  require 'rubygems'
2
7
  require 'rake'
3
8
 
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
- :minor: 3
3
- :patch: 8
4
2
  :major: 0
3
+ :minor: 3
4
+ :patch: 9
5
+ :build:
data/fsm.gemspec ADDED
@@ -0,0 +1,65 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = %q{fsm}
4
+ s.version = "0.3.5"
5
+
6
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
+ s.authors = ["simplificator"]
8
+ s.date = %q{2009-06-30}
9
+ s.email = %q{info@simplificator.com}
10
+ s.extra_rdoc_files = [
11
+ "LICENSE",
12
+ "README.markdown"
13
+ ]
14
+ s.files = [
15
+ "LICENSE",
16
+ "README.markdown",
17
+ "Rakefile",
18
+ "VERSION.yml",
19
+ "lib/fsm.rb",
20
+ "lib/fsm/builder.rb",
21
+ "lib/fsm/errors.rb",
22
+ "lib/fsm/executable.rb",
23
+ "lib/fsm/machine.rb",
24
+ "lib/fsm/options.rb",
25
+ "lib/fsm/state.rb",
26
+ "lib/fsm/state_attribute_interceptor.rb",
27
+ "lib/fsm/transition.rb",
28
+ "test/ar_test.rb",
29
+ "test/executable_test.rb",
30
+ "test/invoice_sample_test.rb",
31
+ "test/options_test.rb",
32
+ "test/state_test.rb",
33
+ "test/test_helper.rb",
34
+ "test/test_helper_ar.rb",
35
+ "test/transition_test.rb",
36
+ "test/water_sample_test.rb"
37
+ ]
38
+ s.has_rdoc = true
39
+ s.homepage = %q{http://github.com/simplificator/fsm}
40
+ s.rdoc_options = ["--charset=UTF-8"]
41
+ s.require_paths = ["lib"]
42
+ s.rubygems_version = %q{1.3.2}
43
+ s.summary = %q{A simple finite state machine (FSM) gem.}
44
+ s.test_files = [
45
+ "test/ar_test.rb",
46
+ "test/executable_test.rb",
47
+ "test/invoice_sample_test.rb",
48
+ "test/options_test.rb",
49
+ "test/state_test.rb",
50
+ "test/test_helper.rb",
51
+ "test/test_helper_ar.rb",
52
+ "test/transition_test.rb",
53
+ "test/water_sample_test.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
+ else
62
+ end
63
+ else
64
+ end
65
+ end
data/lib/fsm/builder.rb CHANGED
@@ -1,18 +1,24 @@
1
1
  module FSM
2
2
  # Builder exposes 'only' (well there are some other methods exposed) the methods that are required to build the configuration
3
3
  class Builder
4
-
4
+
5
5
  # Blank Slate
6
- instance_methods.each do |m|
7
- undef_method m unless m == '__send__' || m == '__id__' || m == 'instance_eval'
6
+ if RUBY_VERSION < "1.9"
7
+ instance_methods.each do |m|
8
+ undef_method m unless m == "object_id" || m == "__send__" || m == "__id__" || m == "instance_eval"
9
+ end
10
+ else
11
+ instance_methods.each do |m|
12
+ undef_method m unless m == :object_id || m == :__send__ || m == :__id__ || m == :instance_eval
13
+ end
8
14
  end
9
-
15
+
10
16
  # Create a new Builder which creates a Machine for the target_class
11
17
  def initialize(target_class)
12
18
  @target_class = target_class
13
19
  @machine = Machine.new(target_class)
14
20
  end
15
-
21
+
16
22
  def process(&block)
17
23
  raise ArgumentError.new('Block expected') unless block_given?
18
24
  self.instance_eval(&block)
@@ -20,37 +26,37 @@ module FSM
20
26
  @machine.build_state_check_methods
21
27
  @machine
22
28
  end
23
-
29
+
24
30
  private
25
31
  # Add a transition
26
- # * name of the transition
32
+ # * name of the transition
27
33
  # * from_name: name of the source state (symbol)
28
34
  # * to_name: name of the target state (symbol)
29
35
  # * options
30
- #
36
+ #
31
37
  def transition(name, from_names, to_name, options = {})
32
38
  Array(from_names).each do |from_name|
33
39
  @machine.transition(name, from_name, to_name, options)
34
40
  end
35
41
  nil # do not expose FSM details
36
42
  end
37
-
43
+
38
44
  def state_attribute(name)
39
45
  raise ArgumentError.new('Invalid attribute name') if name == nil
40
46
  @machine.current_state_attribute_name = name
41
47
  nil # do not expose FSM details
42
48
  end
43
-
49
+
44
50
  def initial(name)
45
51
  @machine.initial_state_name = name
46
52
  nil # do not expose FSM details
47
53
  end
48
-
54
+
49
55
  def state(name, options = {})
50
56
  @machine.state(name, options)
51
57
  nil # do not expose FSM details
52
58
  end
53
-
59
+
54
60
  def states(*names)
55
61
  names.each do |name|
56
62
  state(name)
@@ -1,28 +1,28 @@
1
1
  module FSM
2
2
  #
3
3
  # Execute an action specified by either String, Sylbol or Proc.
4
- # Symbol and String represent methods which are called on the target object, Proc will get executed
4
+ # Symbol and String represent methods which are called on the target object, Proc will get executed
5
5
  # and receives at least the target as parameter. If others parameters are passed then they'll get forwarded as well.
6
6
  class Executable
7
7
  # Create a new Executable
8
- # if args is true, then arguments are passed on to the target method or the Proc, if false nothing
8
+ # if args is true, then arguments are passed on to the target method or the Proc, if false nothing
9
9
  # will get passed
10
10
  def initialize(thing)
11
11
  raise ArgumentError.new("Unknown thing #{thing}") unless thing
12
12
  @thing = thing
13
13
  end
14
-
14
+
15
15
  # execute this executable on the given target
16
16
  def execute(target, *args)
17
17
  case @thing
18
- when String, Symbol:
18
+ when String, Symbol
19
19
  if (args.length > 0)
20
20
  target.send(@thing, *args)
21
21
  else
22
22
  target.send(@thing)
23
23
  end
24
- when Proc:
25
- if (args.length > 0)
24
+ when Proc
25
+ if (args.length > 0)
26
26
  @thing.call(target, *args)
27
27
  else
28
28
  @thing.call(target)
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{simplificator-fsm}
8
+ s.version = "0.3.9"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["simplificator"]
12
+ s.date = %q{2011-10-24}
13
+ s.email = %q{info@simplificator.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ "LICENSE",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION.yml",
24
+ "fsm.gemspec",
25
+ "lib/fsm.rb",
26
+ "lib/fsm/builder.rb",
27
+ "lib/fsm/dot.rb",
28
+ "lib/fsm/errors.rb",
29
+ "lib/fsm/executable.rb",
30
+ "lib/fsm/machine.rb",
31
+ "lib/fsm/options.rb",
32
+ "lib/fsm/state.rb",
33
+ "lib/fsm/state_attribute_interceptor.rb",
34
+ "lib/fsm/transition.rb",
35
+ "samples/ticket/ticket.png",
36
+ "samples/ticket/ticket.ps",
37
+ "samples/ticket/ticket_sample.rb",
38
+ "simplificator-fsm.gemspec",
39
+ "test/ar_test.rb",
40
+ "test/executable_test.rb",
41
+ "test/invoice_sample_test.rb",
42
+ "test/options_test.rb",
43
+ "test/state_test.rb",
44
+ "test/test_helper.rb",
45
+ "test/test_helper_ar.rb",
46
+ "test/transition_test.rb",
47
+ "test/water_sample_test.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/simplificator/fsm}
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.6.2}
52
+ s.summary = %q{A simple finite state machine (FSM) gem.}
53
+
54
+ if s.respond_to? :specification_version then
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
+ else
59
+ end
60
+ else
61
+ end
62
+ end
63
+
@@ -27,5 +27,5 @@ class Order < ActiveRecord::Base
27
27
  end
28
28
  end
29
29
 
30
- ActiveRecord::Base.logger = Logger.new(STDOUT)
31
- ActiveRecord::Base.logger.level = Logger::DEBUG # change to DEBUG if you want to see something :-)
30
+ # ActiveRecord::Base.logger = Logger.new(STDOUT)
31
+ # ActiveRecord::Base.logger.level = Logger::DEBUG # change to DEBUG if you want to see something :-)
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplificator-fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ prerelease:
5
+ version: 0.3.9
5
6
  platform: ruby
6
7
  authors:
7
8
  - simplificator
@@ -9,8 +10,7 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-12-07 00:00:00 +01:00
13
- default_executable:
13
+ date: 2011-10-24 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description:
@@ -24,11 +24,11 @@ extra_rdoc_files:
24
24
  - README.markdown
25
25
  files:
26
26
  - .document
27
- - .gitignore
28
27
  - LICENSE
29
28
  - README.markdown
30
29
  - Rakefile
31
30
  - VERSION.yml
31
+ - fsm.gemspec
32
32
  - lib/fsm.rb
33
33
  - lib/fsm/builder.rb
34
34
  - lib/fsm/dot.rb
@@ -42,6 +42,7 @@ files:
42
42
  - samples/ticket/ticket.png
43
43
  - samples/ticket/ticket.ps
44
44
  - samples/ticket/ticket_sample.rb
45
+ - simplificator-fsm.gemspec
45
46
  - test/ar_test.rb
46
47
  - test/executable_test.rb
47
48
  - test/invoice_sample_test.rb
@@ -51,41 +52,32 @@ files:
51
52
  - test/test_helper_ar.rb
52
53
  - test/transition_test.rb
53
54
  - test/water_sample_test.rb
54
- has_rdoc: true
55
55
  homepage: http://github.com/simplificator/fsm
56
56
  licenses: []
57
57
 
58
58
  post_install_message:
59
- rdoc_options:
60
- - --charset=UTF-8
59
+ rdoc_options: []
60
+
61
61
  require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
64
65
  requirements:
65
66
  - - ">="
66
67
  - !ruby/object:Gem::Version
67
68
  version: "0"
68
- version:
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
70
71
  requirements:
71
72
  - - ">="
72
73
  - !ruby/object:Gem::Version
73
74
  version: "0"
74
- version:
75
75
  requirements: []
76
76
 
77
77
  rubyforge_project:
78
- rubygems_version: 1.3.5
78
+ rubygems_version: 1.8.8
79
79
  signing_key:
80
80
  specification_version: 3
81
81
  summary: A simple finite state machine (FSM) gem.
82
- test_files:
83
- - test/ar_test.rb
84
- - test/executable_test.rb
85
- - test/invoice_sample_test.rb
86
- - test/options_test.rb
87
- - test/state_test.rb
88
- - test/test_helper.rb
89
- - test/test_helper_ar.rb
90
- - test/transition_test.rb
91
- - test/water_sample_test.rb
82
+ test_files: []
83
+
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- **/.DS_Store
4
- coverage
5
- rdoc
6
- pkg
7
- *.sqlite3
8
- **/*.sqlite3