pry 0.9.10pre1-i386-mingw32 → 0.9.11-i386-mingw32
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.
- data/.travis.yml +3 -1
 - data/CHANGELOG +63 -2
 - data/CONTRIBUTORS +43 -25
 - data/Gemfile +7 -0
 - data/Guardfile +62 -0
 - data/README.markdown +4 -4
 - data/Rakefile +34 -35
 - data/lib/pry.rb +107 -54
 - data/lib/pry/cli.rb +34 -11
 - data/lib/pry/code.rb +165 -182
 - data/lib/pry/code/code_range.rb +70 -0
 - data/lib/pry/code/loc.rb +92 -0
 - data/lib/pry/code_object.rb +153 -0
 - data/lib/pry/command.rb +160 -22
 - data/lib/pry/command_set.rb +37 -26
 - data/lib/pry/commands.rb +4 -27
 - data/lib/pry/commands/amend_line.rb +99 -0
 - data/lib/pry/commands/bang.rb +20 -0
 - data/lib/pry/commands/bang_pry.rb +17 -0
 - data/lib/pry/commands/cat.rb +53 -0
 - data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
 - data/lib/pry/commands/cat/exception_formatter.rb +78 -0
 - data/lib/pry/commands/cat/file_formatter.rb +84 -0
 - data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
 - data/lib/pry/commands/cd.rb +30 -0
 - data/lib/pry/commands/code_collector.rb +165 -0
 - data/lib/pry/commands/deprecated_commands.rb +2 -0
 - data/lib/pry/commands/disable_pry.rb +27 -0
 - data/lib/pry/commands/easter_eggs.rb +112 -0
 - data/lib/pry/commands/edit.rb +206 -0
 - data/lib/pry/commands/edit/exception_patcher.rb +25 -0
 - data/lib/pry/commands/edit/file_and_line_locator.rb +38 -0
 - data/lib/pry/commands/edit/method_patcher.rb +122 -0
 - data/lib/pry/commands/exit.rb +42 -0
 - data/lib/pry/commands/exit_all.rb +29 -0
 - data/lib/pry/commands/exit_program.rb +24 -0
 - data/lib/pry/commands/find_method.rb +199 -0
 - data/lib/pry/commands/fix_indent.rb +19 -0
 - data/lib/pry/commands/gem_cd.rb +26 -0
 - data/lib/pry/commands/gem_install.rb +29 -0
 - data/lib/pry/commands/gem_list.rb +33 -0
 - data/lib/pry/commands/gem_open.rb +29 -0
 - data/lib/pry/commands/gist.rb +95 -0
 - data/lib/pry/commands/help.rb +164 -0
 - data/lib/pry/commands/hist.rb +161 -0
 - data/lib/pry/commands/import_set.rb +22 -0
 - data/lib/pry/commands/install_command.rb +51 -0
 - data/lib/pry/commands/jump_to.rb +29 -0
 - data/lib/pry/commands/ls.rb +339 -0
 - data/lib/pry/commands/nesting.rb +25 -0
 - data/lib/pry/commands/play.rb +69 -0
 - data/lib/pry/commands/pry_backtrace.rb +26 -0
 - data/lib/pry/commands/pry_version.rb +17 -0
 - data/lib/pry/commands/raise_up.rb +32 -0
 - data/lib/pry/commands/reload_code.rb +39 -0
 - data/lib/pry/commands/reset.rb +18 -0
 - data/lib/pry/commands/ri.rb +56 -0
 - data/lib/pry/commands/save_file.rb +61 -0
 - data/lib/pry/commands/shell_command.rb +43 -0
 - data/lib/pry/commands/shell_mode.rb +27 -0
 - data/lib/pry/commands/show_doc.rb +78 -0
 - data/lib/pry/commands/show_info.rb +139 -0
 - data/lib/pry/commands/show_input.rb +17 -0
 - data/lib/pry/commands/show_source.rb +37 -0
 - data/lib/pry/commands/simple_prompt.rb +22 -0
 - data/lib/pry/commands/stat.rb +40 -0
 - data/lib/pry/commands/switch_to.rb +23 -0
 - data/lib/pry/commands/toggle_color.rb +20 -0
 - data/lib/pry/commands/whereami.rb +114 -0
 - data/lib/pry/commands/wtf.rb +57 -0
 - data/lib/pry/completion.rb +120 -46
 - data/lib/pry/config.rb +11 -0
 - data/lib/pry/core_extensions.rb +30 -19
 - data/lib/pry/editor.rb +129 -0
 - data/lib/pry/helpers.rb +1 -0
 - data/lib/pry/helpers/base_helpers.rb +89 -119
 - data/lib/pry/helpers/command_helpers.rb +7 -122
 - data/lib/pry/helpers/table.rb +100 -0
 - data/lib/pry/helpers/text.rb +4 -4
 - data/lib/pry/history_array.rb +5 -0
 - data/lib/pry/hooks.rb +1 -3
 - data/lib/pry/indent.rb +104 -30
 - data/lib/pry/method.rb +66 -22
 - data/lib/pry/module_candidate.rb +26 -15
 - data/lib/pry/pager.rb +70 -0
 - data/lib/pry/plugins.rb +1 -2
 - data/lib/pry/pry_class.rb +63 -22
 - data/lib/pry/pry_instance.rb +58 -37
 - data/lib/pry/rubygem.rb +74 -0
 - data/lib/pry/terminal_info.rb +43 -0
 - data/lib/pry/test/helper.rb +185 -0
 - data/lib/pry/version.rb +1 -1
 - data/lib/pry/wrapped_module.rb +58 -24
 - data/pry.gemspec +21 -37
 - data/{test/test_cli.rb → spec/cli_spec.rb} +0 -0
 - data/spec/code_object_spec.rb +277 -0
 - data/{test/test_code.rb → spec/code_spec.rb} +19 -1
 - data/{test/test_command_helpers.rb → spec/command_helpers_spec.rb} +0 -0
 - data/{test/test_command_integration.rb → spec/command_integration_spec.rb} +38 -46
 - data/{test/test_command_set.rb → spec/command_set_spec.rb} +18 -1
 - data/{test/test_command.rb → spec/command_spec.rb} +250 -149
 - data/spec/commands/amend_line_spec.rb +247 -0
 - data/spec/commands/bang_spec.rb +19 -0
 - data/spec/commands/cat_spec.rb +164 -0
 - data/spec/commands/cd_spec.rb +250 -0
 - data/spec/commands/disable_pry_spec.rb +25 -0
 - data/spec/commands/edit_spec.rb +727 -0
 - data/spec/commands/exit_all_spec.rb +34 -0
 - data/spec/commands/exit_program_spec.rb +19 -0
 - data/spec/commands/exit_spec.rb +34 -0
 - data/{test/test_default_commands/test_find_method.rb → spec/commands/find_method_spec.rb} +27 -7
 - data/spec/commands/gem_list_spec.rb +26 -0
 - data/spec/commands/gist_spec.rb +75 -0
 - data/{test/test_default_commands/test_help.rb → spec/commands/help_spec.rb} +8 -9
 - data/spec/commands/hist_spec.rb +181 -0
 - data/spec/commands/jump_to_spec.rb +15 -0
 - data/spec/commands/ls_spec.rb +177 -0
 - data/spec/commands/play_spec.rb +140 -0
 - data/spec/commands/raise_up_spec.rb +56 -0
 - data/spec/commands/save_file_spec.rb +177 -0
 - data/spec/commands/show_doc_spec.rb +378 -0
 - data/spec/commands/show_input_spec.rb +17 -0
 - data/spec/commands/show_source_spec.rb +597 -0
 - data/spec/commands/whereami_spec.rb +154 -0
 - data/spec/completion_spec.rb +233 -0
 - data/spec/control_d_handler_spec.rb +58 -0
 - data/spec/editor_spec.rb +79 -0
 - data/{test/test_exception_whitelist.rb → spec/exception_whitelist_spec.rb} +0 -0
 - data/{test → spec/fixtures}/candidate_helper1.rb +0 -0
 - data/{test → spec/fixtures}/candidate_helper2.rb +0 -0
 - data/{test/test_default_commands → spec/fixtures}/example.erb +0 -0
 - data/spec/fixtures/example_nesting.rb +33 -0
 - data/spec/fixtures/show_source_doc_examples.rb +15 -0
 - data/{test → spec/fixtures}/testrc +0 -0
 - data/{test → spec/fixtures}/testrcbad +0 -0
 - data/spec/helper.rb +34 -0
 - data/spec/helpers/bacon.rb +86 -0
 - data/spec/helpers/mock_pry.rb +43 -0
 - data/spec/helpers/table_spec.rb +83 -0
 - data/{test/test_history_array.rb → spec/history_array_spec.rb} +21 -19
 - data/{test/test_hooks.rb → spec/hooks_spec.rb} +0 -0
 - data/{test/test_indent.rb → spec/indent_spec.rb} +24 -0
 - data/{test/test_input_stack.rb → spec/input_stack_spec.rb} +4 -0
 - data/{test/test_method.rb → spec/method_spec.rb} +65 -1
 - data/{test/test_prompt.rb → spec/prompt_spec.rb} +0 -0
 - data/{test/test_pry_defaults.rb → spec/pry_defaults_spec.rb} +14 -14
 - data/{test/test_pry_history.rb → spec/pry_history_spec.rb} +15 -0
 - data/spec/pry_output_spec.rb +95 -0
 - data/{test/test_pry.rb → spec/pry_spec.rb} +74 -32
 - data/{test/test_sticky_locals.rb → spec/sticky_locals_spec.rb} +27 -25
 - data/{test/test_syntax_checking.rb → spec/syntax_checking_spec.rb} +17 -1
 - data/{test/test_wrapped_module.rb → spec/wrapped_module_spec.rb} +92 -5
 - metadata +239 -115
 - data/examples/example_basic.rb +0 -15
 - data/examples/example_command_override.rb +0 -32
 - data/examples/example_commands.rb +0 -36
 - data/examples/example_hooks.rb +0 -9
 - data/examples/example_image_edit.rb +0 -67
 - data/examples/example_input.rb +0 -7
 - data/examples/example_input2.rb +0 -29
 - data/examples/example_output.rb +0 -11
 - data/examples/example_print.rb +0 -6
 - data/examples/example_prompt.rb +0 -9
 - data/examples/helper.rb +0 -6
 - data/lib/pry/default_commands/cd.rb +0 -81
 - data/lib/pry/default_commands/commands.rb +0 -62
 - data/lib/pry/default_commands/context.rb +0 -98
 - data/lib/pry/default_commands/easter_eggs.rb +0 -95
 - data/lib/pry/default_commands/editing.rb +0 -420
 - data/lib/pry/default_commands/find_method.rb +0 -169
 - data/lib/pry/default_commands/gems.rb +0 -84
 - data/lib/pry/default_commands/gist.rb +0 -187
 - data/lib/pry/default_commands/help.rb +0 -127
 - data/lib/pry/default_commands/hist.rb +0 -120
 - data/lib/pry/default_commands/input_and_output.rb +0 -306
 - data/lib/pry/default_commands/introspection.rb +0 -410
 - data/lib/pry/default_commands/ls.rb +0 -272
 - data/lib/pry/default_commands/misc.rb +0 -38
 - data/lib/pry/default_commands/navigating_pry.rb +0 -110
 - data/lib/pry/default_commands/whereami.rb +0 -92
 - data/lib/pry/extended_commands/experimental.rb +0 -7
 - data/test/helper.rb +0 -223
 - data/test/test_completion.rb +0 -62
 - data/test/test_control_d_handler.rb +0 -45
 - data/test/test_default_commands/test_cd.rb +0 -321
 - data/test/test_default_commands/test_context.rb +0 -288
 - data/test/test_default_commands/test_documentation.rb +0 -315
 - data/test/test_default_commands/test_gems.rb +0 -18
 - data/test/test_default_commands/test_input.rb +0 -428
 - data/test/test_default_commands/test_introspection.rb +0 -511
 - data/test/test_default_commands/test_ls.rb +0 -151
 - data/test/test_default_commands/test_shell.rb +0 -343
 - data/test/test_default_commands/test_show_source.rb +0 -432
 - data/test/test_pry_output.rb +0 -41
 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::ExitProgram < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'exit-program'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Navigating Pry'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description 'End the current program.'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Usage:   exit-program [--help]
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Aliases: quit-program
         
     | 
| 
      
 10 
     | 
    
         
            +
                           !!!
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  End the current program.
         
     | 
| 
      
 13 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def process
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Pry.save_history if Pry.config.history.should_save
         
     | 
| 
      
 17 
     | 
    
         
            +
                  Kernel.exit target.eval(arg_string).to_i
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::ExitProgram)
         
     | 
| 
      
 22 
     | 
    
         
            +
              Pry::Commands.alias_command 'quit-program', 'exit-program'
         
     | 
| 
      
 23 
     | 
    
         
            +
              Pry::Commands.alias_command '!!!', 'exit-program'
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,199 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::FindMethod < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                extend Pry::Helpers::BaseHelpers
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                match 'find-method'
         
     | 
| 
      
 6 
     | 
    
         
            +
                group 'Context'
         
     | 
| 
      
 7 
     | 
    
         
            +
                description 'Recursively search for a method within a Class/Module or the current namespace.'
         
     | 
| 
      
 8 
     | 
    
         
            +
                command_options :shellwords => false
         
     | 
| 
      
 9 
     | 
    
         
            +
                command_options :requires_gem => 'ruby18_source_location' if mri_18?
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 13 
     | 
    
         
            +
                  Usage: find-method  [-n|-c] METHOD [NAMESPACE]
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  Recursively search for a method within a Class/Module or the current namespace.
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Use the `-n` switch (the default) to search for methods whose name matches the
         
     | 
| 
      
 17 
     | 
    
         
            +
                  given regex. Use the `-c` switch to search for methods that contain the given
         
     | 
| 
      
 18 
     | 
    
         
            +
                  code.
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  # Find all methods whose name match /re/ inside
         
     | 
| 
      
 21 
     | 
    
         
            +
                  # the Pry namespace. Matches Pry#repl, etc.
         
     | 
| 
      
 22 
     | 
    
         
            +
                  find-method re Pry
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  # Find all methods that contain the code:
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # output.puts inside the Pry namepsace.
         
     | 
| 
      
 26 
     | 
    
         
            +
                  find-method -c 'output.puts' Pry
         
     | 
| 
      
 27 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 30 
     | 
    
         
            +
                  require 'ruby18_source_location' if mri_18?
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def options(opti)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  opti.on :n, :name,    "Search for a method by name"
         
     | 
| 
      
 35 
     | 
    
         
            +
                  opti.on :c, :content, "Search for a method based on content in Regex form"
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                def process
         
     | 
| 
      
 39 
     | 
    
         
            +
                  return if args.size < 1
         
     | 
| 
      
 40 
     | 
    
         
            +
                  klass = search_class
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  matches = if opts.content?
         
     | 
| 
      
 43 
     | 
    
         
            +
                    content_search(klass)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  else
         
     | 
| 
      
 45 
     | 
    
         
            +
                    name_search(klass)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  show_search_results(matches)
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                private
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                # @return [Regexp] The pattern to search for.
         
     | 
| 
      
 54 
     | 
    
         
            +
                def pattern
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @pattern ||= ::Regexp.new args[0]
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                # Output the result of the search.
         
     | 
| 
      
 59 
     | 
    
         
            +
                #
         
     | 
| 
      
 60 
     | 
    
         
            +
                # @param [Array] matches
         
     | 
| 
      
 61 
     | 
    
         
            +
                def show_search_results(matches)
         
     | 
| 
      
 62 
     | 
    
         
            +
                  if matches.empty?
         
     | 
| 
      
 63 
     | 
    
         
            +
                    output.puts text.bold("No Methods Matched")
         
     | 
| 
      
 64 
     | 
    
         
            +
                  else
         
     | 
| 
      
 65 
     | 
    
         
            +
                    print_matches(matches)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                # The class to search for methods.
         
     | 
| 
      
 70 
     | 
    
         
            +
                # We only search classes, so if the search object is an
         
     | 
| 
      
 71 
     | 
    
         
            +
                # instance, return its class. If no search object is given
         
     | 
| 
      
 72 
     | 
    
         
            +
                # search `target_self`.
         
     | 
| 
      
 73 
     | 
    
         
            +
                def search_class
         
     | 
| 
      
 74 
     | 
    
         
            +
                  klass = if args[1]
         
     | 
| 
      
 75 
     | 
    
         
            +
                            target.eval(args[1])
         
     | 
| 
      
 76 
     | 
    
         
            +
                          else
         
     | 
| 
      
 77 
     | 
    
         
            +
                            target_self
         
     | 
| 
      
 78 
     | 
    
         
            +
                          end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                  klass.is_a?(Module) ? klass : klass.class
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                # pretty-print a list of matching methods.
         
     | 
| 
      
 84 
     | 
    
         
            +
                #
         
     | 
| 
      
 85 
     | 
    
         
            +
                # @param Array[Method]
         
     | 
| 
      
 86 
     | 
    
         
            +
                def print_matches(matches)
         
     | 
| 
      
 87 
     | 
    
         
            +
                  grouped = matches.group_by(&:owner)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  order = grouped.keys.sort_by{ |x| x.name || x.to_s }
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  order.each do |klass|
         
     | 
| 
      
 91 
     | 
    
         
            +
                    print_matches_for_class(klass, grouped)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  end
         
     | 
| 
      
 93 
     | 
    
         
            +
                end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                # Print matched methods for a class
         
     | 
| 
      
 96 
     | 
    
         
            +
                def print_matches_for_class(klass, grouped)
         
     | 
| 
      
 97 
     | 
    
         
            +
                  output.puts text.bold(klass.name)
         
     | 
| 
      
 98 
     | 
    
         
            +
                  grouped[klass].each do |method|
         
     | 
| 
      
 99 
     | 
    
         
            +
                    header = method.name_with_owner
         
     | 
| 
      
 100 
     | 
    
         
            +
                    output.puts header + additional_info(header, method)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                # Return the matched lines of method source if `-c` is given or ""
         
     | 
| 
      
 105 
     | 
    
         
            +
                # if `-c` was not given
         
     | 
| 
      
 106 
     | 
    
         
            +
                def additional_info(header, method)
         
     | 
| 
      
 107 
     | 
    
         
            +
                  if opts.content?
         
     | 
| 
      
 108 
     | 
    
         
            +
                    ": " + colorize_code(matched_method_lines(header, method))
         
     | 
| 
      
 109 
     | 
    
         
            +
                  else
         
     | 
| 
      
 110 
     | 
    
         
            +
                    ""
         
     | 
| 
      
 111 
     | 
    
         
            +
                  end
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                def matched_method_lines(header, method)
         
     | 
| 
      
 115 
     | 
    
         
            +
                  method.source.split(/\n/).select {|x| x =~ pattern }.join("\n#{' ' * header.length}")
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                # Run the given block against every constant in the provided namespace.
         
     | 
| 
      
 119 
     | 
    
         
            +
                #
         
     | 
| 
      
 120 
     | 
    
         
            +
                # @param Module  The namespace in which to start the search.
         
     | 
| 
      
 121 
     | 
    
         
            +
                # @param Hash[Module,Boolean]  The namespaces we've already visited (private)
         
     | 
| 
      
 122 
     | 
    
         
            +
                # @yieldparam klazz  Each class/module in the namespace.
         
     | 
| 
      
 123 
     | 
    
         
            +
                #
         
     | 
| 
      
 124 
     | 
    
         
            +
                def recurse_namespace(klass, done={}, &block)
         
     | 
| 
      
 125 
     | 
    
         
            +
                  return if !(Module === klass) || done[klass]
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                  done[klass] = true
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  yield klass
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                  klass.constants.each do |name|
         
     | 
| 
      
 132 
     | 
    
         
            +
                    next if klass.autoload?(name)
         
     | 
| 
      
 133 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 134 
     | 
    
         
            +
                      const = klass.const_get(name)
         
     | 
| 
      
 135 
     | 
    
         
            +
                    rescue RescuableException
         
     | 
| 
      
 136 
     | 
    
         
            +
                      # constant loading is an inexact science at the best of times,
         
     | 
| 
      
 137 
     | 
    
         
            +
                      # this often happens when a constant was .autoload? but someone
         
     | 
| 
      
 138 
     | 
    
         
            +
                      # tried to load it. It's now not .autoload? but will still raise
         
     | 
| 
      
 139 
     | 
    
         
            +
                      # a NameError when you access it.
         
     | 
| 
      
 140 
     | 
    
         
            +
                    else
         
     | 
| 
      
 141 
     | 
    
         
            +
                      recurse_namespace(const, done, &block)
         
     | 
| 
      
 142 
     | 
    
         
            +
                    end
         
     | 
| 
      
 143 
     | 
    
         
            +
                  end
         
     | 
| 
      
 144 
     | 
    
         
            +
                end
         
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
                # Gather all the methods in a namespace that pass the given block.
         
     | 
| 
      
 147 
     | 
    
         
            +
                #
         
     | 
| 
      
 148 
     | 
    
         
            +
                # @param Module  The namespace in which to search.
         
     | 
| 
      
 149 
     | 
    
         
            +
                # @yieldparam Method  The method to test
         
     | 
| 
      
 150 
     | 
    
         
            +
                # @yieldreturn Boolean
         
     | 
| 
      
 151 
     | 
    
         
            +
                # @return Array[Method]
         
     | 
| 
      
 152 
     | 
    
         
            +
                #
         
     | 
| 
      
 153 
     | 
    
         
            +
                def search_all_methods(namespace)
         
     | 
| 
      
 154 
     | 
    
         
            +
                  done = Hash.new{ |h,k| h[k] = {} }
         
     | 
| 
      
 155 
     | 
    
         
            +
                  matches = []
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                  recurse_namespace(namespace) do |klass|
         
     | 
| 
      
 158 
     | 
    
         
            +
                    (Pry::Method.all_from_class(klass) + Pry::Method.all_from_obj(klass)).each do |method|
         
     | 
| 
      
 159 
     | 
    
         
            +
                      next if done[method.owner][method.name]
         
     | 
| 
      
 160 
     | 
    
         
            +
                      done[method.owner][method.name] = true
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                      matches << method if yield method
         
     | 
| 
      
 163 
     | 
    
         
            +
                    end
         
     | 
| 
      
 164 
     | 
    
         
            +
                  end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                  matches
         
     | 
| 
      
 167 
     | 
    
         
            +
                end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
                # Search for all methods with a name that matches the given regex
         
     | 
| 
      
 170 
     | 
    
         
            +
                # within a namespace.
         
     | 
| 
      
 171 
     | 
    
         
            +
                #
         
     | 
| 
      
 172 
     | 
    
         
            +
                # @param Module  The namespace to search
         
     | 
| 
      
 173 
     | 
    
         
            +
                # @return Array[Method]
         
     | 
| 
      
 174 
     | 
    
         
            +
                #
         
     | 
| 
      
 175 
     | 
    
         
            +
                def name_search(namespace)
         
     | 
| 
      
 176 
     | 
    
         
            +
                  search_all_methods(namespace) do |meth|
         
     | 
| 
      
 177 
     | 
    
         
            +
                    meth.name =~ pattern
         
     | 
| 
      
 178 
     | 
    
         
            +
                  end
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                # Search for all methods who's implementation matches the given regex
         
     | 
| 
      
 182 
     | 
    
         
            +
                # within a namespace.
         
     | 
| 
      
 183 
     | 
    
         
            +
                #
         
     | 
| 
      
 184 
     | 
    
         
            +
                # @param Module  The namespace to search
         
     | 
| 
      
 185 
     | 
    
         
            +
                # @return Array[Method]
         
     | 
| 
      
 186 
     | 
    
         
            +
                #
         
     | 
| 
      
 187 
     | 
    
         
            +
                def content_search(namespace)
         
     | 
| 
      
 188 
     | 
    
         
            +
                  search_all_methods(namespace) do |meth|
         
     | 
| 
      
 189 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 190 
     | 
    
         
            +
                      meth.source =~ pattern
         
     | 
| 
      
 191 
     | 
    
         
            +
                    rescue RescuableException
         
     | 
| 
      
 192 
     | 
    
         
            +
                      false
         
     | 
| 
      
 193 
     | 
    
         
            +
                    end
         
     | 
| 
      
 194 
     | 
    
         
            +
                  end
         
     | 
| 
      
 195 
     | 
    
         
            +
                end
         
     | 
| 
      
 196 
     | 
    
         
            +
              end
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::FindMethod)
         
     | 
| 
      
 199 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::FixIndent < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'fix-indent'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Input and Output'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                description "Correct the indentation for contents of the input buffer"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                banner <<-USAGE
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Usage: fix-indent
         
     | 
| 
      
 10 
     | 
    
         
            +
                USAGE
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def process
         
     | 
| 
      
 13 
     | 
    
         
            +
                  indented_str = Pry::Indent.indent(eval_string)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  eval_string.replace indented_str
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::FixIndent)
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::GemCd < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'gem-cd'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Gems'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description "Change working directory to specified gem's directory."
         
     | 
| 
      
 6 
     | 
    
         
            +
                command_options :argument_required => true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Usage: gem-cd GEM_NAME
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  Change the current working directory to that in which the given gem is
         
     | 
| 
      
 12 
     | 
    
         
            +
                  installed.
         
     | 
| 
      
 13 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def process(gem)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  Dir.chdir(Rubygem.spec(gem).full_gem_path)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  output.puts(Dir.pwd)
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def complete(str)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  Rubygem.complete(str)
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::GemCd)
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::GemInstall < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'gem-install'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Gems'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description 'Install a gem and refresh the gem cache.'
         
     | 
| 
      
 6 
     | 
    
         
            +
                command_options :argument_required => true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Usage: gem-install GEM_NAME
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  Installs the given gem and refreshes the gem cache so that you can immediately
         
     | 
| 
      
 12 
     | 
    
         
            +
                  'require GEM_FILE'.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  gem-install pry-stack_explorer
         
     | 
| 
      
 15 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 18 
     | 
    
         
            +
                  require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def process(gem)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  Rubygem.install(gem)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  output.puts "Gem `#{ text.green(gem) }` installed."
         
     | 
| 
      
 24 
     | 
    
         
            +
                  require gem
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::GemInstall)
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::GemList < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'gem-list'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Gems'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description 'List and search installed gems.'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Usage: gem-list [REGEX]
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  List all installed gems, when a regex is provided, limit the output to those
         
     | 
| 
      
 11 
     | 
    
         
            +
                  that match the regex.
         
     | 
| 
      
 12 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                def process(pattern = nil)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  pattern = Regexp.compile(pattern || '')
         
     | 
| 
      
 16 
     | 
    
         
            +
                  gems    = Rubygem.list(pattern).group_by(&:name)
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  gems.each do |gem, specs|
         
     | 
| 
      
 19 
     | 
    
         
            +
                    specs.sort! do |a,b|
         
     | 
| 
      
 20 
     | 
    
         
            +
                      Gem::Version.new(b.version) <=> Gem::Version.new(a.version)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    versions = specs.each_with_index.map do |spec, index|
         
     | 
| 
      
 24 
     | 
    
         
            +
                      index == 0 ? text.bright_green(spec.version.to_s) : text.green(spec.version.to_s)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    output.puts "#{text.default gem} (#{versions.join ', '})"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::GemList)
         
     | 
| 
      
 33 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::GemOpen < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'gem-open'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Gems'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description 'Opens the working directory of the gem in your editor'
         
     | 
| 
      
 6 
     | 
    
         
            +
                command_options :argument_required => true
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  Usage: gem-open GEM_NAME
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  Change the current working directory to that in which the given gem is
         
     | 
| 
      
 12 
     | 
    
         
            +
                  installed, and then opens your text editor.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  gem-open pry-exception_explorer
         
     | 
| 
      
 15 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def process(gem)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  Dir.chdir(Rubygem.spec(gem).full_gem_path) do
         
     | 
| 
      
 19 
     | 
    
         
            +
                    Pry::Editor.invoke_editor(".", 0, false)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def complete(str)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  Rubygem.complete(str)
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::GemOpen)
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,95 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Pry
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Command::Gist < Pry::ClassCommand
         
     | 
| 
      
 3 
     | 
    
         
            +
                match 'gist'
         
     | 
| 
      
 4 
     | 
    
         
            +
                group 'Misc'
         
     | 
| 
      
 5 
     | 
    
         
            +
                description 'Playback a string variable or a method or a file as input.'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                banner <<-'BANNER'
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Usage: gist [OPTIONS] [--help]
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  The gist command enables you to gist code from files and methods to github.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  gist -i 20 --lines 1..3
         
     | 
| 
      
 13 
     | 
    
         
            +
                  gist Pry#repl --lines 1..-1
         
     | 
| 
      
 14 
     | 
    
         
            +
                  gist Rakefile --lines 5
         
     | 
| 
      
 15 
     | 
    
         
            +
                BANNER
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 18 
     | 
    
         
            +
                  require 'jist'
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def options(opt)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  CodeCollector.inject_options(opt)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  opt.on :login, "Authenticate the jist gem with GitHub"
         
     | 
| 
      
 24 
     | 
    
         
            +
                  opt.on :p, :public, "Create a public gist (default: false)", :default => false
         
     | 
| 
      
 25 
     | 
    
         
            +
                  opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :default => false
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                def process
         
     | 
| 
      
 29 
     | 
    
         
            +
                  return Jist.login! if opts.present?(:login)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  cc = CodeCollector.new(args, opts, _pry_)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  if cc.content =~ /\A\s*\z/
         
     | 
| 
      
 33 
     | 
    
         
            +
                    raise CommandError, "Found no code to gist."
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                  if opts.present?(:clip)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    clipboard_content(cc.content)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  else
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # we're overriding the default behavior of the 'in' option (as
         
     | 
| 
      
 40 
     | 
    
         
            +
                    # defined on CodeCollector) with our local behaviour.
         
     | 
| 
      
 41 
     | 
    
         
            +
                    content = opts.present?(:in) ? input_content : cc.content
         
     | 
| 
      
 42 
     | 
    
         
            +
                    gist_content content, cc.file
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def clipboard_content(content)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  Jist.copy(content)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  output.puts "Copied content to clipboard!"
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                def input_content
         
     | 
| 
      
 52 
     | 
    
         
            +
                  content = ""
         
     | 
| 
      
 53 
     | 
    
         
            +
                  CodeCollector.input_expression_ranges.each do |range|
         
     | 
| 
      
 54 
     | 
    
         
            +
                    input_expressions = _pry_.input_array[range] || []
         
     | 
| 
      
 55 
     | 
    
         
            +
                    Array(input_expressions).each_with_index do |code, index|
         
     | 
| 
      
 56 
     | 
    
         
            +
                      corrected_index = index + range.first
         
     | 
| 
      
 57 
     | 
    
         
            +
                      if code && code != ""
         
     | 
| 
      
 58 
     | 
    
         
            +
                        content << code
         
     | 
| 
      
 59 
     | 
    
         
            +
                        if code !~ /;\Z/
         
     | 
| 
      
 60 
     | 
    
         
            +
                          content << "#{comment_expression_result_for_gist(Pry.config.gist.inspecter.call(_pry_.output_array[corrected_index]))}"
         
     | 
| 
      
 61 
     | 
    
         
            +
                        end
         
     | 
| 
      
 62 
     | 
    
         
            +
                      end
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                  content
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                def comment_expression_result_for_gist(result)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  content = ""
         
     | 
| 
      
 71 
     | 
    
         
            +
                  result.lines.each_with_index do |line, index|
         
     | 
| 
      
 72 
     | 
    
         
            +
                    if index == 0
         
     | 
| 
      
 73 
     | 
    
         
            +
                      content << "# => #{line}"
         
     | 
| 
      
 74 
     | 
    
         
            +
                    else
         
     | 
| 
      
 75 
     | 
    
         
            +
                      content << "#    #{line}"
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  content
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                def gist_content(content, filename)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  response = Jist.gist(content, :filename => filename || "pry_gist.rb", :public => !!opts[:p])
         
     | 
| 
      
 84 
     | 
    
         
            +
                  if response
         
     | 
| 
      
 85 
     | 
    
         
            +
                    url = response['html_url']
         
     | 
| 
      
 86 
     | 
    
         
            +
                    Jist.copy(url)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    output.puts 'Gist created at URL, which is now in the clipboard: ', url
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              Pry::Commands.add_command(Pry::Command::Gist)
         
     | 
| 
      
 93 
     | 
    
         
            +
              Pry::Commands.alias_command 'clipit', 'gist --clip'
         
     | 
| 
      
 94 
     | 
    
         
            +
              Pry::Commands.alias_command 'jist', 'gist'
         
     | 
| 
      
 95 
     | 
    
         
            +
            end
         
     |