gexp 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gexp/command/object.rb +3 -5
- data/lib/gexp/command/stack.rb +1 -1
- data/lib/gexp/receiver.rb +2 -5
- data/lib/gexp/receiver/example.rb +15 -0
- data/lib/gexp/receiver/mongoid.rb +15 -0
- data/lib/gexp/version.rb +1 -1
- data/spec/gexp/command/object_spec.rb +7 -7
- data/spec/gexp/command/stack_spec.rb +15 -4
- data/spec/gexp/receiver_spec.rb +48 -0
- metadata +36 -26
data/lib/gexp/command/object.rb
CHANGED
@@ -23,11 +23,9 @@ module Gexp
|
|
23
23
|
protected
|
24
24
|
|
25
25
|
def load_object
|
26
|
-
if @params[:
|
27
|
-
|
28
|
-
|
29
|
-
label = @params[:object].keys.first
|
30
|
-
id = @params[:object].values.first
|
26
|
+
if @params[:objects]
|
27
|
+
label = @params[:objects].keys.first
|
28
|
+
id = @params[:objects].values.first
|
31
29
|
@object = Gexp.label_to_class(label).find(id)
|
32
30
|
else
|
33
31
|
raise "Can't find object params"
|
data/lib/gexp/command/stack.rb
CHANGED
data/lib/gexp/receiver.rb
CHANGED
data/lib/gexp/version.rb
CHANGED
@@ -13,13 +13,13 @@ describe Gexp::Command::Object do
|
|
13
13
|
:create_at => 123456789.012,
|
14
14
|
:commands => [{
|
15
15
|
# У себя на карте
|
16
|
-
:event
|
17
|
-
:stage
|
18
|
-
:rewards
|
19
|
-
:timestamp
|
20
|
-
:
|
16
|
+
:event => :pick,
|
17
|
+
:stage => { x: 100, y: 200 },
|
18
|
+
:rewards => { energy: -1, exp: 5 },
|
19
|
+
:timestamp => 123456789.012,
|
20
|
+
:objects => { 'item_example' => '55a55' },
|
21
21
|
:transition => { :builded => :builded },
|
22
|
-
:seed
|
22
|
+
:seed => 532434234,
|
23
23
|
}]
|
24
24
|
}
|
25
25
|
})
|
@@ -46,7 +46,7 @@ describe Gexp::Command::Object do
|
|
46
46
|
|
47
47
|
it "Нельзя (так просто взять и) создать команду без параметра-объекта" do
|
48
48
|
params = @request[:params][:commands].first
|
49
|
-
params.delete(:
|
49
|
+
params.delete(:objects)
|
50
50
|
lambda {
|
51
51
|
@command = Gexp::Command::Object.new params
|
52
52
|
}.should raise_error Regexp.new("Can't find object")
|
@@ -16,7 +16,7 @@ describe Gexp::Command::Stack do
|
|
16
16
|
:stage => { x: 100, y: 200 },
|
17
17
|
:rewards => { energy: -1, exp: 5 },
|
18
18
|
:timestamp => 123456789.012,
|
19
|
-
:objects =>
|
19
|
+
:objects => { 'item_example' => '50c12939584aa5488a000001' },
|
20
20
|
:transition => { :builded => :builded },
|
21
21
|
:timestamp => 123456789.010,
|
22
22
|
:seed => 532434234,
|
@@ -26,21 +26,21 @@ describe Gexp::Command::Stack do
|
|
26
26
|
:uid => '<friend_uid>',
|
27
27
|
:rewards => { energy: -1, exp: 5 },
|
28
28
|
:timestamp => 123456789.012,
|
29
|
-
:objects =>
|
29
|
+
:objects => { 'item_example' => '50c12939584aa5488a000002' },
|
30
30
|
:transition => { :builded => :builded },
|
31
31
|
:timestamp => 123456789.011,
|
32
32
|
:seed => 532434234,
|
33
33
|
}, { # создание здания
|
34
34
|
:event => :create,
|
35
35
|
:stage => { x: 100, y: 200 },
|
36
|
-
:objects =>
|
36
|
+
:objects => { 'item_example' => '50c12939584aa5488a000003' },
|
37
37
|
:reward => { gold: -100 },
|
38
38
|
:timestamp => 123456789.012,
|
39
39
|
:seed => 532434234,
|
40
40
|
}, { # создание контракта
|
41
41
|
:event => :pick,
|
42
42
|
:stage => { x: 100, y: 200 },
|
43
|
-
:objects =>
|
43
|
+
:objects => { 'item_example' => '50c12939584aa5488a000004' },
|
44
44
|
:timestamp => 123456789.013,
|
45
45
|
:seed => 532412334,
|
46
46
|
},
|
@@ -49,7 +49,18 @@ describe Gexp::Command::Stack do
|
|
49
49
|
})
|
50
50
|
}
|
51
51
|
|
52
|
+
let(:item1) { ItemExample.new }
|
53
|
+
let(:item2) { ItemExample.new }
|
54
|
+
let(:item3) { ItemExample.new }
|
55
|
+
let(:item4) { ItemExample.new }
|
56
|
+
|
52
57
|
before do
|
58
|
+
|
59
|
+
stub(ItemExample).find('50c12939584aa5488a000001') { item1 }
|
60
|
+
stub(ItemExample).find('50c12939584aa5488a000002') { item2 }
|
61
|
+
stub(ItemExample).find('50c12939584aa5488a000003') { item3 }
|
62
|
+
stub(ItemExample).find('50c12939584aa5488a000004') { item4 }
|
63
|
+
|
53
64
|
@user = UserExample.new
|
54
65
|
@request = request
|
55
66
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
|
3
|
+
|
4
|
+
describe Gexp::Receiver do
|
5
|
+
|
6
|
+
let(:receiver_class) { Gexp::Receiver::Example }
|
7
|
+
let(:user) { UserExample.new }
|
8
|
+
let(:item_id) { 1 }
|
9
|
+
let(:item) { ItemExample.new }
|
10
|
+
let(:request) do
|
11
|
+
HashWithIndifferentAccess.new({
|
12
|
+
:params => {
|
13
|
+
:sended_at => 123456789.012,
|
14
|
+
:create_at => 123456789.012,
|
15
|
+
:commands => [{
|
16
|
+
# У себя на карте
|
17
|
+
:event => :pick,
|
18
|
+
:stage => { x: 100, y: 200 },
|
19
|
+
:rewards => { energy: -1, exp: 5 },
|
20
|
+
:timestamp => 123456789.012,
|
21
|
+
:objects => { 'item_example' => item_id },
|
22
|
+
:transition => { :builded => :builded },
|
23
|
+
:seed => 532434234,
|
24
|
+
}]
|
25
|
+
}
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:subject) do
|
30
|
+
receiver_class.new(user, request)
|
31
|
+
end
|
32
|
+
|
33
|
+
before do
|
34
|
+
stub(ItemExample).find(item_id) { item }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "Успешная обработка комманды" do
|
38
|
+
|
39
|
+
it "должна пройти без ошибок" do
|
40
|
+
#lambda {
|
41
|
+
subject.receive
|
42
|
+
#}.should_not raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gexp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70143297987720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70143297987720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70143297986680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70143297986680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70143297985980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70143297985980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry
|
49
|
-
requirement: &
|
49
|
+
requirement: &70143297984780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70143297984780
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: state_machine
|
60
|
-
requirement: &
|
60
|
+
requirement: &70143297983800 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70143297983800
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
|
-
requirement: &
|
71
|
+
requirement: &70143297982600 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70143297982600
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: bson
|
82
|
-
requirement: &
|
82
|
+
requirement: &70143297980680 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - =
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.8.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70143297980680
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: bson_ext
|
93
|
-
requirement: &
|
93
|
+
requirement: &70143297979760 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - =
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.8.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70143297979760
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: mongo
|
104
|
-
requirement: &
|
104
|
+
requirement: &70143297978700 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 1.8.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70143297978700
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: mongoid
|
115
|
-
requirement: &
|
115
|
+
requirement: &70143297977520 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 3.0.0
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70143297977520
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: money-mongoid
|
126
|
-
requirement: &
|
126
|
+
requirement: &70143297976520 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - =
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 0.1.2
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70143297976520
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: mongoid-rspec
|
137
|
-
requirement: &
|
137
|
+
requirement: &70143297975140 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - =
|
@@ -142,7 +142,7 @@ dependencies:
|
|
142
142
|
version: 1.4.5
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70143297975140
|
146
146
|
description: Gexp - comand hadlers
|
147
147
|
email:
|
148
148
|
- kazantsev.nickolay@gmail.com
|
@@ -176,6 +176,8 @@ files:
|
|
176
176
|
- lib/gexp/mongoid/transaction.rb
|
177
177
|
- lib/gexp/object.rb
|
178
178
|
- lib/gexp/receiver.rb
|
179
|
+
- lib/gexp/receiver/example.rb
|
180
|
+
- lib/gexp/receiver/mongoid.rb
|
179
181
|
- lib/gexp/state_definition.rb
|
180
182
|
- lib/gexp/state_definition/state_machine.rb
|
181
183
|
- lib/gexp/version.rb
|
@@ -191,6 +193,7 @@ files:
|
|
191
193
|
- spec/gexp/handler/transition/builder_spec.rb
|
192
194
|
- spec/gexp/handler/transition_spec.rb
|
193
195
|
- spec/gexp/mongoid/transaction_spec.rb
|
196
|
+
- spec/gexp/receiver_spec.rb
|
194
197
|
- spec/gexp/state_definition/state_machine_spec.rb
|
195
198
|
- spec/spec_helper.rb
|
196
199
|
homepage: http://github.com/realb0t/gexp
|
@@ -205,12 +208,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
208
|
- - ! '>='
|
206
209
|
- !ruby/object:Gem::Version
|
207
210
|
version: '0'
|
211
|
+
segments:
|
212
|
+
- 0
|
213
|
+
hash: -3174103148992928154
|
208
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
215
|
none: false
|
210
216
|
requirements:
|
211
217
|
- - ! '>='
|
212
218
|
- !ruby/object:Gem::Version
|
213
219
|
version: '0'
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
hash: -3174103148992928154
|
214
223
|
requirements: []
|
215
224
|
rubyforge_project: gexp
|
216
225
|
rubygems_version: 1.8.5
|
@@ -230,5 +239,6 @@ test_files:
|
|
230
239
|
- spec/gexp/handler/transition/builder_spec.rb
|
231
240
|
- spec/gexp/handler/transition_spec.rb
|
232
241
|
- spec/gexp/mongoid/transaction_spec.rb
|
242
|
+
- spec/gexp/receiver_spec.rb
|
233
243
|
- spec/gexp/state_definition/state_machine_spec.rb
|
234
244
|
- spec/spec_helper.rb
|