tbpgr_utils 0.0.128 → 0.0.129

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c715c9b8f8173eefe90a135fb8a85ff91a1b3786
4
- data.tar.gz: 5885d3ac9bfc90436e0c2f3a9afe00afc89faf7d
3
+ metadata.gz: 728656798eadbbb94731d51740b80e40b9f5d539
4
+ data.tar.gz: 441fa95ee7eee5fd2c5021dcf6647416d530da02
5
5
  SHA512:
6
- metadata.gz: 1007ac7dff2535a558fd82715fa8871546d2c7f0aa9118020210e58193cba52b51e9abd294c73ac61ec54ae3c3ca4c499d656b650571d2035da25748e646d7ae
7
- data.tar.gz: 65db7c3abb9f20f4b41882138b14a068c487d57bf61c923c2460994bfb2a346bf7541f8bb20f85d8868d38c39d6bd810126f4f0c9b7b28cd12c96b58cf7b4ca4
6
+ metadata.gz: 5caaed72f69bb0c0516db958fe70a37d3a50ff2a01a2c1f223cccbebeb674bb5a3e8fb6793288b21f12ffa4cfdf19d1eb60d8b3fc89f254a665793d68006aa18
7
+ data.tar.gz: f0798c479739d11eb69b9abc4afb100b251e590d05834103bc5efecce7ded68b96a4da86274e7b1809878c39d7caa687403cb16c9fd57389cee250832e656a71
data/README.md CHANGED
@@ -131,6 +131,7 @@ Or install it yourself as:
131
131
  |[TbpgrUtils Numeric to_oct_table](#numeric-to_oct_table) |oct table |
132
132
  |[TbpgrUtils Object#any_of?](#objectany_of) |if self match any one of items, return true |
133
133
  |[TbpgrUtils Object#boolean?](#objectboolean) |data type check for boolean |
134
+ |[TbpgrUtils Object#grep_public_instance_method](#objectgrep_public_instance_method) |grep public instance method |
134
135
  |[TbpgrUtils Object#guard](#objectguard) |data type check for guard |
135
136
  |[TbpgrUtils Object#method_nameable?](#objectmethod_nameable) |object can use method name or not |
136
137
  |[TbpgrUtils Object#my_methods](#objectmy_methods) |return public/protected/private self define methods |
@@ -2937,6 +2938,34 @@ hoge false # => "not guard"
2937
2938
 
2938
2939
  [back to list](#list)
2939
2940
 
2941
+ ### Object#grep_public_instance_method
2942
+ ~~~ruby
2943
+ require 'tbpbr_utils'
2944
+
2945
+ # target class
2946
+ class GrepPublicInstanceMethod
2947
+ def public_method1;end
2948
+ def public_method2;end
2949
+ def public_method11;end
2950
+ protected
2951
+ def protected_method1;end
2952
+ def protected_method2;end
2953
+ def protected_method11;end
2954
+ private
2955
+ def private_method1;end
2956
+ def private_method2;end
2957
+ def private_method11;end
2958
+ end
2959
+
2960
+ # method call
2961
+ GrepPublicInstanceMethod.new.grep_public_instance_method :public_method1, false # => [:public_method1]
2962
+ GrepPublicInstanceMethod.new.grep_public_instance_method /public_method1/, false # => [:public_method1, :public_method11]
2963
+ GrepPublicInstanceMethod.new.grep_public_instance_method /public_method3/, false # => []
2964
+ GrepPublicInstanceMethod.new.grep_public_instance_method :equal?, true # => [:equal?]
2965
+ ~~~
2966
+
2967
+ [back to list](#list)
2968
+
2940
2969
  ### Object#method_nameable?
2941
2970
  ~~~ruby
2942
2971
  require 'tbpbr_utils'
@@ -3649,6 +3678,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3649
3678
  https://github.com/tbpgr/tbpgr_utils_snippets
3650
3679
 
3651
3680
  ## History
3681
+ * version 0.0.129 : add Object#grep_public_instance_method
3652
3682
  * version 0.0.128 : add Array#exchange, change Kernel#bulk_puts_eval output format(justify)
3653
3683
  * version 0.0.127 : add String#uniq_size
3654
3684
  * version 0.0.126 : add Array#uniq_size
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ # Object
4
+ class Object
5
+ # grep public instance method
6
+ #
7
+ # === Example
8
+ #
9
+ # target class
10
+ #
11
+ # class GrepPublicInstanceMethod
12
+ # def public_method1;end
13
+ # def public_method2;end
14
+ # def public_method11;end
15
+ # protected
16
+ # def protected_method1;end
17
+ # def protected_method2;end
18
+ # def protected_method11;end
19
+ # private
20
+ # def private_method1;end
21
+ # def private_method2;end
22
+ # def private_method11;end
23
+ # end
24
+ #
25
+ # method call
26
+ #
27
+ # GrepPublicInstanceMethod.new.grep_public_instance_method :public_method1, false # => [:public_method1]
28
+ # GrepPublicInstanceMethod.new.grep_public_instance_method /public_method1/, false # => [:public_method1, :public_method11]
29
+ # GrepPublicInstanceMethod.new.grep_public_instance_method /public_method3/, false # => []
30
+ # GrepPublicInstanceMethod.new.grep_public_instance_method :equal?, true # => [:equal?]
31
+ #
32
+ def grep_public_instance_method(search, all = true)
33
+ search = search.to_sym unless search.is_a? Regexp
34
+ public_methods(all).grep search
35
+ end
36
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'open_classes/object/any_of'
4
4
  require 'open_classes/object/boolean'
5
+ require 'open_classes/object/grep_public_instance_method'
5
6
  require 'open_classes/object/guard'
6
7
  require 'open_classes/object/method_nameable'
7
8
  require 'open_classes/object/my_methods'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.128'
5
+ VERSION = '0.0.129'
6
6
  end
@@ -0,0 +1,86 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Object do
6
+ class GrepPublicInstanceMethod
7
+ def public_method1; end
8
+ def public_method2; end
9
+ def public_method11; end
10
+ protected
11
+ def protected_method1; end
12
+ def protected_method2; end
13
+ def protected_method11; end
14
+ private
15
+ def private_method1; end
16
+ def private_method2; end
17
+ def private_method11; end
18
+ end
19
+
20
+ context :grep_public_instance_method do
21
+ cases = [
22
+ {
23
+ case_no: 1,
24
+ case_title: 'String case',
25
+ search: 'public_method1',
26
+ all: false,
27
+ expected: [:public_method1],
28
+ },
29
+ {
30
+ case_no: 2,
31
+ case_title: 'Symbol case',
32
+ search: :public_method1,
33
+ all: false,
34
+ expected: [:public_method1],
35
+ },
36
+ {
37
+ case_no: 3,
38
+ case_title: 'Regexp case',
39
+ search: /public_method1/,
40
+ all: false,
41
+ expected: [:public_method1, :public_method11],
42
+ },
43
+ {
44
+ case_no: 4,
45
+ case_title: 'not hit case',
46
+ search: /public_method3/,
47
+ all: false,
48
+ expected: [],
49
+ },
50
+ {
51
+ case_no: 5,
52
+ case_title: 'all case',
53
+ search: :equal?,
54
+ all: true,
55
+ expected: [:equal?],
56
+ },
57
+ ]
58
+
59
+ cases.each do |c|
60
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
61
+ begin
62
+ case_before c
63
+
64
+ # -- given --
65
+ # nothing
66
+
67
+ # -- when --
68
+ actual = GrepPublicInstanceMethod.new.grep_public_instance_method c[:search], c[:all]
69
+
70
+ # -- then --
71
+ expect(actual).to eq(c[:expected])
72
+ ensure
73
+ case_after c
74
+ end
75
+ end
76
+
77
+ def case_before(c)
78
+ # implement each case before
79
+ end
80
+
81
+ def case_after(c)
82
+ # implement each case after
83
+ end
84
+ end
85
+ end
86
+ 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.128
4
+ version: 0.0.129
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-15 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -203,6 +203,7 @@ files:
203
203
  - lib/open_classes/object.rb
204
204
  - lib/open_classes/object/any_of.rb
205
205
  - lib/open_classes/object/boolean.rb
206
+ - lib/open_classes/object/grep_public_instance_method.rb
206
207
  - lib/open_classes/object/guard.rb
207
208
  - lib/open_classes/object/method_nameable.rb
208
209
  - lib/open_classes/object/my_methods.rb
@@ -340,6 +341,7 @@ files:
340
341
  - spec/open_classes/numeric/to_oct_table_spec.rb
341
342
  - spec/open_classes/object/any_of_spec.rb
342
343
  - spec/open_classes/object/boolean_spec.rb
344
+ - spec/open_classes/object/grep_public_instance_method_spec.rb
343
345
  - spec/open_classes/object/guard_spec.rb
344
346
  - spec/open_classes/object/method_nameable_spec.rb
345
347
  - spec/open_classes/object/my_methods_spec.rb
@@ -498,6 +500,7 @@ test_files:
498
500
  - spec/open_classes/numeric/to_oct_table_spec.rb
499
501
  - spec/open_classes/object/any_of_spec.rb
500
502
  - spec/open_classes/object/boolean_spec.rb
503
+ - spec/open_classes/object/grep_public_instance_method_spec.rb
501
504
  - spec/open_classes/object/guard_spec.rb
502
505
  - spec/open_classes/object/method_nameable_spec.rb
503
506
  - spec/open_classes/object/my_methods_spec.rb