wml_action 0.0.2 → 0.0.3
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.
- checksums.yaml +6 -14
- data/.rspec +0 -0
- data/README.md +25 -3
- data/features/wml_action.feature +27 -0
- data/lib/wml_action/expr.rb +74 -0
- data/lib/wml_action/lexer.rex +15 -1
- data/lib/wml_action/lexer.rex.rb +31 -1
- data/lib/wml_action/parser.tab.rb +219 -87
- data/lib/wml_action/parser.y +13 -0
- data/lib/wml_action/tag.rb +16 -0
- data/lib/wml_action/version.rb +1 -1
- data/lib/wml_action.rb +1 -0
- data/spec/document_spec.rb +7 -0
- data/spec/expr_spec.rb +89 -0
- data/spec/fixtures/expr.cfg +4 -0
- data/spec/tag_spec.rb +56 -28
- data/wml_action.gemspec +3 -2
- metadata +52 -30
data/spec/tag_spec.rb
CHANGED
@@ -5,25 +5,35 @@ module WMLAction
|
|
5
5
|
|
6
6
|
describe Tag do
|
7
7
|
|
8
|
+
before(:all) do
|
9
|
+
Attr = Tag::Attribute
|
10
|
+
Macro = Tag::Macro
|
11
|
+
Action = Tag::Action
|
12
|
+
Filter = Tag::Filter
|
13
|
+
Var = Tag::Expr::Var unless WMLAction.const_defined? 'Var'
|
14
|
+
Op = Tag::Expr::Op unless WMLAction.const_defined? 'Op'
|
15
|
+
Expr = Tag::Expr unless WMLAction.const_defined? 'Expr'
|
16
|
+
end
|
17
|
+
|
8
18
|
describe '#merge' do
|
9
19
|
|
10
20
|
context 'when no action' do
|
11
21
|
|
12
22
|
let(:actions) do
|
13
23
|
a = Tag.new
|
14
|
-
a <<
|
15
|
-
a <<
|
24
|
+
a << Attr[:hp,25]
|
25
|
+
a << Macro['{REGENERATE}']
|
16
26
|
sub = Tag.new(name: 'attack')
|
17
|
-
sub <<
|
27
|
+
sub << Attr[:type,'blunt']
|
18
28
|
a << sub
|
19
29
|
sub = Tag.new(name: 'resists')
|
20
|
-
sub <<
|
30
|
+
sub << Attr[:cold,100]
|
21
31
|
a << sub
|
22
32
|
end
|
23
33
|
|
24
34
|
let(:target) do
|
25
35
|
t = Tag.new
|
26
|
-
t <<
|
36
|
+
t << Attr[:hp,10]
|
27
37
|
t << Tag.new(name: 'attack')
|
28
38
|
t << Tag.new(name: 'attack')
|
29
39
|
t.merge(actions)
|
@@ -34,7 +44,7 @@ module WMLAction
|
|
34
44
|
end
|
35
45
|
|
36
46
|
it 'merges existing sections' do
|
37
|
-
# TODO Should
|
47
|
+
# TODO Should this test works through check target receiving messages?
|
38
48
|
expect(target.subs[0].attrs).to include :type
|
39
49
|
expect(target.subs[1].attrs).to include :type
|
40
50
|
end
|
@@ -58,11 +68,11 @@ module WMLAction
|
|
58
68
|
let(:actions) do
|
59
69
|
a = Tag.new
|
60
70
|
sub = Tag.new(name: 'attack')
|
61
|
-
sub <<
|
62
|
-
a <<
|
71
|
+
sub << Attr[:type,'blunt']
|
72
|
+
a << Action[sub, '+']
|
63
73
|
sub = Tag.new(name: 'resists')
|
64
|
-
a <<
|
65
|
-
a <<
|
74
|
+
a << Action[sub, '+']
|
75
|
+
a << Action[Macro['{REGENERATE}'], '+']
|
66
76
|
a
|
67
77
|
end
|
68
78
|
|
@@ -92,14 +102,14 @@ module WMLAction
|
|
92
102
|
let(:actions) do
|
93
103
|
a = Tag.new
|
94
104
|
sub = Tag.new(name: 'attack')
|
95
|
-
a <<
|
96
|
-
a <<
|
105
|
+
a << Action[sub,'-']
|
106
|
+
a << Action[Macro['{REGENERATE}'], '-']
|
97
107
|
end
|
98
108
|
|
99
109
|
let(:target) do
|
100
110
|
t = Tag.new
|
101
111
|
t << Tag.new(name: 'attack')
|
102
|
-
t <<
|
112
|
+
t << Macro['{REGENERATE}']
|
103
113
|
t.merge(actions)
|
104
114
|
end
|
105
115
|
|
@@ -117,20 +127,20 @@ module WMLAction
|
|
117
127
|
let(:actions) do
|
118
128
|
a = Tag.new
|
119
129
|
sub = Tag.new(name: 'attack')
|
120
|
-
sub <<
|
121
|
-
sub <<
|
130
|
+
sub << Filter[Attr[:type,'blunt']]
|
131
|
+
sub << Attr[:damage, 30]
|
122
132
|
a << sub
|
123
133
|
end
|
124
134
|
|
125
135
|
let(:target) do
|
126
136
|
t = Tag.new
|
127
137
|
sub = Tag.new(name: 'attack')
|
128
|
-
sub <<
|
129
|
-
sub <<
|
138
|
+
sub << Attr[:type,'blunt']
|
139
|
+
sub << Attr[:damage, 25]
|
130
140
|
t << sub
|
131
141
|
sub = Tag.new(name: 'attack')
|
132
|
-
sub <<
|
133
|
-
sub <<
|
142
|
+
sub << Attr[:type,'pierce']
|
143
|
+
sub << Attr[:damage, 25]
|
134
144
|
t << sub
|
135
145
|
t.merge(actions)
|
136
146
|
end
|
@@ -146,13 +156,31 @@ module WMLAction
|
|
146
156
|
|
147
157
|
end
|
148
158
|
|
159
|
+
context 'when expression' do
|
160
|
+
let(:actions) do
|
161
|
+
a = Tag.new
|
162
|
+
a << Attr[:damage, Expr[Var[:damage],1.0,Op['+']]]
|
163
|
+
end
|
164
|
+
|
165
|
+
let(:target) do
|
166
|
+
t = Tag.new
|
167
|
+
t << Attr[:damage, 30]
|
168
|
+
t.merge(actions)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'evaluates expression' do
|
172
|
+
expect(target.attrs[:damage]).to eq 31
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
149
177
|
|
150
178
|
end
|
151
179
|
|
152
180
|
describe '#add and #<<' do
|
153
181
|
|
154
182
|
it 'returns self' do
|
155
|
-
s = Tag.new <<
|
183
|
+
s = Tag.new << Attr[:hp,25]
|
156
184
|
expect(s).to be_kind_of(Tag)
|
157
185
|
end
|
158
186
|
|
@@ -170,8 +198,8 @@ module WMLAction
|
|
170
198
|
end
|
171
199
|
|
172
200
|
it 'prints attributes' do
|
173
|
-
s <<
|
174
|
-
s <<
|
201
|
+
s << Attr[:hp,25]
|
202
|
+
s << Attr[:race,'human']
|
175
203
|
expect(s.to_s).to eq <<-EOS.gsub(/^\s+\|/, '')
|
176
204
|
|[unit]
|
177
205
|
|\thp=25
|
@@ -181,8 +209,8 @@ module WMLAction
|
|
181
209
|
end
|
182
210
|
|
183
211
|
it 'prints macros' do
|
184
|
-
s <<
|
185
|
-
s <<
|
212
|
+
s << Macro['{REGENERATES}']
|
213
|
+
s << Macro['{INVISIBLE}']
|
186
214
|
expect(s.to_s).to eq <<-EOS.gsub(/^\s+\|/, '')
|
187
215
|
|[unit]
|
188
216
|
|\t{REGENERATES}
|
@@ -205,8 +233,8 @@ module WMLAction
|
|
205
233
|
end
|
206
234
|
|
207
235
|
it 'prints filters' do
|
208
|
-
s <<
|
209
|
-
s <<
|
236
|
+
s << Filter[Attr[:hp,25]]
|
237
|
+
s << Filter[Macro['{REGENERATES}']]
|
210
238
|
expect(s.to_s).to eq <<-EOS.gsub(/^\s+\|/, '')
|
211
239
|
|[unit]
|
212
240
|
|\t/ hp=25
|
@@ -216,8 +244,8 @@ module WMLAction
|
|
216
244
|
end
|
217
245
|
|
218
246
|
it 'prints actions' do
|
219
|
-
s <<
|
220
|
-
s <<
|
247
|
+
s << Action[Tag.new(name: 'attack'),'+']
|
248
|
+
s << Action[Macro['{REGENERATES}'],'-']
|
221
249
|
expect(s.to_s).to eq <<-EOS.gsub(/^\s+\|/, '')
|
222
250
|
|[unit]
|
223
251
|
|\t+ [attack]
|
data/wml_action.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["paul.schko@gmail.com"]
|
11
11
|
spec.description = %q{Parses WML files and performs actions on them}
|
12
12
|
spec.summary = %q{Parse WML and simple WML extension to make modifications to WML files }
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/PaiPan/wml_action"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -21,12 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "debugger"
|
24
|
+
spec.add_development_dependency "debugger", "~> 1.6.8"
|
25
25
|
spec.add_development_dependency "ruby-prof"
|
26
26
|
spec.add_development_dependency "rubocop"
|
27
27
|
spec.add_development_dependency "rubocop-rspec"
|
28
28
|
spec.add_development_dependency "reek"
|
29
29
|
spec.add_development_dependency "cucumber"
|
30
|
+
spec.add_development_dependency "autotest"
|
30
31
|
|
31
32
|
|
32
33
|
spec.add_development_dependency "racc"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wml_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pancho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,154 +28,168 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: debugger
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.6.8
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.6.8
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ruby-prof
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop-rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: reek
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: cucumber
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: autotest
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- -
|
150
|
+
- - '>='
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: racc
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- -
|
157
|
+
- - '>='
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: '0'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - '>='
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: oedipus_lex
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
|
-
- -
|
171
|
+
- - '>='
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '0'
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
|
-
- -
|
178
|
+
- - '>='
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: thor
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
|
-
- -
|
185
|
+
- - '>='
|
172
186
|
- !ruby/object:Gem::Version
|
173
187
|
version: '0'
|
174
188
|
type: :runtime
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
|
-
- -
|
192
|
+
- - '>='
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
195
|
description: Parses WML files and performs actions on them
|
@@ -187,15 +201,18 @@ extensions: []
|
|
187
201
|
extra_rdoc_files: []
|
188
202
|
files:
|
189
203
|
- .gitignore
|
204
|
+
- .rspec
|
190
205
|
- .rubocop.yml
|
191
206
|
- Gemfile
|
192
207
|
- LICENSE.txt
|
193
208
|
- README.md
|
194
209
|
- Rakefile
|
195
210
|
- bin/wml_action
|
211
|
+
- features/wml_action.feature
|
196
212
|
- lib/wml_action.rb
|
197
213
|
- lib/wml_action/cli.rb
|
198
214
|
- lib/wml_action/document.rb
|
215
|
+
- lib/wml_action/expr.rb
|
199
216
|
- lib/wml_action/lexer.rex
|
200
217
|
- lib/wml_action/lexer.rex.rb
|
201
218
|
- lib/wml_action/log.rb
|
@@ -204,9 +221,11 @@ files:
|
|
204
221
|
- lib/wml_action/tag.rb
|
205
222
|
- lib/wml_action/version.rb
|
206
223
|
- spec/document_spec.rb
|
224
|
+
- spec/expr_spec.rb
|
207
225
|
- spec/fixtures/actions.cfg
|
208
226
|
- spec/fixtures/as_from_file.cfg
|
209
227
|
- spec/fixtures/attributes.cfg
|
228
|
+
- spec/fixtures/expr.cfg
|
210
229
|
- spec/fixtures/filter.cfg
|
211
230
|
- spec/fixtures/inners.cfg
|
212
231
|
- spec/fixtures/macros.cfg
|
@@ -215,7 +234,7 @@ files:
|
|
215
234
|
- spec/fixtures/tag.cfg
|
216
235
|
- spec/tag_spec.rb
|
217
236
|
- wml_action.gemspec
|
218
|
-
homepage:
|
237
|
+
homepage: https://github.com/PaiPan/wml_action
|
219
238
|
licenses:
|
220
239
|
- MIT
|
221
240
|
metadata: {}
|
@@ -225,25 +244,28 @@ require_paths:
|
|
225
244
|
- lib
|
226
245
|
required_ruby_version: !ruby/object:Gem::Requirement
|
227
246
|
requirements:
|
228
|
-
- -
|
247
|
+
- - '>='
|
229
248
|
- !ruby/object:Gem::Version
|
230
249
|
version: '0'
|
231
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
251
|
requirements:
|
233
|
-
- -
|
252
|
+
- - '>='
|
234
253
|
- !ruby/object:Gem::Version
|
235
254
|
version: '0'
|
236
255
|
requirements: []
|
237
256
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.
|
257
|
+
rubygems_version: 2.2.2
|
239
258
|
signing_key:
|
240
259
|
specification_version: 4
|
241
260
|
summary: Parse WML and simple WML extension to make modifications to WML files
|
242
261
|
test_files:
|
262
|
+
- features/wml_action.feature
|
243
263
|
- spec/document_spec.rb
|
264
|
+
- spec/expr_spec.rb
|
244
265
|
- spec/fixtures/actions.cfg
|
245
266
|
- spec/fixtures/as_from_file.cfg
|
246
267
|
- spec/fixtures/attributes.cfg
|
268
|
+
- spec/fixtures/expr.cfg
|
247
269
|
- spec/fixtures/filter.cfg
|
248
270
|
- spec/fixtures/inners.cfg
|
249
271
|
- spec/fixtures/macros.cfg
|