inform-runtime 1.4.0 → 1.5.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/lib/story_teller/io.rb +10 -4
- data/lib/story_teller/session.rb +10 -5
- data/lib/story_teller/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f6e015e55549341a59f8e1556996c1aa58073a0fd59eefd773aa1258a126668
|
|
4
|
+
data.tar.gz: 3841f6b206db14c64d5f7da3535992998932e5e80af56b819ce132e539e930f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1cece70cd39f757e3c455e2dfc5712fb7d3f0aa3b21b0c66aaef53743ad375061a06529aed3cd44ed9e43341d6662377345ff347c0f9500b08fba65b9467d510
|
|
7
|
+
data.tar.gz: 4887504a753634d4247e792823a9389eda28fafc7b48acfd5603fa7a2586d5606977209a9efa64f6b5f2f4a4ed80cad5f21bcf7c96ac5fe78901d48f0428528c
|
data/lib/story_teller/io.rb
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
module StoryTeller
|
|
24
24
|
# The IO module
|
|
25
25
|
module IO
|
|
26
|
+
class << self
|
|
27
|
+
attr_accessor :default_output
|
|
28
|
+
end
|
|
29
|
+
|
|
26
30
|
def session
|
|
27
31
|
return @session if defined?(@session) && !@session.nil?
|
|
28
32
|
return nil unless defined?(StoryTeller::IO::Session)
|
|
@@ -43,10 +47,12 @@ module StoryTeller
|
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
def out(s)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
current_session = session
|
|
51
|
+
|
|
52
|
+
if current_session
|
|
53
|
+
current_session.write_output(s)
|
|
54
|
+
elsif StoryTeller::IO.default_output
|
|
55
|
+
StoryTeller::IO.default_output.write(s)
|
|
50
56
|
else
|
|
51
57
|
$stdout.write(s)
|
|
52
58
|
end
|
data/lib/story_teller/session.rb
CHANGED
|
@@ -181,7 +181,7 @@ class Session
|
|
|
181
181
|
include SessionManagementMethods
|
|
182
182
|
end
|
|
183
183
|
attr_accessor :channel, :machine, :player, :state, :status
|
|
184
|
-
attr_reader :last_good_state, :last_activity, :previous, :inbound, :outbound, :settings
|
|
184
|
+
attr_reader :last_good_state, :last_activity, :previous, :inbound, :outbound, :settings, :output
|
|
185
185
|
|
|
186
186
|
# These states accept any input, including no input
|
|
187
187
|
Promiscuous = Set.new
|
|
@@ -197,7 +197,7 @@ class Session
|
|
|
197
197
|
@settings = settings
|
|
198
198
|
@status = nil
|
|
199
199
|
@last_activity = Time.now
|
|
200
|
-
|
|
200
|
+
self.output = OutputBuffer.new
|
|
201
201
|
|
|
202
202
|
self.class.register(channel, self) unless channel.nil?
|
|
203
203
|
control(player) unless player.nil?
|
|
@@ -206,8 +206,13 @@ class Session
|
|
|
206
206
|
|
|
207
207
|
alias preferences settings
|
|
208
208
|
|
|
209
|
+
def output=(sink)
|
|
210
|
+
@output = sink
|
|
211
|
+
@outbound = sink
|
|
212
|
+
end
|
|
213
|
+
|
|
209
214
|
def write_output(value)
|
|
210
|
-
@
|
|
215
|
+
@output.write(value)
|
|
211
216
|
end
|
|
212
217
|
|
|
213
218
|
def drain_output
|
|
@@ -221,7 +226,6 @@ class Session
|
|
|
221
226
|
columns = columns.to_i
|
|
222
227
|
return output if columns <= 0
|
|
223
228
|
|
|
224
|
-
# output = output.gsub(/^\n+/, "\n")
|
|
225
229
|
output.each_line.map do |line|
|
|
226
230
|
newline = line.end_with?("\n") ? "\n" : ''
|
|
227
231
|
wrap_line(line.chomp, columns) + newline
|
|
@@ -272,7 +276,8 @@ class Session
|
|
|
272
276
|
Session[channel] = self
|
|
273
277
|
@channel = channel
|
|
274
278
|
@inbound = Inbound.new(self) if defined?(Inbound)
|
|
275
|
-
@
|
|
279
|
+
@output = OutputBuffer.new
|
|
280
|
+
@outbound = @output
|
|
276
281
|
@last_activity = Time.now
|
|
277
282
|
end
|
|
278
283
|
|
data/lib/story_teller/version.rb
CHANGED