builtinextension 0.0.2 → 0.0.3
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.
- data/VERSION +1 -1
- data/builtinextension.gemspec +1 -1
- data/lib/array_include_eql.rb +12 -12
- data/lib/array_select_indices.rb +8 -8
- data/lib/string_color.rb +21 -88
- data/lib/string_escape_zsh.rb +19 -19
- data/lib/string_mismatch.rb +18 -18
- data/lib/string_width.rb +7 -9
- data/spec/array_select_indices_spec.rb +15 -15
- data/spec/string_color_spec.rb +58 -58
- data/spec/string_escape_zsh_spec.rb +74 -74
- data/spec/string_mismatch_spec.rb +16 -16
- data/spec/string_width_spec.rb +7 -7
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/builtinextension.gemspec
CHANGED
data/lib/array_include_eql.rb
CHANGED
@@ -5,18 +5,18 @@
|
|
5
5
|
#
|
6
6
|
#
|
7
7
|
class Array
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
# Whereas normal include? uses == method,
|
9
|
+
# this method uses eql? alternatively.
|
10
|
+
def include_eql?(other)
|
11
|
+
result = false
|
12
|
+
each do |i|
|
13
|
+
if i.eql?(other)
|
14
|
+
result ||= true
|
15
|
+
break
|
16
|
+
end
|
17
|
+
end
|
18
|
+
return result
|
19
|
+
end
|
20
20
|
|
21
21
|
end
|
22
22
|
|
data/lib/array_select_indices.rb
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
#
|
6
6
|
#
|
7
7
|
class Array
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
# Return sorted array of indices which a block returns true.
|
9
|
+
def select_indices
|
10
|
+
results = []
|
11
|
+
each_with_index { |item, index|
|
12
|
+
results << index if yield(item)
|
13
|
+
}
|
14
|
+
return results
|
15
|
+
end
|
16
16
|
|
17
17
|
end
|
18
18
|
|
data/lib/string_color.rb
CHANGED
@@ -1,96 +1,29 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
-
#文字列の前後にエスケープシーケンスを加えて表示色などを変更する。
|
5
|
-
#部分的に変更とかややこしい機能はつけず、
|
6
|
-
#単純に self 全体の色を変更する。
|
7
|
-
#
|
8
|
-
#以下はボツ案。
|
9
|
-
# 文字列に表示色情報を加えたクラスを用意すべきか。
|
10
|
-
# 表示色は出力デバイス依存なので、String クラスに直接入れるべきではないとは思う。
|
11
|
-
# また、文字の境界にエスケープシーケンスが入ることでパターンマッチに障害が生じる。
|
12
|
-
# しかし文字列に色をつけるのは殆どの場合表示直前の最終工程なので問題になることは少ないだろう。
|
13
|
-
#
|
14
|
-
# #"[31m" + i + "[39m" }
|
15
|
-
# #^[[35;46m
|
16
|
-
#
|
17
|
-
#EscCode = ""
|
18
|
-
#
|
19
4
|
class String
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# 3:黄 :yellow
|
26
|
-
# 4:青 :blue
|
27
|
-
# 5:紫 :magenta
|
28
|
-
# 6:空 :cyan
|
29
|
-
# 7:白 :white
|
30
|
-
# デフォルト :default
|
31
|
-
COLOR_CODE = {
|
32
|
-
:black => 0, :red => 1, :green => 2, :yellow => 3,
|
33
|
-
:blue => 4, :magenta => 5, :cyan => 6, :white => 7,
|
34
|
-
:default => 9,
|
35
|
-
}
|
5
|
+
COLOR_CODE = {
|
6
|
+
:black => 0, :red => 1, :green => 2, :yellow => 3,
|
7
|
+
:blue => 4, :magenta => 5, :cyan => 6, :white => 7,
|
8
|
+
:default => 9,
|
9
|
+
}
|
36
10
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
11
|
+
#Add escape characters at head and tail of self.
|
12
|
+
#Foreground and background can be indicated by argued symbols.
|
13
|
+
# 0: black
|
14
|
+
# 1: red
|
15
|
+
# 2: green
|
16
|
+
# 3: yellow
|
17
|
+
# 4: blue
|
18
|
+
# 5: magenta
|
19
|
+
# 6: cyan
|
20
|
+
# 7: white
|
21
|
+
# 9: default
|
22
|
+
# Argument bg indicates background color. If not indicated, default color.
|
23
|
+
# Argument fg indicates foreground color. This must be indicated.
|
24
|
+
def color( fg, bg = :default )
|
25
|
+
"\e[3#{COLOR_CODE[ fg ]};4#{COLOR_CODE[ bg ]}m" + self + "\e[39;49m"
|
26
|
+
end
|
45
27
|
|
46
28
|
end
|
47
29
|
|
48
|
-
#class ColoredString
|
49
|
-
# def initialize(str, fg_color = nil, bg_color = nil)
|
50
|
-
# @string = str
|
51
|
-
# @fg_color = fg_color
|
52
|
-
# @bg_color = bg_color
|
53
|
-
# end
|
54
|
-
#
|
55
|
-
# def setFgColor(color)
|
56
|
-
# @fg_color = color
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# def setBgColor(color)
|
60
|
-
# @bg_color = color
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# def getString
|
65
|
-
# if ((@fg_color != nil) && (@bg_color != nil))
|
66
|
-
# fg_colorCode = symbol2ColorCode(@fg_color)
|
67
|
-
# bg_colorCode = symbol2ColorCode(@bg_color)
|
68
|
-
# string = "[3#{fg_colorCode};4#{bg_colorCode}m" + @string + "[39;49m"
|
69
|
-
# elsif (@fg_color != nil)
|
70
|
-
# fg_colorCode = symbol2ColorCode(@fg_color)
|
71
|
-
# string = "[3#{fg_colorCode}m" + @string + "[39m"
|
72
|
-
# elsif (@bg_color != nil)
|
73
|
-
# bg_colorCode = symbol2ColorCode(@bg_color)
|
74
|
-
# string = "[4#{bg_colorCode}m" + @string + "[49m"
|
75
|
-
# else #both of them are not colored
|
76
|
-
# string = @string
|
77
|
-
# end
|
78
|
-
# string
|
79
|
-
# end
|
80
|
-
#
|
81
|
-
# private
|
82
|
-
# def symbol2ColorCode(color)
|
83
|
-
# case color
|
84
|
-
# when :black then colorCode = 0
|
85
|
-
# when :red then colorCode = 1
|
86
|
-
# when :green then colorCode = 2
|
87
|
-
# when :yellow then colorCode = 3
|
88
|
-
# when :blue then colorCode = 4
|
89
|
-
# when :magenta then colorCode = 5
|
90
|
-
# when :cyan then colorCode = 6
|
91
|
-
# when :white then colorCode = 7
|
92
|
-
# end
|
93
|
-
# colorCode
|
94
|
-
# end
|
95
|
-
#end
|
96
|
-
|
data/lib/string_escape_zsh.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
#! /usr/bin/ruby -w
|
2
2
|
|
3
3
|
class String
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
|
5
|
+
# Add backslash escape at the characters that have perticular meaning in zsh.
|
6
|
+
def escape_zsh
|
7
|
+
temp = dup
|
8
|
+
temp.gsub!('\\', '\\\\\\') # This must be at first, not to substitute other results.
|
9
|
+
#temp.gsub!('/', '/') # / is not for escape, due to directory separator.
|
10
|
+
temp.gsub!(' ', '\ ') ; temp.gsub!('!', '\!') ; temp.gsub!('"', '\"') ;
|
11
|
+
temp.gsub!('#', '\#') ; temp.gsub!('$', '\$') ; temp.gsub!('%', '\%') ;
|
12
|
+
temp.gsub!(')', '\)') ; temp.gsub!('(', '\(') ; temp.gsub!('*', '\*') ;
|
13
|
+
temp.gsub!(',', '\,') ; #temp.gsub!('-', '\-') ; #temp.gsub!('.', '\.') ;
|
14
|
+
temp.gsub!(':', '\:') ; temp.gsub!(';', '\;') ; temp.gsub!('<', '\<') ;
|
15
|
+
temp.gsub!('=', '\=') ; temp.gsub!('>', '\>') ; temp.gsub!('?', '\?') ;
|
16
|
+
temp.gsub!('@', '\@') ; temp.gsub!('[', '\[') ; temp.gsub!(']', '\]') ;
|
17
|
+
temp.gsub!('^', '\^') ; temp.gsub!('_', '\_') ; temp.gsub!('{', '\{') ;
|
18
|
+
temp.gsub!('|', '\|') ; temp.gsub!('}', '\}') ; temp.gsub!('~', '\~') ;
|
19
|
+
temp.gsub!('`', '\\\`') ; temp.gsub!('&', '\\\&') ;
|
20
|
+
temp.gsub!('+', '\\\+') ; temp.gsub!("'", "\\\\'") ;
|
21
|
+
return temp
|
22
|
+
end
|
23
23
|
|
24
24
|
end
|
data/lib/string_mismatch.rb
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
class String
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
5
|
+
|
6
|
+
# Return the first index that meet mismatch between self and other String.
|
7
|
+
# Return nil if self == other.
|
8
|
+
#
|
9
|
+
# Note that this method may return an index more than self.size.
|
10
|
+
# e.g., "abc".mismatch( "abcd" ) #=> 3
|
11
|
+
def mismatch( other )
|
12
|
+
ary1 = self.split( // )
|
13
|
+
ary2 = other.split( // )
|
14
|
+
index = nil
|
15
|
+
[ ary1.size, ary2.size ].max.times do |i|
|
16
|
+
if ( ary1[i] != ary2[i] )
|
17
|
+
index = i
|
18
|
+
break
|
19
|
+
end
|
20
|
+
end
|
21
|
+
index
|
22
|
+
end
|
23
23
|
end
|
data/lib/string_width.rb
CHANGED
@@ -2,15 +2,13 @@
|
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
class String
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
return 2 * num_wide + num_ascii
|
13
|
-
end
|
5
|
+
# Return character width in rxvt-unicode.
|
6
|
+
def width
|
7
|
+
chars = ' -~' + '’”' # width of one alphabetic char.
|
8
|
+
num_ascii = count(chars)
|
9
|
+
num_wide = size - num_ascii
|
10
|
+
return 2 * num_wide + num_ascii
|
11
|
+
end
|
14
12
|
|
15
13
|
end
|
16
14
|
|
@@ -7,21 +7,21 @@ require "array_select_indices.rb"
|
|
7
7
|
|
8
8
|
describe Array, "including items" do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
it "should do for empty array." do
|
11
|
+
[].select_indices{ false } .should == []
|
12
|
+
[].select_indices{ true } .should == []
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should do for array of String." do
|
16
|
+
%w[ a b c ].select_indices{ false } .should == []
|
17
|
+
%w[ a b c ].select_indices{ true } .should == [0,1,2]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should do for empty array of Integer." do
|
21
|
+
[0,1,2,3].select_indices{ false } .should == []
|
22
|
+
[0,1,2,3].select_indices{ true } .should == [0,1,2,3]
|
23
|
+
[0,1,2,3].select_indices{ |i| i < 2 } .should == [0,1]
|
24
|
+
end
|
25
25
|
|
26
26
|
end
|
27
27
|
|
data/spec/string_color_spec.rb
CHANGED
@@ -6,64 +6,64 @@ require 'string_color.rb'
|
|
6
6
|
|
7
7
|
|
8
8
|
describe String, "to be added color information" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
before do
|
10
|
+
@s00 = ""
|
11
|
+
@s01 = "abc"
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
14
|
+
it "should be sandwitched escape chars of color" do
|
15
|
+
@s00.color( :black ) .should == "\e[30;49m\e[39;49m"
|
16
|
+
@s00.color( :red ) .should == "\e[31;49m\e[39;49m"
|
17
|
+
@s00.color( :green ) .should == "\e[32;49m\e[39;49m"
|
18
|
+
@s00.color( :yellow ) .should == "\e[33;49m\e[39;49m"
|
19
|
+
@s00.color( :blue ) .should == "\e[34;49m\e[39;49m"
|
20
|
+
@s00.color( :magenta ) .should == "\e[35;49m\e[39;49m"
|
21
|
+
@s00.color( :cyan ) .should == "\e[36;49m\e[39;49m"
|
22
|
+
@s00.color( :white ) .should == "\e[37;49m\e[39;49m"
|
23
|
+
@s00.color( :default ) .should == "\e[39;49m\e[39;49m"
|
24
|
+
@s00.color( :default, :black ) .should == "\e[39;40m\e[39;49m"
|
25
|
+
@s00.color( :default, :red ) .should == "\e[39;41m\e[39;49m"
|
26
|
+
@s00.color( :default, :green ) .should == "\e[39;42m\e[39;49m"
|
27
|
+
@s00.color( :default, :yellow ) .should == "\e[39;43m\e[39;49m"
|
28
|
+
@s00.color( :default, :blue ) .should == "\e[39;44m\e[39;49m"
|
29
|
+
@s00.color( :default, :magenta ) .should == "\e[39;45m\e[39;49m"
|
30
|
+
@s00.color( :default, :cyan ) .should == "\e[39;46m\e[39;49m"
|
31
|
+
@s00.color( :default, :white ) .should == "\e[39;47m\e[39;49m"
|
32
|
+
@s00.color( :default, :default ) .should == "\e[39;49m\e[39;49m"
|
33
|
+
@s00.color( :white , :black ) .should == "\e[37;40m\e[39;49m"
|
34
|
+
@s00.color( :cyan , :red ) .should == "\e[36;41m\e[39;49m"
|
35
|
+
@s00.color( :magenta, :green ) .should == "\e[35;42m\e[39;49m"
|
36
|
+
@s00.color( :blue , :yellow ) .should == "\e[34;43m\e[39;49m"
|
37
|
+
@s00.color( :yellow , :blue ) .should == "\e[33;44m\e[39;49m"
|
38
|
+
@s00.color( :green , :magenta ) .should == "\e[32;45m\e[39;49m"
|
39
|
+
@s00.color( :red , :cyan ) .should == "\e[31;46m\e[39;49m"
|
40
|
+
@s00.color( :black , :white ) .should == "\e[30;47m\e[39;49m"
|
41
|
+
@s01.color( :black ) .should == "\e[30;49mabc\e[39;49m"
|
42
|
+
@s01.color( :red ) .should == "\e[31;49mabc\e[39;49m"
|
43
|
+
@s01.color( :green ) .should == "\e[32;49mabc\e[39;49m"
|
44
|
+
@s01.color( :yellow ) .should == "\e[33;49mabc\e[39;49m"
|
45
|
+
@s01.color( :blue ) .should == "\e[34;49mabc\e[39;49m"
|
46
|
+
@s01.color( :magenta ) .should == "\e[35;49mabc\e[39;49m"
|
47
|
+
@s01.color( :cyan ) .should == "\e[36;49mabc\e[39;49m"
|
48
|
+
@s01.color( :white ) .should == "\e[37;49mabc\e[39;49m"
|
49
|
+
@s01.color( :default ) .should == "\e[39;49mabc\e[39;49m"
|
50
|
+
@s01.color( :default, :black ) .should == "\e[39;40mabc\e[39;49m"
|
51
|
+
@s01.color( :default, :red ) .should == "\e[39;41mabc\e[39;49m"
|
52
|
+
@s01.color( :default, :green ) .should == "\e[39;42mabc\e[39;49m"
|
53
|
+
@s01.color( :default, :yellow ) .should == "\e[39;43mabc\e[39;49m"
|
54
|
+
@s01.color( :default, :blue ) .should == "\e[39;44mabc\e[39;49m"
|
55
|
+
@s01.color( :default, :magenta ) .should == "\e[39;45mabc\e[39;49m"
|
56
|
+
@s01.color( :default, :cyan ) .should == "\e[39;46mabc\e[39;49m"
|
57
|
+
@s01.color( :default, :white ) .should == "\e[39;47mabc\e[39;49m"
|
58
|
+
@s01.color( :default, :default ) .should == "\e[39;49mabc\e[39;49m"
|
59
|
+
@s01.color( :white , :black ) .should == "\e[37;40mabc\e[39;49m"
|
60
|
+
@s01.color( :cyan , :red ) .should == "\e[36;41mabc\e[39;49m"
|
61
|
+
@s01.color( :magenta, :green ) .should == "\e[35;42mabc\e[39;49m"
|
62
|
+
@s01.color( :blue , :yellow ) .should == "\e[34;43mabc\e[39;49m"
|
63
|
+
@s01.color( :yellow , :blue ) .should == "\e[33;44mabc\e[39;49m"
|
64
|
+
@s01.color( :green , :magenta ) .should == "\e[32;45mabc\e[39;49m"
|
65
|
+
@s01.color( :red , :cyan ) .should == "\e[31;46mabc\e[39;49m"
|
66
|
+
@s01.color( :black , :white ) .should == "\e[30;47mabc\e[39;49m"
|
67
|
+
end
|
68
68
|
|
69
69
|
end
|
@@ -6,81 +6,81 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
6
6
|
require 'string_escape_zsh.rb'
|
7
7
|
|
8
8
|
describe String, "with chars to be escaped" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
9
|
+
before do
|
10
|
+
@s00 = "0123456789abcdefghijklmnopqrstuvwxyz"
|
11
|
+
@s10 = "\\abc\\"
|
12
|
+
@s11 = '/abc/'
|
13
|
+
@s12 = ' abc '
|
14
|
+
@s13 = '!abc!'
|
15
|
+
@s14 = '"abc"'
|
16
|
+
@s15 = '#abc#'
|
17
|
+
@s16 = '$abc$'
|
18
|
+
@s17 = '%abc%'
|
19
|
+
@s18 = ')abc)'
|
20
|
+
@s19 = '(abc('
|
21
|
+
@s20 = '*abc*'
|
22
|
+
@s21 = ',abc,'
|
23
|
+
@s22 = '-abc-'
|
24
|
+
@s23 = '.abc.'
|
25
|
+
@s24 = ':abc:'
|
26
|
+
@s25 = ';abc;'
|
27
|
+
@s26 = '<abc<'
|
28
|
+
@s27 = '=abc='
|
29
|
+
@s28 = '>abc>'
|
30
|
+
@s29 = '?abc?'
|
31
|
+
@s30 = '@abc@'
|
32
|
+
@s31 = '[abc['
|
33
|
+
@s32 = ']abc]'
|
34
|
+
@s33 = '^abc^'
|
35
|
+
@s34 = '_abc_'
|
36
|
+
@s35 = '{abc{'
|
37
|
+
@s36 = '|abc|'
|
38
|
+
@s37 = '}abc}'
|
39
|
+
@s38 = '~abc~'
|
40
|
+
@s39 = '`abc`'
|
41
|
+
@s40 = '&abc&'
|
42
|
+
@s41 = '+abc+'
|
43
|
+
@s42 = "'abc'"
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
it "should not escape" do
|
47
|
+
@s00.escape_zsh.should == "0123456789abcdefghijklmnopqrstuvwxyz"
|
48
|
+
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
50
|
+
it "should escape" do
|
51
|
+
@s10.escape_zsh.should == "\\\\abc\\\\"
|
52
|
+
@s11.escape_zsh.should == "/abc/"
|
53
|
+
@s12.escape_zsh.should == "\\ abc\\ "
|
54
|
+
@s13.escape_zsh.should == "\\!abc\\!"
|
55
|
+
@s14.escape_zsh.should == '\\"abc\\"'
|
56
|
+
@s15.escape_zsh.should == "\\#abc\\#"
|
57
|
+
@s16.escape_zsh.should == "\\$abc\\$"
|
58
|
+
@s17.escape_zsh.should == "\\%abc\\%"
|
59
|
+
@s18.escape_zsh.should == "\\)abc\\)"
|
60
|
+
@s19.escape_zsh.should == "\\(abc\\("
|
61
|
+
@s20.escape_zsh.should == "\\*abc\\*"
|
62
|
+
@s21.escape_zsh.should == "\\,abc\\,"
|
63
|
+
@s22.escape_zsh.should == "-abc-"
|
64
|
+
@s23.escape_zsh.should == ".abc."
|
65
|
+
@s24.escape_zsh.should == "\\:abc\\:"
|
66
|
+
@s25.escape_zsh.should == "\\;abc\\;"
|
67
|
+
@s26.escape_zsh.should == "\\<abc\\<"
|
68
|
+
@s27.escape_zsh.should == "\\=abc\\="
|
69
|
+
@s28.escape_zsh.should == "\\>abc\\>"
|
70
|
+
@s29.escape_zsh.should == "\\?abc\\?"
|
71
|
+
@s30.escape_zsh.should == "\\@abc\\@"
|
72
|
+
@s31.escape_zsh.should == "\\[abc\\["
|
73
|
+
@s32.escape_zsh.should == "\\]abc\\]"
|
74
|
+
@s33.escape_zsh.should == "\\^abc\\^"
|
75
|
+
@s34.escape_zsh.should == "\\_abc\\_"
|
76
|
+
@s35.escape_zsh.should == "\\{abc\\{"
|
77
|
+
@s36.escape_zsh.should == "\\|abc\\|"
|
78
|
+
@s37.escape_zsh.should == "\\}abc\\}"
|
79
|
+
@s38.escape_zsh.should == "\\~abc\\~"
|
80
|
+
@s39.escape_zsh.should == "\\`abc\\`"
|
81
|
+
@s40.escape_zsh.should == "\\&abc\\&"
|
82
|
+
@s41.escape_zsh.should == "\\+abc\\+"
|
83
|
+
@s42.escape_zsh.should == "\\'abc\\'"
|
84
|
+
end
|
85
85
|
|
86
86
|
end
|
@@ -6,24 +6,24 @@ require 'string_mismatch.rb'
|
|
6
6
|
|
7
7
|
|
8
8
|
describe String, "for mismatch check" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
before do
|
10
|
+
@s00 = 'abcdefghij'
|
11
|
+
@s01 = 'あいうえお'
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
it "should be indicated first mismatch char index" do
|
15
|
+
@s00.mismatch( "abcdefghij" ) .should == nil
|
16
|
+
@s00.mismatch( "_bcdefghij" ) .should == 0
|
17
|
+
@s00.mismatch( "abcd_fghij" ) .should == 4
|
18
|
+
@s00.mismatch( "abcdefghijk" ) .should == 10
|
19
|
+
@s00.mismatch( "abc" ) .should == 3
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
@s01.mismatch( "あいうえお" ) .should == nil
|
22
|
+
@s01.mismatch( "_いうえお" ) .should == 0
|
23
|
+
@s01.mismatch( "あいうえ_" ) .should == 4
|
24
|
+
@s01.mismatch( "あいうえおか" ) .should == 5
|
25
|
+
@s01.mismatch( "あいう" ) .should == 3
|
26
|
+
end
|
27
27
|
|
28
28
|
end
|
29
29
|
|
data/spec/string_width_spec.rb
CHANGED
@@ -5,13 +5,13 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
5
5
|
require "string_width.rb"
|
6
6
|
|
7
7
|
describe String, "for width in displayed terminal" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
it do
|
9
|
+
"abc".width .should == 3
|
10
|
+
"あいう".width .should == 6
|
11
|
+
"あaいbうc".width .should == 9
|
12
|
+
"’".width .should == 1
|
13
|
+
"”".width .should == 1
|
14
|
+
end
|
15
15
|
|
16
16
|
end
|
17
17
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: builtinextension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
segments:
|
141
141
|
- 0
|
142
|
-
hash: -
|
142
|
+
hash: -802740941
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
none: false
|
145
145
|
requirements:
|