gexp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +1 -0
  6. data/gexp.gemspec +32 -0
  7. data/lib/gexp.rb +16 -0
  8. data/lib/gexp/command.rb +50 -0
  9. data/lib/gexp/command/object.rb +37 -0
  10. data/lib/gexp/command/stack.rb +50 -0
  11. data/lib/gexp/handler.rb +25 -0
  12. data/lib/gexp/handler/caller.rb +8 -0
  13. data/lib/gexp/handler/check.rb +9 -0
  14. data/lib/gexp/handler/check/item.rb +34 -0
  15. data/lib/gexp/handler/check/resources.rb +56 -0
  16. data/lib/gexp/handler/modify.rb +9 -0
  17. data/lib/gexp/handler/modify/resources.rb +81 -0
  18. data/lib/gexp/handler/producer.rb +61 -0
  19. data/lib/gexp/handler/transition.rb +44 -0
  20. data/lib/gexp/handler/transition/builder.rb +33 -0
  21. data/lib/gexp/mongoid.rb +4 -0
  22. data/lib/gexp/mongoid/transaction.rb +266 -0
  23. data/lib/gexp/object.rb +39 -0
  24. data/lib/gexp/receiver.rb +33 -0
  25. data/lib/gexp/state_definition.rb +4 -0
  26. data/lib/gexp/state_definition/state_machine.rb +90 -0
  27. data/lib/gexp/version.rb +3 -0
  28. data/spec/gexp/command/object_spec.rb +84 -0
  29. data/spec/gexp/command/stack_spec.rb +74 -0
  30. data/spec/gexp/command_spec.rb +59 -0
  31. data/spec/gexp/handler/check/item_spec.rb +45 -0
  32. data/spec/gexp/handler/check/resources_spec.rb +81 -0
  33. data/spec/gexp/handler/check_spec.rb +5 -0
  34. data/spec/gexp/handler/modify/resources_spec.rb +96 -0
  35. data/spec/gexp/handler/modify_spec.rb +6 -0
  36. data/spec/gexp/handler/producer_spec.rb +85 -0
  37. data/spec/gexp/handler/transition/builder_spec.rb +122 -0
  38. data/spec/gexp/handler/transition_spec.rb +14 -0
  39. data/spec/gexp/mongoid/transaction_spec.rb +210 -0
  40. data/spec/gexp/state_definition/state_machine_spec.rb +48 -0
  41. data/spec/spec_helper.rb +10 -0
  42. metadata +210 -0
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb')
3
+
4
+ describe Gexp::StateDefinition::StateMachine do
5
+
6
+ before do
7
+ SubjectClass = Class.new do
8
+ include Gexp::StateDefinition::StateMachine
9
+ end
10
+ end
11
+
12
+ it "should be definition states" do
13
+ SubjectClass.instance_eval do
14
+ self.define_state_by({
15
+ states: { first: nil, second: nil, last: nil },
16
+ initial: :created,
17
+ events: {
18
+ do_first: [{
19
+ from: :created,
20
+ to: :first,
21
+ }],
22
+ do_second: [{
23
+ from: :first,
24
+ to: :second,
25
+ }],
26
+ do_last: [{
27
+ from: :second,
28
+ to: :last,
29
+ }]
30
+ },
31
+ after: [],
32
+ before: [],
33
+ })
34
+ end
35
+
36
+ states = SubjectClass.state_machines[:state].states.map(&:name)
37
+ states.should == [ :created, :first, :second, :last ]
38
+
39
+ events = SubjectClass.state_machines[:state].events
40
+
41
+ events.map(&:name).should == [ :do_first, :do_second, :do_last ]
42
+
43
+ events[:do_first].branches[0].state_requirements[0][:from].values.should == [:created]
44
+ events[:do_second].branches[0].state_requirements[0][:from].values.should == [:first]
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,10 @@
1
+ require "bundler"
2
+ require 'bundler/setup'
3
+ require 'gexp'
4
+
5
+ RSpec.configure do |config|
6
+ #config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ #config.run_all_when_everything_filtered = true
8
+ #config.filter_run :focus
9
+ config.mock_with :rr
10
+ end
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gexp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kazantsev Nickolay
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70131204742080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70131204742080
25
+ - !ruby/object:Gem::Dependency
26
+ name: rr
27
+ requirement: &70131204741300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70131204741300
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70131204740800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70131204740800
47
+ - !ruby/object:Gem::Dependency
48
+ name: state_machine
49
+ requirement: &70131204740380 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70131204740380
58
+ - !ruby/object:Gem::Dependency
59
+ name: activesupport
60
+ requirement: &70131204739900 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70131204739900
69
+ - !ruby/object:Gem::Dependency
70
+ name: bson
71
+ requirement: &70131204732540 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70131204732540
80
+ - !ruby/object:Gem::Dependency
81
+ name: bson_ext
82
+ requirement: &70131204731900 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - =
86
+ - !ruby/object:Gem::Version
87
+ version: 1.8.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70131204731900
91
+ - !ruby/object:Gem::Dependency
92
+ name: mongo
93
+ requirement: &70131204731260 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 1.8.0
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70131204731260
102
+ - !ruby/object:Gem::Dependency
103
+ name: mongoid
104
+ requirement: &70131204730280 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 3.0.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70131204730280
113
+ - !ruby/object:Gem::Dependency
114
+ name: money-mongoid
115
+ requirement: &70131204729740 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - =
119
+ - !ruby/object:Gem::Version
120
+ version: 0.1.2
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70131204729740
124
+ description: Gexp - comand hadlers
125
+ email:
126
+ - kazantsev.nickolay@gmail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - .gitignore
132
+ - Gemfile
133
+ - LICENSE.txt
134
+ - README.md
135
+ - Rakefile
136
+ - gexp.gemspec
137
+ - lib/gexp.rb
138
+ - lib/gexp/command.rb
139
+ - lib/gexp/command/object.rb
140
+ - lib/gexp/command/stack.rb
141
+ - lib/gexp/handler.rb
142
+ - lib/gexp/handler/caller.rb
143
+ - lib/gexp/handler/check.rb
144
+ - lib/gexp/handler/check/item.rb
145
+ - lib/gexp/handler/check/resources.rb
146
+ - lib/gexp/handler/modify.rb
147
+ - lib/gexp/handler/modify/resources.rb
148
+ - lib/gexp/handler/producer.rb
149
+ - lib/gexp/handler/transition.rb
150
+ - lib/gexp/handler/transition/builder.rb
151
+ - lib/gexp/mongoid.rb
152
+ - lib/gexp/mongoid/transaction.rb
153
+ - lib/gexp/object.rb
154
+ - lib/gexp/receiver.rb
155
+ - lib/gexp/state_definition.rb
156
+ - lib/gexp/state_definition/state_machine.rb
157
+ - lib/gexp/version.rb
158
+ - spec/gexp/command/object_spec.rb
159
+ - spec/gexp/command/stack_spec.rb
160
+ - spec/gexp/command_spec.rb
161
+ - spec/gexp/handler/check/item_spec.rb
162
+ - spec/gexp/handler/check/resources_spec.rb
163
+ - spec/gexp/handler/check_spec.rb
164
+ - spec/gexp/handler/modify/resources_spec.rb
165
+ - spec/gexp/handler/modify_spec.rb
166
+ - spec/gexp/handler/producer_spec.rb
167
+ - spec/gexp/handler/transition/builder_spec.rb
168
+ - spec/gexp/handler/transition_spec.rb
169
+ - spec/gexp/mongoid/transaction_spec.rb
170
+ - spec/gexp/state_definition/state_machine_spec.rb
171
+ - spec/spec_helper.rb
172
+ homepage: http://github.com/realb0t/gexp
173
+ licenses: []
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ requirements: []
191
+ rubyforge_project: gexp
192
+ rubygems_version: 1.8.5
193
+ signing_key:
194
+ specification_version: 3
195
+ summary: Gexp - comand hadlers
196
+ test_files:
197
+ - spec/gexp/command/object_spec.rb
198
+ - spec/gexp/command/stack_spec.rb
199
+ - spec/gexp/command_spec.rb
200
+ - spec/gexp/handler/check/item_spec.rb
201
+ - spec/gexp/handler/check/resources_spec.rb
202
+ - spec/gexp/handler/check_spec.rb
203
+ - spec/gexp/handler/modify/resources_spec.rb
204
+ - spec/gexp/handler/modify_spec.rb
205
+ - spec/gexp/handler/producer_spec.rb
206
+ - spec/gexp/handler/transition/builder_spec.rb
207
+ - spec/gexp/handler/transition_spec.rb
208
+ - spec/gexp/mongoid/transaction_spec.rb
209
+ - spec/gexp/state_definition/state_machine_spec.rb
210
+ - spec/spec_helper.rb