private_please 0.1.1 → 0.1.2
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/.gitignore +1 -7
 - data/.rubocop.yml +32 -0
 - data/.rubocop_todo.yml +24 -0
 - data/.travis.yml +8 -6
 - data/CHANGELOG +4 -0
 - data/Gemfile +1 -1
 - data/README.md +2 -0
 - data/lib/private_please.rb +4 -0
 - data/lib/private_please/tracking/debug/trace_point_data_logger.rb +1 -1
 - data/lib/private_please/tracking/trace_point_details.rb +7 -5
 - data/lib/private_please/tracking/trace_point_processor.rb +11 -3
 - data/lib/private_please/utils/source_file_utils.rb +6 -3
 - data/lib/private_please/version.rb +1 -1
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1c686287e2a68e5a615222b424c30c5b69904814
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b222e367b3d2ec2f0e3dfb0e34d6c86c18e88011
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 65014fdbf7c069639cb8b7d8c49c7c71c16b8eba850a238cbc8999829f04a3f500bf3dc408a42976d6d2d38fb8cfa35f7bc86ced299a063dbe16adbe130e9531
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ffef276c360f4547ba286db987c04aefd0f27e20540b72adcbe53eb8d191f8660481fc24cf7c47760daaffc4bf8ae620a9d621b82d2218b295cf04bcc3676ae9
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            inherit_from:
         
     | 
| 
      
 2 
     | 
    
         
            +
              - .rubocop_todo.yml
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Metrics/LineLength:
         
     | 
| 
      
 5 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 6 
     | 
    
         
            +
                - 'spec/**/*'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Style/ExtraSpacing:
         
     | 
| 
      
 9 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Style/MultilineTernaryOperator:
         
     | 
| 
      
 12 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Style/ParallelAssignment:
         
     | 
| 
      
 15 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            Style/RegexpLiteral:
         
     | 
| 
      
 18 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            Style/SingleLineMethods:
         
     | 
| 
      
 21 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 22 
     | 
    
         
            +
            EmptyLineBetweenDefs:
         
     | 
| 
      
 23 
     | 
    
         
            +
              AllowAdjacentOneLineDefs: true
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            Style/SpaceBeforeSemicolon:
         
     | 
| 
      
 26 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Style/StructInheritance:
         
     | 
| 
      
 29 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            Style/TrailingCommaInLiteral:
         
     | 
| 
      
 32 
     | 
    
         
            +
              EnforcedStyleForMultiline: comma
         
     | 
    
        data/.rubocop_todo.yml
    ADDED
    
    | 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This configuration was generated by
         
     | 
| 
      
 2 
     | 
    
         
            +
            # `rubocop --auto-gen-config`
         
     | 
| 
      
 3 
     | 
    
         
            +
            # on 2016-01-19 17:37:21 +0100 using RuboCop version 0.36.0.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Offense count: 2
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
         
     | 
| 
      
 7 
     | 
    
         
            +
            # URISchemes: http, https
         
     | 
| 
      
 8 
     | 
    
         
            +
            Metrics/LineLength:
         
     | 
| 
      
 9 
     | 
    
         
            +
              Max: 110
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            # Offense count: 1
         
     | 
| 
      
 12 
     | 
    
         
            +
            Style/Documentation:
         
     | 
| 
      
 13 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 14 
     | 
    
         
            +
                - 'spec/**/*'
         
     | 
| 
      
 15 
     | 
    
         
            +
                - 'test/**/*'
         
     | 
| 
      
 16 
     | 
    
         
            +
                - 'lib/**/*'
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            Style/GlobalVars:
         
     | 
| 
      
 19 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 20 
     | 
    
         
            +
                - 'lib/goody_goody/analyzer.rb'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Metrics/MethodLength:
         
     | 
| 
      
 23 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - 'lib/goody_goody/analyzer.rb'
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,8 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            language: ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            rvm:
         
     | 
| 
       3 
     | 
    
         
            -
              -  
     | 
| 
       4 
     | 
    
         
            -
              -  
     | 
| 
       5 
     | 
    
         
            -
              -  
     | 
| 
       6 
     | 
    
         
            -
              -  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
              - 2.0.0
         
     | 
| 
      
 4 
     | 
    
         
            +
              - 2.1
         
     | 
| 
      
 5 
     | 
    
         
            +
              - 2.2.4
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 2.3.0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - ruby-head
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            script: bundle exec rspec --format documentation  --tag ~fails_on_ci --seed 2222
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
    
        data/CHANGELOG
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -8,6 +8,8 @@ This tool locates public or protected methods that can be made private. 
     | 
|
| 
       8 
8 
     | 
    
         
             
            After you have instrumented the tests suite (see below), it watches the code as the tests are executed and identifies non-private methods that are only called privately.
         
     | 
| 
       9 
9 
     | 
    
         
             
            As the technique used is tracing, the execution is slowed down substantially (ex: 300%)
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            [](https://asciinema.org/a/4sqa7u4defes3akyst27pq066)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       11 
13 
     | 
    
         
             
            ## Usage
         
     | 
| 
       12 
14 
     | 
    
         | 
| 
       13 
15 
     | 
    
         
             
            Add this to the top of `spec_helper.rb`:
         
     | 
    
        data/lib/private_please.rb
    CHANGED
    
    
| 
         @@ -18,11 +18,13 @@ module PrivatePlease 
     | 
|
| 
       18 
18 
     | 
    
         
             
                  #  Array#new
         
     | 
| 
       19 
19 
     | 
    
         
             
                  #  Array.size
         
     | 
| 
       20 
20 
     | 
    
         
             
                  def method_full_name
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
                    defined_class_s = defined_class.to_s
         
     | 
| 
      
 22 
     | 
    
         
            +
                    is_module_class_method = defined_class_s.start_with?('#<Class:')
         
     | 
| 
      
 23 
     | 
    
         
            +
                    if is_module_class_method
         
     | 
| 
      
 24 
     | 
    
         
            +
                      defined_class_s.gsub!(/^#<Class:/, '').delete!('>')
         
     | 
| 
      
 25 
     | 
    
         
            +
                      "#{defined_class_s}.#{method_id}"
         
     | 
| 
      
 26 
     | 
    
         
            +
                    elsif module_method?
         
     | 
| 
      
 27 
     | 
    
         
            +
                      "#{defined_class}##{method_id}"
         
     | 
| 
       26 
28 
     | 
    
         
             
                    else
         
     | 
| 
       27 
29 
     | 
    
         
             
                      instance_method = !(_self.class == Class)
         
     | 
| 
       28 
30 
     | 
    
         
             
                      instance_method ?
         
     | 
| 
         @@ -27,9 +27,16 @@ module PrivatePlease 
     | 
|
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                  private
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
                   
     | 
| 
       31 
     | 
    
         
            -
                     
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
                  if Debug.enabled?
         
     | 
| 
      
 31 
     | 
    
         
            +
                    def remember_trace_point(tp)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      tpd = TracePointDetails.from(tp)
         
     | 
| 
      
 33 
     | 
    
         
            +
                      @latest_tracepoints.push tpd
         
     | 
| 
      
 34 
     | 
    
         
            +
                      Debug.log_to_trace_file  tpd
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
                  else
         
     | 
| 
      
 37 
     | 
    
         
            +
                    def remember_trace_point(tp)
         
     | 
| 
      
 38 
     | 
    
         
            +
                      @latest_tracepoints.push TracePointDetails.from(tp)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
       33 
40 
     | 
    
         
             
                  end
         
     | 
| 
       34 
41 
     | 
    
         | 
| 
       35 
42 
     | 
    
         
             
                  def untracked_code?(path)
         
     | 
| 
         @@ -57,6 +64,7 @@ module PrivatePlease 
     | 
|
| 
       57 
64 
     | 
    
         
             
                  end
         
     | 
| 
       58 
65 
     | 
    
         | 
| 
       59 
66 
     | 
    
         
             
                  def private_call?
         
     | 
| 
      
 67 
     | 
    
         
            +
                    return unless tp_prev  # fails sometime (ex: rspec-core) # UNTESTED
         
     | 
| 
       60 
68 
     | 
    
         
             
                    curr_event, prev_event = tp_curr.event, tp_prev.event
         
     | 
| 
       61 
69 
     | 
    
         
             
                    (curr_event == :call) &&
         
     | 
| 
       62 
70 
     | 
    
         
             
                      [:line, :return, :c_return].include?(prev_event) &&
         
     | 
| 
         @@ -6,9 +6,12 @@ module PrivatePlease 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  def source_path_and_lineno(klass, separator, method)
         
     | 
| 
       7 
7 
     | 
    
         
             
                    is_instance_method = separator == '#'
         
     | 
| 
       8 
8 
     | 
    
         
             
                    if klass.instance_of?(Module)
         
     | 
| 
       9 
     | 
    
         
            -
                      is_instance_method 
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
                      if is_instance_method
         
     | 
| 
      
 10 
     | 
    
         
            +
                        klass.instance_method(method).source_location
         
     | 
| 
      
 11 
     | 
    
         
            +
                      else
         
     | 
| 
      
 12 
     | 
    
         
            +
                        klass.singleton_method(method).source_location
         
     | 
| 
      
 13 
     | 
    
         
            +
                      end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       12 
15 
     | 
    
         
             
                    else
         
     | 
| 
       13 
16 
     | 
    
         
             
                      is_instance_method ?
         
     | 
| 
       14 
17 
     | 
    
         
             
                          klass.instance_method(method).source_location :
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: private_please
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Alain Ravet
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-02-14 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -89,6 +89,8 @@ extra_rdoc_files: [] 
     | 
|
| 
       89 
89 
     | 
    
         
             
            files:
         
     | 
| 
       90 
90 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       91 
91 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 92 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
      
 93 
     | 
    
         
            +
            - ".rubocop_todo.yml"
         
     | 
| 
       92 
94 
     | 
    
         
             
            - ".ruby-version"
         
     | 
| 
       93 
95 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       94 
96 
     | 
    
         
             
            - CHANGELOG
         
     |