inform-runtime 1.0.4 → 1.2.0
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/README.md +10 -12
- data/Rakefile +26 -16
- data/lib/{runtime → story_teller}/articles.rb +14 -10
- data/lib/{runtime → story_teller}/builtins.rb +50 -22
- data/lib/{runtime → story_teller}/color.rb +8 -8
- data/lib/{runtime → story_teller}/command.rb +26 -28
- data/lib/{runtime → story_teller}/context.rb +23 -24
- data/lib/story_teller/core.rb +38 -0
- data/lib/{runtime → story_teller}/daemon.rb +35 -36
- data/lib/story_teller/engine.rb +151 -0
- data/lib/story_teller/ephemeral_adapter.rb +42 -0
- data/lib/{runtime → story_teller}/events.rb +8 -9
- data/lib/{runtime → story_teller}/experimental/handler_dsl.rb +7 -18
- data/lib/story_teller/experimental/reverse_engineer_class.rb +37 -0
- data/lib/{runtime → story_teller}/grammar_parser.rb +24 -40
- data/lib/{runtime → story_teller}/helpers.rb +21 -7
- data/lib/{runtime → story_teller}/history.rb +5 -5
- data/lib/{runtime → story_teller}/inflector.rb +4 -5
- data/lib/story_teller/inform/base.rb +160 -0
- data/lib/{runtime → story_teller/inform/ephemeral}/link.rb +27 -45
- data/lib/{runtime → story_teller/inform/ephemeral}/module.rb +17 -58
- data/lib/story_teller/inform/ephemeral/object.rb +329 -0
- data/lib/{runtime → story_teller/inform/ephemeral}/tag.rb +54 -81
- data/lib/story_teller/inform/models.rb +25 -0
- data/lib/{runtime → story_teller}/io.rb +10 -10
- data/lib/{runtime → story_teller}/kernel.rb +21 -31
- data/lib/story_teller/library/bootstrap.rb +66 -0
- data/lib/story_teller/library/declarations.rb +53 -0
- data/lib/story_teller/library/directives.rb +91 -0
- data/lib/story_teller/library/loader.rb +104 -0
- data/lib/story_teller/library/location.rb +73 -0
- data/lib/{runtime → story_teller}/library.rb +27 -12
- data/lib/{runtime → story_teller}/logging.rb +47 -24
- data/lib/{runtime → story_teller}/mixins.rb +6 -6
- data/lib/story_teller/model_adapter.rb +132 -0
- data/lib/{runtime → story_teller}/plurals.rb +11 -11
- data/lib/{runtime → story_teller}/prototype.rb +11 -10
- data/lib/{runtime → story_teller}/publication.rb +9 -9
- data/lib/{runtime → story_teller}/session.rb +6 -8
- data/lib/{runtime → story_teller}/stdlib.rb +13 -11
- data/lib/{runtime → story_teller}/subscription.rb +8 -8
- data/lib/{runtime → story_teller}/tree.rb +6 -6
- data/lib/{runtime → story_teller}/version.rb +16 -6
- data/lib/story_teller/world_tree.rb +54 -0
- data/lib/story_teller.rb +26 -0
- metadata +59 -99
- data/config/database.yml +0 -37
- data/exe/inform.rb +0 -6
- data/game/config.yml +0 -5
- data/game/example.inf +0 -76
- data/game/example.rb +0 -90
- data/game/forms/example_form.rb +0 -2
- data/game/grammar/game_grammar.inf.rb +0 -11
- data/game/languages/english.rb +0 -2
- data/game/models/example_model.rb +0 -2
- data/game/modules/example_module.rb +0 -9
- data/game/rules/example_state.rb +0 -2
- data/game/scripts/example_script.rb +0 -2
- data/game/topics/example_topic.rb +0 -2
- data/game/verbs/game_verbs.rb +0 -15
- data/game/verbs/metaverbs.rb +0 -2028
- data/lib/runtime/config.rb +0 -48
- data/lib/runtime/database.rb +0 -500
- data/lib/runtime/game.rb +0 -74
- data/lib/runtime/game_loader.rb +0 -132
- data/lib/runtime/library_loader.rb +0 -135
- data/lib/runtime/object.rb +0 -761
- data/lib/runtime/options.rb +0 -104
- data/lib/runtime/persistence.rb +0 -292
- data/lib/runtime/runtime.rb +0 -321
- data/lib/runtime/world_tree.rb +0 -69
- data/lib/runtime.rb +0 -35
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# lib/story_teller/model_adapter.rb
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
# frozen_string_literal: false
|
|
4
|
+
|
|
5
|
+
# Copyright Nels Nelson 2008-2026 but freely usable (see license)
|
|
6
|
+
#
|
|
7
|
+
# This file is part of StoryTeller.
|
|
8
|
+
#
|
|
9
|
+
# StoryTeller is free software: you can redistribute it and/or
|
|
10
|
+
# modify it under the terms of the GNU General Public License as published
|
|
11
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# StoryTeller is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
|
|
22
|
+
# The StoryTeller module
|
|
23
|
+
module StoryTeller
|
|
24
|
+
# The ModelAdapter module
|
|
25
|
+
module ModelAdapter
|
|
26
|
+
RequiredAdapterKeys = %i[name object_class tag_class link_class module_class].freeze
|
|
27
|
+
ExcludedObjectModelModuleNames = ['Inform::Context'].freeze
|
|
28
|
+
|
|
29
|
+
Registry = Struct.new(:memo).new(nil)
|
|
30
|
+
|
|
31
|
+
def current
|
|
32
|
+
Registry.memo
|
|
33
|
+
end
|
|
34
|
+
module_function :current
|
|
35
|
+
|
|
36
|
+
def current=(adapter)
|
|
37
|
+
Registry.memo = adapter
|
|
38
|
+
end
|
|
39
|
+
module_function :current=
|
|
40
|
+
|
|
41
|
+
def register!(adapter)
|
|
42
|
+
validate!(adapter)
|
|
43
|
+
adapt_object_class!(adapter.fetch(:object_class))
|
|
44
|
+
self.current = adapter.freeze
|
|
45
|
+
end
|
|
46
|
+
module_function :register!
|
|
47
|
+
|
|
48
|
+
def validate!(adapter)
|
|
49
|
+
missing = RequiredAdapterKeys.reject { |key| adapter.key?(key) }
|
|
50
|
+
raise ArgumentError, "Model adapter is missing keys: #{missing.join(', ')}" unless missing.empty?
|
|
51
|
+
|
|
52
|
+
%i[object_class tag_class link_class module_class].each do |key|
|
|
53
|
+
value = adapter.fetch(key)
|
|
54
|
+
next if value.is_a?(Class)
|
|
55
|
+
|
|
56
|
+
raise ArgumentError, "Model adapter #{key} must be a Class"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
adapter
|
|
60
|
+
end
|
|
61
|
+
module_function :validate!
|
|
62
|
+
|
|
63
|
+
def adapt_object_class!(klass)
|
|
64
|
+
object_model_modules.reverse_each do |mod|
|
|
65
|
+
klass.include(mod) unless klass < mod
|
|
66
|
+
end
|
|
67
|
+
klass
|
|
68
|
+
end
|
|
69
|
+
module_function :adapt_object_class!
|
|
70
|
+
|
|
71
|
+
def object_model_modules
|
|
72
|
+
return [] unless defined?(Inform::Object)
|
|
73
|
+
|
|
74
|
+
ancestors = Inform::Object.ancestors
|
|
75
|
+
superclass_index = ancestors.index(Inform::Object.superclass)
|
|
76
|
+
ancestors[1...superclass_index].select { |ancestor| object_model_module?(ancestor) }
|
|
77
|
+
end
|
|
78
|
+
module_function :object_model_modules
|
|
79
|
+
|
|
80
|
+
def object_model_module?(ancestor)
|
|
81
|
+
ancestor.is_a?(Module) && !ExcludedObjectModelModuleNames.include?(ancestor.name)
|
|
82
|
+
end
|
|
83
|
+
module_function :object_model_module?
|
|
84
|
+
|
|
85
|
+
def available?
|
|
86
|
+
!current.nil?
|
|
87
|
+
end
|
|
88
|
+
module_function :available?
|
|
89
|
+
|
|
90
|
+
def object_class
|
|
91
|
+
current&.fetch(:object_class, nil) || (defined?(Inform::Object) ? Inform::Object : nil)
|
|
92
|
+
end
|
|
93
|
+
module_function :object_class
|
|
94
|
+
|
|
95
|
+
def tag_class
|
|
96
|
+
current&.fetch(:tag_class, nil) || (defined?(Inform::Tag) ? Inform::Tag : nil)
|
|
97
|
+
end
|
|
98
|
+
module_function :tag_class
|
|
99
|
+
|
|
100
|
+
def link_class
|
|
101
|
+
current&.fetch(:link_class, nil) || (defined?(Inform::Link) ? Inform::Link : nil)
|
|
102
|
+
end
|
|
103
|
+
module_function :link_class
|
|
104
|
+
|
|
105
|
+
def module_class
|
|
106
|
+
current&.fetch(:module_class, nil) || (defined?(Inform::Module) ? Inform::Module : nil)
|
|
107
|
+
end
|
|
108
|
+
module_function :module_class
|
|
109
|
+
|
|
110
|
+
def object_class!
|
|
111
|
+
object_class || raise(NotImplementedError, 'No object model adapter has been registered')
|
|
112
|
+
end
|
|
113
|
+
module_function :object_class!
|
|
114
|
+
|
|
115
|
+
def tag_class!
|
|
116
|
+
tag_class || raise(NotImplementedError, 'No tag model adapter has been registered')
|
|
117
|
+
end
|
|
118
|
+
module_function :tag_class!
|
|
119
|
+
|
|
120
|
+
def link_class!
|
|
121
|
+
link_class || raise(NotImplementedError, 'No link model adapter has been registered')
|
|
122
|
+
end
|
|
123
|
+
module_function :link_class!
|
|
124
|
+
|
|
125
|
+
def module_class!
|
|
126
|
+
module_class || raise(NotImplementedError, 'No module model adapter has been registered')
|
|
127
|
+
end
|
|
128
|
+
module_function :module_class!
|
|
129
|
+
end
|
|
130
|
+
# module ModelAdapter
|
|
131
|
+
end
|
|
132
|
+
# module StoryTeller
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: false
|
|
3
3
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
4
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
5
|
#
|
|
6
|
-
# This file is part of the
|
|
6
|
+
# This file is part of the StoryTeller.
|
|
7
7
|
#
|
|
8
|
-
# The
|
|
8
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
9
9
|
# modify it under the terms of the GNU General Public License as published
|
|
10
10
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
11
|
# (at your option) any later version.
|
|
12
12
|
#
|
|
13
|
-
# The
|
|
13
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
14
14
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
15
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
16
|
# GNU General Public License for more details.
|
|
17
17
|
#
|
|
18
18
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with the
|
|
19
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
|
|
21
21
|
require_relative 'inflector'
|
|
22
22
|
|
|
23
|
-
# The
|
|
24
|
-
module
|
|
23
|
+
# The StoryTeller module
|
|
24
|
+
module StoryTeller
|
|
25
25
|
# The Plurals module
|
|
26
26
|
module Plurals
|
|
27
27
|
# Returns the plural form of the word in the string.
|
|
28
28
|
def pluralize(word, n = nil)
|
|
29
29
|
return word if n == 1
|
|
30
|
-
apply_inflections(word,
|
|
30
|
+
apply_inflections(word, StoryTeller::Inflector.inflections.plurals)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# The reverse of +pluralize+, returns the singular form of a word in a
|
|
34
34
|
# string.
|
|
35
35
|
def singularize(word)
|
|
36
|
-
apply_inflections(word,
|
|
36
|
+
apply_inflections(word, StoryTeller::Inflector.inflections.singulars)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def singular?(s)
|
|
@@ -48,7 +48,7 @@ module Inform
|
|
|
48
48
|
def apply_inflections(word, rules)
|
|
49
49
|
return "" if word.empty?
|
|
50
50
|
result = word.to_s.dup
|
|
51
|
-
return result if
|
|
51
|
+
return result if StoryTeller::Inflector.inflections.uncountables.include?(result.downcase[/\b\w+\Z/])
|
|
52
52
|
for (rule, replacement) in rules
|
|
53
53
|
break if result.sub!(rule, replacement)
|
|
54
54
|
end
|
|
@@ -57,4 +57,4 @@ module Inform
|
|
|
57
57
|
end
|
|
58
58
|
# module Plurals
|
|
59
59
|
end
|
|
60
|
-
# module
|
|
60
|
+
# module StoryTeller
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
# lib/story_teller/prototype.rb
|
|
1
2
|
# encoding: utf-8
|
|
2
3
|
# frozen_string_literal: false
|
|
3
4
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
5
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
6
|
#
|
|
6
|
-
# This file is part of
|
|
7
|
+
# This file is part of StoryTeller.
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
+
# StoryTeller is free software: you can redistribute it and/or
|
|
9
10
|
# modify it under the terms of the GNU General Public License as published
|
|
10
11
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
12
|
# (at your option) any later version.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
+
# StoryTeller is distributed in the hope that it will be useful,
|
|
14
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
16
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
17
|
# GNU General Public License for more details.
|
|
17
18
|
#
|
|
18
19
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with
|
|
20
|
+
# along with StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
21
|
|
|
21
22
|
# The Inform module
|
|
22
23
|
module Inform
|
|
@@ -140,20 +141,20 @@ module Inform
|
|
|
140
141
|
event = context_event
|
|
141
142
|
|
|
142
143
|
if MethodWriterPattern.match?(m) || (LinkPattern.match?(m) && !args.empty?)
|
|
143
|
-
if !event.nil? &&
|
|
144
|
+
if !event.nil? && StoryTeller::Engine.invocation_properties.include?(property)
|
|
144
145
|
event.send(method, *args, &block)
|
|
145
146
|
elsif inflib&.library_method?(method)
|
|
146
147
|
inflib.send(method, *args, &block)
|
|
147
148
|
else
|
|
148
149
|
self.prototype(method, *args, &block)
|
|
149
150
|
end
|
|
150
|
-
elsif !event.nil? &&
|
|
151
|
+
elsif !event.nil? && StoryTeller::Engine.invocation_properties.include?(property)
|
|
151
152
|
result = event.send(method, *args, &block)
|
|
152
153
|
log.debug("Value for event #{event}.#{method} is: #{result || 'nil'}") if defined? DEBUG
|
|
153
154
|
result
|
|
154
155
|
elsif inflib&.library_method?(method)
|
|
155
156
|
inflib.send(method, *args, &block)
|
|
156
|
-
elsif inflib.respond_to?(method) &&
|
|
157
|
+
elsif inflib.respond_to?(method) && StoryTeller::Engine.invocation_properties.include?(property)
|
|
157
158
|
inflib.send(method, *args, &block)
|
|
158
159
|
elsif inflib&.instance_variable_get(variable) || inflib&.instance_variables&.include?(variable)
|
|
159
160
|
inflib.instance_variable_get(variable)
|
|
@@ -176,7 +177,7 @@ module Inform
|
|
|
176
177
|
# return false if m =~ /\?$/
|
|
177
178
|
# mname = m =~ /\=$/ ? m.chop : m
|
|
178
179
|
# property = mname.intern
|
|
179
|
-
#
|
|
180
|
+
# StoryTeller::Engine.invocation_properties.include? property
|
|
180
181
|
# end
|
|
181
182
|
|
|
182
183
|
def accessor_and_writer(key)
|
|
@@ -232,7 +233,7 @@ module Inform
|
|
|
232
233
|
end
|
|
233
234
|
|
|
234
235
|
def key_refers_to_link?(key)
|
|
235
|
-
|
|
236
|
+
StoryTeller::Library.declarations.properties.key?(key) && LinkPattern.match?(key.to_s)
|
|
236
237
|
end
|
|
237
238
|
|
|
238
239
|
def _get(key)
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: false
|
|
3
3
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
4
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
5
|
#
|
|
6
|
-
# This file is part of the
|
|
6
|
+
# This file is part of the StoryTeller.
|
|
7
7
|
#
|
|
8
|
-
# The
|
|
8
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
9
9
|
# modify it under the terms of the GNU General Public License as published
|
|
10
10
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
11
|
# (at your option) any later version.
|
|
12
12
|
#
|
|
13
|
-
# The
|
|
13
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
14
14
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
15
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
16
|
# GNU General Public License for more details.
|
|
17
17
|
#
|
|
18
18
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with the
|
|
19
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
|
|
21
21
|
require_relative 'subscription'
|
|
22
22
|
|
|
23
|
-
# The
|
|
24
|
-
module
|
|
23
|
+
# The StoryTeller module
|
|
24
|
+
module StoryTeller
|
|
25
25
|
# The Publisher module to implement rudimentary pub-sub functionality
|
|
26
26
|
module Publisher
|
|
27
|
-
include
|
|
27
|
+
include StoryTeller::Subscribers
|
|
28
28
|
|
|
29
29
|
def muted?
|
|
30
30
|
false
|
|
@@ -89,4 +89,4 @@ module Inform
|
|
|
89
89
|
end
|
|
90
90
|
# module Publisher
|
|
91
91
|
end
|
|
92
|
-
# module
|
|
92
|
+
# module StoryTeller
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: false
|
|
3
3
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
4
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
5
|
#
|
|
6
|
-
# This file is part of
|
|
6
|
+
# This file is part of StoryTeller.
|
|
7
7
|
#
|
|
8
|
-
#
|
|
8
|
+
# StoryTeller is free software: you can redistribute it and/or
|
|
9
9
|
# modify it under the terms of the GNU General Public License as published
|
|
10
10
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
11
|
# (at your option) any later version.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
13
|
+
# StoryTeller is distributed in the hope that it will be useful,
|
|
14
14
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
15
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
16
|
# GNU General Public License for more details.
|
|
17
17
|
#
|
|
18
18
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with
|
|
20
|
-
|
|
21
|
-
require 'set'
|
|
19
|
+
# along with StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
22
20
|
|
|
23
21
|
# The SessionManagementMethods module
|
|
24
22
|
module SessionManagementMethods
|
|
25
|
-
Registry
|
|
23
|
+
class Registry < Hash; end
|
|
26
24
|
SessionsByChannel = Registry.new
|
|
27
25
|
|
|
28
26
|
def add_promiscuous_states(*states)
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
# lib/story_teller/stdlib.rb
|
|
1
2
|
# encoding: utf-8
|
|
2
3
|
# frozen_string_literal: false
|
|
3
4
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
5
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
6
|
#
|
|
6
|
-
# This file is part of
|
|
7
|
+
# This file is part of StoryTeller.
|
|
7
8
|
#
|
|
8
|
-
#
|
|
9
|
+
# StoryTeller is free software: you can redistribute it and/or
|
|
9
10
|
# modify it under the terms of the GNU General Public License as published
|
|
10
11
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
12
|
# (at your option) any later version.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
+
# StoryTeller is distributed in the hope that it will be useful,
|
|
14
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
16
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
17
|
# GNU General Public License for more details.
|
|
17
18
|
#
|
|
18
19
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with
|
|
20
|
+
# along with StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
21
|
|
|
21
22
|
# The Inform module
|
|
22
23
|
module Inform
|
|
@@ -32,7 +33,7 @@ module StdLib
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def executable
|
|
35
|
-
|
|
36
|
+
StoryTeller::Engine.executable
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def inversion
|
|
@@ -75,7 +76,7 @@ module StdLib
|
|
|
75
76
|
def import_object_yaml(file)
|
|
76
77
|
return unless defined? YAML
|
|
77
78
|
return if file.nil?
|
|
78
|
-
YAML.
|
|
79
|
+
YAML.safe_load_file(file)
|
|
79
80
|
end
|
|
80
81
|
alias import_object_yml import_object_yaml
|
|
81
82
|
|
|
@@ -162,7 +163,7 @@ module StdLib
|
|
|
162
163
|
# rubocop: disable Metrics/AbcSize
|
|
163
164
|
# rubocop: disable Metrics/MethodLength
|
|
164
165
|
def invocation_context(action, *args)
|
|
165
|
-
ctx =
|
|
166
|
+
ctx = StoryTeller.context
|
|
166
167
|
ctx.results = [
|
|
167
168
|
ctx.action = ctx.action_to_be = action,
|
|
168
169
|
ctx.parameters = args.length,
|
|
@@ -215,9 +216,10 @@ module StdLib
|
|
|
215
216
|
# the opportunity to react to the action, like invoke
|
|
216
217
|
# does, above.
|
|
217
218
|
#
|
|
218
|
-
# This should be used to
|
|
219
|
-
# another Verb action subroutine. It
|
|
220
|
-
# if the invoked action is part of the
|
|
219
|
+
# This should be used to cause an action outcome during
|
|
220
|
+
# the execution of another Verb action subroutine. It
|
|
221
|
+
# should appear as if the invoked action is part of the
|
|
222
|
+
# original action.
|
|
221
223
|
# !rubocop: disable Metrics/AbcSize
|
|
222
224
|
def _invoke(action, *args)
|
|
223
225
|
raise "The action parameter may not be nil" if action.nil?
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: false
|
|
3
3
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
4
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
5
|
#
|
|
6
|
-
# This file is part of the
|
|
6
|
+
# This file is part of the StoryTeller.
|
|
7
7
|
#
|
|
8
|
-
# The
|
|
8
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
9
9
|
# modify it under the terms of the GNU General Public License as published
|
|
10
10
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
11
|
# (at your option) any later version.
|
|
12
12
|
#
|
|
13
|
-
# The
|
|
13
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
14
14
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
15
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
16
|
# GNU General Public License for more details.
|
|
17
17
|
#
|
|
18
18
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with the
|
|
19
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
|
|
21
|
-
# The
|
|
22
|
-
module
|
|
21
|
+
# The StoryTeller module
|
|
22
|
+
module StoryTeller
|
|
23
23
|
# The Subscribers module
|
|
24
24
|
module Subscribers
|
|
25
25
|
REGISTRY = Struct.new(:memo).new(defined?(Java) ? java.util.concurrent.ConcurrentHashMap.new : {})
|
|
@@ -41,7 +41,7 @@ module Inform
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def explicit_subscribers
|
|
44
|
-
|
|
44
|
+
StoryTeller::Subscribers::REGISTRY.memo[identity] ||= []
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
# frozen_string_literal: false
|
|
3
3
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
4
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
5
|
#
|
|
6
|
-
# This file is part of the
|
|
6
|
+
# This file is part of the StoryTeller.
|
|
7
7
|
#
|
|
8
|
-
# The
|
|
8
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
9
9
|
# modify it under the terms of the GNU General Public License as published
|
|
10
10
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
11
|
# (at your option) any later version.
|
|
12
12
|
#
|
|
13
|
-
# The
|
|
13
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
14
14
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
15
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
16
|
# GNU General Public License for more details.
|
|
17
17
|
#
|
|
18
18
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with the
|
|
19
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
|
|
21
21
|
# Tree
|
|
22
22
|
|
|
@@ -146,7 +146,7 @@ module Inform
|
|
|
146
146
|
# rubocop: disable Metrics/PerceivedComplexity
|
|
147
147
|
def child(o = self, prop = :@children)
|
|
148
148
|
if o.instance_variable_defined?(prop)
|
|
149
|
-
# The idea here is that o may be an Inform::
|
|
149
|
+
# The idea here is that o may be an Inform::Ephemeral::Object.
|
|
150
150
|
children = o.instance_variable_get(prop)
|
|
151
151
|
return nil unless children.respond_to?(:first)
|
|
152
152
|
children.first
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
+
# lib/story_teller/version.rb
|
|
1
2
|
# encoding: utf-8
|
|
2
3
|
# frozen_string_literal: false
|
|
3
4
|
|
|
4
|
-
# Copyright Nels Nelson 2008-
|
|
5
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
5
6
|
#
|
|
6
|
-
# This file is part of the
|
|
7
|
+
# This file is part of the StoryTeller.
|
|
7
8
|
#
|
|
8
|
-
# The
|
|
9
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
9
10
|
# modify it under the terms of the GNU General Public License as published
|
|
10
11
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
11
12
|
# (at your option) any later version.
|
|
12
13
|
#
|
|
13
|
-
# The
|
|
14
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
14
15
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
16
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
17
|
# GNU General Public License for more details.
|
|
17
18
|
#
|
|
18
19
|
# You should have received a copy of the GNU General Public License
|
|
19
|
-
# along with the
|
|
20
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
20
21
|
|
|
22
|
+
# module StoryTeller
|
|
23
|
+
module StoryTeller
|
|
24
|
+
# module Engine
|
|
25
|
+
module Engine
|
|
26
|
+
VERSION = '1.2.0'.freeze
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# module Inform
|
|
21
31
|
module Inform
|
|
22
|
-
VERSION =
|
|
32
|
+
VERSION = StoryTeller::Engine::VERSION
|
|
23
33
|
VN_1610 = '1610'.freeze
|
|
24
34
|
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# lib/story_teller/world_tree.rb
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
# frozen_string_literal: false
|
|
4
|
+
|
|
5
|
+
# Copyright Nels Nelson 2008-2025 but freely usable (see license)
|
|
6
|
+
#
|
|
7
|
+
# This file is part of the StoryTeller.
|
|
8
|
+
#
|
|
9
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
10
|
+
# modify it under the terms of the GNU General Public License as published
|
|
11
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
|
|
22
|
+
require_relative 'tree'
|
|
23
|
+
require_relative 'daemon'
|
|
24
|
+
|
|
25
|
+
# class Object
|
|
26
|
+
module Inform
|
|
27
|
+
# class Object
|
|
28
|
+
class Object
|
|
29
|
+
include StoryTeller::Builtins
|
|
30
|
+
include StoryTeller::IO if defined?(StoryTeller::IO)
|
|
31
|
+
include StoryTeller::Publisher if defined?(StoryTeller::Publisher)
|
|
32
|
+
include StoryTeller::Daemons if defined?(StoryTeller::Daemons)
|
|
33
|
+
include Inform::Context if defined?(Inform::Context)
|
|
34
|
+
include Inform::Events if defined?(Inform::Events)
|
|
35
|
+
include Inform::Prototypical if defined?(Inform::Prototypical)
|
|
36
|
+
include Inform::Linkable if defined?(Inform::Linkable)
|
|
37
|
+
include Inform::Taggable if defined?(Inform::Taggable)
|
|
38
|
+
include Inform::Modular if defined?(Inform::Modular)
|
|
39
|
+
include Inform::Genealogical if defined?(Inform::Genealogical)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# class Event
|
|
43
|
+
class Event
|
|
44
|
+
include StoryTeller::Publisher
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The ExtendedProperties class
|
|
49
|
+
class ExtendedProperties < Inform::Object
|
|
50
|
+
def init
|
|
51
|
+
has :proper
|
|
52
|
+
super
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/story_teller.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# lib/story_teller.rb
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
# frozen_string_literal: false
|
|
4
|
+
|
|
5
|
+
# Copyright Nels Nelson 2008-2026 but freely usable (see license)
|
|
6
|
+
#
|
|
7
|
+
# This file is part of StoryTeller.
|
|
8
|
+
#
|
|
9
|
+
# The StoryTeller is free software: you can redistribute it and/or
|
|
10
|
+
# modify it under the terms of the GNU General Public License as published
|
|
11
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
# (at your option) any later version.
|
|
13
|
+
#
|
|
14
|
+
# The StoryTeller is distributed in the hope that it will be useful,
|
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
# GNU General Public License for more details.
|
|
18
|
+
#
|
|
19
|
+
# You should have received a copy of the GNU General Public License
|
|
20
|
+
# along with the StoryTeller. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
|
|
22
|
+
require_relative 'story_teller/inform/base'
|
|
23
|
+
require_relative 'story_teller/model_adapter'
|
|
24
|
+
require_relative 'story_teller/inform/models'
|
|
25
|
+
require_relative 'story_teller/ephemeral_adapter'
|
|
26
|
+
require_relative 'story_teller/core'
|