tbpgr_utils 0.0.116 → 0.0.117

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +51 -0
  3. data/README.md +13 -1
  4. data/Rakefile +8 -8
  5. data/lib/attributes_initializable.rb +3 -3
  6. data/lib/eval_helper/attr_init_class_code.rb +1 -1
  7. data/lib/eval_helper/times_code.rb +2 -2
  8. data/lib/markdown/heading.rb +32 -32
  9. data/lib/open_classes/array/kernel_send.rb +15 -0
  10. data/lib/open_classes/array/to_table.rb +1 -1
  11. data/lib/open_classes/array.rb +1 -0
  12. data/lib/open_classes/kernel/aa_ancestors.rb +16 -16
  13. data/lib/open_classes/kernel/p_evals.rb +42 -42
  14. data/lib/open_classes/string/heading_helper.rb +1 -1
  15. data/lib/open_classes/string/stripe.rb +1 -1
  16. data/lib/open_classes/string/to_hatena_heading.rb +35 -35
  17. data/lib/open_classes/string/to_markdown_heading.rb +37 -37
  18. data/lib/open_classes/string/to_space2_heading.rb +35 -35
  19. data/lib/open_classes/string/to_space4_heading.rb +35 -35
  20. data/lib/open_classes/string/to_tab_heading.rb +35 -35
  21. data/lib/simple_tournament.rb +57 -57
  22. data/lib/tbpgr_utils/version.rb +1 -1
  23. data/rubocop-todo.yml +33 -33
  24. data/spec/markdown/heading_spec.rb +4 -4
  25. data/spec/markdown/ol_spec.rb +1 -1
  26. data/spec/markdown/ul_spec.rb +1 -1
  27. data/spec/open_classes/array/kernel_send_spec.rb +43 -0
  28. data/spec/open_classes/array/together_at_spec.rb +61 -61
  29. data/spec/open_classes/array/together_clear_spec.rb +51 -51
  30. data/spec/open_classes/array/together_concat_spec.rb +53 -53
  31. data/spec/open_classes/array/together_delete_at_spec.rb +78 -78
  32. data/spec/open_classes/array/together_delete_if_spec.rb +61 -61
  33. data/spec/open_classes/array/together_delete_spec.rb +80 -80
  34. data/spec/open_classes/array/together_fill_spec.rb +79 -79
  35. data/spec/open_classes/array/together_map_spec.rb +171 -171
  36. data/spec/open_classes/array/together_spec.rb +51 -51
  37. data/spec/open_classes/array/together_with_index_spec.rb +51 -51
  38. data/spec/open_classes/object/any_of_spec.rb +72 -72
  39. data/spec/set_variables_code_spec.rb +2 -1
  40. data/tbpgr_utils.gemspec +27 -27
  41. metadata +41 -26
@@ -1,79 +1,79 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_fill do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'not use block case',
11
- inputs: [[*1..5], [*6..10]],
12
- fill_value: 99,
13
- method_name: :together_fill,
14
- expected: [[99, 99, 99, 99, 99], [99, 99, 99, 99, 99]],
15
- has_block: false,
16
- },
17
- {
18
- case_no: 2,
19
- case_title: 'use block, no args case',
20
- inputs: [[*1..5], [*6..10]],
21
- fill_value: nil,
22
- method_name: :together_fill,
23
- expected: [[2, 3, 4, 5, 6], [2, 3, 4, 5, 6]],
24
- block_logic: '(i + 1) + 1',
25
- has_block: true,
26
- },
27
- {
28
- case_no: 3,
29
- case_title: 'use block, has args case',
30
- inputs: [[*1..5], [*6..10]],
31
- fill_value: 2,
32
- method_name: :together_fill,
33
- expected: [[1, 2, 4, 5, 6], [6, 7, 4, 5, 6]],
34
- block_logic: '(i + 1) + 1',
35
- has_block: true,
36
- },
37
- {
38
- case_no: 4,
39
- case_title: 'not use block case(alias tfill)',
40
- inputs: [[*1..5], [*6..10]],
41
- fill_value: 99,
42
- method_name: :tfill,
43
- expected: [[99, 99, 99, 99, 99], [99, 99, 99, 99, 99]],
44
- has_block: false,
45
- },
46
- ]
47
-
48
- cases.each do |c|
49
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
50
- begin
51
- case_before c
52
-
53
- # -- given --
54
- # nothing
55
-
56
- # -- when --
57
- if c[:has_block]
58
- actual = c[:inputs].send c[:method_name], c[:fill_value] {|i|eval c[:block_logic], binding }
59
- else
60
- actual = c[:inputs].send c[:method_name], c[:fill_value]
61
- end
62
-
63
- # -- then --
64
- expect(actual).to eq(c[:expected])
65
- ensure
66
- case_after c
67
- end
68
- end
69
-
70
- def case_before(c)
71
- # implement each case before
72
- end
73
-
74
- def case_after(c)
75
- # implement each case after
76
- end
77
- end
78
- end
79
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_fill do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'not use block case',
11
+ inputs: [[*1..5], [*6..10]],
12
+ fill_value: 99,
13
+ method_name: :together_fill,
14
+ expected: [[99, 99, 99, 99, 99], [99, 99, 99, 99, 99]],
15
+ has_block: false,
16
+ },
17
+ {
18
+ case_no: 2,
19
+ case_title: 'use block, no args case',
20
+ inputs: [[*1..5], [*6..10]],
21
+ fill_value: nil,
22
+ method_name: :together_fill,
23
+ expected: [[2, 3, 4, 5, 6], [2, 3, 4, 5, 6]],
24
+ block_logic: '(i + 1) + 1',
25
+ has_block: true,
26
+ },
27
+ {
28
+ case_no: 3,
29
+ case_title: 'use block, has args case',
30
+ inputs: [[*1..5], [*6..10]],
31
+ fill_value: 2,
32
+ method_name: :together_fill,
33
+ expected: [[1, 2, 4, 5, 6], [6, 7, 4, 5, 6]],
34
+ block_logic: '(i + 1) + 1',
35
+ has_block: true,
36
+ },
37
+ {
38
+ case_no: 4,
39
+ case_title: 'not use block case(alias tfill)',
40
+ inputs: [[*1..5], [*6..10]],
41
+ fill_value: 99,
42
+ method_name: :tfill,
43
+ expected: [[99, 99, 99, 99, 99], [99, 99, 99, 99, 99]],
44
+ has_block: false,
45
+ },
46
+ ]
47
+
48
+ cases.each do |c|
49
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
50
+ begin
51
+ case_before c
52
+
53
+ # -- given --
54
+ # nothing
55
+
56
+ # -- when --
57
+ if c[:has_block]
58
+ actual = c[:inputs].send c[:method_name], c[:fill_value] { |i|eval c[:block_logic], binding }
59
+ else
60
+ actual = c[:inputs].send c[:method_name], c[:fill_value]
61
+ end
62
+
63
+ # -- then --
64
+ expect(actual).to eq(c[:expected])
65
+ ensure
66
+ case_after c
67
+ end
68
+ end
69
+
70
+ def case_before(c)
71
+ # implement each case before
72
+ end
73
+
74
+ def case_after(c)
75
+ # implement each case after
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,171 +1,171 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_map do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- method_name: :together_map,
12
- inputs: [[1, 2, 3], %w{one two three}],
13
- expected: ['1:one', '2:two', '3:three'],
14
- },
15
- {
16
- case_no: 2,
17
- case_title: 'contain nil case',
18
- method_name: :together_map,
19
- inputs: [[1, 2, 3], %w{one two}],
20
- expected: ['1:one', '2:two', '3:'],
21
- },
22
- {
23
- case_no: 3,
24
- case_title: 'valid case',
25
- method_name: :together_map,
26
- inputs: [[1, 2, 3], %w{one two three}],
27
- expected: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
28
- is_multi: true,
29
- },
30
- {
31
- case_no: 4,
32
- case_title: 'valid case(alias together_collect)',
33
- method_name: :together_collect,
34
- inputs: [[1, 2, 3], %w{one two three}],
35
- expected: ['1:one', '2:two', '3:three'],
36
- },
37
- {
38
- case_no: 5,
39
- case_title: 'valid case(alias tmap)',
40
- method_name: :tmap,
41
- inputs: [[1, 2, 3], %w{one two three}],
42
- expected: ['1:one', '2:two', '3:three'],
43
- },
44
- {
45
- case_no: 6,
46
- case_title: 'valid case(alias tcollect)',
47
- method_name: :tcollect,
48
- inputs: [[1, 2, 3], %w{one two three}],
49
- expected: ['1:one', '2:two', '3:three'],
50
- },
51
- ]
52
-
53
- cases.each do |c|
54
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
55
- begin
56
- case_before c
57
-
58
- # -- given --
59
- # nothing
60
-
61
- # -- when/then --
62
- if c[:is_multi]
63
- actual = c[:inputs].method(c[:method_name]).call { |first, second|["#{first}:#{second}", "#{second}:#{first}"] }
64
- else
65
- actual = c[:inputs].method(c[:method_name]).call { |first, second|"#{first}:#{second}" }
66
- end
67
-
68
- expect(actual).to eq(c[:expected])
69
- ensure
70
- case_after c
71
- end
72
- end
73
-
74
- def case_before(c)
75
- # implement each case before
76
- end
77
-
78
- def case_after(c)
79
- # implement each case after
80
- end
81
- end
82
- end
83
-
84
- context :together_map! do
85
- cases = [
86
- {
87
- case_no: 1,
88
- case_title: 'valid case',
89
- method_name: :together_map!,
90
- inputs: [[1, 2, 3], %w{one two three}],
91
- expected_ret: ['1:one', '2:two', '3:three'],
92
- expected_self: ['1:one', '2:two', '3:three'],
93
- },
94
- {
95
- case_no: 2,
96
- case_title: 'contain nil case',
97
- method_name: :together_map!,
98
- inputs: [[1, 2, 3], %w{one two}],
99
- expected_ret: ['1:one', '2:two', '3:'],
100
- expected_self: ['1:one', '2:two', '3:'],
101
- },
102
- {
103
- case_no: 3,
104
- case_title: 'valid case',
105
- method_name: :together_map!,
106
- inputs: [[1, 2, 3], %w{one two three}],
107
- expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
108
- expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
109
- is_multi: true,
110
- },
111
- {
112
- case_no: 4,
113
- case_title: 'valid case(alias together_collect!)',
114
- method_name: :together_collect!,
115
- inputs: [[1, 2, 3], %w{one two three}],
116
- expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
117
- expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
118
- is_multi: true,
119
- },
120
- {
121
- case_no: 5,
122
- case_title: 'valid case(alias tmap!)',
123
- method_name: :tmap!,
124
- inputs: [[1, 2, 3], %w{one two three}],
125
- expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
126
- expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
127
- is_multi: true,
128
- },
129
- {
130
- case_no: 6,
131
- case_title: 'valid case(alias tcollect!)',
132
- method_name: :tcollect!,
133
- inputs: [[1, 2, 3], %w{one two three}],
134
- expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
135
- expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
136
- is_multi: true,
137
- },
138
- ]
139
-
140
- cases.each do |c|
141
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
142
- begin
143
- case_before c
144
-
145
- # -- given --
146
- # nothing
147
-
148
- # -- when/then --
149
- if c[:is_multi]
150
- actual = c[:inputs].method(c[:method_name]).call { |first, second|["#{first}:#{second}", "#{second}:#{first}"] }
151
- else
152
- actual = c[:inputs].method(c[:method_name]).call { |first, second|"#{first}:#{second}" }
153
- end
154
-
155
- expect(actual).to eq(c[:expected_ret])
156
- expect(c[:inputs]).to eq(c[:expected_self])
157
- ensure
158
- case_after c
159
- end
160
- end
161
-
162
- def case_before(c)
163
- # implement each case before
164
- end
165
-
166
- def case_after(c)
167
- # implement each case after
168
- end
169
- end
170
- end
171
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_map do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ method_name: :together_map,
12
+ inputs: [[1, 2, 3], %w(one two three)],
13
+ expected: ['1:one', '2:two', '3:three'],
14
+ },
15
+ {
16
+ case_no: 2,
17
+ case_title: 'contain nil case',
18
+ method_name: :together_map,
19
+ inputs: [[1, 2, 3], %w(one two)],
20
+ expected: ['1:one', '2:two', '3:'],
21
+ },
22
+ {
23
+ case_no: 3,
24
+ case_title: 'valid case',
25
+ method_name: :together_map,
26
+ inputs: [[1, 2, 3], %w(one two three)],
27
+ expected: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
28
+ is_multi: true,
29
+ },
30
+ {
31
+ case_no: 4,
32
+ case_title: 'valid case(alias together_collect)',
33
+ method_name: :together_collect,
34
+ inputs: [[1, 2, 3], %w(one two three)],
35
+ expected: ['1:one', '2:two', '3:three'],
36
+ },
37
+ {
38
+ case_no: 5,
39
+ case_title: 'valid case(alias tmap)',
40
+ method_name: :tmap,
41
+ inputs: [[1, 2, 3], %w(one two three)],
42
+ expected: ['1:one', '2:two', '3:three'],
43
+ },
44
+ {
45
+ case_no: 6,
46
+ case_title: 'valid case(alias tcollect)',
47
+ method_name: :tcollect,
48
+ inputs: [[1, 2, 3], %w(one two three)],
49
+ expected: ['1:one', '2:two', '3:three'],
50
+ },
51
+ ]
52
+
53
+ cases.each do |c|
54
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
55
+ begin
56
+ case_before c
57
+
58
+ # -- given --
59
+ # nothing
60
+
61
+ # -- when/then --
62
+ if c[:is_multi]
63
+ actual = c[:inputs].method(c[:method_name]).call { |first, second|["#{first}:#{second}", "#{second}:#{first}"] }
64
+ else
65
+ actual = c[:inputs].method(c[:method_name]).call { |first, second|"#{first}:#{second}" }
66
+ end
67
+
68
+ expect(actual).to eq(c[:expected])
69
+ ensure
70
+ case_after c
71
+ end
72
+ end
73
+
74
+ def case_before(c)
75
+ # implement each case before
76
+ end
77
+
78
+ def case_after(c)
79
+ # implement each case after
80
+ end
81
+ end
82
+ end
83
+
84
+ context :together_map! do
85
+ cases = [
86
+ {
87
+ case_no: 1,
88
+ case_title: 'valid case',
89
+ method_name: :together_map!,
90
+ inputs: [[1, 2, 3], %w(one two three)],
91
+ expected_ret: ['1:one', '2:two', '3:three'],
92
+ expected_self: ['1:one', '2:two', '3:three'],
93
+ },
94
+ {
95
+ case_no: 2,
96
+ case_title: 'contain nil case',
97
+ method_name: :together_map!,
98
+ inputs: [[1, 2, 3], %w(one two)],
99
+ expected_ret: ['1:one', '2:two', '3:'],
100
+ expected_self: ['1:one', '2:two', '3:'],
101
+ },
102
+ {
103
+ case_no: 3,
104
+ case_title: 'valid case',
105
+ method_name: :together_map!,
106
+ inputs: [[1, 2, 3], %w(one two three)],
107
+ expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
108
+ expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
109
+ is_multi: true,
110
+ },
111
+ {
112
+ case_no: 4,
113
+ case_title: 'valid case(alias together_collect!)',
114
+ method_name: :together_collect!,
115
+ inputs: [[1, 2, 3], %w(one two three)],
116
+ expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
117
+ expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
118
+ is_multi: true,
119
+ },
120
+ {
121
+ case_no: 5,
122
+ case_title: 'valid case(alias tmap!)',
123
+ method_name: :tmap!,
124
+ inputs: [[1, 2, 3], %w(one two three)],
125
+ expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
126
+ expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
127
+ is_multi: true,
128
+ },
129
+ {
130
+ case_no: 6,
131
+ case_title: 'valid case(alias tcollect!)',
132
+ method_name: :tcollect!,
133
+ inputs: [[1, 2, 3], %w(one two three)],
134
+ expected_ret: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
135
+ expected_self: [['1:one', '2:two', '3:three'], ['one:1', 'two:2', 'three:3']],
136
+ is_multi: true,
137
+ },
138
+ ]
139
+
140
+ cases.each do |c|
141
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
142
+ begin
143
+ case_before c
144
+
145
+ # -- given --
146
+ # nothing
147
+
148
+ # -- when/then --
149
+ if c[:is_multi]
150
+ actual = c[:inputs].method(c[:method_name]).call { |first, second|["#{first}:#{second}", "#{second}:#{first}"] }
151
+ else
152
+ actual = c[:inputs].method(c[:method_name]).call { |first, second|"#{first}:#{second}" }
153
+ end
154
+
155
+ expect(actual).to eq(c[:expected_ret])
156
+ expect(c[:inputs]).to eq(c[:expected_self])
157
+ ensure
158
+ case_after c
159
+ end
160
+ end
161
+
162
+ def case_before(c)
163
+ # implement each case before
164
+ end
165
+
166
+ def case_after(c)
167
+ # implement each case after
168
+ end
169
+ end
170
+ end
171
+ end
@@ -1,51 +1,51 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- inputs: [[1, 2, 3], %w{one two three}],
12
- expected: ['1:one', '2:two', '3:three'],
13
- },
14
- {
15
- case_no: 2,
16
- case_title: 'contain nil case',
17
- inputs: [[1, 2, 3], %w{one two}],
18
- expected: ['1:one', '2:two', '3:'],
19
- },
20
- ]
21
-
22
- cases.each do |c|
23
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
- begin
25
- case_before c
26
-
27
- # -- given --
28
- # nothing
29
-
30
- # -- when/then --
31
- actual = []
32
- c[:inputs].together do |first, second|
33
- actual << "#{first}:#{second}"
34
- end
35
-
36
- expect(actual).to eq(c[:expected])
37
- ensure
38
- case_after c
39
- end
40
- end
41
-
42
- def case_before(c)
43
- # implement each case before
44
- end
45
-
46
- def case_after(c)
47
- # implement each case after
48
- end
49
- end
50
- end
51
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ inputs: [[1, 2, 3], %w(one two three)],
12
+ expected: ['1:one', '2:two', '3:three'],
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'contain nil case',
17
+ inputs: [[1, 2, 3], %w(one two)],
18
+ expected: ['1:one', '2:two', '3:'],
19
+ },
20
+ ]
21
+
22
+ cases.each do |c|
23
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
+ begin
25
+ case_before c
26
+
27
+ # -- given --
28
+ # nothing
29
+
30
+ # -- when/then --
31
+ actual = []
32
+ c[:inputs].together do |first, second|
33
+ actual << "#{first}:#{second}"
34
+ end
35
+
36
+ expect(actual).to eq(c[:expected])
37
+ ensure
38
+ case_after c
39
+ end
40
+ end
41
+
42
+ def case_before(c)
43
+ # implement each case before
44
+ end
45
+
46
+ def case_after(c)
47
+ # implement each case after
48
+ end
49
+ end
50
+ end
51
+ end