dissociated_introspection 0.1.4 → 0.1.5

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: c622b1363c06fc73f8ef83a3645180ba81a4ff54
4
- data.tar.gz: 4880afc33b55e68835300cb782a6d69d09293418
3
+ metadata.gz: c7de5e97524155b0efde5a67e29a0fcf99091613
4
+ data.tar.gz: 8e8fcf6b91d073ffaa5f539f1e17d07acaa41151
5
5
  SHA512:
6
- metadata.gz: 98abb12259e2c5fd7ac436269ff3f37bbd585e7e30d0fa8c42224e40ee7cf1a57e9d842e19f406ff5fef62e2c371baf7717a17c61a7ca4bd1b92d090f04fc744
7
- data.tar.gz: 84ae96f322ec2e815ec1000f4abbb3275f31cbe0ada14266cc1f2a912ee225b131ec3bcfb2091022de11606da84c3bc751bac9c61e98607c2516c8f31790ddc7
6
+ metadata.gz: 3e5cb27924dad988e494aa63e5e51074a6eebf7c69dddf37f25e8978c8d9a825c698a7bf002668a24227c2ee18a03fff83f1bbc71febf2c5827410e258acc604
7
+ data.tar.gz: 62309ed059877884f91889bf211ff6bf6f9879e48c34d50f53dd2d579322c148219304115a8fdd2a1e9f4d432790e614240c9e40024e204fa0dfc85499215c48
data/README.md CHANGED
@@ -86,6 +86,11 @@ inspection.get_class.instance_methods(false)
86
86
  # => [ :method1 ]
87
87
 
88
88
  ```
89
+ ## Other methods
90
+ * `DissociatedIntrospection::Inspection#extended_modules`
91
+ * `DissociatedIntrospection::Inspection#included_modules`
92
+ * `DissociatedIntrospection::Inspection#prepend_modules`
93
+ * `DissociatedIntrospection::Inspection#locally_defined_constants`
89
94
 
90
95
  ## Development
91
96
 
@@ -12,7 +12,7 @@ module DissociatedIntrospection
12
12
 
13
13
  # @return [Class]
14
14
  def get_class
15
- @get_class ||= _get_class
15
+ @get_class ||= get_sandbox_class
16
16
  end
17
17
 
18
18
  # @return [Array]
@@ -22,17 +22,17 @@ module DissociatedIntrospection
22
22
 
23
23
  # @return [Array<Module>]
24
24
  def extended_modules
25
- find_class_macro_by_type(:extend) { |a| add_method_name_wo_parent a.first }
25
+ find_class_macro_by_type(:extend) { |a| add_method_referenced_name a.first }
26
26
  end
27
27
 
28
28
  # @return [Array<Module>]
29
29
  def included_modules
30
- find_class_macro_by_type(:include) { |a| add_method_name_wo_parent a.first }
30
+ find_class_macro_by_type(:include) { |a| add_method_referenced_name a.first }
31
31
  end
32
32
 
33
33
  # @return [Array<Module>]
34
34
  def prepend_modules
35
- find_class_macro_by_type(:prepend) { |a| add_method_name_wo_parent a.first }
35
+ find_class_macro_by_type(:prepend) { |a| add_method_referenced_name a.first }
36
36
  end
37
37
 
38
38
  # @return [Hash{String => Module}]
@@ -40,12 +40,12 @@ module DissociatedIntrospection
40
40
  get_class.__missing_constants__
41
41
  end
42
42
 
43
- # @optional type [Module, Class]
44
- # @return [Array<Symbol>]
43
+ # @optional type [Module, Class, Any]
44
+ # @return [Hash{Symbol => Any}>]
45
45
  def locally_defined_constants(type=nil)
46
- consts = get_class.constants - get_class.__missing_constants__.keys - [:BasicObject]
47
- return consts unless type
48
- consts.select { |c| get_class.const_get(c).is_a?(type) }
46
+ symbol_consts = get_class.constants - get_class.__missing_constants__.keys - [:BasicObject]
47
+ consts = symbol_consts.each_with_object({}){|c, hash| hash[c] = get_class.const_get(c) }
48
+ type ? consts.select { |s, c| c.is_a?(type) } : consts
49
49
  end
50
50
 
51
51
  # @return [DissociatedIntrospection::RubyClass]
@@ -60,7 +60,7 @@ module DissociatedIntrospection
60
60
 
61
61
  private
62
62
 
63
- def add_method_name_wo_parent(_module)
63
+ def add_method_referenced_name(_module)
64
64
  _class_name_ = parsed_source.class_name
65
65
 
66
66
  _module.define_singleton_method(:referenced_name) do
@@ -76,7 +76,7 @@ module DissociatedIntrospection
76
76
  get_class.__missing_class_macros__.select { |h| h.keys.first == type }.map { |h| yield(h.values.first.first) }
77
77
  end
78
78
 
79
- def _get_class
79
+ def get_sandbox_class
80
80
  modified_class_source = parsed_source.modify_parent_class(parent_class_replacement)
81
81
  path = if file.is_a? Pathname
82
82
  file.to_s
@@ -1,3 +1,3 @@
1
1
  module DissociatedIntrospection
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dissociated_introspection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dustin Zeisler