tbpgr_utils 0.0.122 → 0.0.123
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/open_classes/string/gte_gte.rb +21 -0
- data/lib/open_classes/string.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/open_classes/string/gte_gte_spec.rb +57 -0
- data/spec/open_classes/string/justify_char_spec.rb +32 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67f2d5979271ec5df878cc2957ef7eea5673f694
|
4
|
+
data.tar.gz: 15b4aeee1a79eaca06678f7734db27ff42a0620d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff017cd57605cecd33155bf5674338ce7dd9d38c28589d1fae899980b91cbf357ce8a52e066bba13d8da8c49464ba00926a2d6f5ce84169c9cb4ad3e03d4d80
|
7
|
+
data.tar.gz: 7b7b8d716d9d70576b486eca511c53db833e04b470d2d40d55fdf6b8dbe3171b3571dded28b25391d738da87c32d047a68a4de06d7621ee927c966e36f5df07b
|
data/README.md
CHANGED
@@ -135,6 +135,7 @@ Or install it yourself as:
|
|
135
135
|
|[TbpgrUtils Object#to_bool](#objectto_bool) |syntax sugar of !!. convert [false, nil] => fasel, other => true. |
|
136
136
|
|[TbpgrUtils Object#unless_guard](#objectunless_guard) |data type check for unless_guard |
|
137
137
|
|[SimpleTournament](#simpletournament) |simple tournament |
|
138
|
+
|[TbpgrUtils String.>>](#string) |self converto to Array. and execute method |
|
138
139
|
|[TbpgrUtils String#ascii1_other2_size](#stringascii1_other2_size) |count string size. ascii => count1, not ascii => count2 |
|
139
140
|
|[TbpgrUtils String#ascii_unicode_html_table](#stringascii_unicode_html_table) |get ascii_unicode_html_table |
|
140
141
|
|[TbpgrUtils String#ascii_unicode_table](#stringascii_unicode_table) |get ascii_unicode_table |
|
@@ -3022,6 +3023,17 @@ print st.tournament # => [[3], [1, 3], [3, 2]]
|
|
3022
3023
|
|
3023
3024
|
[back to list](#list)
|
3024
3025
|
|
3026
|
+
### String#>>
|
3027
|
+
~~~ruby
|
3028
|
+
require 'tbpgr_utils'
|
3029
|
+
|
3030
|
+
"abc">>:ord # => [97, 98, 99]
|
3031
|
+
"abc">>'ord' # => [97, 98, 99]
|
3032
|
+
"abc">>-> (x) { (x.ord + 1).chr } # => ["c", "d", "e"]
|
3033
|
+
~~~
|
3034
|
+
|
3035
|
+
[back to list](#list)
|
3036
|
+
|
3025
3037
|
### String#ascii1_other2_size
|
3026
3038
|
~~~ruby
|
3027
3039
|
require 'tbpgr_utils'
|
@@ -3592,6 +3604,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3592
3604
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3593
3605
|
|
3594
3606
|
## History
|
3607
|
+
* version 0.0.123 : add String#>>
|
3595
3608
|
* version 0.0.122 : add String#justify_char
|
3596
3609
|
* version 0.0.121 : add Array#average
|
3597
3610
|
* version 0.0.120 : add Array#sum
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# String
|
4
|
+
class String
|
5
|
+
# self converto to Array. and applya operator to execute elements
|
6
|
+
#
|
7
|
+
# === Example
|
8
|
+
#
|
9
|
+
# "abc">>:ord # => [97, 98, 99]
|
10
|
+
# "abc">>'ord' # => [97, 98, 99]
|
11
|
+
# "abc">>-> (x) { (x.ord + 1).chr } # => ["c", "d", "e"]
|
12
|
+
#
|
13
|
+
def >>(method_name)
|
14
|
+
return self unless [Symbol, String, Proc].include? method_name.class
|
15
|
+
if method_name.is_a? Proc
|
16
|
+
split('').map { |v|method_name[v] }
|
17
|
+
else
|
18
|
+
split('').map(&method_name.to_sym)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/open_classes/string.rb
CHANGED
@@ -6,6 +6,7 @@ require 'open_classes/string/comma_to_a'
|
|
6
6
|
require 'open_classes/string/cygwinpath_to_winpath'
|
7
7
|
require 'open_classes/string/escape_double_quote'
|
8
8
|
require 'open_classes/string/escape_quote'
|
9
|
+
require 'open_classes/string/gte_gte'
|
9
10
|
require 'open_classes/string/hyphen_to_a'
|
10
11
|
require 'open_classes/string/is_meta_variable'
|
11
12
|
require 'open_classes/string/justify_char'
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
context :>> do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'string method case',
|
11
|
+
input: 'abc',
|
12
|
+
method_name: 'ord',
|
13
|
+
expected: [97, 98, 99],
|
14
|
+
},
|
15
|
+
{
|
16
|
+
case_no: 2,
|
17
|
+
case_title: 'symbol case',
|
18
|
+
input: 'abc',
|
19
|
+
method_name: :ord,
|
20
|
+
expected: [97, 98, 99],
|
21
|
+
},
|
22
|
+
{
|
23
|
+
case_no: 3,
|
24
|
+
case_title: 'proc case',
|
25
|
+
input: 'abc',
|
26
|
+
method_name: -> (x) { (x.ord + 2).chr },
|
27
|
+
expected: ['c', 'd', 'e'],
|
28
|
+
},
|
29
|
+
]
|
30
|
+
|
31
|
+
cases.each do |c|
|
32
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
33
|
+
begin
|
34
|
+
case_before c
|
35
|
+
|
36
|
+
# -- given --
|
37
|
+
# nothing
|
38
|
+
|
39
|
+
# -- when/then --
|
40
|
+
actual = c[:input] >> c[:method_name]
|
41
|
+
|
42
|
+
expect(actual).to eq(c[:expected])
|
43
|
+
ensure
|
44
|
+
case_after c
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def case_before(c)
|
49
|
+
# implement each case before
|
50
|
+
end
|
51
|
+
|
52
|
+
def case_after(c)
|
53
|
+
# implement each case after
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -41,12 +41,25 @@ print 'hoge' * 2 // => 'hogehoge'
|
|
41
41
|
print 'hoge' + 'hige' // => 'hogehige'
|
42
42
|
EOS
|
43
43
|
|
44
|
+
SAMPLE_JUSTIFIED_STRING4 = <<-EOS
|
45
|
+
print 'hoge' # => 'hoge'
|
46
|
+
print 'hoge' * 2 # => 'hogehoge'
|
47
|
+
print 'hoge' + 'hige' # => 'hogehige'
|
48
|
+
EOS
|
49
|
+
|
50
|
+
SAMPLE_JUSTIFIED_STRING5 = <<-EOS
|
51
|
+
print 'hoge' # => 'hoge'
|
52
|
+
print 'hoge' * 2 # => 'hogehoge'
|
53
|
+
print 'hoge' + 'hige' # => 'hogehige'
|
54
|
+
EOS
|
55
|
+
|
44
56
|
cases = [
|
45
57
|
{
|
46
58
|
case_no: 1,
|
47
59
|
case_title: 'sharp justify case',
|
48
60
|
input: SAMPLE_STRING1,
|
49
61
|
separator: '#',
|
62
|
+
position: :left,
|
50
63
|
expected: SAMPLE_JUSTIFIED_STRING1,
|
51
64
|
},
|
52
65
|
{
|
@@ -57,11 +70,28 @@ print 'hoge' + 'hige' // => 'hogehige'
|
|
57
70
|
},
|
58
71
|
{
|
59
72
|
case_no: 3,
|
60
|
-
case_title: 'double
|
73
|
+
case_title: 'double slash justify case',
|
61
74
|
input: SAMPLE_STRING3,
|
62
75
|
separator: '//',
|
76
|
+
position: :left,
|
63
77
|
expected: SAMPLE_JUSTIFIED_STRING3,
|
64
78
|
},
|
79
|
+
{
|
80
|
+
case_no: 4,
|
81
|
+
case_title: 'sharp right justify case',
|
82
|
+
input: SAMPLE_STRING1,
|
83
|
+
separator: '#',
|
84
|
+
position: :right,
|
85
|
+
expected: SAMPLE_JUSTIFIED_STRING4,
|
86
|
+
},
|
87
|
+
{
|
88
|
+
case_no: 5,
|
89
|
+
case_title: 'sharp center justify case',
|
90
|
+
input: SAMPLE_STRING1,
|
91
|
+
separator: '#',
|
92
|
+
position: :center,
|
93
|
+
expected: SAMPLE_JUSTIFIED_STRING5,
|
94
|
+
},
|
65
95
|
]
|
66
96
|
|
67
97
|
cases.each do |c|
|
@@ -74,7 +104,7 @@ print 'hoge' + 'hige' // => 'hogehige'
|
|
74
104
|
|
75
105
|
# -- when --
|
76
106
|
if (c[:separator])
|
77
|
-
actual = c[:input].justify_char c[:separator]
|
107
|
+
actual = c[:input].justify_char c[:separator], c[:position]
|
78
108
|
else
|
79
109
|
actual = c[:input].justify_char
|
80
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbpgr_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.123
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/open_classes/string/cygwinpath_to_winpath.rb
|
214
214
|
- lib/open_classes/string/escape_double_quote.rb
|
215
215
|
- lib/open_classes/string/escape_quote.rb
|
216
|
+
- lib/open_classes/string/gte_gte.rb
|
216
217
|
- lib/open_classes/string/heading_helper.rb
|
217
218
|
- lib/open_classes/string/hyphen_to_a.rb
|
218
219
|
- lib/open_classes/string/is_meta_variable.rb
|
@@ -344,6 +345,7 @@ files:
|
|
344
345
|
- spec/open_classes/string/cygwinpath_to_winpath_spec.rb
|
345
346
|
- spec/open_classes/string/escape_double_quote_spec.rb
|
346
347
|
- spec/open_classes/string/escape_quote_spec.rb
|
348
|
+
- spec/open_classes/string/gte_gte_spec.rb
|
347
349
|
- spec/open_classes/string/hyphen_to_a_spec.rb
|
348
350
|
- spec/open_classes/string/is_meta_variable_spec.rb
|
349
351
|
- spec/open_classes/string/justify_char_spec.rb
|
@@ -497,6 +499,7 @@ test_files:
|
|
497
499
|
- spec/open_classes/string/cygwinpath_to_winpath_spec.rb
|
498
500
|
- spec/open_classes/string/escape_double_quote_spec.rb
|
499
501
|
- spec/open_classes/string/escape_quote_spec.rb
|
502
|
+
- spec/open_classes/string/gte_gte_spec.rb
|
500
503
|
- spec/open_classes/string/hyphen_to_a_spec.rb
|
501
504
|
- spec/open_classes/string/is_meta_variable_spec.rb
|
502
505
|
- spec/open_classes/string/justify_char_spec.rb
|