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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 474087cc0143425969470924c1fe5e944b06f2d17ee76a097551345c4ca1959e
4
- data.tar.gz: 8f933a9f47d17a247d804d226a32f8ff7d57e38698d0b0a262e40a796efd7972
3
+ metadata.gz: 1f6e015e55549341a59f8e1556996c1aa58073a0fd59eefd773aa1258a126668
4
+ data.tar.gz: 3841f6b206db14c64d5f7da3535992998932e5e80af56b819ce132e539e930f1
5
5
  SHA512:
6
- metadata.gz: 606603f0fa1048e8cf566204167646989a99b1fcc80746ec3c8a7490d737ced8cdfb09be0e0cc7b0674123ed96b8588b387f6ed010328963c700816c172167a1
7
- data.tar.gz: 3bab288d8358fcf11ca366756a1e451f3cfab0b231aa7e35d144397b4cba04257b1a92f2406581611628c03521d986db01aa32501818fe059f85f439d2a34370
6
+ metadata.gz: 1cece70cd39f757e3c455e2dfc5712fb7d3f0aa3b21b0c66aaef53743ad375061a06529aed3cd44ed9e43341d6662377345ff347c0f9500b08fba65b9467d510
7
+ data.tar.gz: 4887504a753634d4247e792823a9389eda28fafc7b48acfd5603fa7a2586d5606977209a9efa64f6b5f2f4a4ed80cad5f21bcf7c96ac5fe78901d48f0428528c
@@ -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
- if defined?(Curses)
47
- Curses.addstr s
48
- elsif session
49
- session.write_output(s)
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
@@ -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
- @outbound = OutputBuffer.new
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
- @outbound.write(value)
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
- @outbound = OutputBuffer.new
279
+ @output = OutputBuffer.new
280
+ @outbound = @output
276
281
  @last_activity = Time.now
277
282
  end
278
283
 
@@ -23,7 +23,7 @@
23
23
  module StoryTeller
24
24
  # module Engine
25
25
  module Engine
26
- VERSION = '1.4.0'.freeze
26
+ VERSION = '1.5.0'.freeze
27
27
  end
28
28
  end
29
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inform-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nels Nelson