chess_engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -0
- data/README.md +26 -0
- data/chess_engine.gemspec +14 -0
- data/lib/chess_engine/board.rb +95 -0
- data/lib/chess_engine/cli.rb +105 -0
- data/lib/chess_engine/game.rb +148 -0
- data/lib/chess_engine/input.rb +19 -0
- data/lib/chess_engine/move.rb +35 -0
- data/lib/chess_engine/piece.rb +97 -0
- data/lib/chess_engine/validator.rb +87 -0
- data/lib/chess_engine.rb +1 -0
- data/spec/board_spec.rb +70 -0
- data/spec/game_helper.rb +5 -0
- data/spec/game_spec.rb +79 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/validator_spec.rb +26 -0
- data/vendor/bundle/bin/coderay +27 -0
- data/vendor/bundle/bin/pry +27 -0
- data/vendor/bundle/cache/coderay-1.1.2.gem +0 -0
- data/vendor/bundle/cache/colorize-0.8.1.gem +0 -0
- data/vendor/bundle/cache/method_source-0.9.2.gem +0 -0
- data/vendor/bundle/cache/pry-0.12.2.gem +0 -0
- data/vendor/bundle/cache/rb-readline-0.5.5.gem +0 -0
- data/vendor/bundle/gems/coderay-1.1.2/MIT-LICENSE +22 -0
- data/vendor/bundle/gems/coderay-1.1.2/README_INDEX.rdoc +123 -0
- data/vendor/bundle/gems/coderay-1.1.2/bin/coderay +215 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/duo.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/_map.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/comment_filter.rb +25 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/count.rb +39 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug.rb +49 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug_lint.rb +63 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/div.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb +190 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/filter.rb +58 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/css.rb +65 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/numbering.rb +108 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/output.rb +166 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html.rb +333 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/json.rb +83 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lines_of_code.rb +45 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lint.rb +59 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/null.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/page.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/span.rb +23 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/statistic.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/terminal.rb +195 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/text.rb +46 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/token_kind_filter.rb +111 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/xml.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/yaml.rb +50 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/for_redcloth.rb +95 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/file_type.rb +151 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin_host.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/word_list.rb +72 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/_map.rb +24 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/c.rb +189 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/clojure.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/cpp.rb +217 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/css.rb +196 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/debug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/delphi.rb +144 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/diff.rb +221 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/erb.rb +81 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/go.rb +208 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/groovy.rb +268 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/haml.rb +168 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/html.rb +275 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java/builtin_types.rb +421 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java.rb +174 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java_script.rb +237 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/json.rb +98 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/lua.rb +280 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/php.rb +527 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/python.rb +287 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/raydebug.rb +75 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/patterns.rb +178 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/string_state.rb +79 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby.rb +477 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sass.rb +232 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb +337 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sql.rb +169 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/taskpaper.rb +36 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/text.rb +26 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/xml.rb +17 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/yaml.rb +140 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners.rb +27 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/_map.rb +7 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/alpha.rb +153 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/style.rb +18 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles.rb +15 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/token_kinds.rb +85 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens.rb +161 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb +55 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/version.rb +3 -0
- data/vendor/bundle/gems/coderay-1.1.2/lib/coderay.rb +284 -0
- data/vendor/bundle/gems/colorize-0.8.1/CHANGELOG +65 -0
- data/vendor/bundle/gems/colorize-0.8.1/LICENSE +339 -0
- data/vendor/bundle/gems/colorize-0.8.1/README.md +105 -0
- data/vendor/bundle/gems/colorize-0.8.1/Rakefile +13 -0
- data/vendor/bundle/gems/colorize-0.8.1/colorize.gemspec +36 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/class_methods.rb +120 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/instance_methods.rb +132 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorize.rb +12 -0
- data/vendor/bundle/gems/colorize-0.8.1/lib/colorized_string.rb +19 -0
- data/vendor/bundle/gems/colorize-0.8.1/test/test_colorize.rb +164 -0
- data/vendor/bundle/gems/method_source-0.9.2/Gemfile +2 -0
- data/vendor/bundle/gems/method_source-0.9.2/LICENSE +25 -0
- data/vendor/bundle/gems/method_source-0.9.2/README.markdown +91 -0
- data/vendor/bundle/gems/method_source-0.9.2/Rakefile +81 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/code_helpers.rb +154 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/source_location.rb +138 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/version.rb +3 -0
- data/vendor/bundle/gems/method_source-0.9.2/lib/method_source.rb +141 -0
- data/vendor/bundle/gems/method_source-0.9.2/method_source.gemspec +35 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source/code_helpers_spec.rb +43 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/method_source_spec.rb +143 -0
- data/vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb +101 -0
- data/vendor/bundle/gems/pry-0.12.2/CHANGELOG.md +953 -0
- data/vendor/bundle/gems/pry-0.12.2/LICENSE +25 -0
- data/vendor/bundle/gems/pry-0.12.2/README.md +390 -0
- data/vendor/bundle/gems/pry-0.12.2/bin/pry +8 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/basic_object.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/cli.rb +218 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_file.rb +110 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_range.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/loc.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code.rb +353 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/code_object.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/color_printer.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command.rb +723 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/command_set.rb +415 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/amend_line.rb +98 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang.rb +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang_pry.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/exception_formatter.rb +79 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/file_formatter.rb +71 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat.rb +63 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cd.rb +41 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_prompt.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/clear_screen.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/code_collector.rb +167 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disable_pry.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disabled_commands.rb +2 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/easter_eggs.rb +112 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb +43 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_all.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_program.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/find_method.rb +191 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/fix_indent.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_cd.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_install.rb +32 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_open.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_readme.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_search.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_stats.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gist.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/help.rb +164 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/hist.rb +181 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/import_set.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/jump_to.rb +29 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/list_inspectors.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/constants.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/formatter.rb +51 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/globals.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/grep.rb +19 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/instance_vars.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_names.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_vars.rb +37 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/ls_entity.rb +69 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods.rb +54 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/self_methods.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls.rb +113 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/nesting.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/play.rb +102 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_backtrace.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_version.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb +33 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reload_code.rb +62 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reset.rb +18 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ri.rb +65 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/save_file.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_command.rb +75 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_mode.rb +25 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_doc.rb +81 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_info.rb +216 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_input.rb +17 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_source.rb +53 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/stat.rb +40 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/switch_to.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/toggle_color.rb +24 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression.rb +107 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/whereami.rb +197 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/wtf.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/behavior.rb +255 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/convenience.rb +28 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/default.rb +159 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/memoization.rb +48 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/config.rb +35 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/core_extensions.rb +142 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/editor.rb +128 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/exceptions.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/forwardable.rb +23 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/base_helpers.rb +200 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/command_helpers.rb +157 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/documentation_helpers.rb +76 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/options_helpers.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/platform.rb +58 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/table.rb +114 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/text.rb +115 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers.rb +6 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/history.rb +161 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/hooks.rb +171 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/indent.rb +408 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_completer.rb +265 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_lock.rb +130 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/inspector.rb +27 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/last_exception.rb +61 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/disowned.rb +55 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/patcher.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb +198 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/method.rb +552 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/object_path.rb +83 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/output.rb +50 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pager.rb +250 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/platform.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/plugins.rb +122 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/prompt.rb +145 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_class.rb +425 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_instance.rb +699 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl.rb +261 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl_file_loader.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/ring.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/rubygem.rb +84 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/LICENSE +20 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/commands.rb +195 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/option.rb +206 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop.rb +661 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/terminal.rb +91 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/evalable.rb +15 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/mockable.rb +14 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/pry_tester.rb +73 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/utility.rb +26 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/variables.rb +46 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable.rb +70 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/version.rb +3 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module/candidate.rb +131 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module.rb +378 -0
- data/vendor/bundle/gems/pry-0.12.2/lib/pry.rb +132 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/CHANGES +94 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/LICENSE +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/README.md +81 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/Rakefile +25 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/bench/_rl_adjust_point.rb +26 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline.rb +8 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline_with_completion.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/examples/tinyirb.rb +11 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rb-readline.rb +18 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline/version.rb +3 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline.rb +8920 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/lib/readline.rb +539 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/rb-readline.gemspec +51 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/setup.rb +1585 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/support/filesystem_completion_helper.rb +53 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_completion.rb +100 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_filename_completion_proc.rb +88 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_history.rb +29 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_rbreadline.rb +23 -0
- data/vendor/bundle/gems/rb-readline-0.5.5/test/test_readline.rb +221 -0
- data/vendor/bundle/specifications/coderay-1.1.2.gemspec +26 -0
- data/vendor/bundle/specifications/colorize-0.8.1.gemspec +38 -0
- data/vendor/bundle/specifications/method_source-0.9.2.gemspec +35 -0
- data/vendor/bundle/specifications/pry-0.12.2.gemspec +38 -0
- data/vendor/bundle/specifications/rb-readline-0.5.5.gemspec +39 -0
- metadata +363 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
module Convenience
|
4
|
+
SHORTCUTS = [
|
5
|
+
:input,
|
6
|
+
:output,
|
7
|
+
:commands,
|
8
|
+
:print,
|
9
|
+
:exception_handler,
|
10
|
+
:hooks,
|
11
|
+
:color,
|
12
|
+
:pager,
|
13
|
+
:editor,
|
14
|
+
:memory_size,
|
15
|
+
:extra_sticky_locals
|
16
|
+
]
|
17
|
+
|
18
|
+
def config_shortcut(*names)
|
19
|
+
names.each do |name|
|
20
|
+
reader = name
|
21
|
+
setter = "#{name}="
|
22
|
+
define_method(reader) { config.public_send(name) }
|
23
|
+
define_method(setter) { |value| config.public_send(setter, value) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
class Default
|
4
|
+
include Config::Behavior
|
5
|
+
include Config::Memoization
|
6
|
+
|
7
|
+
def_memoized({
|
8
|
+
input: proc {
|
9
|
+
lazy_readline
|
10
|
+
},
|
11
|
+
output: proc {
|
12
|
+
$stdout.tap { |out| out.sync = true }
|
13
|
+
},
|
14
|
+
commands: proc {
|
15
|
+
Pry::Commands
|
16
|
+
},
|
17
|
+
prompt_name: proc {
|
18
|
+
Pry::Prompt::DEFAULT_NAME
|
19
|
+
},
|
20
|
+
prompt: proc {
|
21
|
+
Pry::Prompt[:default][:value]
|
22
|
+
},
|
23
|
+
prompt_safe_contexts: proc {
|
24
|
+
Pry::Prompt::SAFE_CONTEXTS
|
25
|
+
},
|
26
|
+
print: proc {
|
27
|
+
Pry::DEFAULT_PRINT
|
28
|
+
},
|
29
|
+
quiet: proc {
|
30
|
+
false
|
31
|
+
},
|
32
|
+
exception_handler: proc {
|
33
|
+
Pry::DEFAULT_EXCEPTION_HANDLER
|
34
|
+
},
|
35
|
+
exception_whitelist: proc {
|
36
|
+
Pry::DEFAULT_EXCEPTION_WHITELIST
|
37
|
+
},
|
38
|
+
hooks: proc {
|
39
|
+
Pry::DEFAULT_HOOKS
|
40
|
+
},
|
41
|
+
pager: proc {
|
42
|
+
true
|
43
|
+
},
|
44
|
+
system: proc {
|
45
|
+
Pry::DEFAULT_SYSTEM
|
46
|
+
},
|
47
|
+
color: proc {
|
48
|
+
Pry::Helpers::BaseHelpers.use_ansi_codes?
|
49
|
+
},
|
50
|
+
default_window_size: proc {
|
51
|
+
5
|
52
|
+
},
|
53
|
+
editor: proc {
|
54
|
+
Pry.default_editor_for_platform
|
55
|
+
},
|
56
|
+
should_load_rc: proc {
|
57
|
+
true
|
58
|
+
},
|
59
|
+
should_load_local_rc: proc {
|
60
|
+
true
|
61
|
+
},
|
62
|
+
should_trap_interrupts: proc {
|
63
|
+
Pry::Helpers::Platform.jruby?
|
64
|
+
},
|
65
|
+
disable_auto_reload: proc {
|
66
|
+
false
|
67
|
+
},
|
68
|
+
command_prefix: proc {
|
69
|
+
""
|
70
|
+
},
|
71
|
+
auto_indent: proc {
|
72
|
+
Pry::Helpers::BaseHelpers.use_ansi_codes?
|
73
|
+
},
|
74
|
+
correct_indent: proc {
|
75
|
+
true
|
76
|
+
},
|
77
|
+
collision_warning: proc {
|
78
|
+
false
|
79
|
+
},
|
80
|
+
output_prefix: proc {
|
81
|
+
"=> "
|
82
|
+
},
|
83
|
+
requires: proc {
|
84
|
+
[]
|
85
|
+
},
|
86
|
+
should_load_requires: proc {
|
87
|
+
true
|
88
|
+
},
|
89
|
+
should_load_plugins: proc {
|
90
|
+
true
|
91
|
+
},
|
92
|
+
windows_console_warning: proc {
|
93
|
+
true
|
94
|
+
},
|
95
|
+
control_d_handler: proc {
|
96
|
+
Pry::DEFAULT_CONTROL_D_HANDLER
|
97
|
+
},
|
98
|
+
memory_size: proc {
|
99
|
+
100
|
100
|
+
},
|
101
|
+
extra_sticky_locals: proc {
|
102
|
+
{}
|
103
|
+
},
|
104
|
+
command_completions: proc {
|
105
|
+
proc { commands.keys }
|
106
|
+
},
|
107
|
+
file_completions: proc {
|
108
|
+
proc { Dir["."] }
|
109
|
+
},
|
110
|
+
ls: proc {
|
111
|
+
Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
|
112
|
+
},
|
113
|
+
completer: proc {
|
114
|
+
require "pry/input_completer"
|
115
|
+
Pry::InputCompleter
|
116
|
+
},
|
117
|
+
gist: proc {
|
118
|
+
Pry::Config.from_hash({inspecter: proc(&:pretty_inspect)}, nil)
|
119
|
+
},
|
120
|
+
history: proc {
|
121
|
+
Pry::Config.from_hash({should_save: true, should_load: true}, nil).tap do |history|
|
122
|
+
history_file =
|
123
|
+
if File.exist?(File.expand_path('~/.pry_history'))
|
124
|
+
'~/.pry_history'
|
125
|
+
elsif ENV.key?('XDG_DATA_HOME') && ENV['XDG_DATA_HOME'] != ''
|
126
|
+
# See XDG Base Directory Specification at
|
127
|
+
# https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
|
128
|
+
ENV['XDG_DATA_HOME'] + '/pry/pry_history'
|
129
|
+
else
|
130
|
+
'~/.local/share/pry/pry_history'
|
131
|
+
end
|
132
|
+
history.file = File.expand_path(history_file)
|
133
|
+
end
|
134
|
+
},
|
135
|
+
exec_string: proc {
|
136
|
+
""
|
137
|
+
}
|
138
|
+
})
|
139
|
+
|
140
|
+
def initialize
|
141
|
+
super(nil)
|
142
|
+
end
|
143
|
+
|
144
|
+
private
|
145
|
+
|
146
|
+
def lazy_readline
|
147
|
+
require 'readline'
|
148
|
+
Readline
|
149
|
+
rescue LoadError
|
150
|
+
warn "Sorry, you can't use Pry without Readline or a compatible library."
|
151
|
+
warn "Possible solutions:"
|
152
|
+
warn " * Rebuild Ruby with Readline support using `--with-readline`"
|
153
|
+
warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline"
|
154
|
+
warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
|
155
|
+
raise
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Pry
|
2
|
+
class Config < Pry::BasicObject
|
3
|
+
module Memoization
|
4
|
+
MEMOIZED_METHODS = Hash.new { |h,k| h[k] = [] }
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
#
|
8
|
+
# Defines one or more methods who return a constant value after being
|
9
|
+
# called once.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# class Foo
|
13
|
+
# include Pry::Config::Memoization
|
14
|
+
# def_memoized({
|
15
|
+
# foo: proc {1+10},
|
16
|
+
# bar: proc{"aaa"<<"a"}
|
17
|
+
# })
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @param [{String => Proc}] method_table
|
21
|
+
#
|
22
|
+
# @return [void]
|
23
|
+
#
|
24
|
+
def def_memoized(method_table)
|
25
|
+
method_table.each do |method_name, method|
|
26
|
+
define_method(method_name) do
|
27
|
+
method_table[method_name] = instance_eval(&method) if method_table[method_name].equal? method
|
28
|
+
method_table[method_name]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
MEMOIZED_METHODS[self] |= method_table.keys
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.included(mod)
|
36
|
+
mod.extend(ClassMethods)
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# @return [Array<Symbol>]
|
41
|
+
# Returns the names of methods that have been defined by {ClassMethods#def_memoized}.
|
42
|
+
#
|
43
|
+
def memoized_methods
|
44
|
+
MEMOIZED_METHODS[self.class]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Pry
|
2
|
+
# The Pry config.
|
3
|
+
# @api public
|
4
|
+
class Config < Pry::BasicObject
|
5
|
+
# Wraps a block so it can have a name.
|
6
|
+
#
|
7
|
+
# @example
|
8
|
+
# proc1 = proc {}
|
9
|
+
# proc2 = Pry::Config::Lazy.new(&proc {})
|
10
|
+
#
|
11
|
+
# proc1.is_a?(Pry::Config::Lazy)
|
12
|
+
# #=> false
|
13
|
+
# proc2.is_a?(Pry::Config::Lazy)
|
14
|
+
# #=> true
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
# @since v0.12.0
|
18
|
+
class Lazy
|
19
|
+
def initialize(&block)
|
20
|
+
@block = block
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Object]
|
24
|
+
def call
|
25
|
+
@block.call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
include Behavior
|
30
|
+
|
31
|
+
def self.shortcuts
|
32
|
+
Convenience::SHORTCUTS
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
class Pry
|
2
|
+
# @return [Array] Code of the method used when implementing Pry's
|
3
|
+
# __binding__, along with line indication to be used with instance_eval (and
|
4
|
+
# friends).
|
5
|
+
#
|
6
|
+
# @see Object#__binding__
|
7
|
+
BINDING_METHOD_IMPL = [<<-METHOD, __FILE__, __LINE__ + 1]
|
8
|
+
# Get a binding with 'self' set to self, and no locals.
|
9
|
+
#
|
10
|
+
# The default definee is determined by the context in which the
|
11
|
+
# definition is eval'd.
|
12
|
+
#
|
13
|
+
# Please don't call this method directly, see {__binding__}.
|
14
|
+
#
|
15
|
+
# @return [Binding]
|
16
|
+
def __pry__
|
17
|
+
binding
|
18
|
+
end
|
19
|
+
METHOD
|
20
|
+
end
|
21
|
+
|
22
|
+
class Object
|
23
|
+
# Start a Pry REPL on self.
|
24
|
+
#
|
25
|
+
# If `self` is a Binding then that will be used to evaluate expressions;
|
26
|
+
# otherwise a new binding will be created.
|
27
|
+
#
|
28
|
+
# @param [Object] object the object or binding to pry
|
29
|
+
# (__deprecated__, use `object.pry`)
|
30
|
+
# @param [Hash] hash the options hash
|
31
|
+
# @example With a binding
|
32
|
+
# binding.pry
|
33
|
+
# @example On any object
|
34
|
+
# "dummy".pry
|
35
|
+
# @example With options
|
36
|
+
# def my_method
|
37
|
+
# binding.pry :quiet => true
|
38
|
+
# end
|
39
|
+
# my_method()
|
40
|
+
# @see Pry.start
|
41
|
+
def pry(object = nil, hash = {})
|
42
|
+
if object.nil? || Hash === object
|
43
|
+
Pry.start(self, object || {})
|
44
|
+
else
|
45
|
+
Pry.start(object, hash)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return a binding object for the receiver.
|
50
|
+
#
|
51
|
+
# The `self` of the binding is set to the current object, and it contains no
|
52
|
+
# local variables.
|
53
|
+
#
|
54
|
+
# The default definee (http://yugui.jp/articles/846) is set such that:
|
55
|
+
#
|
56
|
+
# * If `self` is a class or module, then new methods created in the binding
|
57
|
+
# will be defined in that class or module (as in `class Foo; end`).
|
58
|
+
# * If `self` is a normal object, then new methods created in the binding will
|
59
|
+
# be defined on its singleton class (as in `class << self; end`).
|
60
|
+
# * If `self` doesn't have a real singleton class (i.e. it is a Fixnum, Float,
|
61
|
+
# Symbol, nil, true, or false), then new methods will be created on the
|
62
|
+
# object's class (as in `self.class.class_eval{ }`)
|
63
|
+
#
|
64
|
+
# Newly created constants, including classes and modules, will also be added
|
65
|
+
# to the default definee.
|
66
|
+
#
|
67
|
+
# @return [Binding]
|
68
|
+
def __binding__
|
69
|
+
# If you ever feel like changing this method, be careful about variables
|
70
|
+
# that you use. They shouldn't be inserted into the binding that will
|
71
|
+
# eventually be returned.
|
72
|
+
|
73
|
+
# When you're cd'd into a class, methods you define should be added to it.
|
74
|
+
if is_a?(Module)
|
75
|
+
# A special case, for JRuby.
|
76
|
+
# Module.new.class_eval("binding") has different behaviour than CRuby,
|
77
|
+
# where this is not needed: class_eval("binding") vs class_eval{binding}.
|
78
|
+
# Using a block works around the difference of behaviour on JRuby.
|
79
|
+
# The scope is clear of local variabless. Don't add any.
|
80
|
+
#
|
81
|
+
# This fixes the following two spec failures, at https://travis-ci.org/pry/pry/jobs/274470002
|
82
|
+
# 1) ./spec/pry_spec.rb:360:in `block in (root)'
|
83
|
+
# 2) ./spec/pry_spec.rb:366:in `block in (root)'
|
84
|
+
return class_eval { binding } if Pry::Helpers::Platform.jruby? and self.name == nil
|
85
|
+
|
86
|
+
# class_eval sets both self and the default definee to this class.
|
87
|
+
return class_eval("binding")
|
88
|
+
end
|
89
|
+
|
90
|
+
unless self.class.method_defined?(:__pry__)
|
91
|
+
# The easiest way to check whether an object has a working singleton class
|
92
|
+
# is to try and define a method on it. (just checking for the presence of
|
93
|
+
# the singleton class gives false positives for `true` and `false`).
|
94
|
+
# __pry__ is just the closest method we have to hand, and using
|
95
|
+
# it has the nice property that we can memoize this check.
|
96
|
+
begin
|
97
|
+
# instance_eval sets the default definee to the object's singleton class
|
98
|
+
instance_eval(*Pry::BINDING_METHOD_IMPL)
|
99
|
+
|
100
|
+
# If we can't define methods on the Object's singleton_class. Then we fall
|
101
|
+
# back to setting the default definee to be the Object's class. That seems
|
102
|
+
# nicer than having a REPL in which you can't define methods.
|
103
|
+
rescue TypeError, Pry::FrozenObjectException
|
104
|
+
# class_eval sets the default definee to self.class
|
105
|
+
self.class.class_eval(*Pry::BINDING_METHOD_IMPL)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
__pry__
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class BasicObject
|
114
|
+
# Return a binding object for the receiver.
|
115
|
+
#
|
116
|
+
# The `self` of the binding is set to the current object, and it contains no
|
117
|
+
# local variables.
|
118
|
+
#
|
119
|
+
# The default definee (http://yugui.jp/articles/846) is set such that new
|
120
|
+
# methods defined will be added to the singleton class of the BasicObject.
|
121
|
+
#
|
122
|
+
# @return [Binding]
|
123
|
+
def __binding__
|
124
|
+
# BasicObjects don't have respond_to?, so we just define the method
|
125
|
+
# every time. As they also don't have `.freeze`, this call won't
|
126
|
+
# fail as it can for normal Objects.
|
127
|
+
(class << self; self; end).class_eval <<-EOF, __FILE__, __LINE__ + 1
|
128
|
+
# Get a binding with 'self' set to self, and no locals.
|
129
|
+
#
|
130
|
+
# The default definee is determined by the context in which the
|
131
|
+
# definition is eval'd.
|
132
|
+
#
|
133
|
+
# Please don't call this method directly, see {__binding__}.
|
134
|
+
#
|
135
|
+
# @return [Binding]
|
136
|
+
def __pry__
|
137
|
+
::Kernel.binding
|
138
|
+
end
|
139
|
+
EOF
|
140
|
+
self.__pry__
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
class Pry
|
2
|
+
class Editor
|
3
|
+
include Pry::Helpers::CommandHelpers
|
4
|
+
|
5
|
+
attr_reader :_pry_
|
6
|
+
|
7
|
+
def initialize(_pry_)
|
8
|
+
@_pry_ = _pry_
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit_tempfile_with_content(initial_content, line = 1)
|
12
|
+
temp_file do |f|
|
13
|
+
f.puts(initial_content)
|
14
|
+
f.flush
|
15
|
+
f.close(false)
|
16
|
+
invoke_editor(f.path, line, true)
|
17
|
+
File.read(f.path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def invoke_editor(file, line, blocking = true)
|
22
|
+
raise CommandError, "Please set Pry.config.editor or export $VISUAL or $EDITOR" unless _pry_.config.editor
|
23
|
+
|
24
|
+
editor_invocation = build_editor_invocation_string(file, line, blocking)
|
25
|
+
return nil unless editor_invocation
|
26
|
+
|
27
|
+
if Helpers::Platform.jruby?
|
28
|
+
open_editor_on_jruby(editor_invocation)
|
29
|
+
else
|
30
|
+
open_editor(editor_invocation)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Generate the string that's used to start the editor. This includes
|
37
|
+
# all the flags we want as well as the file and line number we
|
38
|
+
# want to open at.
|
39
|
+
def build_editor_invocation_string(file, line, blocking)
|
40
|
+
|
41
|
+
if _pry_.config.editor.respond_to?(:call)
|
42
|
+
args = [file, line, blocking][0...(_pry_.config.editor.arity)]
|
43
|
+
_pry_.config.editor.call(*args)
|
44
|
+
else
|
45
|
+
sanitized_file = Helpers::Platform.windows? ? file : Shellwords.escape(file)
|
46
|
+
"#{_pry_.config.editor} #{blocking_flag_for_editor(blocking)} #{start_line_syntax_for_editor(sanitized_file, line)}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Start the editor running, using the calculated invocation string
|
51
|
+
def open_editor(editor_invocation)
|
52
|
+
# Note we dont want to use Pry.config.system here as that
|
53
|
+
# may be invoked non-interactively (i.e via Open4), whereas we want to
|
54
|
+
# ensure the editor is always interactive
|
55
|
+
system(*Shellwords.split(editor_invocation)) or raise CommandError, "`#{editor_invocation}` gave exit status: #{$?.exitstatus}"
|
56
|
+
end
|
57
|
+
|
58
|
+
# We need JRuby specific code here cos just shelling out using
|
59
|
+
# system() appears to be pretty broken :/
|
60
|
+
def open_editor_on_jruby(editor_invocation)
|
61
|
+
begin
|
62
|
+
require 'spoon'
|
63
|
+
pid = Spoon.spawnp(*Shellwords.split(editor_invocation))
|
64
|
+
Process.waitpid(pid)
|
65
|
+
rescue FFI::NotFoundError
|
66
|
+
system(editor_invocation)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Some editors that run outside the terminal allow you to control whether or
|
71
|
+
# not to block the process from which they were launched (in this case, Pry).
|
72
|
+
# For those editors, return the flag that produces the desired behavior.
|
73
|
+
def blocking_flag_for_editor(blocking)
|
74
|
+
case editor_name
|
75
|
+
when /^emacsclient/
|
76
|
+
'--no-wait' unless blocking
|
77
|
+
when /^[gm]vim/
|
78
|
+
'--nofork' if blocking
|
79
|
+
when /^jedit/
|
80
|
+
'-wait' if blocking
|
81
|
+
when /^mate/, /^subl/, /^redcar/
|
82
|
+
'-w' if blocking
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Return the syntax for a given editor for starting the editor
|
87
|
+
# and moving to a particular line within that file
|
88
|
+
def start_line_syntax_for_editor(file_name, line_number)
|
89
|
+
# special case for 1st line
|
90
|
+
return file_name if line_number <= 1
|
91
|
+
|
92
|
+
case editor_name
|
93
|
+
when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
|
94
|
+
"+#{line_number} #{file_name}"
|
95
|
+
when /^mate/, /^geany/
|
96
|
+
"-l #{line_number} #{file_name}"
|
97
|
+
when /^subl/
|
98
|
+
"#{file_name}:#{line_number}"
|
99
|
+
when /^uedit32/
|
100
|
+
"#{file_name}/#{line_number}"
|
101
|
+
when /^jedit/
|
102
|
+
"#{file_name} +line:#{line_number}"
|
103
|
+
when /^redcar/
|
104
|
+
"-l#{line_number} #{file_name}"
|
105
|
+
else
|
106
|
+
if Helpers::Platform.windows?
|
107
|
+
"#{file_name}"
|
108
|
+
else
|
109
|
+
"+#{line_number} #{file_name}"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Get the name of the binary that Pry.config.editor points to.
|
115
|
+
#
|
116
|
+
# This is useful for deciding which flags we pass to the editor as
|
117
|
+
# we can just use the program's name and ignore any absolute paths.
|
118
|
+
#
|
119
|
+
# @example
|
120
|
+
# Pry.config.editor="/home/conrad/bin/textmate -w"
|
121
|
+
# editor_name
|
122
|
+
# # => textmate
|
123
|
+
#
|
124
|
+
def editor_name
|
125
|
+
File.basename(_pry_.config.editor).split(" ").first
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|