gamefic 1.3.0 → 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/lib/gamefic/ansi.rb +1 -0
- data/lib/gamefic/character.rb +4 -4
- data/lib/gamefic/engine/tty.rb +11 -3
- data/lib/gamefic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edb52e99ac3e2c2398b119a6998022c6d06f9b4f
|
|
4
|
+
data.tar.gz: 6b621e12bfb8aaf4f284a599b5b23cdae55477cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e413d5ad81d17a7d6d6e77410e039a822dbc98d4516fb3832e209a557a8678c255a6f22ff413f8050a1298011423cb5927cf8d410d266befa32aec3cbf2e9dfc
|
|
7
|
+
data.tar.gz: 3ba4d089d93592709df8f78531a7c8ec7ae2952abde0e6b8db5dab2357b613bc58e64455ba9d1b72321d48aef8350832e97db2401d93853bbf8d0c75bb277a4a
|
data/lib/gamefic/ansi.rb
CHANGED
data/lib/gamefic/character.rb
CHANGED
|
@@ -74,11 +74,11 @@ module Gamefic
|
|
|
74
74
|
if @buffer_stack > 0
|
|
75
75
|
@buffer += message
|
|
76
76
|
else
|
|
77
|
-
message = "<p>#{message}</p>"
|
|
77
|
+
message = "<p>#{message.strip}</p>"
|
|
78
78
|
# This method uses String#gsub instead of String#gsub! for
|
|
79
79
|
# compatibility with Opal.
|
|
80
|
-
message = message.gsub(
|
|
81
|
-
message = message.gsub(
|
|
80
|
+
message = message.gsub(/[ \t]*\n[ \t]*\n[ \t]*/, '</p><p>')
|
|
81
|
+
message = message.gsub(/[ \t]*\n[ \t]*/, ' ')
|
|
82
82
|
user.stream.send message
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -89,7 +89,7 @@ module Gamefic
|
|
|
89
89
|
#
|
|
90
90
|
# @param message [String]
|
|
91
91
|
def stream(message)
|
|
92
|
-
user.stream.send message if !user.nil?
|
|
92
|
+
user.stream.send message.strip if !user.nil?
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def destroy
|
data/lib/gamefic/engine/tty.rb
CHANGED
|
@@ -88,14 +88,13 @@ module Gamefic
|
|
|
88
88
|
return if data.strip == ''
|
|
89
89
|
output = ''
|
|
90
90
|
begin
|
|
91
|
-
doc = Html.parse("<body>#{data}</body>")
|
|
91
|
+
doc = Html.parse("<body>#{data.strip}</body>")
|
|
92
92
|
format_recursively doc
|
|
93
93
|
texts = REXML::XPath.match(doc, './/text()')
|
|
94
94
|
output = texts.join('').gsub(/'/, "'").gsub(/"/, '"').gsub(/</, '<').gsub(/>/, '>')
|
|
95
95
|
output += Ansi.graphics_mode(Attribute::NORMAL)
|
|
96
96
|
output = Html::decode(output)
|
|
97
97
|
rescue REXML::ParseException => e
|
|
98
|
-
puts e.inspect
|
|
99
98
|
output = Html.encode(data) + "\n\n"
|
|
100
99
|
end
|
|
101
100
|
output.gsub!(/(\n\n)+/, "\n\n")
|
|
@@ -150,8 +149,10 @@ module Gamefic
|
|
|
150
149
|
formats.push [Extra::LINE]
|
|
151
150
|
when 'img'
|
|
152
151
|
formats.push [Extra::IGNORED]
|
|
153
|
-
when 'p', 'ol', 'ul'
|
|
152
|
+
when 'body', 'p', 'ol', 'ul'
|
|
154
153
|
formats.push Extra::BLOCK
|
|
154
|
+
when 'pre'
|
|
155
|
+
formats.push [Extra::BLOCK, Extra::PRE]
|
|
155
156
|
when 'nav'
|
|
156
157
|
formats.push Extra::BLOCK
|
|
157
158
|
when 'h1', 'h2', 'h3', 'h4', 'h5'
|
|
@@ -184,6 +185,13 @@ module Gamefic
|
|
|
184
185
|
element.add_text "#{Ansi.graphics_mode(*stack)}"
|
|
185
186
|
end
|
|
186
187
|
end
|
|
188
|
+
if has_code?(stack.last, Extra::BLOCK) and !has_code?(stack.last, Extra::PRE)
|
|
189
|
+
element.texts.first.value.lstrip! unless element.texts.first.nil?
|
|
190
|
+
element.texts.last.value.rstrip! unless element.texts.last.nil?
|
|
191
|
+
element.texts.each { |t|
|
|
192
|
+
t.value = t.value.gsub(/ +/, ' ').strip
|
|
193
|
+
}
|
|
194
|
+
end
|
|
187
195
|
if has_code?(stack.last, Extra::BLOCK)
|
|
188
196
|
element.add_text("\n\n")
|
|
189
197
|
elsif has_code?(stack.last, Extra::LINE)
|
data/lib/gamefic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gamefic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fred Snyder
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-01-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|