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.
Files changed (292) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +21 -0
  4. data/README.md +26 -0
  5. data/chess_engine.gemspec +14 -0
  6. data/lib/chess_engine/board.rb +95 -0
  7. data/lib/chess_engine/cli.rb +105 -0
  8. data/lib/chess_engine/game.rb +148 -0
  9. data/lib/chess_engine/input.rb +19 -0
  10. data/lib/chess_engine/move.rb +35 -0
  11. data/lib/chess_engine/piece.rb +97 -0
  12. data/lib/chess_engine/validator.rb +87 -0
  13. data/lib/chess_engine.rb +1 -0
  14. data/spec/board_spec.rb +70 -0
  15. data/spec/game_helper.rb +5 -0
  16. data/spec/game_spec.rb +79 -0
  17. data/spec/spec_helper.rb +100 -0
  18. data/spec/validator_spec.rb +26 -0
  19. data/vendor/bundle/bin/coderay +27 -0
  20. data/vendor/bundle/bin/pry +27 -0
  21. data/vendor/bundle/cache/coderay-1.1.2.gem +0 -0
  22. data/vendor/bundle/cache/colorize-0.8.1.gem +0 -0
  23. data/vendor/bundle/cache/method_source-0.9.2.gem +0 -0
  24. data/vendor/bundle/cache/pry-0.12.2.gem +0 -0
  25. data/vendor/bundle/cache/rb-readline-0.5.5.gem +0 -0
  26. data/vendor/bundle/gems/coderay-1.1.2/MIT-LICENSE +22 -0
  27. data/vendor/bundle/gems/coderay-1.1.2/README_INDEX.rdoc +123 -0
  28. data/vendor/bundle/gems/coderay-1.1.2/bin/coderay +215 -0
  29. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/duo.rb +81 -0
  30. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/_map.rb +17 -0
  31. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/comment_filter.rb +25 -0
  32. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/count.rb +39 -0
  33. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug.rb +49 -0
  34. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/debug_lint.rb +63 -0
  35. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/div.rb +23 -0
  36. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb +190 -0
  37. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/filter.rb +58 -0
  38. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/css.rb +65 -0
  39. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/numbering.rb +108 -0
  40. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html/output.rb +166 -0
  41. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/html.rb +333 -0
  42. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/json.rb +83 -0
  43. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lines_of_code.rb +45 -0
  44. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/lint.rb +59 -0
  45. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/null.rb +18 -0
  46. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/page.rb +24 -0
  47. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/span.rb +23 -0
  48. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/statistic.rb +95 -0
  49. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/terminal.rb +195 -0
  50. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/text.rb +46 -0
  51. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/token_kind_filter.rb +111 -0
  52. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/xml.rb +72 -0
  53. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders/yaml.rb +50 -0
  54. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/encoders.rb +18 -0
  55. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/for_redcloth.rb +95 -0
  56. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/file_type.rb +151 -0
  57. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin.rb +55 -0
  58. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/plugin_host.rb +221 -0
  59. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/helpers/word_list.rb +72 -0
  60. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/_map.rb +24 -0
  61. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/c.rb +189 -0
  62. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/clojure.rb +217 -0
  63. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/cpp.rb +217 -0
  64. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/css.rb +196 -0
  65. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/debug.rb +75 -0
  66. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/delphi.rb +144 -0
  67. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/diff.rb +221 -0
  68. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/erb.rb +81 -0
  69. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/go.rb +208 -0
  70. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/groovy.rb +268 -0
  71. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/haml.rb +168 -0
  72. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/html.rb +275 -0
  73. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java/builtin_types.rb +421 -0
  74. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java.rb +174 -0
  75. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/java_script.rb +237 -0
  76. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/json.rb +98 -0
  77. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/lua.rb +280 -0
  78. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/php.rb +527 -0
  79. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/python.rb +287 -0
  80. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/raydebug.rb +75 -0
  81. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/patterns.rb +178 -0
  82. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby/string_state.rb +79 -0
  83. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/ruby.rb +477 -0
  84. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sass.rb +232 -0
  85. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb +337 -0
  86. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/sql.rb +169 -0
  87. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/taskpaper.rb +36 -0
  88. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/text.rb +26 -0
  89. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/xml.rb +17 -0
  90. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners/yaml.rb +140 -0
  91. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/scanners.rb +27 -0
  92. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/_map.rb +7 -0
  93. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/alpha.rb +153 -0
  94. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles/style.rb +18 -0
  95. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/styles.rb +15 -0
  96. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/token_kinds.rb +85 -0
  97. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens.rb +161 -0
  98. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb +55 -0
  99. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay/version.rb +3 -0
  100. data/vendor/bundle/gems/coderay-1.1.2/lib/coderay.rb +284 -0
  101. data/vendor/bundle/gems/colorize-0.8.1/CHANGELOG +65 -0
  102. data/vendor/bundle/gems/colorize-0.8.1/LICENSE +339 -0
  103. data/vendor/bundle/gems/colorize-0.8.1/README.md +105 -0
  104. data/vendor/bundle/gems/colorize-0.8.1/Rakefile +13 -0
  105. data/vendor/bundle/gems/colorize-0.8.1/colorize.gemspec +36 -0
  106. data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/class_methods.rb +120 -0
  107. data/vendor/bundle/gems/colorize-0.8.1/lib/colorize/instance_methods.rb +132 -0
  108. data/vendor/bundle/gems/colorize-0.8.1/lib/colorize.rb +12 -0
  109. data/vendor/bundle/gems/colorize-0.8.1/lib/colorized_string.rb +19 -0
  110. data/vendor/bundle/gems/colorize-0.8.1/test/test_colorize.rb +164 -0
  111. data/vendor/bundle/gems/method_source-0.9.2/Gemfile +2 -0
  112. data/vendor/bundle/gems/method_source-0.9.2/LICENSE +25 -0
  113. data/vendor/bundle/gems/method_source-0.9.2/README.markdown +91 -0
  114. data/vendor/bundle/gems/method_source-0.9.2/Rakefile +81 -0
  115. data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/code_helpers.rb +154 -0
  116. data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/source_location.rb +138 -0
  117. data/vendor/bundle/gems/method_source-0.9.2/lib/method_source/version.rb +3 -0
  118. data/vendor/bundle/gems/method_source-0.9.2/lib/method_source.rb +141 -0
  119. data/vendor/bundle/gems/method_source-0.9.2/method_source.gemspec +35 -0
  120. data/vendor/bundle/gems/method_source-0.9.2/spec/method_source/code_helpers_spec.rb +43 -0
  121. data/vendor/bundle/gems/method_source-0.9.2/spec/method_source_spec.rb +143 -0
  122. data/vendor/bundle/gems/method_source-0.9.2/spec/spec_helper.rb +101 -0
  123. data/vendor/bundle/gems/pry-0.12.2/CHANGELOG.md +953 -0
  124. data/vendor/bundle/gems/pry-0.12.2/LICENSE +25 -0
  125. data/vendor/bundle/gems/pry-0.12.2/README.md +390 -0
  126. data/vendor/bundle/gems/pry-0.12.2/bin/pry +8 -0
  127. data/vendor/bundle/gems/pry-0.12.2/lib/pry/basic_object.rb +6 -0
  128. data/vendor/bundle/gems/pry-0.12.2/lib/pry/cli.rb +218 -0
  129. data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_file.rb +110 -0
  130. data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/code_range.rb +71 -0
  131. data/vendor/bundle/gems/pry-0.12.2/lib/pry/code/loc.rb +98 -0
  132. data/vendor/bundle/gems/pry-0.12.2/lib/pry/code.rb +353 -0
  133. data/vendor/bundle/gems/pry-0.12.2/lib/pry/code_object.rb +195 -0
  134. data/vendor/bundle/gems/pry-0.12.2/lib/pry/color_printer.rb +65 -0
  135. data/vendor/bundle/gems/pry-0.12.2/lib/pry/command.rb +723 -0
  136. data/vendor/bundle/gems/pry-0.12.2/lib/pry/command_set.rb +415 -0
  137. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/amend_line.rb +98 -0
  138. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang.rb +20 -0
  139. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/bang_pry.rb +17 -0
  140. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  141. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/exception_formatter.rb +79 -0
  142. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/file_formatter.rb +71 -0
  143. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  144. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cat.rb +63 -0
  145. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/cd.rb +41 -0
  146. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_inspector.rb +27 -0
  147. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/change_prompt.rb +46 -0
  148. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/clear_screen.rb +14 -0
  149. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/code_collector.rb +167 -0
  150. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disable_pry.rb +27 -0
  151. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/disabled_commands.rb +2 -0
  152. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/easter_eggs.rb +112 -0
  153. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/exception_patcher.rb +25 -0
  154. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  155. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/edit.rb +200 -0
  156. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit.rb +43 -0
  157. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_all.rb +29 -0
  158. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/exit_program.rb +23 -0
  159. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/find_method.rb +191 -0
  160. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/fix_indent.rb +19 -0
  161. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_cd.rb +26 -0
  162. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_install.rb +32 -0
  163. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_list.rb +33 -0
  164. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_open.rb +29 -0
  165. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_readme.rb +25 -0
  166. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_search.rb +40 -0
  167. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gem_stats.rb +83 -0
  168. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/gist.rb +102 -0
  169. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/help.rb +164 -0
  170. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/hist.rb +181 -0
  171. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/import_set.rb +23 -0
  172. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/install_command.rb +54 -0
  173. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/jump_to.rb +29 -0
  174. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/list_inspectors.rb +35 -0
  175. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/constants.rb +58 -0
  176. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/formatter.rb +51 -0
  177. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/globals.rb +46 -0
  178. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/grep.rb +19 -0
  179. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/instance_vars.rb +38 -0
  180. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/interrogatable.rb +18 -0
  181. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  182. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_names.rb +33 -0
  183. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/local_vars.rb +37 -0
  184. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/ls_entity.rb +69 -0
  185. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods.rb +54 -0
  186. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/methods_helper.rb +46 -0
  187. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls/self_methods.rb +33 -0
  188. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ls.rb +113 -0
  189. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/nesting.rb +25 -0
  190. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/play.rb +102 -0
  191. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_backtrace.rb +25 -0
  192. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/pry_version.rb +17 -0
  193. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/raise_up.rb +33 -0
  194. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reload_code.rb +62 -0
  195. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/reset.rb +18 -0
  196. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/ri.rb +65 -0
  197. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/save_file.rb +61 -0
  198. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_command.rb +75 -0
  199. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/shell_mode.rb +25 -0
  200. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_doc.rb +81 -0
  201. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_info.rb +216 -0
  202. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_input.rb +17 -0
  203. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/show_source.rb +53 -0
  204. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/stat.rb +40 -0
  205. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/switch_to.rb +23 -0
  206. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/toggle_color.rb +24 -0
  207. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb +38 -0
  208. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression.rb +107 -0
  209. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/whereami.rb +197 -0
  210. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands/wtf.rb +70 -0
  211. data/vendor/bundle/gems/pry-0.12.2/lib/pry/commands.rb +6 -0
  212. data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/behavior.rb +255 -0
  213. data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/convenience.rb +28 -0
  214. data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/default.rb +159 -0
  215. data/vendor/bundle/gems/pry-0.12.2/lib/pry/config/memoization.rb +48 -0
  216. data/vendor/bundle/gems/pry-0.12.2/lib/pry/config.rb +35 -0
  217. data/vendor/bundle/gems/pry-0.12.2/lib/pry/core_extensions.rb +142 -0
  218. data/vendor/bundle/gems/pry-0.12.2/lib/pry/editor.rb +128 -0
  219. data/vendor/bundle/gems/pry-0.12.2/lib/pry/exceptions.rb +76 -0
  220. data/vendor/bundle/gems/pry-0.12.2/lib/pry/forwardable.rb +23 -0
  221. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/base_helpers.rb +200 -0
  222. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/command_helpers.rb +157 -0
  223. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/documentation_helpers.rb +76 -0
  224. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/options_helpers.rb +27 -0
  225. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/platform.rb +58 -0
  226. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/table.rb +114 -0
  227. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers/text.rb +115 -0
  228. data/vendor/bundle/gems/pry-0.12.2/lib/pry/helpers.rb +6 -0
  229. data/vendor/bundle/gems/pry-0.12.2/lib/pry/history.rb +161 -0
  230. data/vendor/bundle/gems/pry-0.12.2/lib/pry/hooks.rb +171 -0
  231. data/vendor/bundle/gems/pry-0.12.2/lib/pry/indent.rb +408 -0
  232. data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_completer.rb +265 -0
  233. data/vendor/bundle/gems/pry-0.12.2/lib/pry/input_lock.rb +130 -0
  234. data/vendor/bundle/gems/pry-0.12.2/lib/pry/inspector.rb +27 -0
  235. data/vendor/bundle/gems/pry-0.12.2/lib/pry/last_exception.rb +61 -0
  236. data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/disowned.rb +55 -0
  237. data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/patcher.rb +122 -0
  238. data/vendor/bundle/gems/pry-0.12.2/lib/pry/method/weird_method_locator.rb +198 -0
  239. data/vendor/bundle/gems/pry-0.12.2/lib/pry/method.rb +552 -0
  240. data/vendor/bundle/gems/pry-0.12.2/lib/pry/object_path.rb +83 -0
  241. data/vendor/bundle/gems/pry-0.12.2/lib/pry/output.rb +50 -0
  242. data/vendor/bundle/gems/pry-0.12.2/lib/pry/pager.rb +250 -0
  243. data/vendor/bundle/gems/pry-0.12.2/lib/pry/platform.rb +91 -0
  244. data/vendor/bundle/gems/pry-0.12.2/lib/pry/plugins.rb +122 -0
  245. data/vendor/bundle/gems/pry-0.12.2/lib/pry/prompt.rb +145 -0
  246. data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_class.rb +425 -0
  247. data/vendor/bundle/gems/pry-0.12.2/lib/pry/pry_instance.rb +699 -0
  248. data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl.rb +261 -0
  249. data/vendor/bundle/gems/pry-0.12.2/lib/pry/repl_file_loader.rb +73 -0
  250. data/vendor/bundle/gems/pry-0.12.2/lib/pry/ring.rb +84 -0
  251. data/vendor/bundle/gems/pry-0.12.2/lib/pry/rubygem.rb +84 -0
  252. data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/LICENSE +20 -0
  253. data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/commands.rb +195 -0
  254. data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop/option.rb +206 -0
  255. data/vendor/bundle/gems/pry-0.12.2/lib/pry/slop.rb +661 -0
  256. data/vendor/bundle/gems/pry-0.12.2/lib/pry/terminal.rb +91 -0
  257. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/evalable.rb +15 -0
  258. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/mockable.rb +14 -0
  259. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/pry_tester.rb +73 -0
  260. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/utility.rb +26 -0
  261. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable/variables.rb +46 -0
  262. data/vendor/bundle/gems/pry-0.12.2/lib/pry/testable.rb +70 -0
  263. data/vendor/bundle/gems/pry-0.12.2/lib/pry/version.rb +3 -0
  264. data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module/candidate.rb +131 -0
  265. data/vendor/bundle/gems/pry-0.12.2/lib/pry/wrapped_module.rb +378 -0
  266. data/vendor/bundle/gems/pry-0.12.2/lib/pry.rb +132 -0
  267. data/vendor/bundle/gems/rb-readline-0.5.5/CHANGES +94 -0
  268. data/vendor/bundle/gems/rb-readline-0.5.5/LICENSE +25 -0
  269. data/vendor/bundle/gems/rb-readline-0.5.5/README.md +81 -0
  270. data/vendor/bundle/gems/rb-readline-0.5.5/Rakefile +25 -0
  271. data/vendor/bundle/gems/rb-readline-0.5.5/bench/_rl_adjust_point.rb +26 -0
  272. data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline.rb +8 -0
  273. data/vendor/bundle/gems/rb-readline-0.5.5/examples/example_readline_with_completion.rb +18 -0
  274. data/vendor/bundle/gems/rb-readline-0.5.5/examples/tinyirb.rb +11 -0
  275. data/vendor/bundle/gems/rb-readline-0.5.5/lib/rb-readline.rb +18 -0
  276. data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline/version.rb +3 -0
  277. data/vendor/bundle/gems/rb-readline-0.5.5/lib/rbreadline.rb +8920 -0
  278. data/vendor/bundle/gems/rb-readline-0.5.5/lib/readline.rb +539 -0
  279. data/vendor/bundle/gems/rb-readline-0.5.5/rb-readline.gemspec +51 -0
  280. data/vendor/bundle/gems/rb-readline-0.5.5/setup.rb +1585 -0
  281. data/vendor/bundle/gems/rb-readline-0.5.5/test/support/filesystem_completion_helper.rb +53 -0
  282. data/vendor/bundle/gems/rb-readline-0.5.5/test/test_completion.rb +100 -0
  283. data/vendor/bundle/gems/rb-readline-0.5.5/test/test_filename_completion_proc.rb +88 -0
  284. data/vendor/bundle/gems/rb-readline-0.5.5/test/test_history.rb +29 -0
  285. data/vendor/bundle/gems/rb-readline-0.5.5/test/test_rbreadline.rb +23 -0
  286. data/vendor/bundle/gems/rb-readline-0.5.5/test/test_readline.rb +221 -0
  287. data/vendor/bundle/specifications/coderay-1.1.2.gemspec +26 -0
  288. data/vendor/bundle/specifications/colorize-0.8.1.gemspec +38 -0
  289. data/vendor/bundle/specifications/method_source-0.9.2.gemspec +35 -0
  290. data/vendor/bundle/specifications/pry-0.12.2.gemspec +38 -0
  291. data/vendor/bundle/specifications/rb-readline-0.5.5.gemspec +39 -0
  292. metadata +363 -0
@@ -0,0 +1,280 @@
1
+ # encoding: utf-8
2
+
3
+ module CodeRay
4
+ module Scanners
5
+
6
+ # Scanner for the Lua[http://lua.org] programming lanuage.
7
+ #
8
+ # The language’s complete syntax is defined in
9
+ # {the Lua manual}[http://www.lua.org/manual/5.2/manual.html],
10
+ # which is what this scanner tries to conform to.
11
+ class Lua < Scanner
12
+
13
+ register_for :lua
14
+ file_extension 'lua'
15
+ title 'Lua'
16
+
17
+ # Keywords used in Lua.
18
+ KEYWORDS = %w[and break do else elseif end
19
+ for function goto if in
20
+ local not or repeat return
21
+ then until while
22
+ ]
23
+
24
+ # Constants set by the Lua core.
25
+ PREDEFINED_CONSTANTS = %w[false true nil]
26
+
27
+ # The expressions contained in this array are parts of Lua’s `basic'
28
+ # library. Although it’s not entirely necessary to load that library,
29
+ # it is highly recommended and one would have to provide own implementations
30
+ # of some of these expressions if one does not do so. They however aren’t
31
+ # keywords, neither are they constants, but nearly predefined, so they
32
+ # get tagged as `predefined' rather than anything else.
33
+ #
34
+ # This list excludes values of form `_UPPERCASE' because the Lua manual
35
+ # requires such identifiers to be reserved by Lua anyway and they are
36
+ # highlighted directly accordingly, without the need for specific
37
+ # identifiers to be listed here.
38
+ PREDEFINED_EXPRESSIONS = %w[
39
+ assert collectgarbage dofile error getmetatable
40
+ ipairs load loadfile next pairs pcall print
41
+ rawequal rawget rawlen rawset select setmetatable
42
+ tonumber tostring type xpcall
43
+ ]
44
+
45
+ # Automatic token kind selection for normal words.
46
+ IDENT_KIND = CodeRay::WordList.new(:ident).
47
+ add(KEYWORDS, :keyword).
48
+ add(PREDEFINED_CONSTANTS, :predefined_constant).
49
+ add(PREDEFINED_EXPRESSIONS, :predefined)
50
+
51
+ protected
52
+
53
+ # Scanner initialization.
54
+ def setup
55
+ @state = :initial
56
+ @brace_depth = 0
57
+ end
58
+
59
+ # CodeRay entry hook. Starts parsing.
60
+ def scan_tokens(encoder, options)
61
+ state = options[:state] || @state
62
+ brace_depth = @brace_depth
63
+ num_equals = nil
64
+
65
+ until eos?
66
+ case state
67
+
68
+ when :initial
69
+ if match = scan(/\-\-\[\=*\[/) #--[[ long (possibly multiline) comment ]]
70
+ num_equals = match.count("=") # Number must match for comment end
71
+ encoder.begin_group(:comment)
72
+ encoder.text_token(match, :delimiter)
73
+ state = :long_comment
74
+
75
+ elsif match = scan(/--.*$/) # --Lua comment
76
+ encoder.text_token(match, :comment)
77
+
78
+ elsif match = scan(/\[=*\[/) # [[ long (possibly multiline) string ]]
79
+ num_equals = match.count("=") # Number must match for comment end
80
+ encoder.begin_group(:string)
81
+ encoder.text_token(match, :delimiter)
82
+ state = :long_string
83
+
84
+ elsif match = scan(/::\s*[a-zA-Z_][a-zA-Z0-9_]+\s*::/) # ::goto_label::
85
+ encoder.text_token(match, :label)
86
+
87
+ elsif match = scan(/_[A-Z]+/) # _UPPERCASE are names reserved for Lua
88
+ encoder.text_token(match, :predefined)
89
+
90
+ elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) # Normal letters (or letters followed by digits)
91
+ kind = IDENT_KIND[match]
92
+
93
+ # Extra highlighting for entities following certain keywords
94
+ if kind == :keyword and match == "function"
95
+ state = :function_expected
96
+ elsif kind == :keyword and match == "goto"
97
+ state = :goto_label_expected
98
+ elsif kind == :keyword and match == "local"
99
+ state = :local_var_expected
100
+ end
101
+
102
+ encoder.text_token(match, kind)
103
+
104
+ elsif match = scan(/\{/) # Opening table brace {
105
+ encoder.begin_group(:map)
106
+ encoder.text_token(match, brace_depth >= 1 ? :inline_delimiter : :delimiter)
107
+ brace_depth += 1
108
+ state = :map
109
+
110
+ elsif match = scan(/\}/) # Closing table brace }
111
+ if brace_depth == 1
112
+ brace_depth = 0
113
+ encoder.text_token(match, :delimiter)
114
+ encoder.end_group(:map)
115
+ elsif brace_depth == 0 # Mismatched brace
116
+ encoder.text_token(match, :error)
117
+ else
118
+ brace_depth -= 1
119
+ encoder.text_token(match, :inline_delimiter)
120
+ encoder.end_group(:map)
121
+ state = :map
122
+ end
123
+
124
+ elsif match = scan(/["']/) # String delimiters " and '
125
+ encoder.begin_group(:string)
126
+ encoder.text_token(match, :delimiter)
127
+ start_delim = match
128
+ state = :string
129
+
130
+ # ↓Prefix hex number ←|→ decimal number
131
+ elsif match = scan(/-? (?:0x\h* \. \h+ (?:p[+\-]?\d+)? | \d*\.\d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power
132
+ encoder.text_token(match, :float)
133
+
134
+ # ↓Prefix hex number ←|→ decimal number
135
+ elsif match = scan(/-? (?:0x\h+ (?:p[+\-]?\d+)? | \d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power
136
+ encoder.text_token(match, :integer)
137
+
138
+ elsif match = scan(/[\+\-\*\/%^\#=~<>\(\)\[\]:;,] | \.(?!\d)/x) # Operators
139
+ encoder.text_token(match, :operator)
140
+
141
+ elsif match = scan(/\s+/) # Space
142
+ encoder.text_token(match, :space)
143
+
144
+ else # Invalid stuff. Note that Lua doesn’t accept multibyte chars outside of strings, hence these are also errors.
145
+ encoder.text_token(getch, :error)
146
+ end
147
+
148
+ # It may be that we’re scanning a full-blown subexpression of a table
149
+ # (tables can contain full expressions in parts).
150
+ # If this is the case, return to :map scanning state.
151
+ state = :map if state == :initial && brace_depth >= 1
152
+
153
+ when :function_expected
154
+ if match = scan(/\(.*?\)/m) # x = function() # "Anonymous" function without explicit name
155
+ encoder.text_token(match, :operator)
156
+ state = :initial
157
+ elsif match = scan(/[a-zA-Z_] (?:[a-zA-Z0-9_\.] (?!\.\d))* [\.\:]/x) # function tbl.subtbl.foo() | function tbl:foo() # Colon only allowed as last separator
158
+ encoder.text_token(match, :ident)
159
+ elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/) # function foo()
160
+ encoder.text_token(match, :function)
161
+ state = :initial
162
+ elsif match = scan(/\s+/) # Between the `function' keyword and the ident may be any amount of whitespace
163
+ encoder.text_token(match, :space)
164
+ else
165
+ encoder.text_token(getch, :error)
166
+ state = :initial
167
+ end
168
+
169
+ when :goto_label_expected
170
+ if match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/)
171
+ encoder.text_token(match, :label)
172
+ state = :initial
173
+ elsif match = scan(/\s+/) # Between the `goto' keyword and the label may be any amount of whitespace
174
+ encoder.text_token(match, :space)
175
+ else
176
+ encoder.text_token(getch, :error)
177
+ end
178
+
179
+ when :local_var_expected
180
+ if match = scan(/function/) # local function ...
181
+ encoder.text_token(match, :keyword)
182
+ state = :function_expected
183
+ elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]*/)
184
+ encoder.text_token(match, :local_variable)
185
+ elsif match = scan(/,/)
186
+ encoder.text_token(match, :operator)
187
+ elsif match = scan(/\=/)
188
+ encoder.text_token(match, :operator)
189
+ # After encountering the equal sign, arbitrary expressions are
190
+ # allowed again, so just return to the main state for further
191
+ # parsing.
192
+ state = :initial
193
+ elsif match = scan(/\n/)
194
+ encoder.text_token(match, :space)
195
+ state = :initial
196
+ elsif match = scan(/\s+/)
197
+ encoder.text_token(match, :space)
198
+ else
199
+ encoder.text_token(getch, :error)
200
+ end
201
+
202
+ when :long_comment
203
+ if match = scan(/.*?(?=\]={#{num_equals}}\])/m)
204
+ encoder.text_token(match, :content)
205
+
206
+ delim = scan(/\]={#{num_equals}}\]/)
207
+ encoder.text_token(delim, :delimiter)
208
+ else # No terminator found till EOF
209
+ encoder.text_token(rest, :error)
210
+ terminate
211
+ end
212
+ encoder.end_group(:comment)
213
+ state = :initial
214
+
215
+ when :long_string
216
+ if match = scan(/.*?(?=\]={#{num_equals}}\])/m) # Long strings do not interpret any escape sequences
217
+ encoder.text_token(match, :content)
218
+
219
+ delim = scan(/\]={#{num_equals}}\]/)
220
+ encoder.text_token(delim, :delimiter)
221
+ else # No terminator found till EOF
222
+ encoder.text_token(rest, :error)
223
+ terminate
224
+ end
225
+ encoder.end_group(:string)
226
+ state = :initial
227
+
228
+ when :string
229
+ if match = scan(/[^\\#{start_delim}\n]+/) # Everything except \ and the start delimiter character is string content (newlines are only allowed if preceeded by \ or \z)
230
+ encoder.text_token(match, :content)
231
+ elsif match = scan(/\\(?:['"abfnrtv\\]|z\s*|x\h\h|\d{1,3}|\n)/m)
232
+ encoder.text_token(match, :char)
233
+ elsif match = scan(Regexp.compile(start_delim))
234
+ encoder.text_token(match, :delimiter)
235
+ encoder.end_group(:string)
236
+ state = :initial
237
+ elsif match = scan(/\n/) # Lua forbids unescaped newlines in normal non-long strings
238
+ encoder.text_token("\\n\n", :error) # Visually appealing error indicator--otherwise users may wonder whether the highlighter cannot highlight multine strings
239
+ encoder.end_group(:string)
240
+ state = :initial
241
+ else
242
+ encoder.text_token(getch, :error)
243
+ end
244
+
245
+ when :map
246
+ if match = scan(/[,;]/)
247
+ encoder.text_token(match, :operator)
248
+ elsif match = scan(/[a-zA-Z_][a-zA-Z0-9_]* (?=\s*=)/x)
249
+ encoder.text_token(match, :key)
250
+ encoder.text_token(scan(/\s+/), :space) if check(/\s+/)
251
+ encoder.text_token(scan(/\=/), :operator)
252
+ state = :initial
253
+ elsif match = scan(/\s+/m)
254
+ encoder.text_token(match, :space)
255
+ else
256
+ # Note this clause doesn’t advance the scan pointer, it’s a kind of
257
+ # "retry with other options" (the :initial state then of course
258
+ # advances the pointer).
259
+ state = :initial
260
+ end
261
+ else
262
+ raise
263
+ end
264
+
265
+ end
266
+
267
+ if options[:keep_state]
268
+ @state = state
269
+ end
270
+
271
+ encoder.end_group :string if [:string].include? state
272
+ brace_depth.times { encoder.end_group :map }
273
+
274
+ encoder
275
+ end
276
+
277
+ end
278
+
279
+ end
280
+ end
@@ -0,0 +1,527 @@
1
+ # encoding: utf-8
2
+ module CodeRay
3
+ module Scanners
4
+
5
+ load :html
6
+
7
+ # Scanner for PHP.
8
+ #
9
+ # Original by Stefan Walk.
10
+ class PHP < Scanner
11
+
12
+ register_for :php
13
+ file_extension 'php'
14
+
15
+ KINDS_NOT_LOC = HTML::KINDS_NOT_LOC
16
+
17
+ protected
18
+
19
+ def setup
20
+ @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
21
+ end
22
+
23
+ def reset_instance
24
+ super
25
+ @html_scanner.reset
26
+ end
27
+
28
+ module Words # :nodoc:
29
+
30
+ # according to http://www.php.net/manual/en/reserved.keywords.php
31
+ KEYWORDS = %w[
32
+ abstract and array as break case catch class clone const continue declare default do else elseif
33
+ enddeclare endfor endforeach endif endswitch endwhile extends final for foreach function global
34
+ goto if implements interface instanceof namespace new or private protected public static switch
35
+ throw try use var while xor
36
+ cfunction old_function
37
+ ]
38
+
39
+ TYPES = %w[ int integer float double bool boolean string array object resource ]
40
+
41
+ LANGUAGE_CONSTRUCTS = %w[
42
+ die echo empty exit eval include include_once isset list
43
+ require require_once return print unset
44
+ ]
45
+
46
+ CLASSES = %w[ Directory stdClass __PHP_Incomplete_Class exception php_user_filter Closure ]
47
+
48
+ # according to http://php.net/quickref.php on 2009-04-21;
49
+ # all functions with _ excluded (module functions) and selected additional functions
50
+ BUILTIN_FUNCTIONS = %w[
51
+ abs acos acosh addcslashes addslashes aggregate array arsort ascii2ebcdic asin asinh asort assert atan atan2
52
+ atanh basename bcadd bccomp bcdiv bcmod bcmul bcpow bcpowmod bcscale bcsqrt bcsub bin2hex bindec
53
+ bindtextdomain bzclose bzcompress bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite
54
+ calculhmac ceil chdir checkdate checkdnsrr chgrp chmod chop chown chr chroot clearstatcache closedir closelog
55
+ compact constant copy cos cosh count crc32 crypt current date dcgettext dcngettext deaggregate decbin dechex
56
+ decoct define defined deg2rad delete dgettext die dirname diskfreespace dl dngettext doubleval each
57
+ ebcdic2ascii echo empty end ereg eregi escapeshellarg escapeshellcmd eval exec exit exp explode expm1 extract
58
+ fclose feof fflush fgetc fgetcsv fgets fgetss file fileatime filectime filegroup fileinode filemtime fileowner
59
+ fileperms filepro filesize filetype floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv
60
+ fputs fread frenchtojd fscanf fseek fsockopen fstat ftell ftok ftruncate fwrite getallheaders getcwd getdate
61
+ getenv gethostbyaddr gethostbyname gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid
62
+ getmyuid getopt getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext
63
+ gettimeofday gettype glob gmdate gmmktime gmstrftime gregoriantojd gzclose gzcompress gzdecode gzdeflate
64
+ gzencode gzeof gzfile gzgetc gzgets gzgetss gzinflate gzopen gzpassthru gzputs gzread gzrewind gzseek gztell
65
+ gzuncompress gzwrite hash header hebrev hebrevc hexdec htmlentities htmlspecialchars hypot iconv idate
66
+ implode include intval ip2long iptcembed iptcparse isset
67
+ jddayofweek jdmonthname jdtofrench jdtogregorian jdtojewish jdtojulian jdtounix jewishtojd join jpeg2wbmp
68
+ juliantojd key krsort ksort lcfirst lchgrp lchown levenshtein link linkinfo list localeconv localtime log
69
+ log10 log1p long2ip lstat ltrim mail main max md5 metaphone mhash microtime min mkdir mktime msql natcasesort
70
+ natsort next ngettext nl2br nthmac octdec opendir openlog
71
+ ord overload pack passthru pathinfo pclose pfsockopen phpcredits phpinfo phpversion pi png2wbmp popen pos pow
72
+ prev print printf putenv quotemeta rad2deg rand range rawurldecode rawurlencode readdir readfile readgzfile
73
+ readline readlink realpath recode rename require reset rewind rewinddir rmdir round rsort rtrim scandir
74
+ serialize setcookie setlocale setrawcookie settype sha1 shuffle signeurlpaiement sin sinh sizeof sleep snmpget
75
+ snmpgetnext snmprealwalk snmpset snmpwalk snmpwalkoid sort soundex split spliti sprintf sqrt srand sscanf stat
76
+ strcasecmp strchr strcmp strcoll strcspn strftime stripcslashes stripos stripslashes stristr strlen
77
+ strnatcasecmp strnatcmp strncasecmp strncmp strpbrk strpos strptime strrchr strrev strripos strrpos strspn
78
+ strstr strtok strtolower strtotime strtoupper strtr strval substr symlink syslog system tan tanh tempnam
79
+ textdomain time tmpfile touch trim uasort ucfirst ucwords uksort umask uniqid unixtojd unlink unpack
80
+ unserialize unset urldecode urlencode usleep usort vfprintf virtual vprintf vsprintf wordwrap
81
+ array_change_key_case array_chunk array_combine array_count_values array_diff array_diff_assoc
82
+ array_diff_key array_diff_uassoc array_diff_ukey array_fill array_fill_keys array_filter array_flip
83
+ array_intersect array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey
84
+ array_key_exists array_keys array_map array_merge array_merge_recursive array_multisort array_pad
85
+ array_pop array_product array_push array_rand array_reduce array_reverse array_search array_shift
86
+ array_slice array_splice array_sum array_udiff array_udiff_assoc array_udiff_uassoc array_uintersect
87
+ array_uintersect_assoc array_uintersect_uassoc array_unique array_unshift array_values array_walk
88
+ array_walk_recursive
89
+ assert_options base_convert base64_decode base64_encode
90
+ chunk_split class_exists class_implements class_parents
91
+ count_chars debug_backtrace debug_print_backtrace debug_zval_dump
92
+ error_get_last error_log error_reporting extension_loaded
93
+ file_exists file_get_contents file_put_contents load_file
94
+ func_get_arg func_get_args func_num_args function_exists
95
+ get_browser get_called_class get_cfg_var get_class get_class_methods get_class_vars
96
+ get_current_user get_declared_classes get_declared_interfaces get_defined_constants
97
+ get_defined_functions get_defined_vars get_extension_funcs get_headers get_html_translation_table
98
+ get_include_path get_included_files get_loaded_extensions get_magic_quotes_gpc get_magic_quotes_runtime
99
+ get_meta_tags get_object_vars get_parent_class get_required_filesget_resource_type
100
+ gc_collect_cycles gc_disable gc_enable gc_enabled
101
+ halt_compiler headers_list headers_sent highlight_file highlight_string
102
+ html_entity_decode htmlspecialchars_decode
103
+ in_array include_once inclued_get_data
104
+ is_a is_array is_binary is_bool is_buffer is_callable is_dir is_double is_executable is_file is_finite
105
+ is_float is_infinite is_int is_integer is_link is_long is_nan is_null is_numeric is_object is_readable
106
+ is_real is_resource is_scalar is_soap_fault is_string is_subclass_of is_unicode is_uploaded_file
107
+ is_writable is_writeable
108
+ locale_get_default locale_set_default
109
+ number_format override_function parse_str parse_url
110
+ php_check_syntax php_ini_loaded_file php_ini_scanned_files php_logo_guid php_sapi_name
111
+ php_strip_whitespace php_uname
112
+ preg_filter preg_grep preg_last_error preg_match preg_match_all preg_quote preg_replace
113
+ preg_replace_callback preg_split print_r
114
+ require_once register_shutdown_function register_tick_function
115
+ set_error_handler set_exception_handler set_file_buffer set_include_path
116
+ set_magic_quotes_runtime set_time_limit shell_exec
117
+ str_getcsv str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split str_word_count
118
+ strip_tags substr_compare substr_count substr_replace
119
+ time_nanosleep time_sleep_until
120
+ token_get_all token_name trigger_error
121
+ unregister_tick_function use_soap_error_handler user_error
122
+ utf8_decode utf8_encode var_dump var_export
123
+ version_compare
124
+ zend_logo_guid zend_thread_id zend_version
125
+ create_function call_user_func_array
126
+ posix_access posix_ctermid posix_get_last_error posix_getcwd posix_getegid
127
+ posix_geteuid posix_getgid posix_getgrgid posix_getgrnam posix_getgroups
128
+ posix_getlogin posix_getpgid posix_getpgrp posix_getpid posix_getppid
129
+ posix_getpwnam posix_getpwuid posix_getrlimit posix_getsid posix_getuid
130
+ posix_initgroups posix_isatty posix_kill posix_mkfifo posix_mknod
131
+ posix_setegid posix_seteuid posix_setgid posix_setpgid posix_setsid
132
+ posix_setuid posix_strerror posix_times posix_ttyname posix_uname
133
+ pcntl_alarm pcntl_exec pcntl_fork pcntl_getpriority pcntl_setpriority
134
+ pcntl_signal pcntl_signal_dispatch pcntl_sigprocmask pcntl_sigtimedwait
135
+ pcntl_sigwaitinfo pcntl_wait pcntl_waitpid pcntl_wexitstatus pcntl_wifexited
136
+ pcntl_wifsignaled pcntl_wifstopped pcntl_wstopsig pcntl_wtermsig
137
+ ]
138
+ # TODO: more built-in PHP functions?
139
+
140
+ EXCEPTIONS = %w[
141
+ E_ERROR E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING
142
+ E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_DEPRECATED E_USER_DEPRECATED E_ALL E_STRICT
143
+ ]
144
+
145
+ CONSTANTS = %w[
146
+ null true false self parent
147
+ __LINE__ __DIR__ __FILE__ __LINE__
148
+ __CLASS__ __NAMESPACE__ __METHOD__ __FUNCTION__
149
+ PHP_VERSION PHP_MAJOR_VERSION PHP_MINOR_VERSION PHP_RELEASE_VERSION PHP_VERSION_ID PHP_EXTRA_VERSION PHP_ZTS
150
+ PHP_DEBUG PHP_MAXPATHLEN PHP_OS PHP_SAPI PHP_EOL PHP_INT_MAX PHP_INT_SIZE DEFAULT_INCLUDE_PATH
151
+ PEAR_INSTALL_DIR PEAR_EXTENSION_DIR PHP_EXTENSION_DIR PHP_PREFIX PHP_BINDIR PHP_LIBDIR PHP_DATADIR
152
+ PHP_SYSCONFDIR PHP_LOCALSTATEDIR PHP_CONFIG_FILE_PATH PHP_CONFIG_FILE_SCAN_DIR PHP_SHLIB_SUFFIX
153
+ PHP_OUTPUT_HANDLER_START PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END
154
+ __COMPILER_HALT_OFFSET__
155
+ EXTR_OVERWRITE EXTR_SKIP EXTR_PREFIX_SAME EXTR_PREFIX_ALL EXTR_PREFIX_INVALID EXTR_PREFIX_IF_EXISTS
156
+ EXTR_IF_EXISTS SORT_ASC SORT_DESC SORT_REGULAR SORT_NUMERIC SORT_STRING CASE_LOWER CASE_UPPER COUNT_NORMAL
157
+ COUNT_RECURSIVE ASSERT_ACTIVE ASSERT_CALLBACK ASSERT_BAIL ASSERT_WARNING ASSERT_QUIET_EVAL CONNECTION_ABORTED
158
+ CONNECTION_NORMAL CONNECTION_TIMEOUT INI_USER INI_PERDIR INI_SYSTEM INI_ALL M_E M_LOG2E M_LOG10E M_LN2 M_LN10
159
+ M_PI M_PI_2 M_PI_4 M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2 CRYPT_SALT_LENGTH CRYPT_STD_DES CRYPT_EXT_DES
160
+ CRYPT_MD5 CRYPT_BLOWFISH DIRECTORY_SEPARATOR SEEK_SET SEEK_CUR SEEK_END LOCK_SH LOCK_EX LOCK_UN LOCK_NB
161
+ HTML_SPECIALCHARS HTML_ENTITIES ENT_COMPAT ENT_QUOTES ENT_NOQUOTES INFO_GENERAL INFO_CREDITS
162
+ INFO_CONFIGURATION INFO_MODULES INFO_ENVIRONMENT INFO_VARIABLES INFO_LICENSE INFO_ALL CREDITS_GROUP
163
+ CREDITS_GENERAL CREDITS_SAPI CREDITS_MODULES CREDITS_DOCS CREDITS_FULLPAGE CREDITS_QA CREDITS_ALL STR_PAD_LEFT
164
+ STR_PAD_RIGHT STR_PAD_BOTH PATHINFO_DIRNAME PATHINFO_BASENAME PATHINFO_EXTENSION PATH_SEPARATOR CHAR_MAX
165
+ LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_ALL LC_MESSAGES ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5
166
+ ABDAY_6 ABDAY_7 DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7 ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
167
+ ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12 MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9
168
+ MON_10 MON_11 MON_12 AM_STR PM_STR D_T_FMT D_FMT T_FMT T_FMT_AMPM ERA ERA_YEAR ERA_D_T_FMT ERA_D_FMT ERA_T_FMT
169
+ ALT_DIGITS INT_CURR_SYMBOL CURRENCY_SYMBOL CRNCYSTR MON_DECIMAL_POINT MON_THOUSANDS_SEP MON_GROUPING
170
+ POSITIVE_SIGN NEGATIVE_SIGN INT_FRAC_DIGITS FRAC_DIGITS P_CS_PRECEDES P_SEP_BY_SPACE N_CS_PRECEDES
171
+ N_SEP_BY_SPACE P_SIGN_POSN N_SIGN_POSN DECIMAL_POINT RADIXCHAR THOUSANDS_SEP THOUSEP GROUPING YESEXPR NOEXPR
172
+ YESSTR NOSTR CODESET LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG LOG_KERN
173
+ LOG_USER LOG_MAIL LOG_DAEMON LOG_AUTH LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON LOG_AUTHPRIV LOG_LOCAL0
174
+ LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_PID LOG_CONS LOG_ODELAY
175
+ LOG_NDELAY LOG_NOWAIT LOG_PERROR
176
+ ]
177
+
178
+ PREDEFINED = %w[
179
+ $GLOBALS $_SERVER $_GET $_POST $_FILES $_REQUEST $_SESSION $_ENV
180
+ $_COOKIE $php_errormsg $HTTP_RAW_POST_DATA $http_response_header
181
+ $argc $argv
182
+ ]
183
+
184
+ IDENT_KIND = WordList::CaseIgnoring.new(:ident).
185
+ add(KEYWORDS, :keyword).
186
+ add(TYPES, :predefined_type).
187
+ add(LANGUAGE_CONSTRUCTS, :keyword).
188
+ add(BUILTIN_FUNCTIONS, :predefined).
189
+ add(CLASSES, :predefined_constant).
190
+ add(EXCEPTIONS, :exception).
191
+ add(CONSTANTS, :predefined_constant)
192
+
193
+ VARIABLE_KIND = WordList.new(:local_variable).
194
+ add(PREDEFINED, :predefined)
195
+ end
196
+
197
+ module RE # :nodoc:
198
+
199
+ PHP_START = /
200
+ <script\s+[^>]*?language\s*=\s*"php"[^>]*?> |
201
+ <script\s+[^>]*?language\s*=\s*'php'[^>]*?> |
202
+ <\?php\d? |
203
+ <\?(?!xml)
204
+ /xi
205
+
206
+ PHP_END = %r!
207
+ </script> |
208
+ \?>
209
+ !xi
210
+
211
+ HTML_INDICATOR = /<!DOCTYPE html|<(?:html|body|div|p)[> ]/i
212
+
213
+ IDENTIFIER = 'ä'[/[[:alpha:]]/] == 'ä' ? Regexp.new('[[:alpha:]_[^\0-\177]][[:alnum:]_[^\0-\177]]*') : Regexp.new('[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]*', true)
214
+ VARIABLE = /\$#{IDENTIFIER}/
215
+
216
+ OPERATOR = /
217
+ \.(?!\d)=? | # dot that is not decimal point, string concatenation
218
+ && | \|\| | # logic
219
+ :: | -> | => | # scope, member, dictionary
220
+ \\(?!\n) | # namespace
221
+ \+\+ | -- | # increment, decrement
222
+ [,;?:()\[\]{}] | # simple delimiters
223
+ [-+*\/%&|^]=? | # ordinary math, binary logic, assignment shortcuts
224
+ [~$] | # whatever
225
+ =& | # reference assignment
226
+ [=!]=?=? | <> | # comparison and assignment
227
+ <<=? | >>=? | [<>]=? # comparison and shift
228
+ /x
229
+
230
+ end
231
+
232
+ protected
233
+
234
+ def scan_tokens encoder, options
235
+
236
+ if check(RE::PHP_START) || # starts with <?
237
+ (match?(/\s*<\S/) && check(/.{1,1000}#{RE::PHP_START}/om)) || # starts with tag and contains <?
238
+ check(/.{0,1000}#{RE::HTML_INDICATOR}/om) ||
239
+ check(/.{1,100}#{RE::PHP_START}/om) # PHP start after max 100 chars
240
+ # is HTML with embedded PHP, so start with HTML
241
+ states = [:initial]
242
+ else
243
+ # is just PHP, so start with PHP surrounded by HTML
244
+ states = [:initial, :php]
245
+ end
246
+
247
+ label_expected = true
248
+ case_expected = false
249
+
250
+ heredoc_delimiter = nil
251
+ delimiter = nil
252
+ modifier = nil
253
+
254
+ until eos?
255
+
256
+ case states.last
257
+
258
+ when :initial # HTML
259
+ if match = scan(RE::PHP_START)
260
+ encoder.text_token match, :inline_delimiter
261
+ label_expected = true
262
+ states << :php
263
+ else
264
+ match = scan_until(/(?=#{RE::PHP_START})/o) || scan_rest
265
+ @html_scanner.tokenize match unless match.empty?
266
+ end
267
+
268
+ when :php, :php_inline
269
+ if match = scan(/\s+/)
270
+ encoder.text_token match, :space
271
+
272
+ elsif match = scan(%r! (?m: \/\* (?: .*? \*\/ | .* ) ) | (?://|\#) .*? (?=#{RE::PHP_END}|$) !xo)
273
+ encoder.text_token match, :comment
274
+
275
+ elsif match = scan(RE::IDENTIFIER)
276
+ kind = Words::IDENT_KIND[match]
277
+ if kind == :ident && label_expected && check(/:(?!:)/)
278
+ kind = :label
279
+ label_expected = true
280
+ else
281
+ label_expected = false
282
+ if kind == :ident && match =~ /^[A-Z]/
283
+ kind = :constant
284
+ elsif kind == :keyword
285
+ case match
286
+ when 'class'
287
+ states << :class_expected
288
+ when 'function'
289
+ states << :function_expected
290
+ when 'case', 'default'
291
+ case_expected = true
292
+ end
293
+ elsif match == 'b' && check(/['"]/) # binary string literal
294
+ modifier = match
295
+ next
296
+ end
297
+ end
298
+ encoder.text_token match, kind
299
+
300
+ elsif match = scan(/(?:\d+\.\d*|\d*\.\d+)(?:e[-+]?\d+)?|\d+e[-+]?\d+/i)
301
+ label_expected = false
302
+ encoder.text_token match, :float
303
+
304
+ elsif match = scan(/0x[0-9a-fA-F]+/)
305
+ label_expected = false
306
+ encoder.text_token match, :hex
307
+
308
+ elsif match = scan(/\d+/)
309
+ label_expected = false
310
+ encoder.text_token match, :integer
311
+
312
+ elsif match = scan(/['"`]/)
313
+ encoder.begin_group :string
314
+ if modifier
315
+ encoder.text_token modifier, :modifier
316
+ modifier = nil
317
+ end
318
+ delimiter = match
319
+ encoder.text_token match, :delimiter
320
+ states.push match == "'" ? :sqstring : :dqstring
321
+
322
+ elsif match = scan(RE::VARIABLE)
323
+ label_expected = false
324
+ encoder.text_token match, Words::VARIABLE_KIND[match]
325
+
326
+ elsif match = scan(/\{/)
327
+ encoder.text_token match, :operator
328
+ label_expected = true
329
+ states.push :php
330
+
331
+ elsif match = scan(/\}/)
332
+ if states.size == 1
333
+ encoder.text_token match, :error
334
+ else
335
+ state = states.pop
336
+ if states.last.is_a?(::Array)
337
+ delimiter = states.last[1]
338
+ states[-1] = states.last[0]
339
+ encoder.text_token match, :delimiter
340
+ encoder.end_group :inline
341
+ else
342
+ encoder.text_token match, :operator
343
+ encoder.end_group :inline if state == :php_inline
344
+ label_expected = true
345
+ end
346
+ end
347
+
348
+ elsif match = scan(/@/)
349
+ label_expected = false
350
+ encoder.text_token match, :exception
351
+
352
+ elsif match = scan(RE::PHP_END)
353
+ encoder.text_token match, :inline_delimiter
354
+ while state = states.pop
355
+ encoder.end_group :string if [:sqstring, :dqstring].include? state
356
+ if state.is_a? Array
357
+ encoder.end_group :inline
358
+ encoder.end_group :string if [:sqstring, :dqstring].include? state.first
359
+ end
360
+ end
361
+ states << :initial
362
+
363
+ elsif match = scan(/<<<(?:(#{RE::IDENTIFIER})|"(#{RE::IDENTIFIER})"|'(#{RE::IDENTIFIER})')/o)
364
+ encoder.begin_group :string
365
+ # warn 'heredoc in heredoc?' if heredoc_delimiter
366
+ heredoc_delimiter = Regexp.escape(self[1] || self[2] || self[3])
367
+ encoder.text_token match, :delimiter
368
+ states.push self[3] ? :sqstring : :dqstring
369
+ heredoc_delimiter = /#{heredoc_delimiter}(?=;?$)/
370
+
371
+ elsif match = scan(/#{RE::OPERATOR}/o)
372
+ label_expected = match == ';'
373
+ if case_expected
374
+ label_expected = true if match == ':'
375
+ case_expected = false
376
+ end
377
+ encoder.text_token match, :operator
378
+
379
+ else
380
+ encoder.text_token getch, :error
381
+
382
+ end
383
+
384
+ when :sqstring
385
+ if match = scan(heredoc_delimiter ? /[^\\\n]+/ : /[^'\\]+/)
386
+ encoder.text_token match, :content
387
+ elsif !heredoc_delimiter && match = scan(/'/)
388
+ encoder.text_token match, :delimiter
389
+ encoder.end_group :string
390
+ delimiter = nil
391
+ label_expected = false
392
+ states.pop
393
+ elsif heredoc_delimiter && match = scan(/\n/)
394
+ if scan heredoc_delimiter
395
+ encoder.text_token "\n", :content
396
+ encoder.text_token matched, :delimiter
397
+ encoder.end_group :string
398
+ heredoc_delimiter = nil
399
+ label_expected = false
400
+ states.pop
401
+ else
402
+ encoder.text_token match, :content
403
+ end
404
+ elsif match = scan(heredoc_delimiter ? /\\\\/ : /\\[\\'\n]/)
405
+ encoder.text_token match, :char
406
+ elsif match = scan(/\\./m)
407
+ encoder.text_token match, :content
408
+ elsif match = scan(/\\/)
409
+ encoder.text_token match, :error
410
+ else
411
+ encoder.end_group :string
412
+ states.pop
413
+ end
414
+
415
+ when :dqstring
416
+ if match = scan(heredoc_delimiter ? /[^${\\\n]+/ : (delimiter == '"' ? /[^"${\\]+/ : /[^`${\\]+/))
417
+ encoder.text_token match, :content
418
+ elsif !heredoc_delimiter && match = scan(delimiter == '"' ? /"/ : /`/)
419
+ encoder.text_token match, :delimiter
420
+ encoder.end_group :string
421
+ delimiter = nil
422
+ label_expected = false
423
+ states.pop
424
+ elsif heredoc_delimiter && match = scan(/\n/)
425
+ if scan heredoc_delimiter
426
+ encoder.text_token "\n", :content
427
+ encoder.text_token matched, :delimiter
428
+ encoder.end_group :string
429
+ heredoc_delimiter = nil
430
+ label_expected = false
431
+ states.pop
432
+ else
433
+ encoder.text_token match, :content
434
+ end
435
+ elsif match = scan(/\\(?:x[0-9A-Fa-f]{1,2}|[0-7]{1,3})/)
436
+ encoder.text_token match, :char
437
+ elsif match = scan(heredoc_delimiter ? /\\[nrtvf\\$]/ : (delimiter == '"' ? /\\[nrtvf\\$"]/ : /\\[nrtvf\\$`]/))
438
+ encoder.text_token match, :char
439
+ elsif match = scan(/\\./m)
440
+ encoder.text_token match, :content
441
+ elsif match = scan(/\\/)
442
+ encoder.text_token match, :error
443
+ elsif match = scan(/#{RE::VARIABLE}/o)
444
+ if check(/\[#{RE::IDENTIFIER}\]/o)
445
+ encoder.begin_group :inline
446
+ encoder.text_token match, :local_variable
447
+ encoder.text_token scan(/\[/), :operator
448
+ encoder.text_token scan(/#{RE::IDENTIFIER}/o), :ident
449
+ encoder.text_token scan(/\]/), :operator
450
+ encoder.end_group :inline
451
+ elsif check(/\[/)
452
+ match << scan(/\[['"]?#{RE::IDENTIFIER}?['"]?\]?/o)
453
+ encoder.text_token match, :error
454
+ elsif check(/->#{RE::IDENTIFIER}/o)
455
+ encoder.begin_group :inline
456
+ encoder.text_token match, :local_variable
457
+ encoder.text_token scan(/->/), :operator
458
+ encoder.text_token scan(/#{RE::IDENTIFIER}/o), :ident
459
+ encoder.end_group :inline
460
+ elsif check(/->/)
461
+ match << scan(/->/)
462
+ encoder.text_token match, :error
463
+ else
464
+ encoder.text_token match, :local_variable
465
+ end
466
+ elsif match = scan(/\{/)
467
+ if check(/\$/)
468
+ encoder.begin_group :inline
469
+ states[-1] = [states.last, delimiter]
470
+ delimiter = nil
471
+ states.push :php_inline
472
+ encoder.text_token match, :delimiter
473
+ else
474
+ encoder.text_token match, :content
475
+ end
476
+ elsif match = scan(/\$\{#{RE::IDENTIFIER}\}/o)
477
+ encoder.text_token match, :local_variable
478
+ elsif match = scan(/\$/)
479
+ encoder.text_token match, :content
480
+ else
481
+ encoder.end_group :string
482
+ states.pop
483
+ end
484
+
485
+ when :class_expected
486
+ if match = scan(/\s+/)
487
+ encoder.text_token match, :space
488
+ elsif match = scan(/#{RE::IDENTIFIER}/o)
489
+ encoder.text_token match, :class
490
+ states.pop
491
+ else
492
+ states.pop
493
+ end
494
+
495
+ when :function_expected
496
+ if match = scan(/\s+/)
497
+ encoder.text_token match, :space
498
+ elsif match = scan(/&/)
499
+ encoder.text_token match, :operator
500
+ elsif match = scan(/#{RE::IDENTIFIER}/o)
501
+ encoder.text_token match, :function
502
+ states.pop
503
+ else
504
+ states.pop
505
+ end
506
+
507
+ else
508
+ raise_inspect 'Unknown state!', encoder, states
509
+ end
510
+
511
+ end
512
+
513
+ while state = states.pop
514
+ encoder.end_group :string if [:sqstring, :dqstring].include? state
515
+ if state.is_a? Array
516
+ encoder.end_group :inline
517
+ encoder.end_group :string if [:sqstring, :dqstring].include? state.first
518
+ end
519
+ end
520
+
521
+ encoder
522
+ end
523
+
524
+ end
525
+
526
+ end
527
+ end