dissociated_introspection 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
 - data/README.md +5 -0
 - data/lib/dissociated_introspection/inspection.rb +11 -11
 - data/lib/dissociated_introspection/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c7de5e97524155b0efde5a67e29a0fcf99091613
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8e8fcf6b91d073ffaa5f539f1e17d07acaa41151
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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 ||=  
     | 
| 
      
 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|  
     | 
| 
      
 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|  
     | 
| 
      
 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|  
     | 
| 
      
 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 [ 
     | 
| 
      
 43 
     | 
    
         
            +
                # @optional type [Module, Class, Any]
         
     | 
| 
      
 44 
     | 
    
         
            +
                # @return [Hash{Symbol => Any}>]
         
     | 
| 
       45 
45 
     | 
    
         
             
                def locally_defined_constants(type=nil)
         
     | 
| 
       46 
     | 
    
         
            -
                   
     | 
| 
       47 
     | 
    
         
            -
                   
     | 
| 
       48 
     | 
    
         
            -
                  consts.select { |c|  
     | 
| 
      
 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  
     | 
| 
      
 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  
     | 
| 
      
 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
         
     |