ansi-sys 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/bin/ansi-to-html +1 -9
- data/lib/ansisys.rb +19 -1
- data/spec/hiki_spec.rb +2 -0
- data/website/index.html +1 -1
- metadata +1 -1
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
* 2007-11-18 zunda <zunda at freeshell.org>
|
2
|
+
- (0.8.2)
|
3
|
+
- spec/hiki_spec.rb: added specs for shift-JIS and EUC-JP input files
|
4
|
+
- lib/ansisys.rb: added AnsiSys::Guess.kcode(data)
|
5
|
+
- bin/ansi-to-html: modified to use KCODE guess inside the library
|
6
|
+
|
1
7
|
* 2007-11-18 zunda <zunda at freeshell.org>
|
2
8
|
- (0.8.1)
|
3
9
|
- lib/ansisys.rb: modified Characters#echo_on, Characters#each_char,
|
data/bin/ansi-to-html
CHANGED
@@ -23,15 +23,7 @@ terminal = AnsiSys::Terminal.new
|
|
23
23
|
puts "<html>\n<head>\n<style>\n#{style}</style>\n</head>\n<body>"
|
24
24
|
srcs.each do |src|
|
25
25
|
data = File.open(src){|f| f.read}
|
26
|
-
|
27
|
-
when NKF::EUC
|
28
|
-
kcode = 'e'
|
29
|
-
when NKF::SJIS
|
30
|
-
kcode = 's'
|
31
|
-
when NKF::UTF8
|
32
|
-
kcode = 'u'
|
33
|
-
end
|
34
|
-
puts terminal.echo(data).render(:html, max_col, nil, colors, nil, nil, kcode)
|
26
|
+
puts terminal.echo(data).render(:html, max_col, nil, colors)
|
35
27
|
terminal.echo("\e[2J\e[m")
|
36
28
|
end
|
37
29
|
puts "</body>\n</html>"
|
data/lib/ansisys.rb
CHANGED
@@ -12,7 +12,7 @@ module AnsiSys
|
|
12
12
|
module VERSION #:nodoc:
|
13
13
|
MAJOR = 0
|
14
14
|
MINOR = 8
|
15
|
-
TINY =
|
15
|
+
TINY = 2
|
16
16
|
|
17
17
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
18
18
|
end
|
@@ -29,6 +29,23 @@ module AnsiSys
|
|
29
29
|
module_function :hash_to_styles
|
30
30
|
end
|
31
31
|
|
32
|
+
module Guess
|
33
|
+
# returns a $KCODE string according to guessed encoding
|
34
|
+
def self.kcode(data)
|
35
|
+
case NKF.guess(data)
|
36
|
+
when NKF::EUC
|
37
|
+
kcode = 'e'
|
38
|
+
when NKF::SJIS
|
39
|
+
kcode = 's'
|
40
|
+
when NKF::UTF8
|
41
|
+
kcode = 'u'
|
42
|
+
else
|
43
|
+
kcode = 'n'
|
44
|
+
end
|
45
|
+
return kcode
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
32
49
|
class AnsiSysError < StandardError; end
|
33
50
|
|
34
51
|
class Lexer
|
@@ -597,6 +614,7 @@ module AnsiSys
|
|
597
614
|
# _colors_ can be Screen.default_css_colors(_inverted_, _bright_).
|
598
615
|
def render(format = :html, max_col = 80, max_row = nil, colors = Screen.default_css_colors, css_class = nil, css_style = nil, kcode = nil)
|
599
616
|
css_class ||= 'screen'
|
617
|
+
kcode ||= Guess.kcode(@lexer.buffer)
|
600
618
|
screens = populate(format, max_col, max_row, colors, kcode)
|
601
619
|
separator = case format
|
602
620
|
when :html
|
data/spec/hiki_spec.rb
CHANGED
@@ -45,5 +45,7 @@ describe "As a Hiki plugin" do
|
|
45
45
|
|
46
46
|
it "should convert charset to EUC-JP" do
|
47
47
|
@plugin.ansi_screen('test_utf8.txt').should include("\306\374\313\334\270\354") # `nihongo' in EUC-JP
|
48
|
+
@plugin.ansi_screen('test_sjis.txt').should include("\306\374\313\334\270\354")
|
49
|
+
@plugin.ansi_screen('test_euc.txt').should include("\306\374\313\334\270\354")
|
48
50
|
end
|
49
51
|
end
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>Ruby-ANSI.SYS</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ansi-sys"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/ansi-sys" class="numbers">0.8.
|
36
|
+
<a href="http://rubyforge.org/projects/ansi-sys" class="numbers">0.8.2</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ansi-sys
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
6
|
+
version: 0.8.2
|
7
7
|
date: 2007-11-18 00:00:00 -10:00
|
8
8
|
summary: Ruby-ANSI.SYS is a library to render texts with ANSI escape sequences.
|
9
9
|
require_paths:
|