tbpgr_utils 0.0.86 → 0.0.87
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/lib/open_classes/string/spacing.rb +20 -0
- data/lib/open_classes/string.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/open_classes/string/spacing_spec.rb +63 -0
- metadata +15 -12
data/README.md
CHANGED
@@ -114,6 +114,7 @@ Or install it yourself as:
|
|
114
114
|
|[TbpgrUtils String#is_meta_variable?](#stringis_meta_variable) |is meta variable. |
|
115
115
|
|[TbpgrUtils String#justify_table](#stringjustify_table) |justify pipe format table string |
|
116
116
|
|[TbpgrUtils String#say](#stringsay) |say string |
|
117
|
+
|[TbpgrUtils String#spacing](#stringspacing) |get spacing string |
|
117
118
|
|[TbpgrUtils String#stripe](#stringstripe) |stripe string |
|
118
119
|
|[TbpgrUtils String#surround](#stringsurround) |surround string |
|
119
120
|
|[TbpgrUtils String#table_to_array](#stringtable_to_array) |convert table format string to array. |
|
@@ -2606,6 +2607,16 @@ hyphen case
|
|
2606
2607
|
|
2607
2608
|
[back to list](#list)
|
2608
2609
|
|
2610
|
+
### String#spacing
|
2611
|
+
~~~ruby
|
2612
|
+
require 'tbpgr_utils'
|
2613
|
+
hoge = 'hoge'
|
2614
|
+
hoge.spacing # => 'h o g e'
|
2615
|
+
hoge.spacing({char: '_', size: 2}) # => 'h__o__g__e'
|
2616
|
+
~~~
|
2617
|
+
|
2618
|
+
[back to list](#list)
|
2619
|
+
|
2609
2620
|
### String#stripe
|
2610
2621
|
default case
|
2611
2622
|
~~~ ruby
|
@@ -2925,6 +2936,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
2925
2936
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
2926
2937
|
|
2927
2938
|
## History
|
2939
|
+
* version 0.0.87 : add String#spacing
|
2928
2940
|
* version 0.0.86 : add Familyable
|
2929
2941
|
* version 0.0.85 : add String#table_to_array
|
2930
2942
|
* version 0.0.84 : add Fixnum to_fixnum_table
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# String
|
4
|
+
class String
|
5
|
+
# get spacing string
|
6
|
+
#
|
7
|
+
# === Example
|
8
|
+
#
|
9
|
+
# input
|
10
|
+
# hoge = 'hoge'
|
11
|
+
# hoge.spacing # => 'h o g e'
|
12
|
+
# hoge.spacing({char: '_', size: 2}) # => 'h__o__g__e'
|
13
|
+
#
|
14
|
+
def spacing(options = {char: ' ', size: 1})
|
15
|
+
options[:char] = ' ' unless options[:char]
|
16
|
+
options[:size] = 1 unless options[:size]
|
17
|
+
self.chars.to_a.join(options[:char] * options[:size])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/open_classes/string.rb
CHANGED
@@ -6,6 +6,7 @@ require 'open_classes/string/hyphen_to_a'
|
|
6
6
|
require 'open_classes/string/is_meta_variable'
|
7
7
|
require 'open_classes/string/justify_table'
|
8
8
|
require 'open_classes/string/say'
|
9
|
+
require 'open_classes/string/spacing'
|
9
10
|
require 'open_classes/string/stripe'
|
10
11
|
require 'open_classes/string/surround'
|
11
12
|
require 'open_classes/string/table_to_array'
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'open_classes/string/spacing'
|
4
|
+
|
5
|
+
describe String do
|
6
|
+
context :spacing do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'no option case',
|
11
|
+
input: 'hoge',
|
12
|
+
expected: 'h o g e',
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'with char and size options case',
|
17
|
+
input: 'hoge',
|
18
|
+
options: {
|
19
|
+
char: '_',
|
20
|
+
size: 2,
|
21
|
+
},
|
22
|
+
expected: 'h__o__g__e',
|
23
|
+
},
|
24
|
+
{
|
25
|
+
case_no: 3,
|
26
|
+
case_title: 'invalid options case',
|
27
|
+
input: 'hoge',
|
28
|
+
options: {
|
29
|
+
invalid_char: '_',
|
30
|
+
invalid_size: 2,
|
31
|
+
},
|
32
|
+
expected: 'h o g e',
|
33
|
+
},
|
34
|
+
]
|
35
|
+
|
36
|
+
cases.each do |c|
|
37
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
38
|
+
begin
|
39
|
+
case_before c
|
40
|
+
|
41
|
+
# -- given --
|
42
|
+
# nothing
|
43
|
+
|
44
|
+
# -- when --
|
45
|
+
actual = c[:options] ? c[:input].spacing(c[:options]) : c[:input].spacing
|
46
|
+
|
47
|
+
# -- then --
|
48
|
+
expect(actual).to eq(c[:expected])
|
49
|
+
ensure
|
50
|
+
case_after c
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def case_before(c)
|
55
|
+
# implement each case before
|
56
|
+
end
|
57
|
+
|
58
|
+
def case_after(c)
|
59
|
+
# implement each case after
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.87
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &27297696 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 4.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *27297696
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &27297408 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *27297408
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &27297180 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *27297180
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &27296856 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.14.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *27296856
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &27296556 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.8.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *27296556
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/open_classes/string/is_meta_variable.rb
|
176
176
|
- lib/open_classes/string/justify_table.rb
|
177
177
|
- lib/open_classes/string/say.rb
|
178
|
+
- lib/open_classes/string/spacing.rb
|
178
179
|
- lib/open_classes/string/stripe.rb
|
179
180
|
- lib/open_classes/string/surround.rb
|
180
181
|
- lib/open_classes/string/table_to_array.rb
|
@@ -272,6 +273,7 @@ files:
|
|
272
273
|
- spec/open_classes/string/is_meta_variable_spec.rb
|
273
274
|
- spec/open_classes/string/justify_table_spec.rb
|
274
275
|
- spec/open_classes/string/say_spec.rb
|
276
|
+
- spec/open_classes/string/spacing_spec.rb
|
275
277
|
- spec/open_classes/string/stripe_spec.rb
|
276
278
|
- spec/open_classes/string/surround_spec.rb
|
277
279
|
- spec/open_classes/string/table_to_array_spec.rb
|
@@ -393,6 +395,7 @@ test_files:
|
|
393
395
|
- spec/open_classes/string/is_meta_variable_spec.rb
|
394
396
|
- spec/open_classes/string/justify_table_spec.rb
|
395
397
|
- spec/open_classes/string/say_spec.rb
|
398
|
+
- spec/open_classes/string/spacing_spec.rb
|
396
399
|
- spec/open_classes/string/stripe_spec.rb
|
397
400
|
- spec/open_classes/string/surround_spec.rb
|
398
401
|
- spec/open_classes/string/table_to_array_spec.rb
|