rib 1.2.5 → 1.2.6
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/.travis.yml +8 -6
- data/CHANGES.md +8 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/rib/core/multiline.rb +3 -0
- data/lib/rib/extra/autoindent.rb +11 -14
- data/lib/rib/test/multiline.rb +24 -24
- data/lib/rib/test.rb +43 -47
- data/lib/rib/version.rb +1 -1
- data/rib.gemspec +6 -6
- data/task/gemgem.rb +1 -5
- data/test/core/test_completion.rb +2 -2
- data/test/core/test_history.rb +8 -8
- data/test/core/test_multiline.rb +3 -3
- data/test/core/test_readline.rb +5 -5
- data/test/core/test_squeeze_history.rb +6 -6
- data/test/core/test_underscore.rb +6 -6
- data/test/extra/test_autoindent.rb +141 -0
- data/test/more/test_color.rb +4 -4
- data/test/more/test_multiline_history.rb +3 -3
- data/test/test_api.rb +2 -2
- data/test/test_plugin.rb +3 -3
- data/test/test_runner.rb +5 -5
- data/test/test_shell.rb +20 -20
- metadata +5 -5
- data/lib/rib/extra/debugger.rb +0 -146
- data/lib/rib/patch/debugger.rb +0 -13
| @@ -2,14 +2,14 @@ | |
| 2 2 | 
             
            require 'rib/test'
         | 
| 3 3 | 
             
            require 'rib/core/squeeze_history'
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 5 | 
            +
            copy :squeeze_history do
         | 
| 6 | 
            +
              would 'after_loop saves squeezed history' do
         | 
| 7 7 | 
             
                @shell.history.push(*@input)
         | 
| 8 8 | 
             
                @shell.after_loop
         | 
| 9 9 | 
             
                File.read(@history).should.eq %w[foo bar foo bar].join("\n") + "\n"
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 | 
            -
               | 
| 12 | 
            +
              would 'loop_once squeeze history' do
         | 
| 13 13 | 
             
                times = @input.size
         | 
| 14 14 | 
             
                stub(@shell).get_input{ (@shell.history << "'#{@input.shift}'").last }
         | 
| 15 15 | 
             
                stub(@shell).print_result{}.with_any_args
         | 
| @@ -17,7 +17,7 @@ shared :squeeze_history do | |
| 17 17 | 
             
                @shell.history.to_a.should.eq %w[foo bar foo bar].map{ |i| "'#{i}'" }
         | 
| 18 18 | 
             
              end
         | 
| 19 19 |  | 
| 20 | 
            -
               | 
| 20 | 
            +
              would 'be disabled if disabled' do
         | 
| 21 21 | 
             
                Rib::SqueezeHistory.disable do
         | 
| 22 22 | 
             
                  times = @input.size
         | 
| 23 23 | 
             
                  input = @input.dup
         | 
| @@ -30,7 +30,7 @@ shared :squeeze_history do | |
| 30 30 | 
             
            end
         | 
| 31 31 |  | 
| 32 32 | 
             
            describe Rib::SqueezeHistory do
         | 
| 33 | 
            -
               | 
| 33 | 
            +
              paste :rib
         | 
| 34 34 |  | 
| 35 35 | 
             
              before do
         | 
| 36 36 | 
             
                @history = "/tmp/test_rib_#{rand}"
         | 
| @@ -44,6 +44,6 @@ describe Rib::SqueezeHistory do | |
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 46 | 
             
              test_for Rib::History, Rib::SqueezeHistory do
         | 
| 47 | 
            -
                 | 
| 47 | 
            +
                paste :squeeze_history
         | 
| 48 48 | 
             
              end
         | 
| 49 49 | 
             
            end
         | 
| @@ -2,8 +2,8 @@ | |
| 2 2 | 
             
            require 'rib/test'
         | 
| 3 3 | 
             
            require 'rib/core/underscore'
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
               | 
| 5 | 
            +
            copy :underscore do
         | 
| 6 | 
            +
              would 'set _' do
         | 
| 7 7 | 
             
                setup
         | 
| 8 8 | 
             
                mock(@shell).get_input{'_'}
         | 
| 9 9 | 
             
                mock(@shell).get_input{'10**2'}
         | 
| @@ -13,7 +13,7 @@ shared :underscore do | |
| 13 13 | 
             
                @shell.loop_once.should.eq [100, nil]
         | 
| 14 14 | 
             
              end
         | 
| 15 15 |  | 
| 16 | 
            -
               | 
| 16 | 
            +
              would 'not set _ if already there' do
         | 
| 17 17 | 
             
                bound = Object.new
         | 
| 18 18 | 
             
                def bound._
         | 
| 19 19 | 
             
                  'hey'
         | 
| @@ -27,7 +27,7 @@ shared :underscore do | |
| 27 27 | 
             
                @shell.loop_once.should.eq ['hey', nil]
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 | 
            -
               | 
| 30 | 
            +
              would 'set __' do
         | 
| 31 31 | 
             
                setup
         | 
| 32 32 | 
             
                stub(@shell).puts{}.with_any_args
         | 
| 33 33 | 
             
                mock(@shell).get_input{'XD'}
         | 
| @@ -38,7 +38,7 @@ shared :underscore do | |
| 38 38 | 
             
            end
         | 
| 39 39 |  | 
| 40 40 | 
             
            describe Rib::Underscore do
         | 
| 41 | 
            -
               | 
| 41 | 
            +
              paste :rib
         | 
| 42 42 |  | 
| 43 43 | 
             
              def setup bound=Object.new
         | 
| 44 44 | 
             
                @shell = Rib::Shell.new(
         | 
| @@ -47,6 +47,6 @@ describe Rib::Underscore do | |
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 49 | 
             
              test_for Rib::Underscore do
         | 
| 50 | 
            -
                 | 
| 50 | 
            +
                paste :underscore
         | 
| 51 51 | 
             
              end
         | 
| 52 52 | 
             
            end
         | 
| @@ -0,0 +1,141 @@ | |
| 1 | 
            +
             | 
| 2 | 
            +
            require 'rib/test'
         | 
| 3 | 
            +
            require 'rib/extra/autoindent'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe Rib::Autoindent do
         | 
| 6 | 
            +
              paste :rib
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              Rib::Multiline.enable
         | 
| 9 | 
            +
              Rib::Autoindent.enable
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              autoindent = Class.new do
         | 
| 12 | 
            +
                include Rib::Autoindent, Rib::Multiline, Rib::API
         | 
| 13 | 
            +
                def config
         | 
| 14 | 
            +
                  {:line => 0, :binding => TOPLEVEL_BINDING, :prompt => '>> '}
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
                def stack_size
         | 
| 17 | 
            +
                  autoindent_stack.size
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              before do
         | 
| 22 | 
            +
                @indent = autoindent.new
         | 
| 23 | 
            +
                mock(@indent).puts(match(/^\e/)).times(0)
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def ri input, size
         | 
| 27 | 
            +
                @indent.eval_input(input)
         | 
| 28 | 
            +
                @indent.stack_size.should.eq size
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def le input, size
         | 
| 32 | 
            +
                mock(@indent).puts(match(/^\e/)){}
         | 
| 33 | 
            +
                @indent.eval_input(input)
         | 
| 34 | 
            +
                @indent.stack_size.should.eq size
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              would 'begin rescue else end' do
         | 
| 38 | 
            +
                @indent.stack_size.should.eq 0
         | 
| 39 | 
            +
                ri('begin'         , 1)
         | 
| 40 | 
            +
                ri(  '1'           , 1)
         | 
| 41 | 
            +
                le('rescue'        , 1)
         | 
| 42 | 
            +
                ri(  '1'           , 1)
         | 
| 43 | 
            +
                le('rescue=>e'     , 1)
         | 
| 44 | 
            +
                le('rescue => e'   , 1)
         | 
| 45 | 
            +
                le('rescue =>e'    , 1)
         | 
| 46 | 
            +
                le('rescue E=>e '  , 1)
         | 
| 47 | 
            +
                le('rescue E'      , 1)
         | 
| 48 | 
            +
                le('rescue E => e ', 1)
         | 
| 49 | 
            +
                le('rescue E=> e'  , 1)
         | 
| 50 | 
            +
                le('rescue E =>e ' , 1)
         | 
| 51 | 
            +
                le('else'          , 1)
         | 
| 52 | 
            +
                le('end while nil' , 0)
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              would 'if elsif else end' do
         | 
| 56 | 
            +
                ri('if true'       , 1)
         | 
| 57 | 
            +
                ri(  'if false'    , 2)
         | 
| 58 | 
            +
                ri(    '1'         , 2)
         | 
| 59 | 
            +
                le(  'end'         , 1)
         | 
| 60 | 
            +
                ri(  'if true'     , 2)
         | 
| 61 | 
            +
                le(  'elsif true'  , 2)
         | 
| 62 | 
            +
                ri(    '1'         , 2)
         | 
| 63 | 
            +
                le(  'else'        , 2)
         | 
| 64 | 
            +
                ri(    '1'         , 2)
         | 
| 65 | 
            +
                le(  'end'         , 1)
         | 
| 66 | 
            +
                ri(  'if 1'        , 2)
         | 
| 67 | 
            +
                ri(    'if 2'      , 3)
         | 
| 68 | 
            +
                le(    'end'       , 2)
         | 
| 69 | 
            +
                le(  'end'         , 1)
         | 
| 70 | 
            +
                le('end'           , 0)
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
              would 'unless else end' do
         | 
| 74 | 
            +
                ri('unless 1'      , 1)
         | 
| 75 | 
            +
                ri(  'unless 1'    , 2)
         | 
| 76 | 
            +
                ri(    '1'         , 2)
         | 
| 77 | 
            +
                le(  'end '        , 1)
         | 
| 78 | 
            +
                le('else'          , 1)
         | 
| 79 | 
            +
                ri(  '1'           , 1)
         | 
| 80 | 
            +
                le('end'           , 0)
         | 
| 81 | 
            +
              end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
              would 'case when else end' do
         | 
| 84 | 
            +
                ri('case 1'        , 1)
         | 
| 85 | 
            +
                le('when 1'        , 1)
         | 
| 86 | 
            +
                ri(  '1'           , 1)
         | 
| 87 | 
            +
                le('when 2'        , 1)
         | 
| 88 | 
            +
                ri('  if 1'        , 2)
         | 
| 89 | 
            +
                le('  end'         , 1)
         | 
| 90 | 
            +
                le('else'          , 1)
         | 
| 91 | 
            +
                ri(  '1'           , 1)
         | 
| 92 | 
            +
                le('end'           , 0)
         | 
| 93 | 
            +
              end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
              would 'def end' do
         | 
| 96 | 
            +
                ri('def f a'       , 1)
         | 
| 97 | 
            +
                ri(  'if a'        , 2)
         | 
| 98 | 
            +
                le(  'end'         , 1)
         | 
| 99 | 
            +
                le('end'           , 0)
         | 
| 100 | 
            +
              end
         | 
| 101 | 
            +
             | 
| 102 | 
            +
              would 'class Object end' do
         | 
| 103 | 
            +
                ri('class Object'  , 1)
         | 
| 104 | 
            +
                ri(  'if true'     , 2)
         | 
| 105 | 
            +
                le(  'end'         , 1)
         | 
| 106 | 
            +
                le('end'           , 0)
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
              would 'module Rib end' do
         | 
| 110 | 
            +
                ri('module Rib'    , 1)
         | 
| 111 | 
            +
                ri(  'module_function', 1)
         | 
| 112 | 
            +
                ri(  'if true'     , 2)
         | 
| 113 | 
            +
                le(  'end'         , 1)
         | 
| 114 | 
            +
                le('end'           , 0)
         | 
| 115 | 
            +
              end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
              would 'while end' do
         | 
| 118 | 
            +
                ri('while false'   , 1)
         | 
| 119 | 
            +
                ri(  'if true'     , 2)
         | 
| 120 | 
            +
                le(  'end'         , 1)
         | 
| 121 | 
            +
                le('end'           , 0)
         | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
              would 'until end' do
         | 
| 125 | 
            +
                ri('until true'    , 1)
         | 
| 126 | 
            +
                ri(  'if true'     , 2)
         | 
| 127 | 
            +
                le(  'end'         , 1)
         | 
| 128 | 
            +
                le('end'           , 0)
         | 
| 129 | 
            +
              end
         | 
| 130 | 
            +
             | 
| 131 | 
            +
              would 'do end' do
         | 
| 132 | 
            +
                ri("to_s''do"      , 1)
         | 
| 133 | 
            +
                ri(  "to_s '' do"  , 2)
         | 
| 134 | 
            +
                le(  'end'         , 1)
         | 
| 135 | 
            +
                ri(  'to_s "" do'  , 2)
         | 
| 136 | 
            +
                le(  'end'         , 1)
         | 
| 137 | 
            +
                ri(  'to_s // do'  , 2)
         | 
| 138 | 
            +
                le(  'end'         , 1)
         | 
| 139 | 
            +
                le('end'           , 0)
         | 
| 140 | 
            +
              end
         | 
| 141 | 
            +
            end
         | 
    
        data/test/more/test_color.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ require 'rib/test' | |
| 3 3 | 
             
            require 'rib/more/color'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Rib::Color do
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              paste :rib
         | 
| 7 7 |  | 
| 8 8 | 
             
              color = Class.new do
         | 
| 9 9 | 
             
                include Rib::Color
         | 
| @@ -12,7 +12,7 @@ describe Rib::Color do | |
| 12 12 | 
             
                end
         | 
| 13 13 | 
             
              end.new
         | 
| 14 14 |  | 
| 15 | 
            -
               | 
| 15 | 
            +
              would 'give correct color' do
         | 
| 16 16 | 
             
                color.send(:format_color,
         | 
| 17 17 | 
             
                  [{0 => :a}, 'b', [nil, {false => Object}], {true => Exception.new}]).
         | 
| 18 18 | 
             
                    should.eq \
         | 
| @@ -24,7 +24,7 @@ describe Rib::Color do | |
| 24 24 | 
             
                      "\e[0m\e[34m}\e[0m\e[34m]\e[0m"
         | 
| 25 25 | 
             
              end
         | 
| 26 26 |  | 
| 27 | 
            -
               | 
| 27 | 
            +
              would 'inspect recursive array and hash just like built-in inspect' do
         | 
| 28 28 | 
             
                a = []
         | 
| 29 29 | 
             
                a << a
         | 
| 30 30 | 
             
                h = {}
         | 
| @@ -36,7 +36,7 @@ describe Rib::Color do | |
| 36 36 | 
             
              end
         | 
| 37 37 |  | 
| 38 38 | 
             
              # regression test
         | 
| 39 | 
            -
               | 
| 39 | 
            +
              would "colorize errors with `/' inside" do
         | 
| 40 40 | 
             
                i = if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
         | 
| 41 41 | 
             
                      1
         | 
| 42 42 | 
             
                    else
         | 
| @@ -4,8 +4,8 @@ require 'rib/test/multiline' | |
| 4 4 | 
             
            require 'rib/more/multiline_history'
         | 
| 5 5 |  | 
| 6 6 | 
             
            describe Rib::MultilineHistory do
         | 
| 7 | 
            -
               | 
| 8 | 
            -
               | 
| 7 | 
            +
              paste :rib
         | 
| 8 | 
            +
              paste :setup_multiline
         | 
| 9 9 |  | 
| 10 10 | 
             
              def check str, err=nil
         | 
| 11 11 | 
             
                @shell.history.clear
         | 
| @@ -37,6 +37,6 @@ describe Rib::MultilineHistory do | |
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 39 | 
             
              test_for Rib::History, Rib::Multiline, Rib::MultilineHistory do
         | 
| 40 | 
            -
                 | 
| 40 | 
            +
                paste :multiline
         | 
| 41 41 | 
             
              end
         | 
| 42 42 | 
             
            end
         | 
    
        data/test/test_api.rb
    CHANGED
    
    | @@ -3,10 +3,10 @@ require 'rib/test' | |
| 3 3 | 
             
            require 'rib/shell'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Rib::API do
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              paste :rib
         | 
| 7 7 |  | 
| 8 8 | 
             
              Rib::API.instance_methods.delete_if{ |e| e[/=$/] }.each do |meth|
         | 
| 9 | 
            -
                 | 
| 9 | 
            +
                would "##{meth} be accessible to plugins" do
         | 
| 10 10 | 
             
                  mod = Module.new do
         | 
| 11 11 | 
             
                    define_method meth do
         | 
| 12 12 | 
             
                      "pong_#{meth}"
         | 
    
        data/test/test_plugin.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ require 'rib/test' | |
| 3 3 | 
             
            require 'rib/all'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Rib::Plugin do
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              paste :rib
         | 
| 7 7 |  | 
| 8 8 | 
             
              before do
         | 
| 9 9 | 
             
                @names = Dir[File.expand_path(
         | 
| @@ -12,7 +12,7 @@ describe Rib::Plugin do | |
| 12 12 | 
             
                @mods  = Rib.plugins
         | 
| 13 13 | 
             
              end
         | 
| 14 14 |  | 
| 15 | 
            -
               | 
| 15 | 
            +
              would 'have shortcut methods' do
         | 
| 16 16 | 
             
                @names.each{ |name|
         | 
| 17 17 | 
             
                  %w[enable disable].each{ |meth|
         | 
| 18 18 | 
             
                    Rib.respond_to?("#{meth}_#{name}").should == true
         | 
| @@ -23,7 +23,7 @@ describe Rib::Plugin do | |
| 23 23 | 
             
                }
         | 
| 24 24 | 
             
              end
         | 
| 25 25 |  | 
| 26 | 
            -
               | 
| 26 | 
            +
              would 'be the same as mod methods' do
         | 
| 27 27 | 
             
                @mods.shuffle.take(@mods.size/2).each(&:disable)
         | 
| 28 28 | 
             
                @names.each{ |name|
         | 
| 29 29 | 
             
                  %w[enabled? disabled?].each{ |meth|
         | 
    
        data/test/test_runner.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ require 'rib/test' | |
| 3 3 | 
             
            require 'rib/runner'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Rib::Runner do
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              paste :rib
         | 
| 7 7 |  | 
| 8 8 | 
             
              before do
         | 
| 9 9 | 
             
                Rib.disable_plugins
         | 
| @@ -21,13 +21,13 @@ describe Rib::Runner do | |
| 21 21 | 
             
                mock(@shell).puts{}
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 | 
            -
               | 
| 24 | 
            +
              would '-e' do
         | 
| 25 25 | 
             
                 input('a')
         | 
| 26 26 | 
             
                output('1')
         | 
| 27 27 | 
             
                Rib::Runner.run(%w[-ea=1]).should.eq @shell
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 | 
            -
               | 
| 30 | 
            +
              would '-e nothing' do
         | 
| 31 31 | 
             
                 input
         | 
| 32 32 | 
             
                output
         | 
| 33 33 | 
             
                Rib::Runner.run(%w[-e]).should.eq @shell
         | 
| @@ -44,11 +44,11 @@ describe Rib::Runner do | |
| 44 44 | 
             
                Rib::Runner.run(argv).should.eq @shell
         | 
| 45 45 | 
             
              end
         | 
| 46 46 |  | 
| 47 | 
            -
               | 
| 47 | 
            +
              would 'min -e' do
         | 
| 48 48 | 
             
                verify_app_e(%w[min -ea=1])
         | 
| 49 49 | 
             
              end
         | 
| 50 50 |  | 
| 51 | 
            -
               | 
| 51 | 
            +
              would '-e min' do
         | 
| 52 52 | 
             
                verify_app_e(%w[-ea=1 min])
         | 
| 53 53 | 
             
              end
         | 
| 54 54 | 
             
            end
         | 
    
        data/test/test_shell.rb
    CHANGED
    
    | @@ -3,7 +3,7 @@ require 'rib/test' | |
| 3 3 | 
             
            require 'rib/shell'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe Rib::Shell do
         | 
| 6 | 
            -
               | 
| 6 | 
            +
              paste :rib
         | 
| 7 7 |  | 
| 8 8 | 
             
              before do
         | 
| 9 9 | 
             
                Rib.disable_plugins
         | 
| @@ -20,11 +20,11 @@ describe Rib::Shell do | |
| 20 20 | 
             
                  shell.loop
         | 
| 21 21 | 
             
                  true.should.eq true
         | 
| 22 22 | 
             
                end
         | 
| 23 | 
            -
                 | 
| 24 | 
            -
                 | 
| 25 | 
            -
                 | 
| 26 | 
            -
                 | 
| 27 | 
            -
                 | 
| 23 | 
            +
                would 'exit'      do                               input('exit' ) end
         | 
| 24 | 
            +
                would 'also exit' do                               input(' exit') end
         | 
| 25 | 
            +
                would 'ctrl+d'    do mock(shell).puts{}         ; input(nil)     end
         | 
| 26 | 
            +
                would ':q'        do shell.config[:exit] << ':q'; input(':q')    end
         | 
| 27 | 
            +
                would '\q'        do shell.config[:exit] << '\q'; input('\q')    end
         | 
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 30 | 
             
              describe '#loop_once' do
         | 
| @@ -38,34 +38,34 @@ describe Rib::Shell do | |
| 38 38 | 
             
                  true.should.eq true
         | 
| 39 39 | 
             
                end
         | 
| 40 40 |  | 
| 41 | 
            -
                 | 
| 41 | 
            +
                would 'handles ctrl+c' do
         | 
| 42 42 | 
             
                  mock(shell).handle_interrupt{}
         | 
| 43 43 | 
             
                  input{ raise Interrupt }
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 | 
            -
                 | 
| 46 | 
            +
                would 'prints result' do
         | 
| 47 47 | 
             
                  mock(shell).puts('=> "mm"'){}
         | 
| 48 48 | 
             
                  input('"m" * 2')
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                 | 
| 51 | 
            +
                would 'error in print_result' do
         | 
| 52 52 | 
             
                  mock(Rib).warn(match(/Error while printing result.*BOOM/m)){}
         | 
| 53 53 | 
             
                  input('obj = Object.new; def obj.inspect; raise "BOOM"; end; obj')
         | 
| 54 54 | 
             
                end
         | 
| 55 55 |  | 
| 56 | 
            -
                 | 
| 56 | 
            +
                would 'not crash if user input is a blackhole' do
         | 
| 57 57 | 
             
                  mock(Rib).warn(match(/Error while printing result/)){}
         | 
| 58 58 | 
             
                  input('Rib::Blackhole')
         | 
| 59 59 | 
             
                end
         | 
| 60 60 |  | 
| 61 | 
            -
                 | 
| 61 | 
            +
                would 'print error from eval' do
         | 
| 62 62 | 
             
                  mock(shell).puts(match(/RuntimeError/)){}
         | 
| 63 63 | 
             
                  input('raise "blah"')
         | 
| 64 64 | 
             
                end
         | 
| 65 65 | 
             
              end
         | 
| 66 66 |  | 
| 67 67 | 
             
              describe '#prompt' do
         | 
| 68 | 
            -
                 | 
| 68 | 
            +
                would 'be changeable' do
         | 
| 69 69 | 
             
                  shell.config[:prompt] = '> '
         | 
| 70 70 | 
             
                  shell.prompt.should.eq  '> '
         | 
| 71 71 | 
             
                end
         | 
| @@ -76,12 +76,12 @@ describe Rib::Shell do | |
| 76 76 | 
             
                  @line = shell.config[:line]
         | 
| 77 77 | 
             
                end
         | 
| 78 78 |  | 
| 79 | 
            -
                 | 
| 79 | 
            +
                would 'line' do
         | 
| 80 80 | 
             
                  shell.eval_input('10 ** 2')
         | 
| 81 81 | 
             
                  shell.config[:line].should.eq @line + 1
         | 
| 82 82 | 
             
                end
         | 
| 83 83 |  | 
| 84 | 
            -
                 | 
| 84 | 
            +
                would 'print error and increments line' do
         | 
| 85 85 | 
             
                  result, err = shell.eval_input('{')
         | 
| 86 86 | 
             
                  result.should.eq nil
         | 
| 87 87 | 
             
                  err.should.kind_of?(SyntaxError)
         | 
| @@ -89,22 +89,22 @@ describe Rib::Shell do | |
| 89 89 | 
             
                end
         | 
| 90 90 | 
             
              end
         | 
| 91 91 |  | 
| 92 | 
            -
               | 
| 92 | 
            +
              would 'call after_loop even if in_loop raises' do
         | 
| 93 93 | 
             
                mock(shell).loop_once{ raise 'boom' }
         | 
| 94 94 | 
             
                mock(Rib).warn(is_a(String)){}
         | 
| 95 95 | 
             
                mock(shell).after_loop{}
         | 
| 96 96 | 
             
                lambda{shell.loop}.should.raise(RuntimeError)
         | 
| 97 97 | 
             
              end
         | 
| 98 98 |  | 
| 99 | 
            -
               | 
| 100 | 
            -
                shell.eval_input('local_variables').first.should.empty
         | 
| 99 | 
            +
              would 'have empty binding' do
         | 
| 100 | 
            +
                shell.eval_input('local_variables').first.should.empty?
         | 
| 101 101 | 
             
              end
         | 
| 102 102 |  | 
| 103 | 
            -
               | 
| 103 | 
            +
              would 'not pollute main' do
         | 
| 104 104 | 
             
                shell.eval_input('main').first.should.eq 'rib'
         | 
| 105 105 | 
             
              end
         | 
| 106 106 |  | 
| 107 | 
            -
               | 
| 107 | 
            +
              would 'warn on removing main' do
         | 
| 108 108 | 
             
                TOPLEVEL_BINDING.eval <<-RUBY
         | 
| 109 109 | 
             
                  singleton_class.module_eval do
         | 
| 110 110 | 
             
                    def main; end
         | 
| @@ -114,7 +114,7 @@ describe Rib::Shell do | |
| 114 114 | 
             
                shell.eval_input('main').first.should.eq 'rib'
         | 
| 115 115 | 
             
              end
         | 
| 116 116 |  | 
| 117 | 
            -
               | 
| 117 | 
            +
              would 'be main' do
         | 
| 118 118 | 
             
                shell.eval_input('self.inspect').first.should.eq 'main'
         | 
| 119 119 | 
             
              end
         | 
| 120 120 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rib
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Lin Jen-Shin (godfat)
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-11-07 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: |-
         | 
| 14 14 | 
             
              Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
         | 
| @@ -68,7 +68,6 @@ files: | |
| 68 68 | 
             
            - lib/rib/core/underscore.rb
         | 
| 69 69 | 
             
            - lib/rib/debug.rb
         | 
| 70 70 | 
             
            - lib/rib/extra/autoindent.rb
         | 
| 71 | 
            -
            - lib/rib/extra/debugger.rb
         | 
| 72 71 | 
             
            - lib/rib/extra/hirb.rb
         | 
| 73 72 | 
             
            - lib/rib/extra/paging.rb
         | 
| 74 73 | 
             
            - lib/rib/more.rb
         | 
| @@ -77,7 +76,6 @@ files: | |
| 77 76 | 
             
            - lib/rib/more/edit.rb
         | 
| 78 77 | 
             
            - lib/rib/more/multiline_history.rb
         | 
| 79 78 | 
             
            - lib/rib/more/multiline_history_file.rb
         | 
| 80 | 
            -
            - lib/rib/patch/debugger.rb
         | 
| 81 79 | 
             
            - lib/rib/plugin.rb
         | 
| 82 80 | 
             
            - lib/rib/runner.rb
         | 
| 83 81 | 
             
            - lib/rib/shell.rb
         | 
| @@ -94,6 +92,7 @@ files: | |
| 94 92 | 
             
            - test/core/test_readline.rb
         | 
| 95 93 | 
             
            - test/core/test_squeeze_history.rb
         | 
| 96 94 | 
             
            - test/core/test_underscore.rb
         | 
| 95 | 
            +
            - test/extra/test_autoindent.rb
         | 
| 97 96 | 
             
            - test/more/test_color.rb
         | 
| 98 97 | 
             
            - test/more/test_multiline_history.rb
         | 
| 99 98 | 
             
            - test/test_api.rb
         | 
| @@ -120,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 120 119 | 
             
                  version: '0'
         | 
| 121 120 | 
             
            requirements: []
         | 
| 122 121 | 
             
            rubyforge_project: 
         | 
| 123 | 
            -
            rubygems_version: 2. | 
| 122 | 
            +
            rubygems_version: 2.4.2
         | 
| 124 123 | 
             
            signing_key: 
         | 
| 125 124 | 
             
            specification_version: 4
         | 
| 126 125 | 
             
            summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
         | 
| @@ -131,6 +130,7 @@ test_files: | |
| 131 130 | 
             
            - test/core/test_readline.rb
         | 
| 132 131 | 
             
            - test/core/test_squeeze_history.rb
         | 
| 133 132 | 
             
            - test/core/test_underscore.rb
         | 
| 133 | 
            +
            - test/extra/test_autoindent.rb
         | 
| 134 134 | 
             
            - test/more/test_color.rb
         | 
| 135 135 | 
             
            - test/more/test_multiline_history.rb
         | 
| 136 136 | 
             
            - test/test_api.rb
         | 
    
        data/lib/rib/extra/debugger.rb
    DELETED
    
    | @@ -1,146 +0,0 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            require 'rib/more/anchor'
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            module Rib::Debugger
         | 
| 5 | 
            -
              extend Rib::Plugin
         | 
| 6 | 
            -
              Shell.use(self)
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              ExcludedCommands = %w[irb quit exit backtrace eval p pp ps]
         | 
| 9 | 
            -
               WrappedCommands = %w[help where edit reload]
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              # --------------- Rib API ---------------
         | 
| 12 | 
            -
             | 
| 13 | 
            -
              def before_loop
         | 
| 14 | 
            -
                return super if Debugger.disabled?
         | 
| 15 | 
            -
                ::Debugger.handler = self
         | 
| 16 | 
            -
                bound_object.extend(Imp)
         | 
| 17 | 
            -
                @debugger_state ||= config[:debugger_state]
         | 
| 18 | 
            -
                @debugger_watch ||= config[:debugger_watch]
         | 
| 19 | 
            -
                bound_object.display(debugger_watch.shift) until debugger_watch.empty?
         | 
| 20 | 
            -
                super
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              # --------------- Plugin API ---------------
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def debugger_watch
         | 
| 26 | 
            -
                @debugger_watch ||= []
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              def debugger_state
         | 
| 30 | 
            -
                @debugger_state ||= config[:debugger_state] ||
         | 
| 31 | 
            -
                  ::Debugger::CommandProcessor::State.new{ |s|
         | 
| 32 | 
            -
                    commands = ::Debugger::Command.commands.select{ |cmd|
         | 
| 33 | 
            -
                      cmd.event                                                      &&
         | 
| 34 | 
            -
                      (!config[:debugger_context].dead? || cmd.allow_in_post_mortem) &&
         | 
| 35 | 
            -
                      !ExcludedCommands.include?([cmd.help_command].flatten.first)
         | 
| 36 | 
            -
                    }
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                    s.context = config[:debugger_context]
         | 
| 39 | 
            -
                    s.file    = config[:debugger_file]
         | 
| 40 | 
            -
                    s.line    = config[:debugger_line]
         | 
| 41 | 
            -
                    s.binding = config[:debugger_context].frame_binding(0)
         | 
| 42 | 
            -
                    s.display = []
         | 
| 43 | 
            -
                    s.interface = ::Debugger::LocalInterface.new
         | 
| 44 | 
            -
                    s.commands  = commands
         | 
| 45 | 
            -
                  }
         | 
| 46 | 
            -
              end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
              # Callback for the debugger
         | 
| 49 | 
            -
              def at_line context, file, line
         | 
| 50 | 
            -
                return if Debugger.disabled?
         | 
| 51 | 
            -
                path = "#{file}:#{line}:in #{caller[1][/`.+?'/]}"
         | 
| 52 | 
            -
                msg0 = if Rib.const_defined?(:StripBacktrace) && StripBacktrace.enabled?
         | 
| 53 | 
            -
                         StripBacktrace.strip_backtrace([path])
         | 
| 54 | 
            -
                       else
         | 
| 55 | 
            -
                         [path]
         | 
| 56 | 
            -
                       end
         | 
| 57 | 
            -
                msg1 = if Rib.const_defined?(:Color) && Color.enabled?
         | 
| 58 | 
            -
                         Color.colorize_backtrace(msg0)
         | 
| 59 | 
            -
                       else
         | 
| 60 | 
            -
                         [msg0].flatten
         | 
| 61 | 
            -
                       end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                Rib.say(msg1.first)
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                if @debugger_state
         | 
| 66 | 
            -
                  @debugger_state.context = context
         | 
| 67 | 
            -
                  @debugger_state.file    = file
         | 
| 68 | 
            -
                  @debugger_state.line    = line
         | 
| 69 | 
            -
                end
         | 
| 70 | 
            -
                Rib::Anchor.enable
         | 
| 71 | 
            -
                Rib.anchor(context.frame_binding(0), :prompt_anchor => false,
         | 
| 72 | 
            -
                  :debugger_context => context,
         | 
| 73 | 
            -
                  :debugger_file    => file   ,
         | 
| 74 | 
            -
                  :debugger_line    => line   ,
         | 
| 75 | 
            -
                  :debugger_state   => @debugger_state,
         | 
| 76 | 
            -
                  :debugger_watch   => @debugger_watch)
         | 
| 77 | 
            -
                ::Debugger.stop
         | 
| 78 | 
            -
              rescue Exception => e
         | 
| 79 | 
            -
                Rib.warn("Error while calling at_line:\n  #{format_error(e)}")
         | 
| 80 | 
            -
              end
         | 
| 81 | 
            -
             | 
| 82 | 
            -
              module Imp
         | 
| 83 | 
            -
                def debug
         | 
| 84 | 
            -
                  return if Rib::Debugger.disabled?
         | 
| 85 | 
            -
                  ::Debugger.handler = Rib.shell
         | 
| 86 | 
            -
                  ::Debugger.start
         | 
| 87 | 
            -
                  ::Debugger.current_context.stop_frame = 0
         | 
| 88 | 
            -
                end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                # You can `Rib.watch` a number of expressions before calling `Rib.debug`
         | 
| 91 | 
            -
                def watch *strs
         | 
| 92 | 
            -
                  Rib.shell.debugger_watch.concat(strs)
         | 
| 93 | 
            -
                end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                def step times=1
         | 
| 96 | 
            -
                  ::Debugger.current_context.step(times)
         | 
| 97 | 
            -
                  display
         | 
| 98 | 
            -
                  throw :rib_exit, Rib::Skip
         | 
| 99 | 
            -
                end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                WrappedCommands.each{ |cmd|
         | 
| 102 | 
            -
                  module_eval <<-RUBY
         | 
| 103 | 
            -
                    def #{cmd} *args
         | 
| 104 | 
            -
                      debugger_execute('#{cmd}', args)
         | 
| 105 | 
            -
                    end
         | 
| 106 | 
            -
                  RUBY
         | 
| 107 | 
            -
                }
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                def display *args
         | 
| 110 | 
            -
                  if args.empty?
         | 
| 111 | 
            -
                    debugger_execute('display', args, 'Display')
         | 
| 112 | 
            -
                  else
         | 
| 113 | 
            -
                    debugger_execute('display', args, 'AddDisplay')
         | 
| 114 | 
            -
                  end
         | 
| 115 | 
            -
                end
         | 
| 116 | 
            -
                alias_method :disp, :display
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                def list *args
         | 
| 119 | 
            -
                  debugger_execute('list', args, 'List', Rib.shell.debugger_state.dup)
         | 
| 120 | 
            -
                end
         | 
| 121 | 
            -
                alias_method :ls, :list
         | 
| 122 | 
            -
             | 
| 123 | 
            -
                def debugger_execute command, args=[], name=command.capitalize,
         | 
| 124 | 
            -
                                     state=Rib.shell.debugger_state
         | 
| 125 | 
            -
                  const = "#{name}Command"
         | 
| 126 | 
            -
                  arg = if args.empty? then '' else " #{args.join(' ')}" end
         | 
| 127 | 
            -
                  cmd = ::Debugger.const_get(const).new(state)
         | 
| 128 | 
            -
                  cmd.match("#{command}#{arg}\n")
         | 
| 129 | 
            -
                  cmd.execute
         | 
| 130 | 
            -
                  Rib::Skip
         | 
| 131 | 
            -
                end
         | 
| 132 | 
            -
              end
         | 
| 133 | 
            -
             | 
| 134 | 
            -
              Rib.extend(Imp)
         | 
| 135 | 
            -
            end
         | 
| 136 | 
            -
             | 
| 137 | 
            -
            begin
         | 
| 138 | 
            -
              Rib.silence{ require 'debugger' }
         | 
| 139 | 
            -
              require 'rib/patch/debugger'
         | 
| 140 | 
            -
            rescue LoadError => e
         | 
| 141 | 
            -
              Rib.warn("Error: #{e}"                                      ,
         | 
| 142 | 
            -
                       "Please install debugger to use debugger plugin:\n",
         | 
| 143 | 
            -
                       "    gem install debugger\n"                       ,
         | 
| 144 | 
            -
                       "Or add debugger to Gemfile if that's the case")
         | 
| 145 | 
            -
              Rib::Debugger.disable
         | 
| 146 | 
            -
            end
         | 
    
        data/lib/rib/patch/debugger.rb
    DELETED
    
    | @@ -1,13 +0,0 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            # never make those convenient methods public!
         | 
| 3 | 
            -
            Kernel.module_eval{ private :debugger }
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            # remove alias 'backtrace'
         | 
| 6 | 
            -
            class ::Debugger::WhereCommand
         | 
| 7 | 
            -
              def self.help_command
         | 
| 8 | 
            -
                'where'
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            # please have a more consistent name
         | 
| 13 | 
            -
            ::Debugger::EditCommand = ::Debugger::Edit
         |