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,53 +1,53 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_concat do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- inputs: [[1, 2, 3], %w{one two three}],
12
- add_list: [4, 5, 6],
13
- method_name: :together_concat,
14
- expected: [[1, 2, 3, 4, 5, 6], ['one', 'two', 'three', 4, 5, 6]],
15
- },
16
- {
17
- case_no: 2,
18
- case_title: 'valid case',
19
- inputs: [[1, 2, 3], %w{one two three}],
20
- add_list: [4, 5, 6],
21
- method_name: :tconcat,
22
- expected: [[1, 2, 3, 4, 5, 6], ['one', 'two', 'three', 4, 5, 6]],
23
- },
24
- ]
25
-
26
- cases.each do |c|
27
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
28
- begin
29
- case_before c
30
-
31
- # -- given --
32
- # nothing
33
-
34
- # -- when --
35
- c[:inputs].send c[:method_name], c[:add_list]
36
-
37
- # -- then --
38
- expect(c[:inputs]).to eq(c[:expected])
39
- ensure
40
- case_after c
41
- end
42
- end
43
-
44
- def case_before(c)
45
- # implement each case before
46
- end
47
-
48
- def case_after(c)
49
- # implement each case after
50
- end
51
- end
52
- end
53
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_concat do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ inputs: [[1, 2, 3], %w(one two three)],
12
+ add_list: [4, 5, 6],
13
+ method_name: :together_concat,
14
+ expected: [[1, 2, 3, 4, 5, 6], ['one', 'two', 'three', 4, 5, 6]],
15
+ },
16
+ {
17
+ case_no: 2,
18
+ case_title: 'valid case',
19
+ inputs: [[1, 2, 3], %w(one two three)],
20
+ add_list: [4, 5, 6],
21
+ method_name: :tconcat,
22
+ expected: [[1, 2, 3, 4, 5, 6], ['one', 'two', 'three', 4, 5, 6]],
23
+ },
24
+ ]
25
+
26
+ cases.each do |c|
27
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
28
+ begin
29
+ case_before c
30
+
31
+ # -- given --
32
+ # nothing
33
+
34
+ # -- when --
35
+ c[:inputs].send c[:method_name], c[:add_list]
36
+
37
+ # -- then --
38
+ expect(c[:inputs]).to eq(c[:expected])
39
+ ensure
40
+ case_after c
41
+ end
42
+ end
43
+
44
+ def case_before(c)
45
+ # implement each case before
46
+ end
47
+
48
+ def case_after(c)
49
+ # implement each case after
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,78 +1,78 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_delete_at do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
12
- delete_value: 2,
13
- method_name: :together_delete_at,
14
- expected: [[1, 2, 4], [2, 3, 5]],
15
- ret: [3, 4],
16
- },
17
- {
18
- case_no: 2,
19
- case_title: 'valid case(not exist)',
20
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
21
- delete_value: 5,
22
- method_name: :together_delete_at,
23
- expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
24
- ret: [nil, nil],
25
- },
26
- {
27
- case_no: 3,
28
- case_title: 'valid case(minus index)',
29
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
30
- delete_value: -3,
31
- method_name: :together_delete_at,
32
- expected: [[1, 3, 4], [2, 4, 5]],
33
- ret: [2, 3],
34
- },
35
- {
36
- case_no: 4,
37
- case_title: 'valid case(use tdelete_at alias)',
38
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
39
- delete_value: 2,
40
- method_name: :tdelete_at,
41
- expected: [[1, 2, 4], [2, 3, 5]],
42
- ret: [3, 4],
43
- },
44
- ]
45
-
46
- cases.each do |c|
47
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
48
- begin
49
- case_before c
50
-
51
- # -- given --
52
- # nothing
53
-
54
- # -- when --
55
- if c[:has_block]
56
- actual = c[:inputs].send c[:method_name], c[:delete_value] {c[:block] }
57
- else
58
- actual = c[:inputs].send c[:method_name], c[:delete_value]
59
- end
60
-
61
- # -- then --
62
- expect(actual).to eq(c[:ret])
63
- expect(c[:inputs]).to eq(c[:expected])
64
- ensure
65
- case_after c
66
- end
67
- end
68
-
69
- def case_before(c)
70
- # implement each case before
71
- end
72
-
73
- def case_after(c)
74
- # implement each case after
75
- end
76
- end
77
- end
78
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_delete_at do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
12
+ delete_value: 2,
13
+ method_name: :together_delete_at,
14
+ expected: [[1, 2, 4], [2, 3, 5]],
15
+ ret: [3, 4],
16
+ },
17
+ {
18
+ case_no: 2,
19
+ case_title: 'valid case(not exist)',
20
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
21
+ delete_value: 5,
22
+ method_name: :together_delete_at,
23
+ expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
24
+ ret: [nil, nil],
25
+ },
26
+ {
27
+ case_no: 3,
28
+ case_title: 'valid case(minus index)',
29
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
30
+ delete_value: -3,
31
+ method_name: :together_delete_at,
32
+ expected: [[1, 3, 4], [2, 4, 5]],
33
+ ret: [2, 3],
34
+ },
35
+ {
36
+ case_no: 4,
37
+ case_title: 'valid case(use tdelete_at alias)',
38
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
39
+ delete_value: 2,
40
+ method_name: :tdelete_at,
41
+ expected: [[1, 2, 4], [2, 3, 5]],
42
+ ret: [3, 4],
43
+ },
44
+ ]
45
+
46
+ cases.each do |c|
47
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
48
+ begin
49
+ case_before c
50
+
51
+ # -- given --
52
+ # nothing
53
+
54
+ # -- when --
55
+ if c[:has_block]
56
+ actual = c[:inputs].send c[:method_name], c[:delete_value] { c[:block] }
57
+ else
58
+ actual = c[:inputs].send c[:method_name], c[:delete_value]
59
+ end
60
+
61
+ # -- then --
62
+ expect(actual).to eq(c[:ret])
63
+ expect(c[:inputs]).to eq(c[:expected])
64
+ ensure
65
+ case_after c
66
+ end
67
+ end
68
+
69
+ def case_before(c)
70
+ # implement each case before
71
+ end
72
+
73
+ def case_after(c)
74
+ # implement each case after
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,61 +1,61 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_delete_if do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- inputs: [[1, 2, 3, 4], [6, 4, 6, 8]],
12
- delete_block_code: '(first + second).odd?',
13
- method_name: :together_delete_if,
14
- expected: [[2, 4], [4, 8]],
15
- },
16
- {
17
- case_no: 2,
18
- case_title: 'not have delete target value case',
19
- inputs: [[2, 2, 4, 4], [6, 4, 6, 8]],
20
- delete_block_code: '(first + second).odd?',
21
- method_name: :together_delete_if,
22
- expected: nil,
23
- },
24
- {
25
- case_no: 3,
26
- case_title: 'valid case(alias tdelete_if)',
27
- inputs: [[1, 2, 3, 4], [6, 4, 6, 8]],
28
- delete_block_code: '(first + second).odd?',
29
- method_name: :tdelete_if,
30
- expected: [[2, 4], [4, 8]],
31
- },
32
- ]
33
-
34
- cases.each do |c|
35
- it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
36
- begin
37
- case_before c
38
-
39
- # -- given --
40
- # nothing
41
-
42
- # -- when --
43
- actual = c[:inputs].send c[:method_name] {|first, second|eval c[:delete_block_code], binding }
44
-
45
- # -- then --
46
- expect(actual).to eq(c[:expected])
47
- ensure
48
- case_after c
49
- end
50
- end
51
-
52
- def case_before(c)
53
- # implement each case before
54
- end
55
-
56
- def case_after(c)
57
- # implement each case after
58
- end
59
- end
60
- end
61
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_delete_if do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ inputs: [[1, 2, 3, 4], [6, 4, 6, 8]],
12
+ delete_block_code: '(first + second).odd?',
13
+ method_name: :together_delete_if,
14
+ expected: [[2, 4], [4, 8]],
15
+ },
16
+ {
17
+ case_no: 2,
18
+ case_title: 'not have delete target value case',
19
+ inputs: [[2, 2, 4, 4], [6, 4, 6, 8]],
20
+ delete_block_code: '(first + second).odd?',
21
+ method_name: :together_delete_if,
22
+ expected: nil,
23
+ },
24
+ {
25
+ case_no: 3,
26
+ case_title: 'valid case(alias tdelete_if)',
27
+ inputs: [[1, 2, 3, 4], [6, 4, 6, 8]],
28
+ delete_block_code: '(first + second).odd?',
29
+ method_name: :tdelete_if,
30
+ expected: [[2, 4], [4, 8]],
31
+ },
32
+ ]
33
+
34
+ cases.each do |c|
35
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
36
+ begin
37
+ case_before c
38
+
39
+ # -- given --
40
+ # nothing
41
+
42
+ # -- when --
43
+ actual = c[:inputs].send c[:method_name] { |first, second|eval c[:delete_block_code], binding }
44
+
45
+ # -- then --
46
+ expect(actual).to eq(c[:expected])
47
+ ensure
48
+ case_after c
49
+ end
50
+ end
51
+
52
+ def case_before(c)
53
+ # implement each case before
54
+ end
55
+
56
+ def case_after(c)
57
+ # implement each case after
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,80 +1,80 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'tbpgr_utils'
4
-
5
- describe Array do
6
- context :together_delete do
7
- cases = [
8
- {
9
- case_no: 1,
10
- case_title: 'valid case',
11
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
12
- delete_value: 2,
13
- method_name: :together_delete,
14
- expected: [[1, 3, 4], [3, 4, 5]],
15
- ret: 2,
16
- },
17
- {
18
- case_no: 2,
19
- case_title: 'valid case(not exist and block use)',
20
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
21
- delete_value: 6,
22
- method_name: :together_delete,
23
- expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
24
- ret: :ret,
25
- has_block: true,
26
- block: :ret,
27
- },
28
- {
29
- case_no: 3,
30
- case_title: 'valid case(not exist and block unuse)',
31
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
32
- delete_value: 6,
33
- method_name: :together_delete,
34
- expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
35
- ret: nil,
36
- },
37
- {
38
- case_no: 4,
39
- case_title: 'valid case(alias tdelete)',
40
- inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
41
- delete_value: 2,
42
- method_name: :tdelete,
43
- expected: [[1, 3, 4], [3, 4, 5]],
44
- ret: 2,
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[:delete_value] {c[:block] }
59
- else
60
- actual = c[:inputs].send c[:method_name], c[:delete_value]
61
- end
62
-
63
- # -- then --
64
- expect(actual).to eq(c[:ret])
65
- expect(c[:inputs]).to eq(c[:expected])
66
- ensure
67
- case_after c
68
- end
69
- end
70
-
71
- def case_before(c)
72
- # implement each case before
73
- end
74
-
75
- def case_after(c)
76
- # implement each case after
77
- end
78
- end
79
- end
80
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :together_delete do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'valid case',
11
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
12
+ delete_value: 2,
13
+ method_name: :together_delete,
14
+ expected: [[1, 3, 4], [3, 4, 5]],
15
+ ret: 2,
16
+ },
17
+ {
18
+ case_no: 2,
19
+ case_title: 'valid case(not exist and block use)',
20
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
21
+ delete_value: 6,
22
+ method_name: :together_delete,
23
+ expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
24
+ ret: :ret,
25
+ has_block: true,
26
+ block: :ret,
27
+ },
28
+ {
29
+ case_no: 3,
30
+ case_title: 'valid case(not exist and block unuse)',
31
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
32
+ delete_value: 6,
33
+ method_name: :together_delete,
34
+ expected: [[1, 2, 3, 4], [2, 3, 4, 5]],
35
+ ret: nil,
36
+ },
37
+ {
38
+ case_no: 4,
39
+ case_title: 'valid case(alias tdelete)',
40
+ inputs: [[1, 2, 3, 4], [2, 3, 4, 5]],
41
+ delete_value: 2,
42
+ method_name: :tdelete,
43
+ expected: [[1, 3, 4], [3, 4, 5]],
44
+ ret: 2,
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[:delete_value] { c[:block] }
59
+ else
60
+ actual = c[:inputs].send c[:method_name], c[:delete_value]
61
+ end
62
+
63
+ # -- then --
64
+ expect(actual).to eq(c[:ret])
65
+ expect(c[:inputs]).to eq(c[:expected])
66
+ ensure
67
+ case_after c
68
+ end
69
+ end
70
+
71
+ def case_before(c)
72
+ # implement each case before
73
+ end
74
+
75
+ def case_after(c)
76
+ # implement each case after
77
+ end
78
+ end
79
+ end
80
+ end