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,25 @@
|
|
1
|
+
License
|
2
|
+
-------
|
3
|
+
|
4
|
+
(The MIT License)
|
5
|
+
|
6
|
+
Copyright (c) 2011 John Mair (banisterfiend)
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
'Software'), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,91 @@
|
|
1
|
+
method_source [](https://travis-ci.org/banister/method_source)
|
2
|
+
=============
|
3
|
+
|
4
|
+
(C) John Mair (banisterfiend) 2011
|
5
|
+
|
6
|
+
_retrieve the sourcecode for a method_
|
7
|
+
|
8
|
+
*NOTE:* This simply utilizes `Method#source_location`; it
|
9
|
+
does not access the live AST.
|
10
|
+
|
11
|
+
`method_source` is a utility to return a method's sourcecode as a
|
12
|
+
Ruby string. Also returns `Proc` and `Lambda` sourcecode.
|
13
|
+
|
14
|
+
Method comments can also be extracted using the `comment` method.
|
15
|
+
|
16
|
+
It is written in pure Ruby (no C).
|
17
|
+
|
18
|
+
* Some Ruby 1.8 support now available.
|
19
|
+
* Support for MRI, RBX, JRuby, REE
|
20
|
+
|
21
|
+
`method_source` provides the `source` and `comment` methods to the `Method` and
|
22
|
+
`UnboundMethod` and `Proc` classes.
|
23
|
+
|
24
|
+
* Install the [gem](https://rubygems.org/gems/method_source): `gem install method_source`
|
25
|
+
* Read the [documentation](http://rdoc.info/github/banister/method_source/master/file/README.markdown)
|
26
|
+
* See the [source code](http://github.com/banister/method_source)
|
27
|
+
|
28
|
+
Example: display method source
|
29
|
+
------------------------------
|
30
|
+
|
31
|
+
Set.instance_method(:merge).source.display
|
32
|
+
# =>
|
33
|
+
def merge(enum)
|
34
|
+
if enum.instance_of?(self.class)
|
35
|
+
@hash.update(enum.instance_variable_get(:@hash))
|
36
|
+
else
|
37
|
+
do_with_enum(enum) { |o| add(o) }
|
38
|
+
end
|
39
|
+
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
Example: display method comments
|
44
|
+
--------------------------------
|
45
|
+
|
46
|
+
Set.instance_method(:merge).comment.display
|
47
|
+
# =>
|
48
|
+
# Merges the elements of the given enumerable object to the set and
|
49
|
+
# returns self.
|
50
|
+
|
51
|
+
Limitations:
|
52
|
+
------------
|
53
|
+
|
54
|
+
* Occasional strange behaviour in Ruby 1.8
|
55
|
+
* Cannot return source for C methods.
|
56
|
+
* Cannot return source for dynamically defined methods.
|
57
|
+
|
58
|
+
Special Thanks
|
59
|
+
--------------
|
60
|
+
|
61
|
+
[Adam Sanderson](https://github.com/adamsanderson) for `comment` functionality.
|
62
|
+
|
63
|
+
[Dmitry Elastic](https://github.com/dmitryelastic) for the brilliant Ruby 1.8 `source_location` hack.
|
64
|
+
|
65
|
+
[Samuel Kadolph](https://github.com/samuelkadolph) for the JRuby 1.8 `source_location`.
|
66
|
+
|
67
|
+
License
|
68
|
+
-------
|
69
|
+
|
70
|
+
(The MIT License)
|
71
|
+
|
72
|
+
Copyright (c) 2011 John Mair (banisterfiend)
|
73
|
+
|
74
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
75
|
+
a copy of this software and associated documentation files (the
|
76
|
+
'Software'), to deal in the Software without restriction, including
|
77
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
78
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
79
|
+
permit persons to whom the Software is furnished to do so, subject to
|
80
|
+
the following conditions:
|
81
|
+
|
82
|
+
The above copyright notice and this permission notice shall be
|
83
|
+
included in all copies or substantial portions of the Software.
|
84
|
+
|
85
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
88
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
89
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
90
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
91
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,81 @@
|
|
1
|
+
dlext = RbConfig::CONFIG['DLEXT']
|
2
|
+
direc = File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rubygems/package_task'
|
6
|
+
require "#{direc}/lib/method_source/version"
|
7
|
+
|
8
|
+
CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
9
|
+
CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
|
10
|
+
"ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*.rbc",
|
11
|
+
"ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake")
|
12
|
+
|
13
|
+
def apply_spec_defaults(s)
|
14
|
+
s.name = "method_source"
|
15
|
+
s.summary = "retrieve the sourcecode for a method"
|
16
|
+
s.version = MethodSource::VERSION
|
17
|
+
s.date = Time.now.strftime '%Y-%m-%d'
|
18
|
+
s.author = "John Mair (banisterfiend)"
|
19
|
+
s.email = 'jrmair@gmail.com'
|
20
|
+
s.description = s.summary
|
21
|
+
s.require_path = 'lib'
|
22
|
+
s.license = 'MIT'
|
23
|
+
|
24
|
+
s.add_development_dependency("rspec","~>3.6")
|
25
|
+
s.add_development_dependency("rake", "~>0.9")
|
26
|
+
s.homepage = "http://banisterfiend.wordpress.com"
|
27
|
+
s.has_rdoc = 'yard'
|
28
|
+
s.files = `git ls-files`.split("\n")
|
29
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
require "rspec/core/rake_task"
|
33
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
34
|
+
t.ruby_opts = %w[-w]
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "reinstall gem"
|
38
|
+
task :reinstall => :gems do
|
39
|
+
sh "gem uninstall method_source" rescue nil
|
40
|
+
sh "gem install #{direc}/pkg/method_source-#{MethodSource::VERSION}.gem"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Set up and run tests"
|
44
|
+
task :default => [:spec]
|
45
|
+
|
46
|
+
desc "Build the gemspec file"
|
47
|
+
task :gemspec => "ruby:gemspec"
|
48
|
+
|
49
|
+
namespace :ruby do
|
50
|
+
spec = Gem::Specification.new do |s|
|
51
|
+
apply_spec_defaults(s)
|
52
|
+
s.platform = Gem::Platform::RUBY
|
53
|
+
end
|
54
|
+
|
55
|
+
Gem::PackageTask.new(spec) do |pkg|
|
56
|
+
pkg.need_zip = false
|
57
|
+
pkg.need_tar = false
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Generate gemspec file"
|
61
|
+
task :gemspec do
|
62
|
+
File.open("#{spec.name}.gemspec", "w") do |f|
|
63
|
+
f << spec.to_ruby
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "build all platform gems at once"
|
69
|
+
task :gems => [:rmgems, "ruby:gem"]
|
70
|
+
|
71
|
+
desc "remove all platform gems"
|
72
|
+
task :rmgems => ["ruby:clobber_package"]
|
73
|
+
|
74
|
+
desc "build and push latest gems"
|
75
|
+
task :pushgems => :gems do
|
76
|
+
chdir("#{direc}/pkg") do
|
77
|
+
Dir["*.gem"].each do |gemfile|
|
78
|
+
sh "gem push #{gemfile}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
module MethodSource
|
2
|
+
|
3
|
+
module CodeHelpers
|
4
|
+
# Retrieve the first expression starting on the given line of the given file.
|
5
|
+
#
|
6
|
+
# This is useful to get module or method source code.
|
7
|
+
#
|
8
|
+
# @param [Array<String>, File, String] file The file to parse, either as a File or as
|
9
|
+
# @param [Integer] line_number The line number at which to look.
|
10
|
+
# NOTE: The first line in a file is
|
11
|
+
# line 1!
|
12
|
+
# @param [Hash] options The optional configuration parameters.
|
13
|
+
# @option options [Boolean] :strict If set to true, then only completely
|
14
|
+
# valid expressions are returned. Otherwise heuristics are used to extract
|
15
|
+
# expressions that may have been valid inside an eval.
|
16
|
+
# @option options [Integer] :consume A number of lines to automatically
|
17
|
+
# consume (add to the expression buffer) without checking for validity.
|
18
|
+
# @return [String] The first complete expression
|
19
|
+
# @raise [SyntaxError] If the first complete expression can't be identified
|
20
|
+
def expression_at(file, line_number, options={})
|
21
|
+
options = {
|
22
|
+
:strict => false,
|
23
|
+
:consume => 0
|
24
|
+
}.merge!(options)
|
25
|
+
|
26
|
+
lines = file.is_a?(Array) ? file : file.each_line.to_a
|
27
|
+
|
28
|
+
relevant_lines = lines[(line_number - 1)..-1] || []
|
29
|
+
|
30
|
+
extract_first_expression(relevant_lines, options[:consume])
|
31
|
+
rescue SyntaxError => e
|
32
|
+
raise if options[:strict]
|
33
|
+
|
34
|
+
begin
|
35
|
+
extract_first_expression(relevant_lines) do |code|
|
36
|
+
code.gsub(/\#\{.*?\}/, "temp")
|
37
|
+
end
|
38
|
+
rescue SyntaxError
|
39
|
+
raise e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Retrieve the comment describing the expression on the given line of the given file.
|
44
|
+
#
|
45
|
+
# This is useful to get module or method documentation.
|
46
|
+
#
|
47
|
+
# @param [Array<String>, File, String] file The file to parse, either as a File or as
|
48
|
+
# a String or an Array of lines.
|
49
|
+
# @param [Integer] line_number The line number at which to look.
|
50
|
+
# NOTE: The first line in a file is line 1!
|
51
|
+
# @return [String] The comment
|
52
|
+
def comment_describing(file, line_number)
|
53
|
+
lines = file.is_a?(Array) ? file : file.each_line.to_a
|
54
|
+
|
55
|
+
extract_last_comment(lines[0..(line_number - 2)])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Determine if a string of code is a complete Ruby expression.
|
59
|
+
# @param [String] code The code to validate.
|
60
|
+
# @return [Boolean] Whether or not the code is a complete Ruby expression.
|
61
|
+
# @raise [SyntaxError] Any SyntaxError that does not represent incompleteness.
|
62
|
+
# @example
|
63
|
+
# complete_expression?("class Hello") #=> false
|
64
|
+
# complete_expression?("class Hello; end") #=> true
|
65
|
+
# complete_expression?("class 123") #=> SyntaxError: unexpected tINTEGER
|
66
|
+
def complete_expression?(str)
|
67
|
+
old_verbose = $VERBOSE
|
68
|
+
$VERBOSE = nil
|
69
|
+
|
70
|
+
catch(:valid) do
|
71
|
+
eval("BEGIN{throw :valid}\n#{str}")
|
72
|
+
end
|
73
|
+
|
74
|
+
# Assert that a line which ends with a , or \ is incomplete.
|
75
|
+
str !~ /[,\\]\s*\z/
|
76
|
+
rescue IncompleteExpression
|
77
|
+
false
|
78
|
+
ensure
|
79
|
+
$VERBOSE = old_verbose
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
# Get the first expression from the input.
|
85
|
+
#
|
86
|
+
# @param [Array<String>] lines
|
87
|
+
# @param [Integer] consume A number of lines to automatically
|
88
|
+
# consume (add to the expression buffer) without checking for validity.
|
89
|
+
# @yield a clean-up function to run before checking for complete_expression
|
90
|
+
# @return [String] a valid ruby expression
|
91
|
+
# @raise [SyntaxError]
|
92
|
+
def extract_first_expression(lines, consume=0, &block)
|
93
|
+
code = consume.zero? ? "" : lines.slice!(0..(consume - 1)).join
|
94
|
+
|
95
|
+
lines.each do |v|
|
96
|
+
code << v
|
97
|
+
return code if complete_expression?(block ? block.call(code) : code)
|
98
|
+
end
|
99
|
+
raise SyntaxError, "unexpected $end"
|
100
|
+
end
|
101
|
+
|
102
|
+
# Get the last comment from the input.
|
103
|
+
#
|
104
|
+
# @param [Array<String>] lines
|
105
|
+
# @return [String]
|
106
|
+
def extract_last_comment(lines)
|
107
|
+
buffer = ""
|
108
|
+
|
109
|
+
lines.each do |line|
|
110
|
+
# Add any line that is a valid ruby comment,
|
111
|
+
# but clear as soon as we hit a non comment line.
|
112
|
+
if (line =~ /^\s*#/) || (line =~ /^\s*$/)
|
113
|
+
buffer << line.lstrip
|
114
|
+
else
|
115
|
+
buffer.replace("")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
buffer
|
120
|
+
end
|
121
|
+
|
122
|
+
# An exception matcher that matches only subsets of SyntaxErrors that can be
|
123
|
+
# fixed by adding more input to the buffer.
|
124
|
+
module IncompleteExpression
|
125
|
+
GENERIC_REGEXPS = [
|
126
|
+
/unexpected (\$end|end-of-file|end-of-input|END_OF_FILE)/, # mri, jruby, ruby-2.0, ironruby
|
127
|
+
/embedded document meets end of file/, # =begin
|
128
|
+
/unterminated (quoted string|string|regexp) meets end of file/, # "quoted string" is ironruby
|
129
|
+
/can't find string ".*" anywhere before EOF/, # rbx and jruby
|
130
|
+
/missing 'end' for/, /expecting kWHEN/ # rbx
|
131
|
+
]
|
132
|
+
|
133
|
+
RBX_ONLY_REGEXPS = [
|
134
|
+
/expecting '[})\]]'(?:$|:)/, /expecting keyword_end/
|
135
|
+
]
|
136
|
+
|
137
|
+
def self.===(ex)
|
138
|
+
return false unless SyntaxError === ex
|
139
|
+
case ex.message
|
140
|
+
when *GENERIC_REGEXPS
|
141
|
+
true
|
142
|
+
when *RBX_ONLY_REGEXPS
|
143
|
+
rbx?
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.rbx?
|
150
|
+
RbConfig::CONFIG['ruby_install_name'] == 'rbx'
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
module MethodSource
|
2
|
+
module ReeSourceLocation
|
3
|
+
# Ruby enterprise edition provides all the information that's
|
4
|
+
# needed, in a slightly different way.
|
5
|
+
def source_location
|
6
|
+
[__file__, __line__] rescue nil
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module SourceLocation
|
11
|
+
module MethodExtensions
|
12
|
+
if Proc.method_defined? :__file__
|
13
|
+
include ReeSourceLocation
|
14
|
+
|
15
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
16
|
+
require 'java'
|
17
|
+
|
18
|
+
# JRuby version source_location hack
|
19
|
+
# @return [Array] A two element array containing the source location of the method
|
20
|
+
def source_location
|
21
|
+
to_java.source_location(Thread.current.to_java.getContext())
|
22
|
+
end
|
23
|
+
else
|
24
|
+
|
25
|
+
|
26
|
+
def trace_func(event, file, line, id, binding, classname)
|
27
|
+
return unless event == 'call'
|
28
|
+
set_trace_func nil
|
29
|
+
|
30
|
+
@file, @line = file, line
|
31
|
+
raise :found
|
32
|
+
end
|
33
|
+
|
34
|
+
private :trace_func
|
35
|
+
|
36
|
+
# Return the source location of a method for Ruby 1.8.
|
37
|
+
# @return [Array] A two element array. First element is the
|
38
|
+
# file, second element is the line in the file where the
|
39
|
+
# method definition is found.
|
40
|
+
def source_location
|
41
|
+
if @file.nil?
|
42
|
+
args =[*(1..(arity<-1 ? -arity-1 : arity ))]
|
43
|
+
|
44
|
+
set_trace_func method(:trace_func).to_proc
|
45
|
+
call(*args) rescue nil
|
46
|
+
set_trace_func nil
|
47
|
+
@file = File.expand_path(@file) if @file && File.exist?(File.expand_path(@file))
|
48
|
+
end
|
49
|
+
[@file, @line] if @file
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module ProcExtensions
|
55
|
+
if Proc.method_defined? :__file__
|
56
|
+
include ReeSourceLocation
|
57
|
+
|
58
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
59
|
+
|
60
|
+
# Return the source location for a Proc (Rubinius only)
|
61
|
+
# @return [Array] A two element array. First element is the
|
62
|
+
# file, second element is the line in the file where the
|
63
|
+
# proc definition is found.
|
64
|
+
def source_location
|
65
|
+
[block.file.to_s, block.line]
|
66
|
+
end
|
67
|
+
else
|
68
|
+
|
69
|
+
# Return the source location for a Proc (in implementations
|
70
|
+
# without Proc#source_location)
|
71
|
+
# @return [Array] A two element array. First element is the
|
72
|
+
# file, second element is the line in the file where the
|
73
|
+
# proc definition is found.
|
74
|
+
def source_location
|
75
|
+
self.to_s =~ /@(.*):(\d+)/
|
76
|
+
[$1, $2.to_i]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
module UnboundMethodExtensions
|
82
|
+
if Proc.method_defined? :__file__
|
83
|
+
include ReeSourceLocation
|
84
|
+
|
85
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
86
|
+
require 'java'
|
87
|
+
|
88
|
+
# JRuby version source_location hack
|
89
|
+
# @return [Array] A two element array containing the source location of the method
|
90
|
+
def source_location
|
91
|
+
to_java.source_location(Thread.current.to_java.getContext())
|
92
|
+
end
|
93
|
+
|
94
|
+
else
|
95
|
+
|
96
|
+
|
97
|
+
# Return the source location of an instance method for Ruby 1.8.
|
98
|
+
# @return [Array] A two element array. First element is the
|
99
|
+
# file, second element is the line in the file where the
|
100
|
+
# method definition is found.
|
101
|
+
def source_location
|
102
|
+
klass = case owner
|
103
|
+
when Class
|
104
|
+
owner
|
105
|
+
when Module
|
106
|
+
method_owner = owner
|
107
|
+
Class.new { include(method_owner) }
|
108
|
+
end
|
109
|
+
|
110
|
+
# deal with immediate values
|
111
|
+
case
|
112
|
+
when klass == Symbol
|
113
|
+
return :a.method(name).source_location
|
114
|
+
when klass == Integer
|
115
|
+
return 0.method(name).source_location
|
116
|
+
when klass == TrueClass
|
117
|
+
return true.method(name).source_location
|
118
|
+
when klass == FalseClass
|
119
|
+
return false.method(name).source_location
|
120
|
+
when klass == NilClass
|
121
|
+
return nil.method(name).source_location
|
122
|
+
end
|
123
|
+
|
124
|
+
begin
|
125
|
+
Object.instance_method(:method).bind(klass.allocate).call(name).source_location
|
126
|
+
rescue TypeError
|
127
|
+
|
128
|
+
# Assume we are dealing with a Singleton Class:
|
129
|
+
# 1. Get the instance object
|
130
|
+
# 2. Forward the source_location lookup to the instance
|
131
|
+
instance ||= ObjectSpace.each_object(owner).first
|
132
|
+
Object.instance_method(:method).bind(instance).call(name).source_location
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|