inform-runtime 1.2.3 → 1.3.1
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 +33 -41
- data/lib/story_teller/articles.rb +2 -1
- data/lib/story_teller/builtins.rb +63 -10
- data/lib/story_teller/color.rb +2 -1
- data/lib/story_teller/command.rb +2 -1
- data/lib/story_teller/context.rb +23 -27
- data/lib/story_teller/daemon.rb +2 -2
- data/lib/story_teller/engine.rb +45 -10
- data/lib/story_teller/events.rb +1 -1
- data/lib/story_teller/experimental/handler_dsl.rb +1 -16
- data/lib/story_teller/experimental/reverse_engineer_class.rb +1 -1
- data/lib/story_teller/grammar_parser.rb +60 -13
- data/lib/story_teller/helpers.rb +8 -4
- data/lib/story_teller/history.rb +1 -1
- data/lib/story_teller/inflector.rb +4 -2
- data/lib/story_teller/inform/ephemeral/link.rb +63 -31
- data/lib/story_teller/inform/ephemeral/module.rb +6 -5
- data/lib/story_teller/inform/ephemeral/object.rb +223 -236
- data/lib/story_teller/inform/ephemeral/tag.rb +27 -14
- data/lib/story_teller/io.rb +99 -49
- data/lib/story_teller/kernel.rb +2 -2
- data/lib/story_teller/library/bootstrap.rb +2 -2
- data/lib/story_teller/library/declarations.rb +1 -1
- data/lib/story_teller/library/directives.rb +1 -1
- data/lib/story_teller/library/loader.rb +3 -20
- data/lib/story_teller/library/location.rb +9 -3
- data/lib/story_teller/library.rb +1 -1
- data/lib/story_teller/logging.rb +1 -1
- data/lib/story_teller/mixins.rb +11 -4
- data/lib/story_teller/plurals.rb +2 -1
- data/lib/story_teller/privileges.rb +89 -6
- data/lib/story_teller/prototype.rb +150 -32
- data/lib/story_teller/publication.rb +2 -1
- data/lib/story_teller/session.rb +115 -25
- data/lib/story_teller/stdlib.rb +231 -1
- data/lib/story_teller/subscription.rb +2 -1
- data/lib/story_teller/tree.rb +2 -1
- data/lib/story_teller/version.rb +2 -2
- data/lib/story_teller/world_tree.rb +21 -23
- data/lib/story_teller.rb +18 -5
- metadata +6 -10
- data/lib/story_teller/core.rb +0 -39
- data/lib/story_teller/ephemeral_adapter.rb +0 -40
- data/lib/story_teller/inform/base.rb +0 -160
- data/lib/story_teller/model_adapter.rb +0 -132
|
@@ -1,132 +0,0 @@
|
|
|
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)
|
|
92
|
-
end
|
|
93
|
-
module_function :object_class
|
|
94
|
-
|
|
95
|
-
def tag_class
|
|
96
|
-
current&.fetch(:tag_class, nil)
|
|
97
|
-
end
|
|
98
|
-
module_function :tag_class
|
|
99
|
-
|
|
100
|
-
def link_class
|
|
101
|
-
current&.fetch(:link_class, nil)
|
|
102
|
-
end
|
|
103
|
-
module_function :link_class
|
|
104
|
-
|
|
105
|
-
def module_class
|
|
106
|
-
current&.fetch(:module_class, 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
|