puts_debuggerer 0.2.0 → 0.3.0
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 +84 -22
- data/lib/puts_debuggerer.rb +153 -24
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: c88bd5fef7057cd180ae60e177dc981f4c55e8db
         | 
| 4 | 
            +
              data.tar.gz: 4d9f9d965df2e88f79a82c899e01f772fa60b316
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 87a8e6e07e3e294ed74fafb2b47fb64e3f12de5438b0969d9daa20c8c20a49677bfbf807521ca117142ecc727ad21c5327ec6ce2c1e1ad0d35f127588ba1ff95
         | 
| 7 | 
            +
              data.tar.gz: a775f0476aeb9544707396a6d06b5d06452314af1607a766f404e7ecf827c8020ee6266d92c81d07f2bf577acb329ec7b68842d877c5d3a8a83117b04f1d2c49
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            # puts_debuggerer v0. | 
| 1 | 
            +
            # puts_debuggerer v0.3.0
         | 
| 2 2 | 
             
            [](http://badge.fury.io/rb/puts_debuggerer)
         | 
| 3 3 | 
             
            [](https://travis-ci.org/AndyObtiva/puts_debuggerer)
         | 
| 4 4 | 
             
            [](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master)
         | 
| @@ -16,7 +16,7 @@ https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html | |
| 16 16 | 
             
            Add the following to bundler's `Gemfile`.
         | 
| 17 17 |  | 
| 18 18 | 
             
            ```ruby
         | 
| 19 | 
            -
            gem 'puts_debuggerer', '~> 0. | 
| 19 | 
            +
            gem 'puts_debuggerer', '~> 0.3.0'
         | 
| 20 20 | 
             
            ```
         | 
| 21 21 |  | 
| 22 22 | 
             
            ### Manual
         | 
| @@ -24,7 +24,7 @@ gem 'puts_debuggerer', '~> 0.2.0' | |
| 24 24 | 
             
            Or manually install and require library.
         | 
| 25 25 |  | 
| 26 26 | 
             
            ```bash
         | 
| 27 | 
            -
            gem install puts_debuggerer -v0. | 
| 27 | 
            +
            gem install puts_debuggerer -v0.3.0
         | 
| 28 28 | 
             
            ```
         | 
| 29 29 |  | 
| 30 30 | 
             
            ```ruby
         | 
| @@ -33,12 +33,17 @@ require 'puts_debuggerer' | |
| 33 33 |  | 
| 34 34 | 
             
            ### Usage
         | 
| 35 35 |  | 
| 36 | 
            -
             | 
| 36 | 
            +
            Simply invoke global `pd` method anywhere you'd like to see line number and source code with output.
         | 
| 37 37 | 
             
            If the argument is a pure string, the print out is simplified by not showing duplicate source.
         | 
| 38 38 |  | 
| 39 | 
            -
            Quickly  | 
| 39 | 
            +
            Quickly locate printed lines using Find feature (e.g. CTRL+F) by looking for:
         | 
| 40 | 
            +
            * [PD]
         | 
| 41 | 
            +
            * file:line_number
         | 
| 42 | 
            +
            * ruby expression.
         | 
| 40 43 |  | 
| 41 | 
            -
             | 
| 44 | 
            +
            This gives you the added benefit of easily removing your pd statements later on from the code.
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            Happy puts_debuggerering!
         | 
| 42 47 |  | 
| 43 48 | 
             
            Example Code:
         | 
| 44 49 |  | 
| @@ -52,8 +57,10 @@ pd 'What line number am I?'                     # line 4 | |
| 52 57 | 
             
            Example Printout:
         | 
| 53 58 |  | 
| 54 59 | 
             
            ```bash
         | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 60 | 
            +
            [PD] /Users/User/finance_calculator_app/pd_test.rb:3
         | 
| 61 | 
            +
               > ("Show me the source of the bug: #{bug}").inspect
         | 
| 62 | 
            +
              => "Show me the source of the bug: beattle"
         | 
| 63 | 
            +
            [PD] /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"
         | 
| 57 64 | 
             
            ```
         | 
| 58 65 |  | 
| 59 66 | 
             
            ### Options
         | 
| @@ -74,8 +81,58 @@ pd 'What line number am I?' | |
| 74 81 | 
             
            Example Printout:
         | 
| 75 82 |  | 
| 76 83 | 
             
            ```bash
         | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 84 | 
            +
            [PD] pd_test.rb:4
         | 
| 85 | 
            +
               > ("Show me the source of the bug: #{bug}").inspect
         | 
| 86 | 
            +
              => "Show me the source of the bug: beattle"
         | 
| 87 | 
            +
            [PD] pd_test.rb:5 "What line number am I?"
         | 
| 88 | 
            +
            ```
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            #### `PutsDebuggerer.header`
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            Header to include at the top of every print out.
         | 
| 93 | 
            +
            * Default value is `nil`
         | 
| 94 | 
            +
            * Value `true` enables header as `'*'*80`
         | 
| 95 | 
            +
            * Value `false`, `nil`, or empty string disables header
         | 
| 96 | 
            +
            * Any other string value gets set as a custom header
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            Example:
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            ```ruby
         | 
| 101 | 
            +
            PutsDebuggerer.header = true
         | 
| 102 | 
            +
            pd (x=1)
         | 
| 103 | 
            +
            ```
         | 
| 104 | 
            +
             | 
| 105 | 
            +
            Prints out:
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            ```bash
         | 
| 108 | 
            +
            ********************************************************************************
         | 
| 109 | 
            +
            [PD] /Users/User/example.rb:2
         | 
| 110 | 
            +
               > (x=1).inspect
         | 
| 111 | 
            +
              => "1"
         | 
| 112 | 
            +
            ```
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            #### `PutsDebuggerer.footer`
         | 
| 115 | 
            +
             | 
| 116 | 
            +
            Footer to include at the bottom of every print out.
         | 
| 117 | 
            +
            * Default value is `nil`
         | 
| 118 | 
            +
            * Value `true` enables footer as `'*'*80`
         | 
| 119 | 
            +
            * Value `false`, `nil`, or empty string disables footer
         | 
| 120 | 
            +
            * Any other string value gets set as a custom footer
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            Example:
         | 
| 123 | 
            +
             | 
| 124 | 
            +
            ```ruby
         | 
| 125 | 
            +
            PutsDebuggerer.footer = true
         | 
| 126 | 
            +
            pd (x=1)
         | 
| 127 | 
            +
            ```
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            Prints out
         | 
| 130 | 
            +
             | 
| 131 | 
            +
            ```bash
         | 
| 132 | 
            +
            [PD] /Users/User/example.rb:2
         | 
| 133 | 
            +
               > (x=1).inspect
         | 
| 134 | 
            +
              => "1"
         | 
| 135 | 
            +
            ********************************************************************************
         | 
| 79 136 | 
             
            ```
         | 
| 80 137 |  | 
| 81 138 | 
             
            ### Bonus
         | 
| @@ -89,49 +146,54 @@ Provides caller line number starting 1 level above caller of this method (with d | |
| 89 146 | 
             
            Example:
         | 
| 90 147 |  | 
| 91 148 | 
             
            ```ruby
         | 
| 92 | 
            -
            # lib/example.rb | 
| 93 | 
            -
             | 
| 149 | 
            +
            # File Name: lib/example.rb             # line 1
         | 
| 150 | 
            +
            # Print out __caller_line_number__      # line 2
         | 
| 94 151 | 
             
            puts __caller_line_number__             # line 3
         | 
| 95 152 | 
             
            ```
         | 
| 96 153 |  | 
| 97 154 | 
             
            Prints out `3`
         | 
| 98 155 |  | 
| 99 156 |  | 
| 100 | 
            -
            #### ` | 
| 157 | 
            +
            #### `__caller_file__(caller_depth=0)`
         | 
| 101 158 |  | 
| 102 159 | 
             
            Provides caller file starting 1 level above caller of this method (with default `caller_depth=0`).
         | 
| 103 160 |  | 
| 104 161 | 
             
            Example:
         | 
| 105 162 |  | 
| 106 163 | 
             
            ```ruby
         | 
| 107 | 
            -
            # lib/example.rb
         | 
| 108 | 
            -
            puts  | 
| 109 | 
            -
            puts __caller_line_number__
         | 
| 164 | 
            +
            # File Name: lib/example.rb
         | 
| 165 | 
            +
            puts __caller_file__
         | 
| 110 166 | 
             
            ```
         | 
| 111 167 |  | 
| 112 168 | 
             
            Prints out `lib/example.rb`
         | 
| 113 169 |  | 
| 114 | 
            -
            #### ` | 
| 170 | 
            +
            #### `__caller_source_line__(caller_depth=0)`
         | 
| 115 171 |  | 
| 116 172 | 
             
            Provides caller source line starting 1 level above caller of this method (with default `caller_depth=0`).
         | 
| 117 173 |  | 
| 118 174 | 
             
            Example:
         | 
| 119 175 |  | 
| 120 176 | 
             
            ```ruby
         | 
| 121 | 
            -
             | 
| 122 | 
            -
            puts "Print out __caller_line_number__"
         | 
| 123 | 
            -
            puts __caller_line_number__
         | 
| 177 | 
            +
            puts __caller_source_line__
         | 
| 124 178 | 
             
            ```
         | 
| 125 179 |  | 
| 126 180 | 
             
            Prints out `puts __caller_source_line__`
         | 
| 127 181 |  | 
| 128 | 
            -
            ##  | 
| 182 | 
            +
            ## Release Notes
         | 
| 183 | 
            +
             | 
| 184 | 
            +
            * v0.3.0: header/footer support, multi-line printout, improved format
         | 
| 185 | 
            +
            * v0.2.0: App path exclusion support, Rails root support, improved format
         | 
| 186 | 
            +
            * v0.1.0: File/line/expression print out
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            ## Contributing
         | 
| 129 189 |  | 
| 130 190 | 
             
            * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
         | 
| 131 191 | 
             
            * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
         | 
| 132 192 | 
             
            * Fork the project.
         | 
| 193 | 
            +
            * Change directory into project
         | 
| 194 | 
            +
            * Run `gem install bundler && bundle && rake` and make sure RSpec tests are passing
         | 
| 133 195 | 
             
            * Start a feature/bugfix branch.
         | 
| 134 | 
            -
            * Commit and push until you are happy with your contribution.
         | 
| 196 | 
            +
            * Write RSpec tests, Code, Commit and push until you are happy with your contribution.
         | 
| 135 197 | 
             
            * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
         | 
| 136 198 | 
             
            * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
         | 
| 137 199 |  | 
    
        data/lib/puts_debuggerer.rb
    CHANGED
    
    | @@ -1,25 +1,131 @@ | |
| 1 1 | 
             
            module PutsDebuggerer
         | 
| 2 | 
            +
              HEADER_DEFAULT = '*'*80
         | 
| 3 | 
            +
              FOOTER_DEFAULT = '*'*80
         | 
| 2 4 | 
             
              class << self
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            +
                # Application root path to exclude when printing out file path
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # Example:
         | 
| 8 | 
            +
                #
         | 
| 9 | 
            +
                #   # File Name: /Users/User/sample_app/lib/sample.rb
         | 
| 10 | 
            +
                #   PutsDebuggerer.app_path = '/Users/User/sample_app'
         | 
| 11 | 
            +
                #   pd (x=1)
         | 
| 12 | 
            +
                #
         | 
| 13 | 
            +
                # Prints out:
         | 
| 14 | 
            +
                #
         | 
| 15 | 
            +
                #   [PD] lib/sample.rb:3
         | 
| 16 | 
            +
                #      > (x=1).inspect
         | 
| 17 | 
            +
                #     => "1"
         | 
| 5 18 | 
             
                def app_path
         | 
| 6 19 | 
             
                  (@app_path || Rails.root.to_s) rescue nil
         | 
| 7 20 | 
             
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                attr_writer :app_path
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                # Header to include at the top of every print out.
         | 
| 25 | 
            +
                # * Default value is `nil`
         | 
| 26 | 
            +
                # * Value `true` enables header as `'*'*80`
         | 
| 27 | 
            +
                # * Value `false`, `nil`, or empty string disables header
         | 
| 28 | 
            +
                # * Any other string value gets set as a custom header
         | 
| 29 | 
            +
                #
         | 
| 30 | 
            +
                # Example:
         | 
| 31 | 
            +
                #
         | 
| 32 | 
            +
                #   PutsDebuggerer.header = true
         | 
| 33 | 
            +
                #   pd (x=1)
         | 
| 34 | 
            +
                #
         | 
| 35 | 
            +
                # Prints out:
         | 
| 36 | 
            +
                #
         | 
| 37 | 
            +
                #   ********************************************************************************
         | 
| 38 | 
            +
                #   [PD] /Users/User/example.rb:2
         | 
| 39 | 
            +
                #      > (x=1).inspect
         | 
| 40 | 
            +
                #     => "1"
         | 
| 41 | 
            +
                attr_reader :header
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                def header=(value)
         | 
| 44 | 
            +
                  if value.equal?(true)
         | 
| 45 | 
            +
                    @header = HEADER_DEFAULT
         | 
| 46 | 
            +
                  elsif value == ''
         | 
| 47 | 
            +
                    @header = nil
         | 
| 48 | 
            +
                  else
         | 
| 49 | 
            +
                    @header = value
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                def header?
         | 
| 54 | 
            +
                  !!@header
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                # Footer to include at the bottom of every print out.
         | 
| 58 | 
            +
                # * Default value is `nil`
         | 
| 59 | 
            +
                # * Value `true` enables footer as `'*'*80`
         | 
| 60 | 
            +
                # * Value `false`, `nil`, or empty string disables footer
         | 
| 61 | 
            +
                # * Any other string value gets set as a custom footer
         | 
| 62 | 
            +
                #
         | 
| 63 | 
            +
                # Example:
         | 
| 64 | 
            +
                #
         | 
| 65 | 
            +
                #   PutsDebuggerer.footer = true
         | 
| 66 | 
            +
                #   pd (x=1)
         | 
| 67 | 
            +
                #
         | 
| 68 | 
            +
                # Prints out
         | 
| 69 | 
            +
                #
         | 
| 70 | 
            +
                #   [PD] /Users/User/example.rb:2
         | 
| 71 | 
            +
                #      > (x=1).inspect
         | 
| 72 | 
            +
                #     => "1"
         | 
| 73 | 
            +
                #   ********************************************************************************
         | 
| 74 | 
            +
                attr_reader :footer
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                def footer=(value)
         | 
| 77 | 
            +
                  if value.equal?(true)
         | 
| 78 | 
            +
                    @footer = FOOTER_DEFAULT
         | 
| 79 | 
            +
                  else
         | 
| 80 | 
            +
                    @footer = value
         | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                def footer?
         | 
| 85 | 
            +
                  !!@footer
         | 
| 86 | 
            +
                end
         | 
| 8 87 | 
             
              end
         | 
| 9 88 | 
             
            end
         | 
| 10 89 |  | 
| 90 | 
            +
            # Prints object with bonus info such as file name, line number and source
         | 
| 91 | 
            +
            # expression. Optionally prints out header and footer.
         | 
| 92 | 
            +
            # Lookup PutsDebuggerer attributes for more details about configuration options.
         | 
| 93 | 
            +
            #
         | 
| 94 | 
            +
            # Simply invoke global `pd` method anywhere you'd like to see line number and source code with output.
         | 
| 95 | 
            +
            # If the argument is a pure string, the print out is simplified by not showing duplicate source.
         | 
| 96 | 
            +
            #
         | 
| 97 | 
            +
            # Quickly locate printed lines using Find feature (e.g. CTRL+F) by looking for:
         | 
| 98 | 
            +
            # * \[PD\]
         | 
| 99 | 
            +
            # * file:line_number
         | 
| 100 | 
            +
            # * ruby expression.
         | 
| 101 | 
            +
            #
         | 
| 102 | 
            +
            # This gives you the added benefit of easily removing your pd statements later on from the code.
         | 
| 103 | 
            +
            #
         | 
| 104 | 
            +
            # Happy puts_debuggerering!
         | 
| 105 | 
            +
            #
         | 
| 106 | 
            +
            # Example Code:
         | 
| 107 | 
            +
            #
         | 
| 108 | 
            +
            #   # /Users/User/finance_calculator_app/pd_test.rb # line 1
         | 
| 109 | 
            +
            #   bug = 'beattle'                                 # line 2
         | 
| 110 | 
            +
            #   pd "Show me the source of the bug: #{bug}"      # line 3
         | 
| 111 | 
            +
            #   pd 'What line number am I?'                     # line 4
         | 
| 112 | 
            +
            #
         | 
| 113 | 
            +
            # Example Printout:
         | 
| 114 | 
            +
            #
         | 
| 115 | 
            +
            #   [PD] /Users/User/finance_calculator_app/pd_test.rb:3
         | 
| 116 | 
            +
            #      > ("Show me the source of the bug: #{bug}").inspect
         | 
| 117 | 
            +
            #     => "Show me the source of the bug: beattle"
         | 
| 118 | 
            +
            #   [PD] /Users/User/finance_calculator_app/pd_test.rb:4 "What line number am I?"
         | 
| 11 119 | 
             
            def pd(object)
         | 
| 12 | 
            -
               | 
| 13 | 
            -
               | 
| 14 | 
            -
                source_line = ''
         | 
| 15 | 
            -
              else
         | 
| 16 | 
            -
                source_line += '.inspect => '
         | 
| 17 | 
            -
              end
         | 
| 120 | 
            +
              header = PutsDebuggerer.header? ? "#{PutsDebuggerer.header}\n" : ''
         | 
| 121 | 
            +
              pd_expression = __caller_pd_expression__(object)
         | 
| 18 122 | 
             
              line_number = __caller_line_number__(1)
         | 
| 19 123 | 
             
              file = __caller_file__(1).sub(PutsDebuggerer.app_path.to_s, '')
         | 
| 20 | 
            -
               | 
| 124 | 
            +
              footer = PutsDebuggerer.footer? ? "\n#{PutsDebuggerer.footer}" : ''
         | 
| 125 | 
            +
              puts "#{header}[PD] #{file}:#{line_number}#{pd_expression} #{object.inspect}#{footer}"
         | 
| 21 126 | 
             
            end
         | 
| 22 127 |  | 
| 128 | 
            +
             | 
| 23 129 | 
             
            STACK_TRACE_CALL_LINE_NUMBER_REGEX = /\:(\d+)\:in /
         | 
| 24 130 | 
             
            STACK_TRACE_CALL_SOURCE_FILE_REGEX = /[ ]*([^:]+)\:\d+\:in /
         | 
| 25 131 |  | 
| @@ -27,11 +133,11 @@ STACK_TRACE_CALL_SOURCE_FILE_REGEX = /[ ]*([^:]+)\:\d+\:in / | |
| 27 133 | 
             
            # this method.
         | 
| 28 134 | 
             
            #
         | 
| 29 135 | 
             
            # Example:
         | 
| 30 | 
            -
            # | 
| 31 | 
            -
            # | 
| 32 | 
            -
            # | 
| 33 | 
            -
            # | 
| 34 | 
            -
            # | 
| 136 | 
            +
            #
         | 
| 137 | 
            +
            #   # lib/example.rb                        # line 1
         | 
| 138 | 
            +
            #   puts "Print out __caller_line_number__" # line 2
         | 
| 139 | 
            +
            #   puts __caller_line_number__             # line 3
         | 
| 140 | 
            +
            #
         | 
| 35 141 | 
             
            # prints out `3`
         | 
| 36 142 | 
             
            def __caller_line_number__(caller_depth=0)
         | 
| 37 143 | 
             
              caller[caller_depth][STACK_TRACE_CALL_LINE_NUMBER_REGEX, 1].to_i
         | 
| @@ -41,11 +147,10 @@ end | |
| 41 147 | 
             
            # this method.
         | 
| 42 148 | 
             
            #
         | 
| 43 149 | 
             
            # Example:
         | 
| 44 | 
            -
            # | 
| 45 | 
            -
            # | 
| 46 | 
            -
            # | 
| 47 | 
            -
            # | 
| 48 | 
            -
            # ```
         | 
| 150 | 
            +
            #
         | 
| 151 | 
            +
            #   # File Name: lib/example.rb
         | 
| 152 | 
            +
            #   puts __caller_file__
         | 
| 153 | 
            +
            #
         | 
| 49 154 | 
             
            # prints out `lib/example.rb`
         | 
| 50 155 | 
             
            def __caller_file__(caller_depth=0)
         | 
| 51 156 | 
             
              caller[caller_depth][STACK_TRACE_CALL_SOURCE_FILE_REGEX, 1]
         | 
| @@ -56,11 +161,9 @@ end | |
| 56 161 | 
             
            # this method.
         | 
| 57 162 | 
             
            #
         | 
| 58 163 | 
             
            # Example:
         | 
| 59 | 
            -
            # | 
| 60 | 
            -
            #  | 
| 61 | 
            -
            # | 
| 62 | 
            -
            # puts __caller_line_number__
         | 
| 63 | 
            -
            # ```
         | 
| 164 | 
            +
            #
         | 
| 165 | 
            +
            #   puts __caller_source_line__
         | 
| 166 | 
            +
            #
         | 
| 64 167 | 
             
            # prints out `puts __caller_source_line__`
         | 
| 65 168 | 
             
            def __caller_source_line__(caller_depth=0)
         | 
| 66 169 | 
             
              source_line_number = __caller_line_number__(caller_depth+1)
         | 
| @@ -72,3 +175,29 @@ def __caller_source_line__(caller_depth=0) | |
| 72 175 | 
             
              end
         | 
| 73 176 | 
             
              source_line
         | 
| 74 177 | 
             
            end
         | 
| 178 | 
            +
             | 
| 179 | 
            +
            private
         | 
| 180 | 
            +
             | 
| 181 | 
            +
            def __caller_pd_expression__(object)
         | 
| 182 | 
            +
              # Caller Source Line Depth 2 = 1 to pd method + 1 to caller
         | 
| 183 | 
            +
              source_line = __caller_source_line__(2)
         | 
| 184 | 
            +
              source_line = __extract_pd_expression__(source_line)
         | 
| 185 | 
            +
              source_line = source_line.gsub(/(^'|'$)/, '"') if source_line.start_with?("'") && source_line.end_with?("'")
         | 
| 186 | 
            +
              source_line = source_line.gsub(/(^\(|\)$)/, '') if source_line.start_with?("(") && source_line.end_with?(")")
         | 
| 187 | 
            +
              if source_line == object.inspect.sub("\n$", '')
         | 
| 188 | 
            +
                ""
         | 
| 189 | 
            +
              else
         | 
| 190 | 
            +
                "\n   > (#{source_line}).inspect\n  =>"
         | 
| 191 | 
            +
              end
         | 
| 192 | 
            +
            end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
            # Extracts pd source line expression.
         | 
| 195 | 
            +
            #
         | 
| 196 | 
            +
            # Example:
         | 
| 197 | 
            +
            #
         | 
| 198 | 
            +
            # __extract_pd_expression__("pd (x=1)")
         | 
| 199 | 
            +
            #
         | 
| 200 | 
            +
            # outputs `(x=1)`
         | 
| 201 | 
            +
            def __extract_pd_expression__(source_line)
         | 
| 202 | 
            +
              source_line.strip.sub(/^[ ]*pd[ ]+/, '').strip
         | 
| 203 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: puts_debuggerer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Andy Maleh
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-03-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rspec
         |