builtinextension 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,6 +1,9 @@
1
1
  = builtinextension Changelog
2
2
 
3
- == Master (for 0.1.2)
3
+ == Master (for 0.1.3)
4
+
5
+ == Version 0.1.2 [2014-08-30] released
6
+ * Change test method from rspec to test-unit.
4
7
 
5
8
  == Version 0.1.1 [2014-08-30] released
6
9
  * Update dependency on other gems.
data/Gemfile CHANGED
@@ -6,9 +6,9 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", "~> 2.13.0"
10
- gem "rdoc", "~> 4.0.1"
11
-
9
+ #gem "rspec", "~> 3.0.0"
10
+ gem "test-unit", "~> 3.0.1"
11
+ gem "rdoc", "~> 4.1.1"
12
12
  gem "bundler", "~> 1.7.2"
13
13
  gem "jeweler", "~> 2.0.1"
14
14
  gem "simplecov", "~> 0.9.0"
data/Rakefile CHANGED
@@ -30,18 +30,26 @@ Jeweler::Tasks.new do |gem|
30
30
  end
31
31
  Jeweler::RubygemsDotOrgTasks.new
32
32
 
33
- require 'rspec/core'
34
- require 'rspec/core/rake_task'
35
- RSpec::Core::RakeTask.new(:spec) do |spec|
36
- spec.pattern = FileList['spec/**/*_spec.rb']
33
+ #require 'rspec/core'
34
+ #require 'rspec/core/rake_task'
35
+ #RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ # spec.pattern = FileList['spec/**/*_spec.rb']
37
+ #end
38
+ #
39
+ #RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ # spec.pattern = 'spec/**/*_spec.rb'
41
+ # spec.rcov = true
42
+ #end
43
+ #
44
+ #task :default => :spec
45
+ #
46
+ require 'rake/testtask'
47
+ Rake::TestTask.new(:test) do |test|
48
+ test.libs << 'lib' << 'test'
49
+ test.pattern = 'test/**/test_*.rb'
50
+ test.verbose = true
37
51
  end
38
-
39
- RSpec::Core::RakeTask.new(:rcov) do |spec|
40
- spec.pattern = 'spec/**/*_spec.rb'
41
- spec.rcov = true
42
- end
43
-
44
- task :default => :spec
52
+ task :default => :test
45
53
 
46
54
  require 'rdoc/task'
47
55
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "builtinextension"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ippei94da"]
12
- s.date = "2014-08-29"
12
+ s.date = "2014-08-30"
13
13
  s.description = "Personally frequently used methods for builtin classes,\n e.g., String, Array, etc.\n These methods are not implemented in Ruby and\n are doubted to offer to be implemented into Ruby core system.\n A main target is my personal programming.\n "
14
14
  s.email = "ippei94da@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -33,15 +33,15 @@ Gem::Specification.new do |s|
33
33
  "lib/string/mismatch.rb",
34
34
  "lib/string/splitparens.rb",
35
35
  "lib/string/width.rb",
36
- "spec/array_include_eql_spec.rb",
37
- "spec/array_select_indices_spec.rb",
38
- "spec/print_color",
39
- "spec/spec_helper.rb",
40
- "spec/string_color_spec.rb",
41
- "spec/string_escape_zsh_spec.rb",
42
- "spec/string_mismatch_spec.rb",
43
- "spec/string_split_parens_spec.rb",
44
- "spec/string_width_spec.rb"
36
+ "test/helper.rb",
37
+ "test/print_color",
38
+ "test/test_array_include_eql.rb",
39
+ "test/test_array_select_indices.rb",
40
+ "test/test_string_color.rb",
41
+ "test/test_string_escape_zsh.rb",
42
+ "test/test_string_mismatch.rb",
43
+ "test/test_string_split_parens.rb",
44
+ "test/test_string_width.rb"
45
45
  ]
46
46
  s.homepage = "http://github.com/ippei94da/builtinextension"
47
47
  s.licenses = ["MIT"]
@@ -53,21 +53,21 @@ Gem::Specification.new do |s|
53
53
  s.specification_version = 3
54
54
 
55
55
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
- s.add_development_dependency(%q<rspec>, ["~> 2.13.0"])
57
- s.add_development_dependency(%q<rdoc>, ["~> 4.0.1"])
56
+ s.add_development_dependency(%q<test-unit>, ["~> 3.0.1"])
57
+ s.add_development_dependency(%q<rdoc>, ["~> 4.1.1"])
58
58
  s.add_development_dependency(%q<bundler>, ["~> 1.7.2"])
59
59
  s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
60
60
  s.add_development_dependency(%q<simplecov>, ["~> 0.9.0"])
61
61
  else
62
- s.add_dependency(%q<rspec>, ["~> 2.13.0"])
63
- s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
62
+ s.add_dependency(%q<test-unit>, ["~> 3.0.1"])
63
+ s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
64
64
  s.add_dependency(%q<bundler>, ["~> 1.7.2"])
65
65
  s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
66
66
  s.add_dependency(%q<simplecov>, ["~> 0.9.0"])
67
67
  end
68
68
  else
69
- s.add_dependency(%q<rspec>, ["~> 2.13.0"])
70
- s.add_dependency(%q<rdoc>, ["~> 4.0.1"])
69
+ s.add_dependency(%q<test-unit>, ["~> 3.0.1"])
70
+ s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
71
71
  s.add_dependency(%q<bundler>, ["~> 1.7.2"])
72
72
  s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
73
73
  s.add_dependency(%q<simplecov>, ["~> 0.9.0"])
data/test/helper.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ #require 'builtinextension'
15
+
16
+ class Test::Unit::TestCase
17
+ end
File without changes
@@ -0,0 +1,43 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+
7
+ require "array/includeeql"
8
+
9
+ class Klass
10
+ def initialize(val)
11
+ @val = (val)
12
+ end
13
+
14
+ def eql?(other)
15
+ return @val.floor == other.floor
16
+ end
17
+ end
18
+
19
+
20
+ #describe Array, "including items with eql? method" do
21
+ #class TC_Array < Test::Unit::TestCase
22
+ class TC_Array_include_eql < Test::Unit::TestCase
23
+ def setup
24
+ @a00 = [
25
+ Klass.new(0.0),
26
+ Klass.new(1.0),
27
+ Klass.new(2.0),
28
+ ]
29
+ end
30
+
31
+ def test_include_eql?
32
+ #it "should be true" do
33
+ assert_equal(true, @a00.include_eql?( 0.1))
34
+ assert_equal(true, @a00.include_eql?( 1.1))
35
+ assert_equal(true, @a00.include_eql?( 2.1))
36
+
37
+ #it "should be false" do
38
+ assert_equal(false, @a00.include_eql?( 3.1))
39
+ assert_equal(false, @a00.include_eql?(-0.9))
40
+ end
41
+
42
+ end
43
+
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+
5
+ require 'helper'
6
+ require "test/unit"
7
+
8
+ require "array/selectindices.rb"
9
+
10
+ #describe Array, "including items" do
11
+
12
+ class TC_Array_select_indices < Test::Unit::TestCase
13
+ #it "should do for empty array." do
14
+ def test_select_indices
15
+ assert_equal([], [].select_indices{ false })
16
+ assert_equal([], [].select_indices{ true } )
17
+
18
+ #it "should do for array of String." do
19
+ assert_equal([] , %w[ a b c ].select_indices{ false } )
20
+ assert_equal([0,1,2] , %w[ a b c ].select_indices{ true } )
21
+
22
+ #it "should do for empty array of Integer." do
23
+ assert_equal([] , [0,1,2,3].select_indices{ false } )
24
+ assert_equal([0,1,2,3] , [0,1,2,3].select_indices{ true } )
25
+ assert_equal([0,1] , [0,1,2,3].select_indices{ |i| i < 2 } )
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,71 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+ require "string/color.rb"
7
+
8
+ #describe String, "to be added color information" do
9
+ class TC_String_color < Test::Unit::TestCase
10
+ def setup
11
+ @s00 = ""
12
+ @s01 = "abc"
13
+ end
14
+
15
+ #it "should be sandwitched escape chars of color" do
16
+ def test_color
17
+ assert_equal("\e[30;49m\e[39;49m" , @s00.color( :black ))
18
+ assert_equal("\e[31;49m\e[39;49m" , @s00.color( :red ))
19
+ assert_equal("\e[32;49m\e[39;49m" , @s00.color( :green ))
20
+ assert_equal("\e[33;49m\e[39;49m" , @s00.color( :yellow ))
21
+ assert_equal("\e[34;49m\e[39;49m" , @s00.color( :blue ))
22
+ assert_equal("\e[35;49m\e[39;49m" , @s00.color( :magenta ))
23
+ assert_equal("\e[36;49m\e[39;49m" , @s00.color( :cyan ))
24
+ assert_equal("\e[37;49m\e[39;49m" , @s00.color( :white ))
25
+ assert_equal("\e[39;49m\e[39;49m" , @s00.color( :default ))
26
+ assert_equal("\e[39;40m\e[39;49m" , @s00.color( :default, :black ))
27
+ assert_equal("\e[39;41m\e[39;49m" , @s00.color( :default, :red ))
28
+ assert_equal("\e[39;42m\e[39;49m" , @s00.color( :default, :green ))
29
+ assert_equal("\e[39;43m\e[39;49m" , @s00.color( :default, :yellow ))
30
+ assert_equal("\e[39;44m\e[39;49m" , @s00.color( :default, :blue ))
31
+ assert_equal("\e[39;45m\e[39;49m" , @s00.color( :default, :magenta))
32
+ assert_equal("\e[39;46m\e[39;49m" , @s00.color( :default, :cyan ))
33
+ assert_equal("\e[39;47m\e[39;49m" , @s00.color( :default, :white ))
34
+ assert_equal("\e[39;49m\e[39;49m" , @s00.color( :default, :default))
35
+ assert_equal("\e[37;40m\e[39;49m" , @s00.color( :white , :black ))
36
+ assert_equal("\e[36;41m\e[39;49m" , @s00.color( :cyan , :red ))
37
+ assert_equal("\e[35;42m\e[39;49m" , @s00.color( :magenta, :green ))
38
+ assert_equal("\e[34;43m\e[39;49m" , @s00.color( :blue , :yellow ))
39
+ assert_equal("\e[33;44m\e[39;49m" , @s00.color( :yellow , :blue ))
40
+ assert_equal("\e[32;45m\e[39;49m" , @s00.color( :green , :magenta))
41
+ assert_equal("\e[31;46m\e[39;49m" , @s00.color( :red , :cyan ))
42
+ assert_equal("\e[30;47m\e[39;49m" , @s00.color( :black , :white ))
43
+ assert_equal("\e[30;49mabc\e[39;49m", @s01.color( :black ))
44
+ assert_equal("\e[31;49mabc\e[39;49m", @s01.color( :red ))
45
+ assert_equal("\e[32;49mabc\e[39;49m", @s01.color( :green ))
46
+ assert_equal("\e[33;49mabc\e[39;49m", @s01.color( :yellow ))
47
+ assert_equal("\e[34;49mabc\e[39;49m", @s01.color( :blue ))
48
+ assert_equal("\e[35;49mabc\e[39;49m", @s01.color( :magenta ))
49
+ assert_equal("\e[36;49mabc\e[39;49m", @s01.color( :cyan ))
50
+ assert_equal("\e[37;49mabc\e[39;49m", @s01.color( :white ))
51
+ assert_equal("\e[39;49mabc\e[39;49m", @s01.color( :default ))
52
+ assert_equal("\e[39;40mabc\e[39;49m", @s01.color( :default, :black ))
53
+ assert_equal("\e[39;41mabc\e[39;49m", @s01.color( :default, :red ))
54
+ assert_equal("\e[39;42mabc\e[39;49m", @s01.color( :default, :green ))
55
+ assert_equal("\e[39;43mabc\e[39;49m", @s01.color( :default, :yellow ))
56
+ assert_equal("\e[39;44mabc\e[39;49m", @s01.color( :default, :blue ))
57
+ assert_equal("\e[39;45mabc\e[39;49m", @s01.color( :default, :magenta))
58
+ assert_equal("\e[39;46mabc\e[39;49m", @s01.color( :default, :cyan ))
59
+ assert_equal("\e[39;47mabc\e[39;49m", @s01.color( :default, :white ))
60
+ assert_equal("\e[39;49mabc\e[39;49m", @s01.color( :default, :default))
61
+ assert_equal("\e[37;40mabc\e[39;49m", @s01.color( :white , :black ))
62
+ assert_equal("\e[36;41mabc\e[39;49m", @s01.color( :cyan , :red ))
63
+ assert_equal("\e[35;42mabc\e[39;49m", @s01.color( :magenta, :green ))
64
+ assert_equal("\e[34;43mabc\e[39;49m", @s01.color( :blue , :yellow ))
65
+ assert_equal("\e[33;44mabc\e[39;49m", @s01.color( :yellow , :blue ))
66
+ assert_equal("\e[32;45mabc\e[39;49m", @s01.color( :green , :magenta))
67
+ assert_equal("\e[31;46mabc\e[39;49m", @s01.color( :red , :cyan ))
68
+ assert_equal("\e[30;47mabc\e[39;49m", @s01.color( :black , :white ))
69
+ end
70
+
71
+ end
@@ -0,0 +1,87 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+ require "string/escapezsh.rb"
7
+
8
+ #describe String, "with chars to be escaped" do
9
+ class TC_String_escapezsh < Test::Unit::TestCase
10
+ def setup
11
+ @s00 = "0123456789abcdefghijklmnopqrstuvwxyz"
12
+ @s10 = "\\abc\\"
13
+ @s11 = '/abc/'
14
+ @s12 = ' abc '
15
+ @s13 = '!abc!'
16
+ @s14 = '"abc"'
17
+ @s15 = '#abc#'
18
+ @s16 = '$abc$'
19
+ @s17 = '%abc%'
20
+ @s18 = ')abc)'
21
+ @s19 = '(abc('
22
+ @s20 = '*abc*'
23
+ @s21 = ',abc,'
24
+ @s22 = '-abc-'
25
+ @s23 = '.abc.'
26
+ @s24 = ':abc:'
27
+ @s25 = ';abc;'
28
+ @s26 = '<abc<'
29
+ @s27 = '=abc='
30
+ @s28 = '>abc>'
31
+ @s29 = '?abc?'
32
+ @s30 = '@abc@'
33
+ @s31 = '[abc['
34
+ @s32 = ']abc]'
35
+ @s33 = '^abc^'
36
+ @s34 = '_abc_'
37
+ @s35 = '{abc{'
38
+ @s36 = '|abc|'
39
+ @s37 = '}abc}'
40
+ @s38 = '~abc~'
41
+ @s39 = '`abc`'
42
+ @s40 = '&abc&'
43
+ @s41 = '+abc+'
44
+ @s42 = "'abc'"
45
+ end
46
+
47
+ def test_escape_zsh
48
+ #it "should not escape" do
49
+ assert_equal("0123456789abcdefghijklmnopqrstuvwxyz", @s00.escape_zsh)
50
+
51
+ #it "should escape" do
52
+ assert_equal("\\\\abc\\\\", @s10.escape_zsh)
53
+ assert_equal("/abc/" , @s11.escape_zsh)
54
+ assert_equal("\\ abc\\ " , @s12.escape_zsh)
55
+ assert_equal("\\!abc\\!" , @s13.escape_zsh)
56
+ assert_equal('\\"abc\\"' , @s14.escape_zsh)
57
+ assert_equal("\\#abc\\#" , @s15.escape_zsh)
58
+ assert_equal("\\$abc\\$" , @s16.escape_zsh)
59
+ assert_equal("\\%abc\\%" , @s17.escape_zsh)
60
+ assert_equal("\\)abc\\)" , @s18.escape_zsh)
61
+ assert_equal("\\(abc\\(" , @s19.escape_zsh)
62
+ assert_equal("\\*abc\\*" , @s20.escape_zsh)
63
+ assert_equal("\\,abc\\," , @s21.escape_zsh)
64
+ assert_equal("-abc-" , @s22.escape_zsh)
65
+ assert_equal(".abc." , @s23.escape_zsh)
66
+ assert_equal("\\:abc\\:" , @s24.escape_zsh)
67
+ assert_equal("\\;abc\\;" , @s25.escape_zsh)
68
+ assert_equal("\\<abc\\<" , @s26.escape_zsh)
69
+ assert_equal("\\=abc\\=" , @s27.escape_zsh)
70
+ assert_equal("\\>abc\\>" , @s28.escape_zsh)
71
+ assert_equal("\\?abc\\?" , @s29.escape_zsh)
72
+ assert_equal("\\@abc\\@" , @s30.escape_zsh)
73
+ assert_equal("\\[abc\\[" , @s31.escape_zsh)
74
+ assert_equal("\\]abc\\]" , @s32.escape_zsh)
75
+ assert_equal("\\^abc\\^" , @s33.escape_zsh)
76
+ assert_equal("\\_abc\\_" , @s34.escape_zsh)
77
+ assert_equal("\\{abc\\{" , @s35.escape_zsh)
78
+ assert_equal("\\|abc\\|" , @s36.escape_zsh)
79
+ assert_equal("\\}abc\\}" , @s37.escape_zsh)
80
+ assert_equal("\\~abc\\~" , @s38.escape_zsh)
81
+ assert_equal("\\`abc\\`" , @s39.escape_zsh)
82
+ assert_equal("\\&abc\\&" , @s40.escape_zsh)
83
+ assert_equal("\\+abc\\+" , @s41.escape_zsh)
84
+ assert_equal("\\'abc\\'" , @s42.escape_zsh)
85
+ end
86
+
87
+ end
@@ -0,0 +1,31 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+ require "string/mismatch.rb"
7
+
8
+ #describe String, "for mismatch check" do
9
+ class TC_String_mismatch < Test::Unit::TestCase
10
+ def setup
11
+ @s00 = 'abcdefghij'
12
+ @s01 = 'あいうえお'
13
+ end
14
+
15
+ #it "should be indicated first mismatch char index" do
16
+ def test_mismatch
17
+ assert_equal(nil, @s00.mismatch( "abcdefghij" ) )
18
+ assert_equal( 0 , @s00.mismatch( "_bcdefghij" ) )
19
+ assert_equal( 4 , @s00.mismatch( "abcd_fghij" ) )
20
+ assert_equal(10 , @s00.mismatch( "abcdefghijk" ) )
21
+ assert_equal( 3 , @s00.mismatch( "abc" ) )
22
+
23
+ assert_equal(nil, @s01.mismatch( "あいうえお" ) )
24
+ assert_equal( 0 , @s01.mismatch( "_いうえお" ) )
25
+ assert_equal( 4 , @s01.mismatch( "あいうえ_" ) )
26
+ assert_equal( 5 , @s01.mismatch( "あいうえおか" ) )
27
+ assert_equal( 3 , @s01.mismatch( "あいう" ) )
28
+ end
29
+
30
+ end
31
+
@@ -0,0 +1,90 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+ require "string/splitparens.rb"
7
+
8
+ #describe String, "" do
9
+ class TC_String_splitparens < Test::Unit::TestCase
10
+
11
+ def setup
12
+ @s00 = "(ab)(cd(ef))gh(ij)kl(mn)"
13
+ @s01 = "((ab)(cd(ef))gh(ij)kl(mn)" # open paren excess.
14
+ @s02 = "(ab)(cd(ef)))gh(ij)kl(mn)" # close paren excess.
15
+ end
16
+
17
+ def test_split_parens
18
+ #describe "many parens" do
19
+ assert_equal(["(ab)", "(cd(ef))", "gh", "(ij)", "kl", "(mn)"],
20
+ @s00.split_parens)
21
+ assert_equal(["((ab)(cd(ef))gh(ij)kl(mn)"] ,
22
+ @s01.split_parens)
23
+ assert_equal(["(ab)", "(cd(ef))", ")gh(ij)kl(mn)"] ,
24
+ @s02.split_parens)
25
+ end
26
+
27
+ def test_open_close
28
+ #describe "single char" do
29
+ assert_equal( false, '(' .close_paren?)
30
+ assert_equal( true , '(' .open_paren? )
31
+ assert_equal( true , ')' .close_paren?)
32
+ assert_equal( false, ')' .open_paren? )
33
+ assert_equal( false, '<' .close_paren?)
34
+ assert_equal( true , '<' .open_paren? )
35
+ assert_equal( true , '>' .close_paren?)
36
+ assert_equal( false, '>' .open_paren? )
37
+ assert_equal( false, '[' .close_paren?)
38
+ assert_equal( true , '[' .open_paren? )
39
+ assert_equal( true , ']' .close_paren?)
40
+ assert_equal( false, ']' .open_paren? )
41
+ assert_equal( false, '{' .close_paren?)
42
+ assert_equal( true , '{' .open_paren? )
43
+ assert_equal( true , '}' .close_paren?)
44
+ assert_equal( false, '}' .open_paren? )
45
+ assert_equal( false, '('.close_paren?)
46
+ assert_equal( true , '('.open_paren? )
47
+ assert_equal( true , ')'.close_paren?)
48
+ assert_equal( false, ')'.open_paren? )
49
+ assert_equal( false, '〔'.close_paren?)
50
+ assert_equal( true , '〔'.open_paren? )
51
+ assert_equal( true , '〕'.close_paren?)
52
+ assert_equal( false, '〕'.open_paren? )
53
+ assert_equal( false, '['.close_paren?)
54
+ assert_equal( true , '['.open_paren? )
55
+ assert_equal( true , ']'.close_paren?)
56
+ assert_equal( false, ']'.open_paren? )
57
+ assert_equal( false, '{'.close_paren?)
58
+ assert_equal( true , '{'.open_paren? )
59
+ assert_equal( true , '}'.close_paren?)
60
+ assert_equal( false, '}'.open_paren? )
61
+ assert_equal( false, '〈'.close_paren?)
62
+ assert_equal( true , '〈'.open_paren? )
63
+ assert_equal( true , '〉'.close_paren?)
64
+ assert_equal( false, '〉'.open_paren? )
65
+ assert_equal( false, '《'.close_paren?)
66
+ assert_equal( true , '《'.open_paren? )
67
+ assert_equal( true , '》'.close_paren?)
68
+ assert_equal( false, '》'.open_paren? )
69
+ assert_equal( false, '「'.close_paren?)
70
+ assert_equal( true , '「'.open_paren? )
71
+ assert_equal( true , '」'.close_paren?)
72
+ assert_equal( false, '」'.open_paren? )
73
+ assert_equal( false, '『'.close_paren?)
74
+ assert_equal( true , '『'.open_paren? )
75
+ assert_equal( true , '』'.close_paren?)
76
+ assert_equal( false, '』'.open_paren? )
77
+ assert_equal( false, '【'.close_paren?)
78
+ assert_equal( true , '【'.open_paren? )
79
+ assert_equal( true , '】'.close_paren?)
80
+ assert_equal( false, '】'.open_paren? )
81
+ assert_equal( false, '<'.close_paren?)
82
+ assert_equal( true , '<'.open_paren? )
83
+ assert_equal( true , '>'.close_paren?)
84
+ assert_equal( false, '>'.open_paren? )
85
+ assert_equal( false, '(('.open_paren? )
86
+ assert_equal( false, '))'.open_paren? )
87
+ assert_equal( false, '({'.open_paren? )
88
+ assert_equal( false, ')}'.open_paren? )
89
+ end
90
+ end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'helper'
5
+ require "test/unit"
6
+ require "string/width.rb"
7
+
8
+ class TC_String_width < Test::Unit::TestCase
9
+ #describe String, "for width in displayed terminal" do
10
+ def test_width
11
+ assert_equal( 3, "abc".width )
12
+ assert_equal( 6, "あいう".width )
13
+ assert_equal( 9, "あaいbうc".width )
14
+ assert_equal( 1, "’".width )
15
+ assert_equal( 1, "”".width )
16
+ end
17
+
18
+ end
19
+
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.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-29 00:00:00.000000000 Z
12
+ date: 2014-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: test-unit
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.13.0
21
+ version: 3.0.1
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.13.0
29
+ version: 3.0.1
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rdoc
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 4.0.1
37
+ version: 4.1.1
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 4.0.1
45
+ version: 4.1.1
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bundler
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -118,15 +118,15 @@ files:
118
118
  - lib/string/mismatch.rb
119
119
  - lib/string/splitparens.rb
120
120
  - lib/string/width.rb
121
- - spec/array_include_eql_spec.rb
122
- - spec/array_select_indices_spec.rb
123
- - spec/print_color
124
- - spec/spec_helper.rb
125
- - spec/string_color_spec.rb
126
- - spec/string_escape_zsh_spec.rb
127
- - spec/string_mismatch_spec.rb
128
- - spec/string_split_parens_spec.rb
129
- - spec/string_width_spec.rb
121
+ - test/helper.rb
122
+ - test/print_color
123
+ - test/test_array_include_eql.rb
124
+ - test/test_array_select_indices.rb
125
+ - test/test_string_color.rb
126
+ - test/test_string_escape_zsh.rb
127
+ - test/test_string_mismatch.rb
128
+ - test/test_string_split_parens.rb
129
+ - test/test_string_width.rb
130
130
  homepage: http://github.com/ippei94da/builtinextension
131
131
  licenses:
132
132
  - MIT
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -3688864369875448176
145
+ hash: 4197041403979202951
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  none: false
148
148
  requirements:
@@ -1,40 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
- require "array/includeeql.rb"
6
-
7
- class Klass
8
- def initialize(val)
9
- @val = (val)
10
- end
11
-
12
- def eql?(other)
13
- return @val.floor == other.floor
14
- end
15
- end
16
-
17
-
18
- describe Array, "including items with eql? method" do
19
- #class TC_Array < Test::Unit::TestCase
20
- before do
21
- @a00 = [
22
- Klass.new(0.0),
23
- Klass.new(1.0),
24
- Klass.new(2.0),
25
- ]
26
- end
27
-
28
- it "should be true" do
29
- @a00.include_eql?( 0.1).should be_true
30
- @a00.include_eql?( 1.1).should be_true
31
- @a00.include_eql?( 2.1).should be_true
32
- end
33
-
34
- it "should be false" do
35
- @a00.include_eql?( 3.1).should be_false
36
- @a00.include_eql?(-0.9).should be_false
37
- end
38
-
39
- end
40
-
@@ -1,27 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
- require "array/selectindices.rb"
6
-
7
-
8
- describe Array, "including items" do
9
-
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
-
26
- end
27
-
data/spec/spec_helper.rb DELETED
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
-
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
@@ -1,69 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
- require "string/color.rb"
6
-
7
-
8
- describe String, "to be added color information" do
9
- before do
10
- @s00 = ""
11
- @s01 = "abc"
12
- end
13
-
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
-
69
- end
@@ -1,86 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
-
6
- require "string/escapezsh.rb"
7
-
8
- describe String, "with chars to be escaped" do
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
-
46
- it "should not escape" do
47
- @s00.escape_zsh.should == "0123456789abcdefghijklmnopqrstuvwxyz"
48
- end
49
-
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
-
86
- end
@@ -1,29 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
- require "string/mismatch.rb"
6
-
7
-
8
- describe String, "for mismatch check" do
9
- before do
10
- @s00 = 'abcdefghij'
11
- @s01 = 'あいうえお'
12
- end
13
-
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
-
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
-
28
- end
29
-
@@ -1,124 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
-
6
- require "string/splitparens.rb"
7
-
8
- #class String
9
- # public :open_paren?, :close_paren?
10
- #end
11
-
12
- describe String, "" do
13
- describe "many parens" do
14
- before do
15
- @s00 = "(ab)(cd(ef))gh(ij)kl(mn)"
16
- @s01 = "((ab)(cd(ef))gh(ij)kl(mn)" # open paren excess.
17
- @s02 = "(ab)(cd(ef)))gh(ij)kl(mn)" # close paren excess.
18
- end
19
-
20
- it "" do
21
- @s00.split_parens.should == ["(ab)", "(cd(ef))", "gh", "(ij)", "kl", "(mn)"]
22
- @s01.split_parens.should == ["((ab)(cd(ef))gh(ij)kl(mn)"]
23
- @s02.split_parens.should == ["(ab)", "(cd(ef))", ")gh(ij)kl(mn)"]
24
- end
25
- end
26
-
27
- describe "single char" do
28
- it do
29
- '(' .close_paren?.should == false
30
- '(' .open_paren?.should == true
31
-
32
- ')' .close_paren?.should == true
33
- ')' .open_paren?.should == false
34
-
35
- '<' .close_paren?.should == false
36
- '<' .open_paren?.should == true
37
-
38
- '>' .close_paren?.should == true
39
- '>' .open_paren?.should == false
40
-
41
- '[' .close_paren?.should == false
42
- '[' .open_paren?.should == true
43
-
44
- ']' .close_paren?.should == true
45
- ']' .open_paren?.should == false
46
-
47
- '{' .close_paren?.should == false
48
- '{' .open_paren?.should == true
49
-
50
- '}' .close_paren?.should == true
51
- '}' .open_paren?.should == false
52
-
53
- '('.close_paren?.should == false
54
- '('.open_paren?.should == true
55
-
56
- ')'.close_paren?.should == true
57
- ')'.open_paren?.should == false
58
-
59
- '〔'.close_paren?.should == false
60
- '〔'.open_paren?.should == true
61
-
62
- '〕'.close_paren?.should == true
63
- '〕'.open_paren?.should == false
64
-
65
- '['.close_paren?.should == false
66
- '['.open_paren?.should == true
67
-
68
- ']'.close_paren?.should == true
69
- ']'.open_paren?.should == false
70
-
71
- '{'.close_paren?.should == false
72
- '{'.open_paren?.should == true
73
-
74
- '}'.close_paren?.should == true
75
- '}'.open_paren?.should == false
76
-
77
- '〈'.close_paren?.should == false
78
- '〈'.open_paren?.should == true
79
-
80
- '〉'.close_paren?.should == true
81
- '〉'.open_paren?.should == false
82
-
83
- '《'.close_paren?.should == false
84
- '《'.open_paren?.should == true
85
-
86
- '》'.close_paren?.should == true
87
- '》'.open_paren?.should == false
88
-
89
- '「'.close_paren?.should == false
90
- '「'.open_paren?.should == true
91
-
92
- '」'.close_paren?.should == true
93
- '」'.open_paren?.should == false
94
-
95
- '『'.close_paren?.should == false
96
- '『'.open_paren?.should == true
97
-
98
- '』'.close_paren?.should == true
99
- '』'.open_paren?.should == false
100
-
101
- '【'.close_paren?.should == false
102
- '【'.open_paren?.should == true
103
-
104
- '】'.close_paren?.should == true
105
- '】'.open_paren?.should == false
106
-
107
- '<'.close_paren?.should == false
108
- '<'.open_paren?.should == true
109
-
110
- '>'.close_paren?.should == true
111
- '>'.open_paren?.should == false
112
-
113
- '(('.open_paren?.should == false
114
- '))'.open_paren?.should == false
115
-
116
- '({'.open_paren?.should == false
117
- ')}'.open_paren?.should == false
118
-
119
- end
120
- end
121
-
122
-
123
-
124
- end
@@ -1,17 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
5
- require "string/width.rb"
6
-
7
- describe String, "for width in displayed terminal" do
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
-
16
- end
17
-