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,37 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::Ls < Pry::ClassCommand
|
3
|
+
class LocalVars < Pry::Command::Ls::Formatter
|
4
|
+
def initialize(opts, _pry_)
|
5
|
+
super(_pry_)
|
6
|
+
@default_switch = opts[:locals]
|
7
|
+
@sticky_locals = _pry_.sticky_locals
|
8
|
+
end
|
9
|
+
|
10
|
+
def output_self
|
11
|
+
name_value_pairs = @target.eval('local_variables').reject { |e|
|
12
|
+
@sticky_locals.keys.include?(e.to_sym)
|
13
|
+
}.map { |name|
|
14
|
+
[name, (@target.eval(name.to_s))]
|
15
|
+
}
|
16
|
+
format(name_value_pairs).join('')
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def format(name_value_pairs)
|
22
|
+
name_value_pairs.sort_by { |name, value|
|
23
|
+
value.to_s.size
|
24
|
+
}.reverse.map { |name, value|
|
25
|
+
colorized_assignment_style(name, format_value(value))
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def colorized_assignment_style(lhs, rhs, desired_width = 7)
|
30
|
+
colorized_lhs = color(:local_var, lhs)
|
31
|
+
color_escape_padding = colorized_lhs.size - lhs.size
|
32
|
+
pad = desired_width + color_escape_padding
|
33
|
+
"%-#{pad}s = %s" % [color(:local_var, colorized_lhs), rhs]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'pry/commands/ls/grep'
|
2
|
+
require 'pry/commands/ls/formatter'
|
3
|
+
require 'pry/commands/ls/globals'
|
4
|
+
require 'pry/commands/ls/constants'
|
5
|
+
require 'pry/commands/ls/methods'
|
6
|
+
require 'pry/commands/ls/self_methods'
|
7
|
+
require 'pry/commands/ls/instance_vars'
|
8
|
+
require 'pry/commands/ls/local_names'
|
9
|
+
require 'pry/commands/ls/local_vars'
|
10
|
+
|
11
|
+
class Pry
|
12
|
+
class Command::Ls < Pry::ClassCommand
|
13
|
+
class LsEntity
|
14
|
+
attr_reader :_pry_
|
15
|
+
|
16
|
+
def initialize(opts)
|
17
|
+
@interrogatee = opts[:interrogatee]
|
18
|
+
@no_user_opts = opts[:no_user_opts]
|
19
|
+
@opts = opts[:opts]
|
20
|
+
@args = opts[:args]
|
21
|
+
@grep = Grep.new(Regexp.new(opts[:opts][:G] || '.'))
|
22
|
+
@_pry_ = opts.delete(:_pry_)
|
23
|
+
end
|
24
|
+
|
25
|
+
def entities_table
|
26
|
+
entities.map(&:write_out).reject { |o| !o }.join('')
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def grep(entity)
|
32
|
+
entity.tap { |o| o.grep = @grep }
|
33
|
+
end
|
34
|
+
|
35
|
+
def globals
|
36
|
+
grep Globals.new(@opts, _pry_)
|
37
|
+
end
|
38
|
+
|
39
|
+
def constants
|
40
|
+
grep Constants.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
41
|
+
end
|
42
|
+
|
43
|
+
def methods
|
44
|
+
grep(Methods.new(@interrogatee, @no_user_opts, @opts, _pry_))
|
45
|
+
end
|
46
|
+
|
47
|
+
def self_methods
|
48
|
+
grep SelfMethods.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
49
|
+
end
|
50
|
+
|
51
|
+
def instance_vars
|
52
|
+
grep InstanceVars.new(@interrogatee, @no_user_opts, @opts, _pry_)
|
53
|
+
end
|
54
|
+
|
55
|
+
def local_names
|
56
|
+
grep LocalNames.new(@no_user_opts, @args, _pry_)
|
57
|
+
end
|
58
|
+
|
59
|
+
def local_vars
|
60
|
+
LocalVars.new(@opts, _pry_)
|
61
|
+
end
|
62
|
+
|
63
|
+
def entities
|
64
|
+
[globals, constants, methods, self_methods, instance_vars, local_names,
|
65
|
+
local_vars]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'pry/commands/ls/methods_helper'
|
2
|
+
require 'pry/commands/ls/interrogatable'
|
3
|
+
|
4
|
+
class Pry
|
5
|
+
class Command::Ls < Pry::ClassCommand
|
6
|
+
class Methods < Pry::Command::Ls::Formatter
|
7
|
+
include Pry::Command::Ls::Interrogatable
|
8
|
+
include Pry::Command::Ls::MethodsHelper
|
9
|
+
|
10
|
+
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
11
|
+
super(_pry_)
|
12
|
+
@interrogatee = interrogatee
|
13
|
+
@no_user_opts = no_user_opts
|
14
|
+
@default_switch = opts[:methods]
|
15
|
+
@instance_methods_switch = opts['instance-methods']
|
16
|
+
@ppp_switch = opts[:ppp]
|
17
|
+
@jruby_switch = opts['all-java']
|
18
|
+
@quiet_switch = opts[:quiet]
|
19
|
+
@verbose_switch = opts[:verbose]
|
20
|
+
end
|
21
|
+
|
22
|
+
def output_self
|
23
|
+
methods = all_methods.group_by(&:owner)
|
24
|
+
# Reverse the resolution order so that the most useful information
|
25
|
+
# appears right by the prompt.
|
26
|
+
resolution_order.take_while(&below_ceiling).reverse.map do |klass|
|
27
|
+
methods_here = (methods[klass] || []).select { |m| grep.regexp[m.name] }
|
28
|
+
heading = "#{ Pry::WrappedModule.new(klass).method_prefix }methods"
|
29
|
+
output_section(heading, format(methods_here))
|
30
|
+
end.join('')
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def correct_opts?
|
36
|
+
super || @instance_methods_switch || @ppp_switch || @no_user_opts
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a lambda that can be used with `take_while` to prevent over-eager
|
40
|
+
# traversal of the Object's ancestry graph.
|
41
|
+
def below_ceiling
|
42
|
+
ceiling = if @quiet_switch
|
43
|
+
[Pry::Method.safe_send(interrogatee_mod, :ancestors)[1]] +
|
44
|
+
_pry_.config.ls.ceiling
|
45
|
+
elsif @verbose_switch
|
46
|
+
[]
|
47
|
+
else
|
48
|
+
_pry_.config.ls.ceiling.dup
|
49
|
+
end
|
50
|
+
lambda { |klass| !ceiling.include?(klass) }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'pry/commands/ls/jruby_hacks'
|
2
|
+
|
3
|
+
module Pry::Command::Ls::MethodsHelper
|
4
|
+
|
5
|
+
include Pry::Command::Ls::JRubyHacks
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
# Get all the methods that we'll want to output.
|
10
|
+
def all_methods(instance_methods = false)
|
11
|
+
methods = if instance_methods || @instance_methods_switch
|
12
|
+
Pry::Method.all_from_class(@interrogatee)
|
13
|
+
else
|
14
|
+
Pry::Method.all_from_obj(@interrogatee)
|
15
|
+
end
|
16
|
+
|
17
|
+
if Pry::Helpers::Platform.jruby? && !@jruby_switch
|
18
|
+
methods = trim_jruby_aliases(methods)
|
19
|
+
end
|
20
|
+
|
21
|
+
methods.select { |method| @ppp_switch || method.visibility == :public }
|
22
|
+
end
|
23
|
+
|
24
|
+
def resolution_order
|
25
|
+
if @instance_methods_switch
|
26
|
+
Pry::Method.instance_resolution_order(@interrogatee)
|
27
|
+
else
|
28
|
+
Pry::Method.resolution_order(@interrogatee)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def format(methods)
|
33
|
+
methods.sort_by(&:name).map do |method|
|
34
|
+
if method.name == 'method_missing'
|
35
|
+
color(:method_missing, 'method_missing')
|
36
|
+
elsif method.visibility == :private
|
37
|
+
color(:private_method, method.name)
|
38
|
+
elsif method.visibility == :protected
|
39
|
+
color(:protected_method, method.name)
|
40
|
+
else
|
41
|
+
color(:public_method, method.name)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pry/commands/ls/interrogatable'
|
2
|
+
require 'pry/commands/ls/methods_helper'
|
3
|
+
|
4
|
+
class Pry
|
5
|
+
class Command::Ls < Pry::ClassCommand
|
6
|
+
class SelfMethods < Pry::Command::Ls::Formatter
|
7
|
+
include Pry::Command::Ls::Interrogatable
|
8
|
+
include Pry::Command::Ls::MethodsHelper
|
9
|
+
|
10
|
+
def initialize(interrogatee, no_user_opts, opts, _pry_)
|
11
|
+
super(_pry_)
|
12
|
+
@interrogatee = interrogatee
|
13
|
+
@no_user_opts = no_user_opts
|
14
|
+
@ppp_switch = opts[:ppp]
|
15
|
+
@jruby_switch = opts['all-java']
|
16
|
+
end
|
17
|
+
|
18
|
+
def output_self
|
19
|
+
methods = all_methods(true).select do |m|
|
20
|
+
m.owner == @interrogatee && grep.regexp[m.name]
|
21
|
+
end
|
22
|
+
heading = "#{ Pry::WrappedModule.new(@interrogatee).method_prefix }methods"
|
23
|
+
output_section(heading, format(methods))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def correct_opts?
|
29
|
+
@no_user_opts && interrogating_a_module?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'pry/commands/ls/ls_entity'
|
2
|
+
class Pry
|
3
|
+
class Command::Ls < Pry::ClassCommand
|
4
|
+
DEFAULT_OPTIONS = {
|
5
|
+
heading_color: :bright_blue,
|
6
|
+
public_method_color: :default,
|
7
|
+
private_method_color: :blue,
|
8
|
+
protected_method_color: :blue,
|
9
|
+
method_missing_color: :bright_red,
|
10
|
+
local_var_color: :yellow,
|
11
|
+
pry_var_color: :default, # e.g. _, _pry_, _file_
|
12
|
+
instance_var_color: :blue, # e.g. @foo
|
13
|
+
class_var_color: :bright_blue, # e.g. @@foo
|
14
|
+
global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
15
|
+
builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
|
16
|
+
pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
17
|
+
constant_color: :default, # e.g. VERSION, ARGF
|
18
|
+
class_constant_color: :blue, # e.g. Object, Kernel
|
19
|
+
exception_constant_color: :magenta, # e.g. Exception, RuntimeError
|
20
|
+
unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
|
21
|
+
separator: " ",
|
22
|
+
ceiling: [Object, Module, Class]
|
23
|
+
}
|
24
|
+
|
25
|
+
match 'ls'
|
26
|
+
group 'Context'
|
27
|
+
description 'Show the list of vars and methods in the current scope.'
|
28
|
+
command_options shellwords: false, interpolate: false
|
29
|
+
|
30
|
+
banner <<-'BANNER'
|
31
|
+
Usage: ls [-m|-M|-p|-pM] [-q|-v] [-c|-i] [Object]
|
32
|
+
ls [-g] [-l]
|
33
|
+
|
34
|
+
ls shows you which methods, constants and variables are accessible to Pry. By
|
35
|
+
default it shows you the local variables defined in the current shell, and any
|
36
|
+
public methods or instance variables defined on the current object.
|
37
|
+
|
38
|
+
The colours used are configurable using Pry.config.ls.*_color, and the separator
|
39
|
+
is Pry.config.ls.separator.
|
40
|
+
|
41
|
+
Pry.config.ls.ceiling is used to hide methods defined higher up in the
|
42
|
+
inheritance chain, this is by default set to [Object, Module, Class] so that
|
43
|
+
methods defined on all Objects are omitted. The -v flag can be used to ignore
|
44
|
+
this setting and show all methods, while the -q can be used to set the ceiling
|
45
|
+
much lower and show only methods defined on the object or its direct class.
|
46
|
+
|
47
|
+
Also check out `find-method` command (run `help find-method`).
|
48
|
+
BANNER
|
49
|
+
|
50
|
+
def options(opt)
|
51
|
+
opt.on :m, :methods, "Show public methods defined on the Object"
|
52
|
+
opt.on :M, "instance-methods", "Show public methods defined in a Module or Class"
|
53
|
+
opt.on :p, :ppp, "Show public, protected (in yellow) and private (in green) methods"
|
54
|
+
opt.on :q, :quiet, "Show only methods defined on object.singleton_class and object.class"
|
55
|
+
opt.on :v, :verbose, "Show methods and constants on all super-classes (ignores Pry.config.ls.ceiling)"
|
56
|
+
opt.on :g, :globals, "Show global variables, including those builtin to Ruby (in cyan)"
|
57
|
+
opt.on :l, :locals, "Show hash of local vars, sorted by descending size"
|
58
|
+
opt.on :c, :constants, "Show constants, highlighting classes (in blue), and exceptions (in purple).\n" <<
|
59
|
+
" " * 32 << "Constants that are pending autoload? are also shown (in yellow)"
|
60
|
+
opt.on :i, :ivars, "Show instance variables (in blue) and class variables (in bright blue)"
|
61
|
+
opt.on :G, :grep, "Filter output by regular expression", argument: true
|
62
|
+
if Object.respond_to?(:deprecate_constant)
|
63
|
+
opt.on :d, :dconstants, "Show deprecated constants"
|
64
|
+
end
|
65
|
+
if Helpers::Platform.jruby?
|
66
|
+
opt.on :J, "all-java", "Show all the aliases for methods from java (default is to show only prettiest)"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Exclude -q, -v and --grep because they,
|
71
|
+
# don't specify what the user wants to see.
|
72
|
+
def no_user_opts?
|
73
|
+
!(opts[:methods] || opts['instance-methods'] || opts[:ppp] ||
|
74
|
+
opts[:globals] || opts[:locals] || opts[:constants] || opts[:ivars])
|
75
|
+
end
|
76
|
+
|
77
|
+
def process
|
78
|
+
@interrogatee = args.empty? ? target_self : target.eval(args.join(' '))
|
79
|
+
raise_errors_if_arguments_are_weird
|
80
|
+
ls_entity = LsEntity.new({
|
81
|
+
interrogatee: @interrogatee,
|
82
|
+
no_user_opts: no_user_opts?,
|
83
|
+
opts: opts,
|
84
|
+
args: args,
|
85
|
+
_pry_: _pry_
|
86
|
+
})
|
87
|
+
|
88
|
+
_pry_.pager.page ls_entity.entities_table
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def error_list
|
94
|
+
any_args = args.any?
|
95
|
+
non_mod_interrogatee = !(Module === @interrogatee)
|
96
|
+
[
|
97
|
+
['-l does not make sense with a specified Object', :locals, any_args],
|
98
|
+
['-g does not make sense with a specified Object', :globals, any_args],
|
99
|
+
['-q does not make sense with -v', :quiet, opts.present?(:verbose)],
|
100
|
+
['-M only makes sense with a Module or a Class', 'instance-methods', non_mod_interrogatee],
|
101
|
+
['-c only makes sense with a Module or a Class', :constants, any_args && non_mod_interrogatee]
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
def raise_errors_if_arguments_are_weird
|
106
|
+
error_list.each do |message, option, invalid_expr|
|
107
|
+
raise Pry::CommandError, message if opts.present?(option) && invalid_expr
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
Pry::Commands.add_command(Pry::Command::Ls)
|
113
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::Nesting < Pry::ClassCommand
|
3
|
+
match 'nesting'
|
4
|
+
group 'Navigating Pry'
|
5
|
+
description 'Show nesting information.'
|
6
|
+
|
7
|
+
banner <<-'BANNER'
|
8
|
+
Show nesting information.
|
9
|
+
BANNER
|
10
|
+
|
11
|
+
def process
|
12
|
+
output.puts 'Nesting status:'
|
13
|
+
output.puts '--'
|
14
|
+
_pry_.binding_stack.each_with_index do |obj, level|
|
15
|
+
if level == 0
|
16
|
+
output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))} (Pry top level)"
|
17
|
+
else
|
18
|
+
output.puts "#{level}. #{Pry.view_clip(obj.eval('self'))}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Pry::Commands.add_command(Pry::Command::Nesting)
|
25
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
class Pry
|
2
|
+
class Command::Play < Pry::ClassCommand
|
3
|
+
match 'play'
|
4
|
+
group 'Editing'
|
5
|
+
description 'Playback a string variable, method, line, or file as input.'
|
6
|
+
|
7
|
+
banner <<-'BANNER'
|
8
|
+
Usage: play [OPTIONS] [--help]
|
9
|
+
|
10
|
+
The play command enables you to replay code from files and methods as if they
|
11
|
+
were entered directly in the Pry REPL.
|
12
|
+
|
13
|
+
play --lines 149..153 # assumes current context
|
14
|
+
play -i 20 --lines 1..3 # assumes lines of the input expression at 20
|
15
|
+
play -o 4 # the output of an expression at 4
|
16
|
+
play Pry#repl -l 1..-1 # play the contents of Pry#repl method
|
17
|
+
play -e 2 # play from specified line until end of valid expression
|
18
|
+
play hello.rb # play a file
|
19
|
+
play Rakefile -l 5 # play line 5 of a file
|
20
|
+
play -d hi # play documentation of hi method
|
21
|
+
play hi --open # play hi method and leave it open
|
22
|
+
|
23
|
+
https://github.com/pry/pry/wiki/User-Input#wiki-Play
|
24
|
+
BANNER
|
25
|
+
|
26
|
+
def options(opt)
|
27
|
+
CodeCollector.inject_options(opt)
|
28
|
+
|
29
|
+
opt.on :open, 'Plays the selected content except the last line. Useful' \
|
30
|
+
' for replaying methods and leaving the method definition' \
|
31
|
+
' "open". `amend-line` can then be used to' \
|
32
|
+
' modify the method.'
|
33
|
+
|
34
|
+
opt.on :e, :expression=, 'Executes until end of valid expression', as: Integer
|
35
|
+
opt.on :p, :print, 'Prints executed code'
|
36
|
+
end
|
37
|
+
|
38
|
+
def process
|
39
|
+
@cc = CodeCollector.new(args, opts, _pry_)
|
40
|
+
|
41
|
+
perform_play
|
42
|
+
show_input
|
43
|
+
end
|
44
|
+
|
45
|
+
def perform_play
|
46
|
+
eval_string << content_after_options
|
47
|
+
run "fix-indent"
|
48
|
+
end
|
49
|
+
|
50
|
+
def show_input
|
51
|
+
if opts.present?(:print) or !Pry::Code.complete_expression?(eval_string)
|
52
|
+
run "show-input"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def content_after_options
|
57
|
+
if opts.present?(:open)
|
58
|
+
restrict_to_lines(content, (0..-2))
|
59
|
+
elsif opts.present?(:expression)
|
60
|
+
content_at_expression
|
61
|
+
else
|
62
|
+
content
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def content_at_expression
|
67
|
+
code_object.expression_at(opts[:expression])
|
68
|
+
end
|
69
|
+
|
70
|
+
def code_object
|
71
|
+
Pry::Code.new(content)
|
72
|
+
end
|
73
|
+
|
74
|
+
def should_use_default_file?
|
75
|
+
!args.first && !opts.present?(:in) && !opts.present?(:out)
|
76
|
+
end
|
77
|
+
|
78
|
+
def content
|
79
|
+
if should_use_default_file?
|
80
|
+
file_content
|
81
|
+
else
|
82
|
+
@cc.content
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# The file to play from when no code object is specified.
|
87
|
+
# e.g `play --lines 4..10`
|
88
|
+
def default_file
|
89
|
+
target.eval("__FILE__") && File.expand_path(target.eval("__FILE__"))
|
90
|
+
end
|
91
|
+
|
92
|
+
def file_content
|
93
|
+
if default_file && File.exist?(default_file)
|
94
|
+
@cc.restrict_to_lines(File.read(default_file), @cc.line_range)
|
95
|
+
else
|
96
|
+
raise CommandError, "File does not exist! File was: #{default_file.inspect}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
Pry::Commands.add_command(Pry::Command::Play)
|
102
|
+
end
|