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,83 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
# A simple JSON Encoder.
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
# CodeRay.scan('puts "Hello world!"', :ruby).json
|
8
|
+
# yields
|
9
|
+
# [
|
10
|
+
# {"type"=>"text", "text"=>"puts", "kind"=>"ident"},
|
11
|
+
# {"type"=>"text", "text"=>" ", "kind"=>"space"},
|
12
|
+
# {"type"=>"block", "action"=>"open", "kind"=>"string"},
|
13
|
+
# {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
|
14
|
+
# {"type"=>"text", "text"=>"Hello world!", "kind"=>"content"},
|
15
|
+
# {"type"=>"text", "text"=>"\"", "kind"=>"delimiter"},
|
16
|
+
# {"type"=>"block", "action"=>"close", "kind"=>"string"},
|
17
|
+
# ]
|
18
|
+
class JSON < Encoder
|
19
|
+
|
20
|
+
begin
|
21
|
+
require 'json'
|
22
|
+
rescue LoadError
|
23
|
+
begin
|
24
|
+
require 'rubygems' unless defined? Gem
|
25
|
+
gem 'json'
|
26
|
+
require 'json'
|
27
|
+
rescue LoadError
|
28
|
+
$stderr.puts "The JSON encoder needs the JSON library.\n" \
|
29
|
+
"Please gem install json."
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
register_for :json
|
35
|
+
FILE_EXTENSION = 'json'
|
36
|
+
|
37
|
+
protected
|
38
|
+
def setup options
|
39
|
+
super
|
40
|
+
|
41
|
+
@first = true
|
42
|
+
@out << '['
|
43
|
+
end
|
44
|
+
|
45
|
+
def finish options
|
46
|
+
@out << ']'
|
47
|
+
end
|
48
|
+
|
49
|
+
def append data
|
50
|
+
if @first
|
51
|
+
@first = false
|
52
|
+
else
|
53
|
+
@out << ','
|
54
|
+
end
|
55
|
+
|
56
|
+
@out << data.to_json
|
57
|
+
end
|
58
|
+
|
59
|
+
public
|
60
|
+
def text_token text, kind
|
61
|
+
append :type => 'text', :text => text, :kind => kind
|
62
|
+
end
|
63
|
+
|
64
|
+
def begin_group kind
|
65
|
+
append :type => 'block', :action => 'open', :kind => kind
|
66
|
+
end
|
67
|
+
|
68
|
+
def end_group kind
|
69
|
+
append :type => 'block', :action => 'close', :kind => kind
|
70
|
+
end
|
71
|
+
|
72
|
+
def begin_line kind
|
73
|
+
append :type => 'block', :action => 'begin_line', :kind => kind
|
74
|
+
end
|
75
|
+
|
76
|
+
def end_line kind
|
77
|
+
append :type => 'block', :action => 'end_line', :kind => kind
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
# Counts the LoC (Lines of Code). Returns an Integer >= 0.
|
5
|
+
#
|
6
|
+
# Alias: +loc+
|
7
|
+
#
|
8
|
+
# Everything that is not comment, markup, doctype/shebang, or an empty line,
|
9
|
+
# is considered to be code.
|
10
|
+
#
|
11
|
+
# For example,
|
12
|
+
# * HTML files not containing JavaScript have 0 LoC
|
13
|
+
# * in a Java class without comments, LoC is the number of non-empty lines
|
14
|
+
#
|
15
|
+
# A Scanner class should define the token kinds that are not code in the
|
16
|
+
# KINDS_NOT_LOC constant, which defaults to [:comment, :doctype].
|
17
|
+
class LinesOfCode < TokenKindFilter
|
18
|
+
|
19
|
+
register_for :lines_of_code
|
20
|
+
|
21
|
+
NON_EMPTY_LINE = /^\s*\S.*$/
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def setup options
|
26
|
+
if scanner
|
27
|
+
kinds_not_loc = scanner.class::KINDS_NOT_LOC
|
28
|
+
else
|
29
|
+
warn "Tokens have no associated scanner, counting all nonempty lines." if $VERBOSE
|
30
|
+
kinds_not_loc = CodeRay::Scanners::Scanner::KINDS_NOT_LOC
|
31
|
+
end
|
32
|
+
|
33
|
+
options[:exclude] = kinds_not_loc
|
34
|
+
|
35
|
+
super options
|
36
|
+
end
|
37
|
+
|
38
|
+
def finish options
|
39
|
+
output @tokens.text.scan(NON_EMPTY_LINE).size
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
# = Lint Encoder
|
5
|
+
#
|
6
|
+
# Checks for:
|
7
|
+
#
|
8
|
+
# - empty tokens
|
9
|
+
# - incorrect nesting
|
10
|
+
#
|
11
|
+
# It will raise an InvalidTokenStream exception when any of the above occurs.
|
12
|
+
#
|
13
|
+
# See also: Encoders::DebugLint
|
14
|
+
class Lint < Debug
|
15
|
+
|
16
|
+
register_for :lint
|
17
|
+
|
18
|
+
InvalidTokenStream = Class.new StandardError
|
19
|
+
EmptyToken = Class.new InvalidTokenStream
|
20
|
+
UnknownTokenKind = Class.new InvalidTokenStream
|
21
|
+
IncorrectTokenGroupNesting = Class.new InvalidTokenStream
|
22
|
+
|
23
|
+
def text_token text, kind
|
24
|
+
raise EmptyToken, 'empty token for %p' % [kind] if text.empty?
|
25
|
+
raise UnknownTokenKind, 'unknown token kind %p (text was %p)' % [kind, text] unless TokenKinds.has_key? kind
|
26
|
+
end
|
27
|
+
|
28
|
+
def begin_group kind
|
29
|
+
@opened << kind
|
30
|
+
end
|
31
|
+
|
32
|
+
def end_group kind
|
33
|
+
raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_group)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
|
34
|
+
@opened.pop
|
35
|
+
end
|
36
|
+
|
37
|
+
def begin_line kind
|
38
|
+
@opened << kind
|
39
|
+
end
|
40
|
+
|
41
|
+
def end_line kind
|
42
|
+
raise IncorrectTokenGroupNesting, 'We are inside %s, not %p (end_line)' % [@opened.reverse.map(&:inspect).join(' < '), kind] if @opened.last != kind
|
43
|
+
@opened.pop
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def setup options
|
49
|
+
@opened = []
|
50
|
+
end
|
51
|
+
|
52
|
+
def finish options
|
53
|
+
raise 'Some tokens still open at end of token stream: %p' % [@opened] unless @opened.empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
load :html
|
5
|
+
|
6
|
+
# Wraps the output into a HTML page, using CSS classes and
|
7
|
+
# line numbers in the table format by default.
|
8
|
+
#
|
9
|
+
# See Encoders::HTML for available options.
|
10
|
+
class Page < HTML
|
11
|
+
|
12
|
+
FILE_EXTENSION = 'html'
|
13
|
+
|
14
|
+
register_for :page
|
15
|
+
|
16
|
+
DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \
|
17
|
+
:css => :class,
|
18
|
+
:wrap => :page,
|
19
|
+
:line_numbers => :table
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
load :html
|
5
|
+
|
6
|
+
# Wraps HTML output into a SPAN element, using inline styles by default.
|
7
|
+
#
|
8
|
+
# See Encoders::HTML for available options.
|
9
|
+
class Span < HTML
|
10
|
+
|
11
|
+
FILE_EXTENSION = 'span.html'
|
12
|
+
|
13
|
+
register_for :span
|
14
|
+
|
15
|
+
DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \
|
16
|
+
:css => :style,
|
17
|
+
:wrap => :span,
|
18
|
+
:line_numbers => false
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
# Makes a statistic for the given tokens.
|
5
|
+
#
|
6
|
+
# Alias: +stats+
|
7
|
+
class Statistic < Encoder
|
8
|
+
|
9
|
+
register_for :statistic
|
10
|
+
|
11
|
+
attr_reader :type_stats, :real_token_count # :nodoc:
|
12
|
+
|
13
|
+
TypeStats = Struct.new :count, :size # :nodoc:
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def setup options
|
18
|
+
super
|
19
|
+
|
20
|
+
@type_stats = Hash.new { |h, k| h[k] = TypeStats.new 0, 0 }
|
21
|
+
@real_token_count = 0
|
22
|
+
end
|
23
|
+
|
24
|
+
STATS = <<-STATS # :nodoc:
|
25
|
+
|
26
|
+
Code Statistics
|
27
|
+
|
28
|
+
Tokens %8d
|
29
|
+
Non-Whitespace %8d
|
30
|
+
Bytes Total %8d
|
31
|
+
|
32
|
+
Token Types (%d):
|
33
|
+
type count ratio size (average)
|
34
|
+
-------------------------------------------------------------
|
35
|
+
%s
|
36
|
+
STATS
|
37
|
+
|
38
|
+
TOKEN_TYPES_ROW = <<-TKR # :nodoc:
|
39
|
+
%-20s %8d %6.2f %% %5.1f
|
40
|
+
TKR
|
41
|
+
|
42
|
+
def finish options
|
43
|
+
all = @type_stats['TOTAL']
|
44
|
+
all_count, all_size = all.count, all.size
|
45
|
+
@type_stats.each do |type, stat|
|
46
|
+
stat.size /= stat.count.to_f
|
47
|
+
end
|
48
|
+
types_stats = @type_stats.sort_by { |k, v| [-v.count, k.to_s] }.map do |k, v|
|
49
|
+
TOKEN_TYPES_ROW % [k, v.count, 100.0 * v.count / all_count, v.size]
|
50
|
+
end.join
|
51
|
+
@out << STATS % [
|
52
|
+
all_count, @real_token_count, all_size,
|
53
|
+
@type_stats.delete_if { |k, v| k.is_a? String }.size,
|
54
|
+
types_stats
|
55
|
+
]
|
56
|
+
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
public
|
61
|
+
|
62
|
+
def text_token text, kind
|
63
|
+
@real_token_count += 1 unless kind == :space
|
64
|
+
@type_stats[kind].count += 1
|
65
|
+
@type_stats[kind].size += text.size
|
66
|
+
@type_stats['TOTAL'].size += text.size
|
67
|
+
@type_stats['TOTAL'].count += 1
|
68
|
+
end
|
69
|
+
|
70
|
+
def begin_group kind
|
71
|
+
block_token ':begin_group', kind
|
72
|
+
end
|
73
|
+
|
74
|
+
def end_group kind
|
75
|
+
block_token ':end_group', kind
|
76
|
+
end
|
77
|
+
|
78
|
+
def begin_line kind
|
79
|
+
block_token ':begin_line', kind
|
80
|
+
end
|
81
|
+
|
82
|
+
def end_line kind
|
83
|
+
block_token ':end_line', kind
|
84
|
+
end
|
85
|
+
|
86
|
+
def block_token action, kind
|
87
|
+
@type_stats['TOTAL'].count += 1
|
88
|
+
@type_stats[action].count += 1
|
89
|
+
@type_stats[kind].count += 1
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
module CodeRay
|
2
|
+
module Encoders
|
3
|
+
|
4
|
+
# Outputs code highlighted for a color terminal.
|
5
|
+
#
|
6
|
+
# Note: This encoder is in beta. It currently doesn't use the Styles.
|
7
|
+
#
|
8
|
+
# Alias: +term+
|
9
|
+
#
|
10
|
+
# == Authors & License
|
11
|
+
#
|
12
|
+
# By Rob Aldred (http://robaldred.co.uk)
|
13
|
+
#
|
14
|
+
# Based on idea by Nathan Weizenbaum (http://nex-3.com)
|
15
|
+
#
|
16
|
+
# MIT License (http://www.opensource.org/licenses/mit-license.php)
|
17
|
+
class Terminal < Encoder
|
18
|
+
|
19
|
+
register_for :terminal
|
20
|
+
|
21
|
+
TOKEN_COLORS = {
|
22
|
+
:debug => "\e[1;37;44m",
|
23
|
+
|
24
|
+
:annotation => "\e[34m",
|
25
|
+
:attribute_name => "\e[35m",
|
26
|
+
:attribute_value => "\e[31m",
|
27
|
+
:binary => {
|
28
|
+
:self => "\e[31m",
|
29
|
+
:char => "\e[1;31m",
|
30
|
+
:delimiter => "\e[1;31m",
|
31
|
+
},
|
32
|
+
:char => {
|
33
|
+
:self => "\e[35m",
|
34
|
+
:delimiter => "\e[1;35m"
|
35
|
+
},
|
36
|
+
:class => "\e[1;35;4m",
|
37
|
+
:class_variable => "\e[36m",
|
38
|
+
:color => "\e[32m",
|
39
|
+
:comment => {
|
40
|
+
:self => "\e[1;30m",
|
41
|
+
:char => "\e[37m",
|
42
|
+
:delimiter => "\e[37m",
|
43
|
+
},
|
44
|
+
:constant => "\e[1;34;4m",
|
45
|
+
:decorator => "\e[35m",
|
46
|
+
:definition => "\e[1;33m",
|
47
|
+
:directive => "\e[33m",
|
48
|
+
:docstring => "\e[31m",
|
49
|
+
:doctype => "\e[1;34m",
|
50
|
+
:done => "\e[1;30;2m",
|
51
|
+
:entity => "\e[31m",
|
52
|
+
:error => "\e[1;37;41m",
|
53
|
+
:exception => "\e[1;31m",
|
54
|
+
:float => "\e[1;35m",
|
55
|
+
:function => "\e[1;34m",
|
56
|
+
:global_variable => "\e[1;32m",
|
57
|
+
:hex => "\e[1;36m",
|
58
|
+
:id => "\e[1;34m",
|
59
|
+
:include => "\e[31m",
|
60
|
+
:integer => "\e[1;34m",
|
61
|
+
:imaginary => "\e[1;34m",
|
62
|
+
:important => "\e[1;31m",
|
63
|
+
:key => {
|
64
|
+
:self => "\e[35m",
|
65
|
+
:char => "\e[1;35m",
|
66
|
+
:delimiter => "\e[1;35m",
|
67
|
+
},
|
68
|
+
:keyword => "\e[32m",
|
69
|
+
:label => "\e[1;33m",
|
70
|
+
:local_variable => "\e[33m",
|
71
|
+
:namespace => "\e[1;35m",
|
72
|
+
:octal => "\e[1;34m",
|
73
|
+
:predefined => "\e[36m",
|
74
|
+
:predefined_constant => "\e[1;36m",
|
75
|
+
:predefined_type => "\e[1;32m",
|
76
|
+
:preprocessor => "\e[1;36m",
|
77
|
+
:pseudo_class => "\e[1;34m",
|
78
|
+
:regexp => {
|
79
|
+
:self => "\e[35m",
|
80
|
+
:delimiter => "\e[1;35m",
|
81
|
+
:modifier => "\e[35m",
|
82
|
+
:char => "\e[1;35m",
|
83
|
+
},
|
84
|
+
:reserved => "\e[32m",
|
85
|
+
:shell => {
|
86
|
+
:self => "\e[33m",
|
87
|
+
:char => "\e[1;33m",
|
88
|
+
:delimiter => "\e[1;33m",
|
89
|
+
:escape => "\e[1;33m",
|
90
|
+
},
|
91
|
+
:string => {
|
92
|
+
:self => "\e[31m",
|
93
|
+
:modifier => "\e[1;31m",
|
94
|
+
:char => "\e[1;35m",
|
95
|
+
:delimiter => "\e[1;31m",
|
96
|
+
:escape => "\e[1;31m",
|
97
|
+
},
|
98
|
+
:symbol => {
|
99
|
+
:self => "\e[33m",
|
100
|
+
:delimiter => "\e[1;33m",
|
101
|
+
},
|
102
|
+
:tag => "\e[32m",
|
103
|
+
:type => "\e[1;34m",
|
104
|
+
:value => "\e[36m",
|
105
|
+
:variable => "\e[34m",
|
106
|
+
|
107
|
+
:insert => {
|
108
|
+
:self => "\e[42m",
|
109
|
+
:insert => "\e[1;32;42m",
|
110
|
+
:eyecatcher => "\e[102m",
|
111
|
+
},
|
112
|
+
:delete => {
|
113
|
+
:self => "\e[41m",
|
114
|
+
:delete => "\e[1;31;41m",
|
115
|
+
:eyecatcher => "\e[101m",
|
116
|
+
},
|
117
|
+
:change => {
|
118
|
+
:self => "\e[44m",
|
119
|
+
:change => "\e[37;44m",
|
120
|
+
},
|
121
|
+
:head => {
|
122
|
+
:self => "\e[45m",
|
123
|
+
:filename => "\e[37;45m"
|
124
|
+
},
|
125
|
+
}
|
126
|
+
|
127
|
+
TOKEN_COLORS[:keyword] = TOKEN_COLORS[:reserved]
|
128
|
+
TOKEN_COLORS[:method] = TOKEN_COLORS[:function]
|
129
|
+
TOKEN_COLORS[:escape] = TOKEN_COLORS[:delimiter]
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
def setup(options)
|
134
|
+
super
|
135
|
+
@opened = []
|
136
|
+
@color_scopes = [TOKEN_COLORS]
|
137
|
+
end
|
138
|
+
|
139
|
+
public
|
140
|
+
|
141
|
+
def text_token text, kind
|
142
|
+
if color = @color_scopes.last[kind]
|
143
|
+
color = color[:self] if color.is_a? Hash
|
144
|
+
|
145
|
+
@out << color
|
146
|
+
@out << (text.index("\n") ? text.gsub("\n", "\e[0m\n" + color) : text)
|
147
|
+
@out << "\e[0m"
|
148
|
+
if outer_color = @color_scopes.last[:self]
|
149
|
+
@out << outer_color
|
150
|
+
end
|
151
|
+
else
|
152
|
+
@out << text
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def begin_group kind
|
157
|
+
@opened << kind
|
158
|
+
@out << open_token(kind)
|
159
|
+
end
|
160
|
+
alias begin_line begin_group
|
161
|
+
|
162
|
+
def end_group kind
|
163
|
+
if @opened.pop
|
164
|
+
@color_scopes.pop
|
165
|
+
@out << "\e[0m"
|
166
|
+
if outer_color = @color_scopes.last[:self]
|
167
|
+
@out << outer_color
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def end_line kind
|
173
|
+
@out << (@line_filler ||= "\t" * 100)
|
174
|
+
end_group kind
|
175
|
+
end
|
176
|
+
|
177
|
+
private
|
178
|
+
|
179
|
+
def open_token kind
|
180
|
+
if color = @color_scopes.last[kind]
|
181
|
+
if color.is_a? Hash
|
182
|
+
@color_scopes << color
|
183
|
+
color[:self]
|
184
|
+
else
|
185
|
+
@color_scopes << @color_scopes.last
|
186
|
+
color
|
187
|
+
end
|
188
|
+
else
|
189
|
+
@color_scopes << @color_scopes.last
|
190
|
+
''
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|