tbpgr_utils 0.0.84 → 0.0.85
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/README.md +21 -0
- data/lib/open_classes/string/table_to_array.rb +23 -0
- data/lib/open_classes/string.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/open_classes/string/table_to_array_spec.rb +44 -0
- metadata +21 -13
data/README.md
CHANGED
@@ -115,6 +115,7 @@ Or install it yourself as:
|
|
115
115
|
|[TbpgrUtils String#say](#stringsay) |say string |
|
116
116
|
|[TbpgrUtils String#stripe](#stringstripe) |stripe string |
|
117
117
|
|[TbpgrUtils String#surround](#stringsurround) |surround string |
|
118
|
+
|[TbpgrUtils String#table_to_array](#stringtable_to_array) |convert table format string to array. |
|
118
119
|
|[TbpgrUtils String#to_hatena_heading](#stringto_hatena_heading) |create hatena-format heading string with Emmet-like grammar |
|
119
120
|
|[TbpgrUtils String#to_markdown_heading](#stringto_markdown_heading) |create markdown-format heading string with Emmet-like grammar |
|
120
121
|
|[TbpgrUtils String#to_space2_heading](#stringto_space2_heading) |create space2-format heading string with Emmet-like grammar |
|
@@ -2661,6 +2662,25 @@ result
|
|
2661
2662
|
|
2662
2663
|
[back to list](#list)
|
2663
2664
|
|
2665
|
+
### String#table_to_array
|
2666
|
+
sample case.
|
2667
|
+
|
2668
|
+
~~~ruby
|
2669
|
+
require 'tbpgr_utils'
|
2670
|
+
BEFORE =<<-EOS
|
2671
|
+
|header1|header2 |header3|
|
2672
|
+
|line1_1| line1_2|line1_3|
|
2673
|
+
EOS
|
2674
|
+
BEFORE.table_to_array
|
2675
|
+
~~~
|
2676
|
+
|
2677
|
+
result
|
2678
|
+
~~~ruby
|
2679
|
+
[["header1", "header2", "header3"], ["line1_1", "line1_2", "line1_3"]]
|
2680
|
+
~~~
|
2681
|
+
|
2682
|
+
[back to list](#list)
|
2683
|
+
|
2664
2684
|
### String#to_hatena_heading
|
2665
2685
|
> case
|
2666
2686
|
~~~ruby
|
@@ -2880,6 +2900,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
2880
2900
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
2881
2901
|
|
2882
2902
|
## History
|
2903
|
+
* version 0.0.85 : add String#table_to_array
|
2883
2904
|
* version 0.0.84 : add Fixnum to_fixnum_table
|
2884
2905
|
* version 0.0.83 : add Numeric to_digit_table
|
2885
2906
|
* version 0.0.82 : add Numeric to_oct_table
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class String
|
4
|
+
# convert table format string to array.
|
5
|
+
#
|
6
|
+
# === Example
|
7
|
+
#
|
8
|
+
# sample case.
|
9
|
+
#
|
10
|
+
# BEFORE =<<-EOS
|
11
|
+
# |header1|header2 |header3|
|
12
|
+
# |line1_1| line1_2|line1_3|
|
13
|
+
# EOS
|
14
|
+
# BEFORE.table_to_array
|
15
|
+
#
|
16
|
+
# result
|
17
|
+
#
|
18
|
+
# [["header1", "header2", "header3"], ["line1_1", "line1_2", "line1_3"]]
|
19
|
+
#
|
20
|
+
def table_to_array
|
21
|
+
split("\n").map { |v|v.split('|')[1..-1].map(&:strip) }
|
22
|
+
end
|
23
|
+
end
|
data/lib/open_classes/string.rb
CHANGED
@@ -8,6 +8,7 @@ require 'open_classes/string/justify_table'
|
|
8
8
|
require 'open_classes/string/say'
|
9
9
|
require 'open_classes/string/stripe'
|
10
10
|
require 'open_classes/string/surround'
|
11
|
+
require 'open_classes/string/table_to_array'
|
11
12
|
require 'open_classes/string/to_hatena_heading'
|
12
13
|
require 'open_classes/string/to_markdown_heading'
|
13
14
|
require 'open_classes/string/to_space2_heading'
|
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'open_classes/string/table_to_array'
|
4
|
+
require 'open_classes/array/to_table'
|
5
|
+
|
6
|
+
describe String do
|
7
|
+
context :table_to_array do
|
8
|
+
cases = [
|
9
|
+
{
|
10
|
+
case_no: 1,
|
11
|
+
case_title: '> case',
|
12
|
+
input: [['header1', 'header2 ', 'header3'], ['line1_1', 'line1_2', 'line1_3']].to_table,
|
13
|
+
expected: [['header1', 'header2', 'header3'], ['line1_1', 'line1_2', 'line1_3']]
|
14
|
+
},
|
15
|
+
]
|
16
|
+
|
17
|
+
cases.each do |c|
|
18
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
19
|
+
begin
|
20
|
+
case_before c
|
21
|
+
|
22
|
+
# -- given --
|
23
|
+
# nothing*
|
24
|
+
|
25
|
+
# -- when --
|
26
|
+
actual = c[:input].table_to_array
|
27
|
+
|
28
|
+
# -- then --
|
29
|
+
expect(actual).to eq(c[:expected])
|
30
|
+
ensure
|
31
|
+
case_after c
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def case_before(c)
|
36
|
+
# implement each case before
|
37
|
+
end
|
38
|
+
|
39
|
+
def case_after(c)
|
40
|
+
# implement each case after
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.85
|
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-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &27738144 !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: *27738144
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &27737808 !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: *27737808
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &27737508 !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: *27737508
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &27737064 !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: *27737064
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &27736560 !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: *27736560
|
69
69
|
description: Utilities
|
70
70
|
email:
|
71
71
|
- tbpgr@tbpgr.jp
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/open_classes/string/say.rb
|
174
174
|
- lib/open_classes/string/stripe.rb
|
175
175
|
- lib/open_classes/string/surround.rb
|
176
|
+
- lib/open_classes/string/table_to_array.rb
|
176
177
|
- lib/open_classes/string/to_hatena_heading.rb
|
177
178
|
- lib/open_classes/string/to_markdown_heading.rb
|
178
179
|
- lib/open_classes/string/to_space2_heading.rb
|
@@ -268,6 +269,7 @@ files:
|
|
268
269
|
- spec/open_classes/string/say_spec.rb
|
269
270
|
- spec/open_classes/string/stripe_spec.rb
|
270
271
|
- spec/open_classes/string/surround_spec.rb
|
272
|
+
- spec/open_classes/string/table_to_array_spec.rb
|
271
273
|
- spec/open_classes/string/to_hatena_heading_spec.rb
|
272
274
|
- spec/open_classes/string/to_markdown_heading_spec.rb
|
273
275
|
- spec/open_classes/string/to_space2_heading_spec.rb
|
@@ -294,12 +296,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
296
|
- - ! '>='
|
295
297
|
- !ruby/object:Gem::Version
|
296
298
|
version: '0'
|
299
|
+
segments:
|
300
|
+
- 0
|
301
|
+
hash: -333289357
|
297
302
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
303
|
none: false
|
299
304
|
requirements:
|
300
305
|
- - ! '>='
|
301
306
|
- !ruby/object:Gem::Version
|
302
307
|
version: '0'
|
308
|
+
segments:
|
309
|
+
- 0
|
310
|
+
hash: -333289357
|
303
311
|
requirements: []
|
304
312
|
rubyforge_project:
|
305
313
|
rubygems_version: 1.8.11
|
@@ -387,6 +395,7 @@ test_files:
|
|
387
395
|
- spec/open_classes/string/say_spec.rb
|
388
396
|
- spec/open_classes/string/stripe_spec.rb
|
389
397
|
- spec/open_classes/string/surround_spec.rb
|
398
|
+
- spec/open_classes/string/table_to_array_spec.rb
|
390
399
|
- spec/open_classes/string/to_hatena_heading_spec.rb
|
391
400
|
- spec/open_classes/string/to_markdown_heading_spec.rb
|
392
401
|
- spec/open_classes/string/to_space2_heading_spec.rb
|
@@ -399,4 +408,3 @@ test_files:
|
|
399
408
|
- spec/templatable_spec.rb
|
400
409
|
- spec/template_methodable_spec.rb
|
401
410
|
- spec/test_toolbox/kernel_spec.rb
|
402
|
-
has_rdoc:
|