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,25 @@
1
+ License
2
+ -------
3
+
4
+ (The MIT License)
5
+
6
+ Copyright (c) 2018 The Pry Team
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,390 @@
1
+ [![Circle Build Status](https://circleci.com/gh/pry/pry.svg?style=shield)](https://circleci.com/gh/pry/pry)
2
+ [![Code Climate](https://codeclimate.com/github/pry/pry.svg)](https://codeclimate.com/github/pry/pry)
3
+ [![Gem Version](https://badge.fury.io/rb/pry.svg)](http://badge.fury.io/rb/pry)
4
+ [![Documentation Status](http://inch-ci.org/github/pry/pry.svg?branch=master)](http://inch-ci.org/github/pry/pry)
5
+ [![Downloads](https://img.shields.io/gem/dt/pry.svg?style=flat)](https://rubygems.org/gems/pry)
6
+ <br><br>
7
+ ![logo for Pry](https://www.dropbox.com/s/zp8o63kquby2rln/pry_logo_350.png?raw=1)
8
+
9
+ **Other Resources**
10
+
11
+ [Skip to the website (recommended)](http://pryrepl.org/) <br />
12
+ [Skip to the wiki](https://github.com/pry/pry/wiki)
13
+
14
+
15
+ Pry is a powerful alternative to the standard IRB shell for Ruby. It is
16
+ written from scratch to provide a number of advanced features,
17
+ including:
18
+
19
+ * Source code browsing (including core C source with the pry-doc gem)
20
+ * Documentation browsing
21
+ * Live help system
22
+ * Open methods in editors (`edit Class#method`)
23
+ * Syntax highlighting
24
+ * Command shell integration (start editors, run git, and rake from within Pry)
25
+ * Gist integration
26
+ * Navigation around state (`cd`, `ls` and friends)
27
+ * Runtime invocation (use Pry as a developer console or debugger)
28
+ * Exotic object support (BasicObject instances, IClasses, ...)
29
+ * A Powerful and flexible command system
30
+ * Ability to view and replay history
31
+ * Many convenience commands inspired by IPython, Smalltalk and other advanced REPLs
32
+ * A wide-range number of [plugins](https://github.com/pry/pry/wiki/Available-plugins) that provide remote sessions, full debugging functionality, and more.
33
+
34
+ Pry also aims to be more than an IRB replacement; it is an
35
+ attempt to bring REPL driven programming to the Ruby language. It is
36
+ currently not as powerful as tools like [SLIME](https://en.wikipedia.org/wiki/SLIME) for lisp, but that is the
37
+ general direction Pry is heading.
38
+
39
+ Pry is also fairly flexible and allows significant user
40
+ [customization](https://github.com/pry/pry/wiki/Customization-and-configuration)
41
+ is trivial to set it to read from any object that has a `readline` method and write to any object that has a
42
+ `puts` method - many other aspects of Pry are also configurable making
43
+ it a good choice for implementing custom shells.
44
+
45
+ Pry comes with an executable so it can be invoked at the command line. Just
46
+ enter `pry` to start. A `pryrc` file in `$XDG_CONFIG_HOME/pry/` or the user's
47
+ home directory will be loaded if it exists. Type `pry --help` at the command
48
+ line for more information.
49
+
50
+ Try `gem install pry-doc` for additional documentation on Ruby Core
51
+ methods. The additional docs are accessed through the `show-doc` and
52
+ `show-method` commands.
53
+
54
+ * Install the [gem](https://rubygems.org/gems/pry): `gem install pry`
55
+ * Browse the comprehensive [documentation at the official Pry wiki](https://github.com/pry/pry/wiki)
56
+ * Read the [YARD API documentation](http://www.rubydoc.info/github/pry/pry/)
57
+ * See the [source code](https://github.com/pry/pry)
58
+
59
+ ### Commands
60
+
61
+ Nearly every piece of functionality in a Pry session is implemented as
62
+ a command. Commands are not methods and must start at the beginning of a line, with no
63
+ whitespace in between. Commands support a flexible syntax and allow
64
+ 'options' in the same way as shell commands, for example the following
65
+ Pry command will show a list of all private instance methods (in
66
+ scope) that begin with 'pa'
67
+
68
+ pry(YARD::Parser::SourceParser):5> ls -Mp --grep ^pa
69
+ YARD::Parser::SourceParser#methods: parse parser_class parser_type parser_type= parser_type_for_filename
70
+
71
+ ### Navigating around state
72
+
73
+ Pry allows us to pop in and out of different scopes (objects) using
74
+ the `cd` command. This enables us to explore the run-time view of a
75
+ program or library. To view which variables and methods are available
76
+ within a particular scope we use the versatile [ls command.](https://gist.github.com/c0fc686ef923c8b87715)
77
+
78
+ Here we will begin Pry at top-level, then Pry on a class and then on
79
+ an instance variable inside that class:
80
+
81
+ pry(main)> class Hello
82
+ pry(main)* @x = 20
83
+ pry(main)* end
84
+ => 20
85
+ pry(main)> cd Hello
86
+ pry(Hello):1> ls -i
87
+ instance variables: @x
88
+ pry(Hello):1> cd @x
89
+ pry(20):2> self + 10
90
+ => 30
91
+ pry(20):2> cd ..
92
+ pry(Hello):1> cd ..
93
+ pry(main)> cd ..
94
+
95
+ The number after the `:` in the pry prompt indicates the nesting
96
+ level. To display more information about nesting, use the `nesting`
97
+ command. E.g
98
+
99
+ pry("friend"):3> nesting
100
+ Nesting status:
101
+ 0. main (Pry top level)
102
+ 1. Hello
103
+ 2. 100
104
+ 3. "friend"
105
+ => nil
106
+
107
+ We can then jump back to any of the previous nesting levels by using
108
+ the `jump-to` command:
109
+
110
+ pry("friend"):3> jump-to 1
111
+ => 100
112
+ pry(Hello):1>
113
+
114
+ ### Runtime invocation
115
+
116
+ Pry can be invoked in the middle of a running program. It opens a Pry
117
+ session at the point it's called and makes all program state at that
118
+ point available. It can be invoked on any object using the
119
+ `my_object.pry` syntax or on the current binding (or any binding)
120
+ using `binding.pry`. The Pry session will then begin within the scope
121
+ of the object (or binding). When the session ends the program continues with any
122
+ modifications you made to it.
123
+
124
+ This functionality can be used for such things as: debugging,
125
+ implementing developer consoles and applying hot patches.
126
+
127
+ code:
128
+
129
+ ```ruby
130
+ # test.rb
131
+ require 'pry'
132
+
133
+ class A
134
+ def hello() puts "hello world!" end
135
+ end
136
+
137
+ a = A.new
138
+
139
+ # start a REPL session
140
+ binding.pry
141
+
142
+ # program resumes here (after pry session)
143
+ puts "program resumes here."
144
+ ```
145
+
146
+ Pry session:
147
+
148
+ pry(main)> a.hello
149
+ hello world!
150
+ => nil
151
+ pry(main)> def a.goodbye
152
+ pry(main)* puts "goodbye cruel world!"
153
+ pry(main)* end
154
+ => nil
155
+ pry(main)> a.goodbye
156
+ goodbye cruel world!
157
+ => nil
158
+ pry(main)> exit
159
+
160
+ program resumes here.
161
+
162
+ ### Command Shell Integration
163
+
164
+ A line of input that begins with a '.' will be forwarded to the
165
+ command shell. This enables us to navigate the file system, spawn
166
+ editors, and run git and rake directly from within Pry.
167
+
168
+ Further, we can use the `shell-mode` command to incorporate the
169
+ present working directory into the Pry prompt and bring in (limited at this stage, sorry) file name completion.
170
+ We can also interpolate Ruby code directly into the shell by
171
+ using the normal `#{}` string interpolation syntax.
172
+
173
+ In the code below we're going to switch to `shell-mode` and edit the `pryrc`
174
+ file. We'll then cat its contents and reload the file.
175
+
176
+ pry(main)> shell-mode
177
+ pry main:/home/john/ruby/projects/pry $ .cd ~
178
+ pry main:/home/john $ .emacsclient .pryrc
179
+ pry main:/home/john $ .cat .pryrc
180
+ def hello_world
181
+ puts "hello world!"
182
+ end
183
+ pry main:/home/john $ load ".pryrc"
184
+ => true
185
+ pry main:/home/john $ hello_world
186
+ hello world!
187
+
188
+ We can also interpolate Ruby code into the shell. In the
189
+ example below we use the shell command `cat` on a random file from the
190
+ current directory and count the number of lines in that file with
191
+ `wc`:
192
+
193
+ pry main:/home/john $ .cat #{Dir['*.*'].sample} | wc -l
194
+ 44
195
+
196
+ ### Code Browsing
197
+
198
+ You can browse method source code with the `show-method` command. Nearly all Ruby methods (and some C methods, with the pry-doc
199
+ gem) can have their source viewed. Code that is longer than a page is
200
+ sent through a pager (such as less), and all code is properly syntax
201
+ highlighted (even C code).
202
+
203
+ The `show-method` command accepts two syntaxes, the typical ri
204
+ `Class#method` syntax and also simply the name of a method that's in
205
+ scope. You can optionally pass the `-l` option to show-method to
206
+ include line numbers in the output.
207
+
208
+ In the following example we will enter the `Pry` class, list the
209
+ instance methods beginning with 're' and display the source code for the `rep` method:
210
+
211
+ pry(main)> cd Pry
212
+ pry(Pry):1> ls -M --grep re
213
+ Pry#methods: re readline refresh rep repl repl_epilogue repl_prologue retrieve_line
214
+ pry(Pry):1> show-method rep -l
215
+
216
+ From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb @ line 143:
217
+ Number of lines: 6
218
+
219
+ 143: def rep(target=TOPLEVEL_BINDING)
220
+ 144: target = Pry.binding_for(target)
221
+ 145: result = re(target)
222
+ 146:
223
+ 147: show_result(result) if should_print?
224
+ 148: end
225
+
226
+ Note that we can also view C methods (from Ruby Core) using the
227
+ `pry-doc` plugin; we also show off the alternate syntax for
228
+ `show-method`:
229
+
230
+ pry(main)> show-method Array#select
231
+
232
+ From: array.c in Ruby Core (C Method):
233
+ Number of lines: 15
234
+
235
+ static VALUE
236
+ rb_ary_select(VALUE ary)
237
+ {
238
+ VALUE result;
239
+ long i;
240
+
241
+ RETURN_ENUMERATOR(ary, 0, 0);
242
+ result = rb_ary_new2(RARRAY_LEN(ary));
243
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
244
+ if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) {
245
+ rb_ary_push(result, rb_ary_elt(ary, i));
246
+ }
247
+ }
248
+ return result;
249
+ }
250
+
251
+ ### Documentation Browsing
252
+
253
+ One use-case for Pry is to explore a program at run-time by `cd`-ing
254
+ in and out of objects and viewing and invoking methods. In the course
255
+ of exploring it may be useful to read the documentation for a
256
+ specific method that you come across. Like `show-method` the `show-doc` command supports
257
+ two syntaxes - the normal `ri` syntax as well as accepting the name of
258
+ any method that is currently in scope.
259
+
260
+ The Pry documentation system does not rely on pre-generated `rdoc` or
261
+ `ri`, instead it grabs the comments directly above the method on
262
+ demand. This results in speedier documentation retrieval and allows
263
+ the Pry system to retrieve documentation for methods that would not be
264
+ picked up by `rdoc`. Pry also has a basic understanding of both the
265
+ rdoc and yard formats and will attempt to syntax highlight the
266
+ documentation appropriately.
267
+
268
+ Nonetheless, the `ri` functionality is very good and
269
+ has an advantage over Pry's system in that it allows documentation
270
+ lookup for classes as well as methods. Pry therefore has good
271
+ integration with `ri` through the `ri` command. The syntax
272
+ for the command is exactly as it would be in command-line -
273
+ so it is not necessary to quote strings.
274
+
275
+ In our example we will enter the `Gem` class and view the
276
+ documentation for the `try_activate` method:
277
+
278
+ pry(main)> cd Gem
279
+ pry(Gem):1> show-doc try_activate
280
+
281
+ From: /Users/john/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb @ line 201:
282
+ Number of lines: 3
283
+
284
+ Try to activate a gem containing path. Returns true if
285
+ activation succeeded or wasn't needed because it was already
286
+ activated. Returns false if it can't find the path in a gem.
287
+ pry(Gem):1>
288
+
289
+ We can also use `ri` in the normal way:
290
+
291
+ pry(main) ri Array#each
292
+ ----------------------------------------------------------- Array#each
293
+ array.each {|item| block } -> array
294
+ ------------------------------------------------------------------------
295
+ Calls _block_ once for each element in _self_, passing that element
296
+ as a parameter.
297
+
298
+ a = [ "a", "b", "c" ]
299
+ a.each {|x| print x, " -- " }
300
+
301
+ produces:
302
+
303
+ a -- b -- c --
304
+
305
+ ### Gist integration
306
+
307
+ If the `gist` gem is installed then method source or documentation can be gisted to GitHub with the
308
+ `gist` command. The `gist` command is capable of gisting [almost any REPL content](https://gist.github.com/cae143e4533416529726), including methods, documentation,
309
+ input expressions, command source, and so on. In the example below we will gist the C source
310
+ code for the `Symbol#to_proc` method to GitHub:
311
+
312
+ pry(main)> gist -m Symbol#to_proc
313
+ Gist created at https://gist.github.com/5332c38afc46d902ce46 and added to clipboard.
314
+ pry(main)>
315
+
316
+ You can see the actual gist generated here: [https://gist.github.com/5332c38afc46d902ce46](https://gist.github.com/5332c38afc46d902ce46)
317
+
318
+ ### Edit methods
319
+
320
+ You can use `edit Class#method` or `edit my_method`
321
+ (if the method is in scope) to open a method for editing directly in
322
+ your favorite editor. Pry has knowledge of a few different editors and
323
+ will attempt to open the file at the line the method is defined.
324
+
325
+ You can set the editor to use by assigning to the `Pry.editor`
326
+ accessor. `Pry.editor` will default to `$EDITOR` or failing that will
327
+ use `nano` as the backup default. The file that is edited will be
328
+ automatically reloaded after exiting the editor - reloading can be
329
+ suppressed by passing the `--no-reload` option to `edit`
330
+
331
+ In the example below we will set our default editor to "emacsclient"
332
+ and open the `Pry#repl` method for editing:
333
+
334
+ pry(main)> Pry.editor = "emacsclient"
335
+ pry(main)> edit Pry#repl
336
+
337
+ ### Live Help System
338
+
339
+ Many other commands are available in Pry; to see the full list type
340
+ `help` at the prompt. A short description of each command is provided
341
+ with basic instructions for use; some commands have a more extensive
342
+ help that can be accessed via typing `command_name --help`. A command
343
+ will typically say in its description if the `--help` option is
344
+ available.
345
+
346
+ ### Use Pry as your Rails Console
347
+
348
+ The recommended way to use Pry as your Rails console is to add
349
+ [the `pry-rails` gem](https://github.com/rweng/pry-rails) to
350
+ your Gemfile. This replaces the default console with Pry, in
351
+ addition to loading the Rails console helpers and adding some
352
+ useful Rails-specific commands.
353
+
354
+ If you don't want to change your Gemfile, you can still run a Pry
355
+ console in your app's environment using Pry's `-r` flag:
356
+
357
+ pry -r ./config/environment
358
+
359
+ Also check out the [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry)
360
+ for more information about integrating Pry with Rails.
361
+
362
+ ### Limitations:
363
+
364
+ * Tab completion is currently a bit broken/limited this will have a
365
+ major overhaul in a future version.
366
+
367
+ ### Syntax Highlighting
368
+
369
+ Syntax highlighting is on by default in Pry. If you want to change
370
+ the colors, check out the [pry-theme](https://github.com/kyrylo/pry-theme)
371
+ gem.
372
+
373
+ You can toggle the syntax highlighting on and off in a session by
374
+ using the `toggle-color` command. Alternatively, you can turn it off
375
+ permanently by putting the line `Pry.color = false` in your `pryrc`
376
+ file.
377
+
378
+ ### Future Directions
379
+
380
+ Many new features are planned such as:
381
+
382
+ * Increase modularity (rely more on plugin system)
383
+ * Much improved documentation system, better support for YARD
384
+ * Better support for code and method reloading and saving code
385
+ * Extended and more sophisticated command system, allowing piping
386
+ between commands and running commands in background
387
+
388
+ ### Contact
389
+
390
+ Problems or questions? File an issue at [GitHub](https://github.com/pry/pry/issues).
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ $0 = 'pry'
3
+
4
+ require 'pry'
5
+
6
+ # Process command line options and run Pry
7
+ opts = Pry::CLI.parse_options
8
+ Pry::CLI.start(opts)
@@ -0,0 +1,6 @@
1
+ class Pry::BasicObject < BasicObject
2
+ [:Kernel, :Pry].each do |constant|
3
+ const_set constant, ::Object.const_get(constant)
4
+ end
5
+ include Kernel
6
+ end
@@ -0,0 +1,218 @@
1
+ class Pry
2
+ # Manage the processing of command line options
3
+ class CLI
4
+ NoOptionsError = Class.new(StandardError)
5
+
6
+ class << self
7
+ # @return [Proc] The Proc defining the valid command line options.
8
+ attr_accessor :options
9
+
10
+ # @return [Array] The Procs that process the parsed options. Plugins can
11
+ # utilize this facility in order to add and process their own Pry
12
+ # options.
13
+ attr_accessor :option_processors
14
+
15
+ # @return [Array<String>] The input array of strings to process
16
+ # as CLI options.
17
+ attr_accessor :input_args
18
+
19
+ # Add another set of CLI options (a Pry::Slop block)
20
+ def add_options(&block)
21
+ if options
22
+ old_options = options
23
+ self.options = proc do
24
+ instance_exec(&old_options)
25
+ instance_exec(&block)
26
+ end
27
+ else
28
+ self.options = block
29
+ end
30
+
31
+ self
32
+ end
33
+
34
+ # Bring in options defined in plugins
35
+ def add_plugin_options
36
+ Pry.plugins.values.each do |plugin|
37
+ plugin.load_cli_options
38
+ end
39
+
40
+ self
41
+ end
42
+
43
+ # Add a block responsible for processing parsed options.
44
+ def add_option_processor(&block)
45
+ self.option_processors ||= []
46
+ option_processors << block
47
+
48
+ self
49
+ end
50
+
51
+ # Clear `options` and `option_processors`
52
+ def reset
53
+ self.options = nil
54
+ self.option_processors = nil
55
+ end
56
+
57
+ def parse_options(args = ARGV)
58
+ unless options
59
+ raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
60
+ end
61
+
62
+ self.input_args = args
63
+
64
+ begin
65
+ opts = Pry::Slop.parse!(
66
+ args,
67
+ help: true,
68
+ multiple_switches: false,
69
+ strict: true,
70
+ &options
71
+ )
72
+ rescue Pry::Slop::InvalidOptionError
73
+ # Display help message on unknown switches and exit.
74
+ puts Pry::Slop.new(&options)
75
+ exit
76
+ end
77
+
78
+ Pry.initial_session_setup
79
+ Pry.final_session_setup
80
+
81
+ # Option processors are optional.
82
+ if option_processors
83
+ option_processors.each { |processor| processor.call(opts) }
84
+ end
85
+
86
+ opts
87
+ end
88
+
89
+ def start(opts)
90
+ exit if opts.help?
91
+
92
+ # invoked via cli
93
+ Pry.cli = true
94
+
95
+ # create the actual context
96
+ if opts[:context]
97
+ Pry.initial_session_setup
98
+ context = Pry.binding_for(eval(opts[:context]))
99
+ Pry.final_session_setup
100
+ else
101
+ context = Pry.toplevel_binding
102
+ end
103
+
104
+ if Pry::CLI.input_args.any? && Pry::CLI.input_args != ["pry"]
105
+ full_name = File.expand_path(Pry::CLI.input_args.first)
106
+ Pry.load_file_through_repl(full_name)
107
+ exit
108
+ end
109
+
110
+ # Start the session (running any code passed with -e, if there is any)
111
+ Pry.start(context, input: StringIO.new(Pry.config.exec_string))
112
+ end
113
+ end
114
+
115
+ reset
116
+ end
117
+ end
118
+
119
+ # Bring in options defined by plugins
120
+ Pry::Slop.new do
121
+ on "no-plugins" do
122
+ Pry.config.should_load_plugins = false
123
+ end
124
+ end.parse(ARGV.dup)
125
+
126
+ if Pry.config.should_load_plugins
127
+ Pry::CLI.add_plugin_options
128
+ end
129
+
130
+ # The default Pry command line options (before plugin options are included)
131
+ Pry::CLI.add_options do
132
+ banner(
133
+ "Usage: pry [OPTIONS]\n" \
134
+ "Start a Pry session.\n" \
135
+ "See http://pryrepl.org/ for more information.\n"
136
+ )
137
+
138
+ on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
139
+ Pry.config.exec_string += "\n" if Pry.config.exec_string.length > 0
140
+ Pry.config.exec_string += input
141
+ end
142
+
143
+ on "no-pager", "Disable pager for long output" do
144
+ Pry.config.pager = false
145
+ end
146
+
147
+ on "no-history", "Disable history loading" do
148
+ Pry.config.history.should_load = false
149
+ end
150
+
151
+ on "no-color", "Disable syntax highlighting for session" do
152
+ Pry.config.color = false
153
+ end
154
+
155
+ on :f, "Suppress loading of pryrc" do
156
+ Pry.config.should_load_rc = false
157
+ Pry.config.should_load_local_rc = false
158
+ end
159
+
160
+ on :s, "select-plugin=", "Only load specified plugin (and no others)." do |plugin_name|
161
+ Pry.config.should_load_plugins = false
162
+ Pry.plugins[plugin_name].activate!
163
+ end
164
+
165
+ on :d, "disable-plugin=", "Disable a specific plugin." do |plugin_name|
166
+ Pry.plugins[plugin_name].disable!
167
+ end
168
+
169
+ on "no-plugins", "Suppress loading of plugins." do
170
+ Pry.config.should_load_plugins = false
171
+ end
172
+
173
+ on "plugins", "List installed plugins." do
174
+ puts "Installed Plugins:"
175
+ puts "--"
176
+ Pry.locate_plugins.each do |plugin|
177
+ puts "#{plugin.name}".ljust(18) << plugin.spec.summary
178
+ end
179
+ exit
180
+ end
181
+
182
+ on "simple-prompt", "Enable simple prompt mode" do
183
+ Pry.config.prompt = Pry::Prompt[:simple][:value]
184
+ end
185
+
186
+ on "noprompt", "No prompt mode" do
187
+ Pry.config.prompt = Pry::Prompt[:none][:value]
188
+ end
189
+
190
+ on :r, :require=, "`require` a Ruby script at startup" do |file|
191
+ Pry.config.requires << file
192
+ end
193
+
194
+ on :I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":" do |load_path|
195
+ load_path.map! do |path|
196
+ /\A\.\// =~ path ? path : File.expand_path(path)
197
+ end
198
+
199
+ $LOAD_PATH.unshift(*load_path)
200
+ end
201
+
202
+ on "gem", "Shorthand for -I./lib -rgemname" do |load_path|
203
+ $LOAD_PATH.unshift("./lib")
204
+ Dir["./lib/*.rb"].each do |file|
205
+ Pry.config.requires << file
206
+ end
207
+ end
208
+
209
+ on :v, :version, "Display the Pry version" do
210
+ puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
211
+ exit
212
+ end
213
+
214
+ on(:c, :context=,
215
+ "Start the session in the specified context. Equivalent to `context.pry` in a session.",
216
+ default: "Pry.toplevel_binding"
217
+ )
218
+ end