debugging 1.0.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 +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/ChangeLog.rdoc +17 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +102 -0
- data/Rakefile +36 -0
- data/debugging.gemspec +28 -0
- data/lib/debugging/all.rb +9 -0
- data/lib/debugging/at.rb +12 -0
- data/lib/debugging/beep.rb +9 -0
- data/lib/debugging/callstack.rb +16 -0
- data/lib/debugging/mof.rb +35 -0
- data/lib/debugging/q.rb +9 -0
- data/lib/debugging/re.rb +29 -0
- data/lib/debugging/repl.rb +16 -0
- data/lib/debugging/version.rb +3 -0
- data/lib/debugging.rb +4 -0
- data/spec/q_spec.rb +19 -0
- data/spec/re_spec.rb +39 -0
- data/spec/spec_helper.rb +18 -0
- metadata +173 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: f540cf321629826fd4539a2460b2b42f91726eec
         | 
| 4 | 
            +
              data.tar.gz: 96bade08c3b33fd008c6057f4e0c0abd40c2f133
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 525abd17e17c032113e739150b84f390c98c71b5e7ce4c1f03773aa879ca117d43006150b0a146206011e83e4c9b3a0c21785b847b73daddd2b5d0018ed693b9
         | 
| 7 | 
            +
              data.tar.gz: f11f34f6d50cb16bc4be14890fd9ba6aa98bcdc84f92eeb0b916c3e5f713a0c5dbe45c5055f4798d2c4dd0ae4f136c79efdc9bfb70fd9378c6f8791a05e7fcc1
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --colour --format documentation
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/ChangeLog.rdoc
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            === 1.0.0 / 2014-01-19
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * Adjusted concept: Only helper method style
         | 
| 4 | 
            +
            * Removed:
         | 
| 5 | 
            +
              * dd
         | 
| 6 | 
            +
              * binding.vars
         | 
| 7 | 
            +
            * Added:
         | 
| 8 | 
            +
              * beep
         | 
| 9 | 
            +
              * repl
         | 
| 10 | 
            +
            * Renamed:
         | 
| 11 | 
            +
              * oo -> at
         | 
| 12 | 
            +
              * cc -> callstack
         | 
| 13 | 
            +
              * mm -> mof
         | 
| 14 | 
            +
              * regexp_visualize -> re
         | 
| 15 | 
            +
            * Method List: Display all available ancestors by default and add third argument for grepping
         | 
| 16 | 
            +
            * Moved from zucker 13.1 gem into its own gem
         | 
| 17 | 
            +
             | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                debugging (1.0.0)
         | 
| 5 | 
            +
                  binding.repl (~> 0)
         | 
| 6 | 
            +
                  paint (~> 0, >= 0.8.7)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            GEM
         | 
| 9 | 
            +
              remote: https://rubygems.org/
         | 
| 10 | 
            +
              specs:
         | 
| 11 | 
            +
                binding.repl (0.9.0)
         | 
| 12 | 
            +
                  toml (~> 0.0.3)
         | 
| 13 | 
            +
                binding_of_caller (0.7.2)
         | 
| 14 | 
            +
                  debug_inspector (>= 0.0.1)
         | 
| 15 | 
            +
                blankslate (2.1.2.4)
         | 
| 16 | 
            +
                debug_inspector (0.0.2)
         | 
| 17 | 
            +
                diff-lcs (1.2.5)
         | 
| 18 | 
            +
                json (1.8.1)
         | 
| 19 | 
            +
                paint (0.8.7)
         | 
| 20 | 
            +
                parslet (1.5.0)
         | 
| 21 | 
            +
                  blankslate (~> 2.0)
         | 
| 22 | 
            +
                rake (10.1.1)
         | 
| 23 | 
            +
                rdoc (3.12.2)
         | 
| 24 | 
            +
                  json (~> 1.4)
         | 
| 25 | 
            +
                rspec (2.14.1)
         | 
| 26 | 
            +
                  rspec-core (~> 2.14.0)
         | 
| 27 | 
            +
                  rspec-expectations (~> 2.14.0)
         | 
| 28 | 
            +
                  rspec-mocks (~> 2.14.0)
         | 
| 29 | 
            +
                rspec-core (2.14.7)
         | 
| 30 | 
            +
                rspec-expectations (2.14.4)
         | 
| 31 | 
            +
                  diff-lcs (>= 1.1.3, < 2.0)
         | 
| 32 | 
            +
                rspec-mocks (2.14.4)
         | 
| 33 | 
            +
                rubygems-tasks (0.2.4)
         | 
| 34 | 
            +
                rubysl-singleton (2.0.0)
         | 
| 35 | 
            +
                toml (0.0.4)
         | 
| 36 | 
            +
                  parslet
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            PLATFORMS
         | 
| 39 | 
            +
              ruby
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            DEPENDENCIES
         | 
| 42 | 
            +
              binding_of_caller
         | 
| 43 | 
            +
              bundler (~> 1.0)
         | 
| 44 | 
            +
              debugging!
         | 
| 45 | 
            +
              rake (~> 10.1)
         | 
| 46 | 
            +
              rdoc (~> 3.0)
         | 
| 47 | 
            +
              rspec (~> 2.4)
         | 
| 48 | 
            +
              rubygems-tasks (~> 0.2)
         | 
| 49 | 
            +
              rubysl-singleton
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2014 Jan Lelis
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.rdoc
    ADDED
    
    | @@ -0,0 +1,102 @@ | |
| 1 | 
            +
            = Ruby Print Debugging {<img src="https://travis-ci.org/janlelis/debugging.png" />}[https://travis-ci.org/janlelis/debugging]
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
            == Setup
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                $ gem install debugging binding_of_caller
         | 
| 7 | 
            +
             | 
| 8 | 
            +
             | 
| 9 | 
            +
            Or in your Gemfile:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                gem 'debugging'
         | 
| 12 | 
            +
                gem 'binding_of_caller'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             | 
| 15 | 
            +
            In Ruby:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                require 'debugging/all'
         | 
| 18 | 
            +
             | 
| 19 | 
            +
             | 
| 20 | 
            +
            == Methods
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            === at(label = nil)
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                [label] @ method `...', line ... of file ....
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
            === beep
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                Lets your terminal bell ring.
         | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
            === callstack
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                <main>
         | 
| 35 | 
            +
                  start
         | 
| 36 | 
            +
                    catch
         | 
| 37 | 
            +
                      block in start
         | 
| 38 | 
            +
                        eval_input
         | 
| 39 | 
            +
                          each_top_level_statement
         | 
| 40 | 
            +
                            catch
         | 
| 41 | 
            +
                              block in each_top_level_statement
         | 
| 42 | 
            +
                                loop
         | 
| 43 | 
            +
                                  block (2 levels) in each_top_level_statement
         | 
| 44 | 
            +
                                    block in eval_input
         | 
| 45 | 
            +
                                      signal_status
         | 
| 46 | 
            +
                                        block (2 levels) in eval_input
         | 
| 47 | 
            +
                                          evaluate
         | 
| 48 | 
            +
                                            evaluate
         | 
| 49 | 
            +
                                              eval
         | 
| 50 | 
            +
                                                irb_binding
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| 53 | 
            +
            === mof(obj, depth = nil)
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            Methods of:
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                >> mof [1,2,3]
         | 
| 58 | 
            +
                ###
         | 
| 59 | 
            +
                Eigenclass
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                Array
         | 
| 62 | 
            +
                inspect  to_s  to_a  to_h  to_ary  frozen?  ==  eql?  hash  []  []=  at  fetch  first  last  concat  <<  push  pop  shift  unshift  insert  each  each_index  reverse_each  length  size  empty?  find_index  index  rindex  join  reverse  reverse!  rotate  rotate!  sort  sort!  sort_by!  collect  collect!  map  map!  select  select!  keep_if  values_at  delete  delete_at  delete_if  reject  reject!  zip  transpose  replace  clear  fill  include?  <=>  slice  slice!  assoc  rassoc  +  *  -  &  |  uniq  uniq!  compact  compact!  flatten  flatten!  count  shuffle!  shuffle  sample  cycle  permutation  combination  repeated_permutation  repeated_combination  product  take  take_while  drop  drop_while  bsearch  pack
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                Enumerable
         | 
| 65 | 
            +
                to_a  entries  to_h  sort  sort_by  grep  count  find  detect  find_index  find_all  select  reject  collect  map  flat_map  collect_concat  inject  reduce  partition  group_by  first  all?  any?  one?  none?  min  max  minmax  min_by  max_by  minmax_by  member?  include?  each_with_index  reverse_each  each_entry  each_slice  each_cons  each_with_object  zip  take  take_while  drop  drop_while  cycle  chunk  slice_before  lazy
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                Object
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                Debugging
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                Kernel
         | 
| 72 | 
            +
                nil?  ===  =~  !~  eql?  hash  <=>  class  singleton_class  clone  dup  taint  tainted?  untaint  untrust  untrusted?  trust  freeze  frozen?  to_s  inspect  methods  singleton_methods  protected_methods  private_methods  public_methods  instance_variables  instance_variable_get  instance_variable_set  instance_variable_defined?  remove_instance_variable  instance_of?  kind_of?  is_a?  tap  send  public_send  respond_to?  extend  display  method  public_method  singleton_method  define_singleton_method  object_id  to_enum  enum_for
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                BasicObject
         | 
| 75 | 
            +
                ==  equal?  !  !=  instance_eval  instance_exec  __send__  __id__
         | 
| 76 | 
            +
             | 
| 77 | 
            +
             | 
| 78 | 
            +
            === q(*args)
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                q :is_like, ?p, "but on one line"
         | 
| 81 | 
            +
             | 
| 82 | 
            +
             | 
| 83 | 
            +
            === re(string, regex, groups = nil)
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            An utility to assist you matching regexes againts strings. Try this one:
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                >> re "mail@janlelis.de", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
         | 
| 88 | 
            +
             | 
| 89 | 
            +
             | 
| 90 | 
            +
            === repl
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                Starts your favorite IRB session.
         | 
| 93 | 
            +
             | 
| 94 | 
            +
             | 
| 95 | 
            +
            == Also See
         | 
| 96 | 
            +
             | 
| 97 | 
            +
            https://github.com/davejacobs/letters
         | 
| 98 | 
            +
             | 
| 99 | 
            +
             | 
| 100 | 
            +
            == J-_-L
         | 
| 101 | 
            +
             | 
| 102 | 
            +
            Copyright (c) 2010-2014 Jan Lelis. MIT License. Originated from the zucker gem.
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              require 'bundler'
         | 
| 7 | 
            +
            rescue LoadError => e
         | 
| 8 | 
            +
              warn e.message
         | 
| 9 | 
            +
              warn "Run `gem install bundler` to install Bundler."
         | 
| 10 | 
            +
              exit -1
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            begin
         | 
| 14 | 
            +
              Bundler.setup(:development)
         | 
| 15 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 16 | 
            +
              warn e.message
         | 
| 17 | 
            +
              warn "Run `bundle install` to install missing gems."
         | 
| 18 | 
            +
              exit e.status_code
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            require 'rake'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            require 'rubygems/tasks'
         | 
| 24 | 
            +
            Gem::Tasks.new
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            require 'rdoc/task'
         | 
| 27 | 
            +
            RDoc::Task.new do |rdoc|
         | 
| 28 | 
            +
              rdoc.title = "ruby_version"
         | 
| 29 | 
            +
            end
         | 
| 30 | 
            +
            task :doc => :rdoc
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            require 'rspec/core/rake_task'
         | 
| 33 | 
            +
            RSpec::Core::RakeTask.new
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            task :test    => :spec
         | 
| 36 | 
            +
            task :default => :spec
         | 
    
        data/debugging.gemspec
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require File.expand_path('../lib/debugging/version', __FILE__)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |gem|
         | 
| 6 | 
            +
              gem.name          = "debugging"
         | 
| 7 | 
            +
              gem.version       = Debugging::VERSION
         | 
| 8 | 
            +
              gem.summary       = 'Print debugging helpers.'
         | 
| 9 | 
            +
              gem.description   = 'Provides useful print debugging helpers.'
         | 
| 10 | 
            +
              gem.license       = "MIT"
         | 
| 11 | 
            +
              gem.authors       = ["Jan Lelis"]
         | 
| 12 | 
            +
              gem.email         = "mail@janlelis.de"
         | 
| 13 | 
            +
              gem.homepage      = "https://github.com/janlelis/debugging"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              gem.files         = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
         | 
| 16 | 
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         | 
| 17 | 
            +
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              gem.require_paths = ['lib']
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              gem.add_dependency 'paint', '~> 0', '>= 0.8.7'
         | 
| 21 | 
            +
              gem.add_dependency 'binding.repl', '~> 0'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              gem.add_development_dependency 'bundler', '~> 1.0'
         | 
| 24 | 
            +
              gem.add_development_dependency 'rake', '~> 10.1'
         | 
| 25 | 
            +
              gem.add_development_dependency 'rdoc', '~> 3.0'
         | 
| 26 | 
            +
              gem.add_development_dependency 'rspec', '~> 2.4'
         | 
| 27 | 
            +
              gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
         | 
| 28 | 
            +
            end
         | 
    
        data/lib/debugging/at.rb
    ADDED
    
    | @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            require 'debugging'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Debugging
         | 
| 4 | 
            +
              private
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def at(label = nil)
         | 
| 7 | 
            +
                caller[0].rindex( /:(\d+)(:in (`.*'))?$/ )
         | 
| 8 | 
            +
                puts "#{ label && Paint["#{label} ", :yellow] }@"\
         | 
| 9 | 
            +
                     " #{ $3 && "method #{ Paint[$3, :red] }, " }line "\
         | 
| 10 | 
            +
                     "#{ Paint[$1, :blue]} of file #{ Paint[$`, :green]}"
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            require 'debugging'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Debugging
         | 
| 4 | 
            +
              private
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def mof(obj, depth = nil, grep_for = //)
         | 
| 7 | 
            +
                grep_for = Regexp.new(grep_for)
         | 
| 8 | 
            +
                puts Paint["###", :red, :bold]
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                eigen_methods = obj.singleton_methods.grep(grep_for)
         | 
| 11 | 
            +
                if eigen_methods.empty?
         | 
| 12 | 
            +
                  puts Paint['Eigenclass', :yellow]
         | 
| 13 | 
            +
                else
         | 
| 14 | 
            +
                  puts Paint['Eigenclass', :green, :underline], eigen_methods.map(&:to_s)*'  '
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
                puts
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                if obj.is_a? Module
         | 
| 19 | 
            +
                  klass, method_function = obj, :public_methods
         | 
| 20 | 
            +
                else
         | 
| 21 | 
            +
                  klass, method_function = obj.class, :public_instance_methods
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                (depth || klass.ancestors.size).times{ |level|
         | 
| 25 | 
            +
                  if cur = klass.ancestors[level]
         | 
| 26 | 
            +
                    level_methods = cur.send(method_function, false).grep(grep_for)
         | 
| 27 | 
            +
                    colors = level_methods.empty? ? [:yellow] : [:green, :underline]
         | 
| 28 | 
            +
                    puts Paint["#{cur}", *colors], level_methods.map(&:to_s)*'  '
         | 
| 29 | 
            +
                    puts unless level_methods.empty?
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                nil
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
    
        data/lib/debugging/q.rb
    ADDED
    
    
    
        data/lib/debugging/re.rb
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require 'debugging'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Debugging
         | 
| 4 | 
            +
              private
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def re(string, regex, groups = nil)
         | 
| 7 | 
            +
                if regex =~ string
         | 
| 8 | 
            +
                  if !groups
         | 
| 9 | 
            +
                    puts $` + Paint[$&, :green] + $'
         | 
| 10 | 
            +
                  else
         | 
| 11 | 
            +
                    Array( groups ).each{ |group_nr|
         | 
| 12 | 
            +
                      begin
         | 
| 13 | 
            +
                        raise IndexError unless $~[group_nr]
         | 
| 14 | 
            +
                        gr_string = string.dup
         | 
| 15 | 
            +
                        gr_string[ $~.end( group_nr ),   0 ] = Paint::NOTHING
         | 
| 16 | 
            +
                        gr_string[ $~.begin( group_nr ), 0 ] = Paint.color(:green)
         | 
| 17 | 
            +
                        puts group_nr.to_s + ': ' + gr_string
         | 
| 18 | 
            +
                      rescue IndexError
         | 
| 19 | 
            +
                        puts group_nr.to_s + ': ' + Paint['no match', :red]
         | 
| 20 | 
            +
                      end
         | 
| 21 | 
            +
                    }
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                else
         | 
| 24 | 
            +
                  puts Paint['no match', :red]
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                nil
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            require 'debugging'
         | 
| 2 | 
            +
            require 'binding.repl'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            begin
         | 
| 5 | 
            +
              require 'binding_of_caller'
         | 
| 6 | 
            +
            rescue LoadError
         | 
| 7 | 
            +
              warn 'Using Debugging#repl requires the "binding_of_caller" gem. Please install it or add it to your Gemfile!'
         | 
| 8 | 
            +
            end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            module Debugging
         | 
| 11 | 
            +
              private
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              def repl
         | 
| 14 | 
            +
                binding.of_caller(1).repl.auto
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
    
        data/lib/debugging.rb
    ADDED
    
    
    
        data/spec/q_spec.rb
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'debugging/q'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'q' do
         | 
| 5 | 
            +
              it 'should output the same as p for a single arg' do
         | 
| 6 | 
            +
                Paint.unpaint(capture_stdout{q /some object/}).should ==
         | 
| 7 | 
            +
                capture_stdout{p /some object/}
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              it "should output the same as p but for multiple args one one line, values separated by two spaces" do
         | 
| 11 | 
            +
                Paint.unpaint(capture_stdout do
         | 
| 12 | 
            +
                  q 1, "1", 2..5, [], {:hallo => :du}, nil, true
         | 
| 13 | 
            +
                end).chop.should ==
         | 
| 14 | 
            +
                capture_stdout do
         | 
| 15 | 
            +
                  p 1, "1", 2..5, [], {:hallo => :du}, nil, true
         | 
| 16 | 
            +
                end.chop.gsub( "\n", '  ' )
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| 19 | 
            +
             | 
    
        data/spec/re_spec.rb
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'debugging/re'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 're' do
         | 
| 5 | 
            +
              let :regex do /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})\b/i end # r from regular-expressions.info/email.html
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              it 'should display a string where mark the found regex in green' do
         | 
| 8 | 
            +
                capture_stdout do
         | 
| 9 | 
            +
                  re 'I do not contain an email address.', regex
         | 
| 10 | 
            +
                end.chomp.should == Paint.color(:red) + 'no match' + Paint::NOTHING
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it 'should display "no match" if the regex could not be matched' do
         | 
| 14 | 
            +
                capture_stdout do
         | 
| 15 | 
            +
                  re 'I contain an email address: mail@example.com', regex
         | 
| 16 | 
            +
                end.chomp.should == 'I contain an email address: ' + Paint.color(:green) + 'mail@example.com' + Paint::NOTHING + ''
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              it 'should display a string and mark the found regex group in green if group identifier is given as arg2' do
         | 
| 20 | 
            +
                capture_stdout do
         | 
| 21 | 
            +
                  re 'mail@example.com', regex, 1
         | 
| 22 | 
            +
                end.chomp.should == '1: ' + Paint.color(:green) + 'mail' + Paint::NOTHING + '@example.com'
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              it 'should display "group identifier: no match" if the arg2 group could not be matched' do
         | 
| 26 | 
            +
                capture_stdout do
         | 
| 27 | 
            +
                  re 'mail@example.com', regex, 3
         | 
| 28 | 
            +
                end.chomp.should == '3: ' + Paint.color(:red) + 'no match' + Paint::NOTHING
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it 'should also take an array of group identfiers as arg2' do
         | 
| 32 | 
            +
                capture_stdout do
         | 
| 33 | 
            +
                  re 'mail@example.com', regex, [0,1,2]
         | 
| 34 | 
            +
                end.chomp.should == '0: ' + Paint.color(:green) + 'mail@example.com' + Paint::NOTHING + "\n" +
         | 
| 35 | 
            +
                                    '1: ' + Paint.color(:green) + 'mail' + Paint::NOTHING + '@example.com' + "\n" +
         | 
| 36 | 
            +
                                    '2: mail@' + Paint.color(:green) + 'example.com' + Paint::NOTHING
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| 39 | 
            +
             | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require 'rspec'
         | 
| 2 | 
            +
            require 'stringio'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            def capture_stdout
         | 
| 5 | 
            +
              capture = StringIO.new
         | 
| 6 | 
            +
              restore, $stdout = $stdout, capture
         | 
| 7 | 
            +
              yield
         | 
| 8 | 
            +
              $stdout = restore
         | 
| 9 | 
            +
              capture.string
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            def capture_stderr
         | 
| 13 | 
            +
              capture = StringIO.new
         | 
| 14 | 
            +
              restore, $stderr = $stderr, capture
         | 
| 15 | 
            +
              yield
         | 
| 16 | 
            +
              $stderr = restore
         | 
| 17 | 
            +
              capture.string
         | 
| 18 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,173 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: debugging
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Jan Lelis
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-01-19 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: paint
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 0.8.7
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '0'
         | 
| 30 | 
            +
                - - ">="
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 0.8.7
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: binding.repl
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - "~>"
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '0'
         | 
| 40 | 
            +
              type: :runtime
         | 
| 41 | 
            +
              prerelease: false
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - "~>"
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '0'
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: bundler
         | 
| 49 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - "~>"
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '1.0'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - "~>"
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '1.0'
         | 
| 61 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 62 | 
            +
              name: rake
         | 
| 63 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '10.1'
         | 
| 68 | 
            +
              type: :development
         | 
| 69 | 
            +
              prerelease: false
         | 
| 70 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
                requirements:
         | 
| 72 | 
            +
                - - "~>"
         | 
| 73 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                    version: '10.1'
         | 
| 75 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 76 | 
            +
              name: rdoc
         | 
| 77 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 78 | 
            +
                requirements:
         | 
| 79 | 
            +
                - - "~>"
         | 
| 80 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                    version: '3.0'
         | 
| 82 | 
            +
              type: :development
         | 
| 83 | 
            +
              prerelease: false
         | 
| 84 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - "~>"
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: '3.0'
         | 
| 89 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 90 | 
            +
              name: rspec
         | 
| 91 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 92 | 
            +
                requirements:
         | 
| 93 | 
            +
                - - "~>"
         | 
| 94 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 95 | 
            +
                    version: '2.4'
         | 
| 96 | 
            +
              type: :development
         | 
| 97 | 
            +
              prerelease: false
         | 
| 98 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 99 | 
            +
                requirements:
         | 
| 100 | 
            +
                - - "~>"
         | 
| 101 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            +
                    version: '2.4'
         | 
| 103 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 104 | 
            +
              name: rubygems-tasks
         | 
| 105 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - "~>"
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: '0.2'
         | 
| 110 | 
            +
              type: :development
         | 
| 111 | 
            +
              prerelease: false
         | 
| 112 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 113 | 
            +
                requirements:
         | 
| 114 | 
            +
                - - "~>"
         | 
| 115 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 116 | 
            +
                    version: '0.2'
         | 
| 117 | 
            +
            description: Provides useful print debugging helpers.
         | 
| 118 | 
            +
            email: mail@janlelis.de
         | 
| 119 | 
            +
            executables: []
         | 
| 120 | 
            +
            extensions: []
         | 
| 121 | 
            +
            extra_rdoc_files: []
         | 
| 122 | 
            +
            files:
         | 
| 123 | 
            +
            - ".gitignore"
         | 
| 124 | 
            +
            - ".rspec"
         | 
| 125 | 
            +
            - ".travis.yml"
         | 
| 126 | 
            +
            - ChangeLog.rdoc
         | 
| 127 | 
            +
            - Gemfile
         | 
| 128 | 
            +
            - Gemfile.lock
         | 
| 129 | 
            +
            - LICENSE.txt
         | 
| 130 | 
            +
            - README.rdoc
         | 
| 131 | 
            +
            - Rakefile
         | 
| 132 | 
            +
            - debugging.gemspec
         | 
| 133 | 
            +
            - lib/debugging.rb
         | 
| 134 | 
            +
            - lib/debugging/all.rb
         | 
| 135 | 
            +
            - lib/debugging/at.rb
         | 
| 136 | 
            +
            - lib/debugging/beep.rb
         | 
| 137 | 
            +
            - lib/debugging/callstack.rb
         | 
| 138 | 
            +
            - lib/debugging/mof.rb
         | 
| 139 | 
            +
            - lib/debugging/q.rb
         | 
| 140 | 
            +
            - lib/debugging/re.rb
         | 
| 141 | 
            +
            - lib/debugging/repl.rb
         | 
| 142 | 
            +
            - lib/debugging/version.rb
         | 
| 143 | 
            +
            - spec/q_spec.rb
         | 
| 144 | 
            +
            - spec/re_spec.rb
         | 
| 145 | 
            +
            - spec/spec_helper.rb
         | 
| 146 | 
            +
            homepage: https://github.com/janlelis/debugging
         | 
| 147 | 
            +
            licenses:
         | 
| 148 | 
            +
            - MIT
         | 
| 149 | 
            +
            metadata: {}
         | 
| 150 | 
            +
            post_install_message: 
         | 
| 151 | 
            +
            rdoc_options: []
         | 
| 152 | 
            +
            require_paths:
         | 
| 153 | 
            +
            - lib
         | 
| 154 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 155 | 
            +
              requirements:
         | 
| 156 | 
            +
              - - ">="
         | 
| 157 | 
            +
                - !ruby/object:Gem::Version
         | 
| 158 | 
            +
                  version: '0'
         | 
| 159 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 160 | 
            +
              requirements:
         | 
| 161 | 
            +
              - - ">="
         | 
| 162 | 
            +
                - !ruby/object:Gem::Version
         | 
| 163 | 
            +
                  version: '0'
         | 
| 164 | 
            +
            requirements: []
         | 
| 165 | 
            +
            rubyforge_project: 
         | 
| 166 | 
            +
            rubygems_version: 2.2.1
         | 
| 167 | 
            +
            signing_key: 
         | 
| 168 | 
            +
            specification_version: 4
         | 
| 169 | 
            +
            summary: Print debugging helpers.
         | 
| 170 | 
            +
            test_files:
         | 
| 171 | 
            +
            - spec/q_spec.rb
         | 
| 172 | 
            +
            - spec/re_spec.rb
         | 
| 173 | 
            +
            - spec/spec_helper.rb
         |