woyo-world 0.0.6 → 0.0.7
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 +4 -4
- data/lib/woyo/world/actions.rb +24 -0
- data/lib/woyo/world/attributes.rb +105 -154
- data/lib/woyo/world/character.rb +4 -1
- data/lib/woyo/world/{dsl.rb → evaluate.rb} +1 -2
- data/lib/woyo/world/group.rb +21 -6
- data/lib/woyo/world/item.rb +26 -0
- data/lib/woyo/world/location.rb +5 -3
- data/lib/woyo/world/version.rb +1 -1
- data/lib/woyo/world/way.rb +5 -4
- data/lib/woyo/world/world.rb +7 -3
- data/lib/woyo/world/world_object.rb +8 -4
- data/rspec.json +1 -0
- data/spec/spec_doc.haml +68 -0
- data/spec/spec_doc_formatter.rb +89 -0
- data/spec/spec_helper.rb +115 -0
- data/spec/woyo/dsl/dsl_spec.rb +367 -0
- data/spec/woyo/world/actions_spec.rb +71 -0
- data/spec/woyo/world/attributes_spec.rb +300 -382
- data/spec/woyo/world/character_spec.rb +30 -28
- data/spec/woyo/world/evaluate_spec.rb +75 -0
- data/spec/woyo/world/group_spec.rb +45 -44
- data/spec/woyo/world/item_spec.rb +46 -0
- data/spec/woyo/world/location_spec.rb +48 -32
- data/spec/woyo/world/way_spec.rb +54 -45
- data/spec/woyo/world/world_object_spec.rb +48 -6
- data/spec/woyo/world/world_spec.rb +15 -7
- data/todo.txt +2 -2
- data/woyo-world.gemspec +3 -2
- metadata +38 -11
- data/spec/woyo/world/dsl_spec.rb +0 -74
- data/spec/woyo/world/language_spec.rb +0 -350
data/spec/woyo/world/way_spec.rb
CHANGED
@@ -1,37 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'woyo/world/world'
|
2
3
|
require 'woyo/world/location'
|
3
4
|
require 'woyo/world/way'
|
4
5
|
|
5
6
|
describe Woyo::Way do
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
let(:way) { Woyo::Way.new :door }
|
9
|
+
|
10
|
+
context 'has attributes' do
|
11
|
+
|
12
|
+
it ':open' do
|
13
|
+
expect(way.attributes.names).to include :open
|
14
|
+
end
|
15
|
+
|
16
|
+
it ':closed' do
|
17
|
+
expect(way.attributes.names).to include :closed
|
18
|
+
end
|
19
|
+
|
20
|
+
it ':going' do
|
21
|
+
expect(way.attributes.names).to include :going
|
22
|
+
end
|
11
23
|
|
12
|
-
it 'name attribute defaults to id' do
|
13
|
-
wo = Woyo::Way.new(:door)
|
14
|
-
wo.name.should eq 'Door'
|
15
24
|
end
|
16
25
|
|
17
26
|
it 'accepts location for parameter context:' do
|
18
27
|
wo = nil
|
19
28
|
expect { wo = Woyo::Way.new(:my_id, context: Woyo::Location.new(:here)) }.to_not raise_error
|
20
|
-
wo.context.
|
21
|
-
wo.context.id.
|
29
|
+
expect(wo.context).to be_instance_of Woyo::Location
|
30
|
+
expect(wo.context.id).to eq :here
|
22
31
|
end
|
23
32
|
|
24
33
|
it 'is in a world' do
|
25
34
|
world = Woyo::World.new
|
26
35
|
here = Woyo::Location.new :here, context: world
|
27
36
|
door = Woyo::Way.new :door, context: here
|
28
|
-
door.world.
|
37
|
+
expect(door.world).to eq world
|
29
38
|
end
|
30
39
|
|
31
40
|
it 'leads from a location' do
|
32
41
|
here = Woyo::Location.new(:here)
|
33
42
|
door = Woyo::Way.new :door, context: here
|
34
|
-
door.from.
|
43
|
+
expect(door.from).to eq here
|
35
44
|
end
|
36
45
|
|
37
46
|
it 'leads to a location' do
|
@@ -39,83 +48,83 @@ describe Woyo::Way do
|
|
39
48
|
door = Woyo::Way.new :door, context: here do
|
40
49
|
to :away
|
41
50
|
end
|
42
|
-
door.to.
|
51
|
+
expect(door.to).to be_a Woyo::Location
|
43
52
|
end
|
44
53
|
|
45
54
|
it 'defaults to closed if "to" not defined' do
|
46
55
|
door = Woyo::Way.new(:door)
|
47
|
-
door.open.
|
48
|
-
door.closed.
|
56
|
+
expect(door.open).to be false
|
57
|
+
expect(door.closed).to be true
|
49
58
|
end
|
50
59
|
|
51
60
|
it 'defaults to open if "to" defined' do
|
52
61
|
door = Woyo::Way.new(:door)
|
53
62
|
door.to = :someplace
|
54
|
-
door.open.
|
55
|
-
door.closed.
|
63
|
+
expect(door.open).to be true
|
64
|
+
expect(door.closed).to be false
|
56
65
|
end
|
57
66
|
|
58
67
|
it 'may be made closed' do
|
59
68
|
door = Woyo::Way.new(:door)
|
60
69
|
door.to = :someplace
|
61
|
-
door.open.
|
62
|
-
door.closed.
|
70
|
+
expect(door.open).to be true
|
71
|
+
expect(door.closed).to be false
|
63
72
|
door.closed = true
|
64
|
-
door.open.
|
65
|
-
door.closed.
|
73
|
+
expect(door.open).to be false
|
74
|
+
expect(door.closed).to be true
|
66
75
|
end
|
67
76
|
|
68
77
|
it 'may be made open' do
|
69
78
|
door = Woyo::Way.new(:door)
|
70
|
-
door.open.
|
71
|
-
door.closed.
|
79
|
+
expect(door.open).to be false
|
80
|
+
expect(door.closed).to be true
|
72
81
|
door.open = true
|
73
|
-
door.open.
|
74
|
-
door.closed.
|
82
|
+
expect(door.open).to be true
|
83
|
+
expect(door.closed).to be false
|
75
84
|
end
|
76
85
|
|
77
86
|
it 'may be closed!' do
|
78
87
|
door = Woyo::Way.new(:door)
|
79
88
|
door.to = :someplace
|
80
|
-
door.open.
|
81
|
-
door.closed.
|
89
|
+
expect(door.open).to be true
|
90
|
+
expect(door.closed).to be false
|
82
91
|
door.close!
|
83
|
-
door.open.
|
84
|
-
door.closed.
|
92
|
+
expect(door.open).to be false
|
93
|
+
expect(door.closed).to be true
|
85
94
|
end
|
86
95
|
|
87
96
|
it 'can close!' do
|
88
97
|
door = Woyo::Way.new(:door)
|
89
98
|
door.to = :someplace
|
90
|
-
door.open.
|
91
|
-
door.closed.
|
99
|
+
expect(door.open).to be true
|
100
|
+
expect(door.closed).to be false
|
92
101
|
door.close!
|
93
|
-
door.open.
|
94
|
-
door.closed.
|
102
|
+
expect(door.open).to be false
|
103
|
+
expect(door.closed).to be true
|
95
104
|
end
|
96
105
|
|
97
106
|
it 'can open!' do
|
98
107
|
door = Woyo::Way.new(:door)
|
99
|
-
door.open.
|
100
|
-
door.closed.
|
108
|
+
expect(door.open).to be false
|
109
|
+
expect(door.closed).to be true
|
101
110
|
door.open!
|
102
|
-
door.open.
|
103
|
-
door.closed.
|
111
|
+
expect(door.open).to be true
|
112
|
+
expect(door.closed).to be false
|
104
113
|
end
|
105
114
|
|
106
115
|
it 'query open?' do
|
107
116
|
door = Woyo::Way.new(:door)
|
108
117
|
door.to = :someplace
|
109
|
-
door.
|
118
|
+
expect(door).to be_open
|
110
119
|
door.close!
|
111
|
-
door.
|
120
|
+
expect(door).not_to be_open
|
112
121
|
end
|
113
122
|
|
114
123
|
it 'query closed?' do
|
115
124
|
door = Woyo::Way.new(:door)
|
116
|
-
door.
|
125
|
+
expect(door).to be_closed
|
117
126
|
door.open!
|
118
|
-
door.
|
127
|
+
expect(door).not_to be_closed
|
119
128
|
end
|
120
129
|
|
121
130
|
context 'description' do
|
@@ -127,17 +136,17 @@ describe Woyo::Way do
|
|
127
136
|
|
128
137
|
it 'can be described' do
|
129
138
|
@door.description = 'Just a door'
|
130
|
-
@door.description.
|
139
|
+
expect(@door.description).to eq 'Just a door'
|
131
140
|
end
|
132
141
|
|
133
142
|
it 'can be described open' do
|
134
143
|
@door.description open: 'An open door', closed: 'A closed door'
|
135
|
-
@door.description.
|
144
|
+
expect(@door.description).to eq 'An open door'
|
136
145
|
end
|
137
146
|
|
138
147
|
it 'can be described closed' do
|
139
148
|
@door.close!
|
140
|
-
@door.description.
|
149
|
+
expect(@door.description).to eq 'A closed door'
|
141
150
|
end
|
142
151
|
|
143
152
|
end
|
@@ -151,12 +160,12 @@ describe Woyo::Way do
|
|
151
160
|
end
|
152
161
|
|
153
162
|
it 'when open' do
|
154
|
-
@door.go.
|
163
|
+
expect(@door.go).to eq ( { go: true, going: 'Swings open' } )
|
155
164
|
end
|
156
165
|
|
157
166
|
it 'when closed' do
|
158
167
|
@door.close!
|
159
|
-
@door.go.
|
168
|
+
expect(@door.go).to eq ( { go: false, going: 'Slams shut' } )
|
160
169
|
end
|
161
170
|
|
162
171
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'woyo/world/world_object'
|
2
3
|
|
3
4
|
describe Woyo::WorldObject do
|
@@ -9,11 +10,11 @@ describe Woyo::WorldObject do
|
|
9
10
|
end
|
10
11
|
|
11
12
|
it 'creates id' do
|
12
|
-
Woyo::WorldObject.new(:my_id).id.
|
13
|
+
expect(Woyo::WorldObject.new(:my_id).id).to eq :my_id
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'converts id to lowercase' do
|
16
|
-
Woyo::WorldObject.new(:MY_id ).id.
|
17
|
+
expect(Woyo::WorldObject.new(:MY_id ).id).to eq :my_id
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'accepts named parameter context:' do
|
@@ -23,7 +24,7 @@ describe Woyo::WorldObject do
|
|
23
24
|
it 'accepts a block with arity 0' do
|
24
25
|
result = ''
|
25
26
|
Woyo::WorldObject.new( :home ) { result = 'ok' }
|
26
|
-
result.
|
27
|
+
expect(result).to eq 'ok'
|
27
28
|
end
|
28
29
|
|
29
30
|
it 'instance evals block with arity 0' do
|
@@ -33,18 +34,59 @@ describe Woyo::WorldObject do
|
|
33
34
|
it 'accepts a block with arity 1' do
|
34
35
|
result = ''
|
35
36
|
Woyo::WorldObject.new( :home ) { |scope| result = 'ok' }
|
36
|
-
result.
|
37
|
+
expect(result).to eq 'ok'
|
37
38
|
end
|
38
39
|
|
39
40
|
it 'passes self to block with arity 1' do
|
40
|
-
Woyo::WorldObject.new( :home ) { |scope| scope.
|
41
|
+
Woyo::WorldObject.new( :home ) { |scope| expect(scope).to be_instance_of Woyo::WorldObject }
|
41
42
|
end
|
42
43
|
|
43
44
|
end
|
44
45
|
|
45
46
|
it 'provides access to context' do
|
46
47
|
wo = Woyo::WorldObject.new(:my_id, context: :just_a_test )
|
47
|
-
wo.context.
|
48
|
+
expect(wo.context).to eq :just_a_test
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'has' do
|
52
|
+
|
53
|
+
it 'attributes' do
|
54
|
+
wo = Woyo::WorldObject.new :thing do
|
55
|
+
attribute color: :red
|
56
|
+
end
|
57
|
+
expect(wo.color).to eq :red
|
58
|
+
wo.color = :blue
|
59
|
+
expect(wo.color).to eq :blue
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'actions' do
|
63
|
+
wo = Woyo::WorldObject.new :thing do
|
64
|
+
action :time do
|
65
|
+
Time.now
|
66
|
+
end
|
67
|
+
end
|
68
|
+
expect(wo.time).to be < Time.now
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'has attributes' do
|
74
|
+
|
75
|
+
it 'name' do
|
76
|
+
wo = Woyo::WorldObject.new( :thing ) { name 'Thingy' }
|
77
|
+
expect(wo.name).to eq 'Thingy'
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'default name' do
|
81
|
+
wo = Woyo::WorldObject.new( :thing )
|
82
|
+
expect(wo.name).to eq 'Thing'
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'description' do
|
86
|
+
wo = Woyo::WorldObject.new( :thing ) { description 'A thing.' }
|
87
|
+
expect(wo.description).to eq 'A thing.'
|
88
|
+
end
|
89
|
+
|
48
90
|
end
|
49
91
|
|
50
92
|
end
|
@@ -1,18 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
1
2
|
require 'woyo/world/world'
|
2
3
|
|
3
4
|
describe Woyo::World do
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
let(:world) { Woyo::World.new }
|
7
|
+
|
8
|
+
it 'has attribute :start' do
|
9
|
+
expect(world.attributes).to be_instance_of Woyo::Attributes::AttributesHash
|
10
|
+
expect(world.attributes.names).to include :start
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'has locations' do
|
14
|
+
expect(world.locations).to be_empty
|
8
15
|
end
|
9
16
|
|
10
|
-
it '
|
11
|
-
|
17
|
+
it 'has characters' do
|
18
|
+
expect(world.characters).to be_empty
|
12
19
|
end
|
13
20
|
|
14
|
-
it '
|
15
|
-
|
21
|
+
it 'has items' do
|
22
|
+
expect(world.items).to be_empty
|
16
23
|
end
|
17
24
|
|
18
25
|
end
|
26
|
+
|
data/todo.txt
CHANGED
@@ -28,7 +28,7 @@ ok query boolean attribute values... ?
|
|
28
28
|
dark? # ... dark ? true : false
|
29
29
|
is? :dark # ... def is? attr ; attributes[attr] ? true : false ; end
|
30
30
|
|
31
|
-
additional class level define (and detect?) boolean attribute values...
|
31
|
+
ok additional class level define (and detect?) boolean attribute values...
|
32
32
|
|
33
33
|
is :open
|
34
34
|
is :dark
|
@@ -55,7 +55,7 @@ ok attribute methods for members in parent
|
|
55
55
|
world_object.sword
|
56
56
|
world_object.knife
|
57
57
|
|
58
|
-
is group a namespace ? - optional ... attribute methods in group
|
58
|
+
no is group a namespace ? - optional ... attribute methods in group
|
59
59
|
|
60
60
|
world_object.weapons.sword
|
61
61
|
world_object.weapons.knife
|
data/woyo-world.gemspec
CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "haml"
|
24
25
|
|
25
26
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woyo-world
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerard Fowley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: haml
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -67,20 +81,28 @@ files:
|
|
67
81
|
- README.md
|
68
82
|
- Rakefile
|
69
83
|
- lib/woyo/world.rb
|
84
|
+
- lib/woyo/world/actions.rb
|
70
85
|
- lib/woyo/world/attributes.rb
|
71
86
|
- lib/woyo/world/character.rb
|
72
|
-
- lib/woyo/world/
|
87
|
+
- lib/woyo/world/evaluate.rb
|
73
88
|
- lib/woyo/world/group.rb
|
89
|
+
- lib/woyo/world/item.rb
|
74
90
|
- lib/woyo/world/location.rb
|
75
91
|
- lib/woyo/world/version.rb
|
76
92
|
- lib/woyo/world/way.rb
|
77
93
|
- lib/woyo/world/world.rb
|
78
94
|
- lib/woyo/world/world_object.rb
|
95
|
+
- rspec.json
|
96
|
+
- spec/spec_doc.haml
|
97
|
+
- spec/spec_doc_formatter.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- spec/woyo/dsl/dsl_spec.rb
|
100
|
+
- spec/woyo/world/actions_spec.rb
|
79
101
|
- spec/woyo/world/attributes_spec.rb
|
80
102
|
- spec/woyo/world/character_spec.rb
|
81
|
-
- spec/woyo/world/
|
103
|
+
- spec/woyo/world/evaluate_spec.rb
|
82
104
|
- spec/woyo/world/group_spec.rb
|
83
|
-
- spec/woyo/world/
|
105
|
+
- spec/woyo/world/item_spec.rb
|
84
106
|
- spec/woyo/world/location_spec.rb
|
85
107
|
- spec/woyo/world/way_spec.rb
|
86
108
|
- spec/woyo/world/world_object_spec.rb
|
@@ -113,11 +135,16 @@ signing_key:
|
|
113
135
|
specification_version: 4
|
114
136
|
summary: World of Your Own
|
115
137
|
test_files:
|
138
|
+
- spec/spec_doc.haml
|
139
|
+
- spec/spec_doc_formatter.rb
|
140
|
+
- spec/spec_helper.rb
|
141
|
+
- spec/woyo/dsl/dsl_spec.rb
|
142
|
+
- spec/woyo/world/actions_spec.rb
|
116
143
|
- spec/woyo/world/attributes_spec.rb
|
117
144
|
- spec/woyo/world/character_spec.rb
|
118
|
-
- spec/woyo/world/
|
145
|
+
- spec/woyo/world/evaluate_spec.rb
|
119
146
|
- spec/woyo/world/group_spec.rb
|
120
|
-
- spec/woyo/world/
|
147
|
+
- spec/woyo/world/item_spec.rb
|
121
148
|
- spec/woyo/world/location_spec.rb
|
122
149
|
- spec/woyo/world/way_spec.rb
|
123
150
|
- spec/woyo/world/world_object_spec.rb
|