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,14 @@
1
+ class Pry::Command::ClearScreen < Pry::ClassCommand
2
+ match 'clear-screen'
3
+ group 'Input and Output'
4
+ description 'Clear the contents of the screen/window Pry is running in.'
5
+
6
+ def process
7
+ if Helpers::Platform.windows?
8
+ _pry_.config.system.call(_pry_.output, 'cls', _pry_)
9
+ else
10
+ _pry_.config.system.call(_pry_.output, 'clear', _pry_)
11
+ end
12
+ end
13
+ Pry::Commands.add_command(self)
14
+ end
@@ -0,0 +1,167 @@
1
+ class Pry
2
+ class Command::CodeCollector
3
+ include Helpers::CommandHelpers
4
+
5
+ attr_reader :args
6
+ attr_reader :opts
7
+ attr_reader :_pry_
8
+
9
+ # The name of the explicitly given file (if any).
10
+ attr_accessor :file
11
+
12
+ class << self
13
+ attr_accessor :input_expression_ranges
14
+ attr_accessor :output_result_ranges
15
+ end
16
+
17
+ @input_expression_ranges = []
18
+ @output_result_ranges = []
19
+
20
+ def initialize(args, opts, _pry_)
21
+ @args = args
22
+ @opts = opts
23
+ @_pry_ = _pry_
24
+ end
25
+
26
+ # Add the `--lines`, `-o`, `-i`, `-s`, `-d` options.
27
+ def self.inject_options(opt)
28
+ @input_expression_ranges = []
29
+ @output_result_ranges = []
30
+
31
+ opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range",
32
+ optional_argument: true, as: Range, default: 1..-1
33
+ opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
34
+ optional_argument: true, as: Range, default: -5..-1 do |r|
35
+ output_result_ranges << (r || (-5..-1))
36
+ end
37
+ opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
38
+ optional_argument: true, as: Range, default: -5..-1 do |r|
39
+ input_expression_ranges << (r || (-5..-1))
40
+ end
41
+ opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
42
+ as: :count
43
+ opt.on :d, :doc, "Select lines from the code object's documentation"
44
+ end
45
+
46
+ # The content (i.e code/docs) for the selected object.
47
+ # If the user provided a bare code object, it returns the source.
48
+ # If the user provided the `-i` or `-o` switches, it returns the
49
+ # selected input/output lines joined as a string. If the user used
50
+ # `-d CODE_OBJECT` it returns the docs for that code object.
51
+ #
52
+ # @return [String]
53
+ def content
54
+ @content ||=
55
+ begin
56
+ raise CommandError, "Only one of --out, --in, --doc and CODE_OBJECT may be specified." if bad_option_combination?
57
+
58
+ content = case
59
+ when opts.present?(:o)
60
+ pry_output_content
61
+ when opts.present?(:i)
62
+ pry_input_content
63
+ when opts.present?(:d)
64
+ code_object_doc
65
+ else
66
+ code_object_source_or_file
67
+ end
68
+
69
+ restrict_to_lines(content, line_range)
70
+ end
71
+ end
72
+
73
+ # The code object
74
+ #
75
+ # @return [Pry::WrappedModule, Pry::Method, Pry::Command]
76
+ def code_object
77
+ Pry::CodeObject.lookup(obj_name, _pry_, super: opts[:super])
78
+ end
79
+
80
+ # Given a string and a range, return the `range` lines of that
81
+ # string.
82
+ #
83
+ # @param [String] content
84
+ # @param [Range, Fixnum] range
85
+ # @return [String] The string restricted to the given range
86
+ def restrict_to_lines(content, range)
87
+ Array(content.lines.to_a[range]).join
88
+ end
89
+
90
+ # The selected `_pry_.output_ring` as a string, as specified by
91
+ # the `-o` switch.
92
+ #
93
+ # @return [String]
94
+ def pry_output_content
95
+ pry_array_content_as_string(_pry_.output_ring, self.class.output_result_ranges) do |v|
96
+ _pry_.config.gist.inspecter.call(v)
97
+ end
98
+ end
99
+
100
+ # The selected `_pry_.input_ring` as a string, as specified by
101
+ # the `-i` switch.
102
+ #
103
+ # @return [String]
104
+ def pry_input_content
105
+ pry_array_content_as_string(_pry_.input_ring, self.class.input_expression_ranges) { |v| v }
106
+ end
107
+
108
+ # The line range passed to `--lines`, converted to a 0-indexed range.
109
+ def line_range
110
+ opts.present?(:lines) ? one_index_range_or_number(opts[:lines]) : 0..-1
111
+ end
112
+
113
+ # Name of the object argument
114
+ def obj_name
115
+ @obj_name ||= args.empty? ? "" : args.join(" ")
116
+ end
117
+
118
+ private
119
+
120
+ def bad_option_combination?
121
+ [opts.present?(:in), opts.present?(:out),
122
+ !args.empty?].count(true) > 1
123
+ end
124
+
125
+ def pry_array_content_as_string(array, ranges, &block)
126
+ all = ''
127
+ ranges.each do |range|
128
+ raise CommandError, "Minimum value for range is 1, not 0." if convert_to_range(range).first == 0
129
+
130
+ ranged_array = Array(array[range]) || []
131
+ ranged_array.compact.each { |v| all << block.call(v) }
132
+ end
133
+
134
+ all
135
+ end
136
+
137
+ def code_object_doc
138
+ (code_object && code_object.doc) or could_not_locate(obj_name)
139
+ end
140
+
141
+ def code_object_source_or_file
142
+ (code_object && code_object.source) || file_content
143
+ end
144
+
145
+ def file_content
146
+ if File.exist?(obj_name)
147
+ # Set the file accessor.
148
+ self.file = obj_name
149
+ File.read(obj_name)
150
+ else
151
+ could_not_locate(obj_name)
152
+ end
153
+ end
154
+
155
+ def could_not_locate(name)
156
+ raise CommandError, "Cannot locate: #{name}!"
157
+ end
158
+
159
+ def convert_to_range(n)
160
+ if !n.is_a?(Range)
161
+ (n..n)
162
+ else
163
+ n
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,27 @@
1
+ class Pry
2
+ class Command::DisablePry < Pry::ClassCommand
3
+ match 'disable-pry'
4
+ group 'Navigating Pry'
5
+ description 'Stops all future calls to pry and exits the current session.'
6
+
7
+ banner <<-'BANNER'
8
+ Usage: disable-pry
9
+
10
+ After this command is run any further calls to pry will immediately return `nil`
11
+ without interrupting the flow of your program. This is particularly useful when
12
+ you've debugged the problem you were having, and now wish the program to run to
13
+ the end.
14
+
15
+ As alternatives, consider using `exit!` to force the current Ruby process
16
+ to quit immediately; or using `edit-method -p` to remove the `binding.pry`
17
+ from the code.
18
+ BANNER
19
+
20
+ def process
21
+ ENV['DISABLE_PRY'] = 'true'
22
+ _pry_.run_command "exit"
23
+ end
24
+ end
25
+
26
+ Pry::Commands.add_command(Pry::Command::DisablePry)
27
+ end
@@ -0,0 +1,2 @@
1
+ Pry::Commands.disabled_command("edit-method", "Use `edit` instead.")
2
+ Pry::Commands.disabled_command("show-command", "Use show-source [command_name] instead.")
@@ -0,0 +1,112 @@
1
+ class Pry
2
+ Pry::Commands.instance_eval do
3
+ command "nyan-cat", "", requires_gem: ["nyancat"] do
4
+ run ".nyancat"
5
+ end
6
+
7
+ command(/!s\/(.*?)\/(.*?)/, "") do |source, dest|
8
+ eval_string.gsub!(/#{source}/) { dest }
9
+ run "show-input"
10
+ end
11
+
12
+ command "get-naked", "" do
13
+ txt = %{
14
+ --
15
+ We dont have to take our clothes off to have a good time.
16
+ We could dance & party all night And drink some cherry wine.
17
+ -- Jermaine Stewart }
18
+ output.puts txt
19
+ txt
20
+ end
21
+
22
+ command "east-coker", "" do
23
+ txt = %{
24
+ --
25
+ Now the light falls
26
+ Across the open field, leaving the deep lane
27
+ Shuttered with branches, dark in the afternoon,
28
+ Where you lean against a bank while a van passes,
29
+ And the deep lane insists on the direction
30
+ Into the village, in the electric heat
31
+ Hypnotised. In a warm haze the sultry light
32
+ Is absorbed, not refracted, by grey stone.
33
+ The dahlias sleep in the empty silence.
34
+ Wait for the early owl.
35
+ -- T.S Eliot
36
+ }
37
+ output.puts txt
38
+ txt
39
+ end
40
+
41
+ command "cohen-poem", "" do
42
+ txt = %{
43
+ --
44
+ When this American woman,
45
+ whose thighs are bound in casual red cloth,
46
+ comes thundering past my sitting place
47
+ like a forest-burning Mongol tribe,
48
+ the city is ravished
49
+ and brittle buildings of a hundred years
50
+ splash into the street;
51
+ and my eyes are burnt
52
+ for the embroidered Chinese girls,
53
+ already old,
54
+ and so small between the thin pines
55
+ on these enormous landscapes,
56
+ that if you turn your head
57
+ they are lost for hours.
58
+ -- Leonard Cohen
59
+ }
60
+ output.puts txt
61
+ txt
62
+ end
63
+
64
+ command "pessoa-poem", "" do
65
+ output.puts <<-TEXT
66
+ --
67
+ I've gone to bed with every feeling,
68
+ I've been the pimp of every emotion,
69
+ All felt sensations have bought me drinks,
70
+ I've traded glances with every motive for every act,
71
+ I've held hands with every urge to depart,
72
+ ..
73
+ Rage, foam, the vastness that doesn't fit in my handkerchief,
74
+ The dog in heat howling in the night,
75
+ The pond from the farm going in circles around my insomnia,
76
+ The woods as they were, on our late-afternoon walks, the rose,
77
+ The indifferent tuft of hair, the moss, the pines,
78
+ The rage of not containing all this, not retaining all this,
79
+ O abstract hunger for things, impotent libido for moments,
80
+ Intellectual orgy of feeling life!
81
+ -- Fernando Pessoa
82
+ TEXT
83
+ end
84
+
85
+ command "test-ansi", "" do
86
+ prev_color = _pry_.config.color
87
+ _pry_.config.color = true
88
+
89
+ picture = unindent <<-'EOS'.gsub(/[[:alpha:]!]/) { |s| red(s) }
90
+ ____ _______________________
91
+ / \ | A W G |
92
+ / O O \ | N I O N ! |
93
+ | | | S S R I ! |
94
+ \ \__/ / __| I K ! |
95
+ \____/ \________________________|
96
+ EOS
97
+
98
+ if Helpers::Platform.windows_ansi?
99
+ move_up = proc { |n| "\e[#{n}F" }
100
+ else
101
+ move_up = proc { |n| "\e[#{n}A\e[0G" }
102
+ end
103
+
104
+ output.puts "\n" * 6
105
+ output.puts picture.lines.map(&:chomp).reverse.join(move_up[1])
106
+ output.puts "\n" * 6
107
+ output.puts "** ENV['TERM'] is #{ENV['TERM']} **\n\n"
108
+
109
+ _pry_.config.color = prev_color
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,25 @@
1
+ class Pry
2
+ class Command::Edit
3
+ class ExceptionPatcher
4
+ attr_accessor :_pry_
5
+ attr_accessor :state
6
+ attr_accessor :file_and_line
7
+
8
+ def initialize(_pry_, state, exception_file_and_line)
9
+ @_pry_ = _pry_
10
+ @state = state
11
+ @file_and_line = exception_file_and_line
12
+ end
13
+
14
+ # perform the patch
15
+ def perform_patch
16
+ file_name, _ = file_and_line
17
+ lines = state.dynamical_ex_file || File.read(file_name)
18
+
19
+ source = Pry::Editor.new(_pry_).edit_tempfile_with_content(lines)
20
+ _pry_.evaluate_ruby source
21
+ state.dynamical_ex_file = source.split("\n")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ class Pry
2
+ class Command::Edit
3
+ module FileAndLineLocator
4
+ class << self
5
+ def from_binding(target)
6
+ [target.eval("__FILE__"), target.eval("__LINE__")]
7
+ end
8
+
9
+ def from_code_object(code_object, filename_argument)
10
+ if File.exist?(code_object.source_file.to_s)
11
+ [code_object.source_file, code_object.source_line]
12
+ else
13
+ raise CommandError, "Cannot find a file for #{filename_argument}!"
14
+ end
15
+ end
16
+
17
+ def from_exception(exception, backtrace_level)
18
+ raise CommandError, "No exception found." if exception.nil?
19
+
20
+ file_name, line = exception.bt_source_location_for(backtrace_level)
21
+ raise CommandError, "Exception has no associated file." if file_name.nil?
22
+ raise CommandError, "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
23
+
24
+ [file_name, line]
25
+ end
26
+
27
+ # when file and line are passed as a single arg, e.g my_file.rb:30
28
+ def from_filename_argument(filename_argument)
29
+ f = File.expand_path(filename_argument)
30
+ l = f.sub!(/:(\d+)$/, "") ? $1.to_i : 1
31
+ [f, l]
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,200 @@
1
+ class Pry
2
+ class Command::Edit < Pry::ClassCommand
3
+ require 'pry/commands/edit/exception_patcher'
4
+ require 'pry/commands/edit/file_and_line_locator'
5
+
6
+ match 'edit'
7
+ group 'Editing'
8
+ description 'Invoke the default editor on a file.'
9
+
10
+ banner <<-'BANNER'
11
+ Usage: edit [--no-reload|--reload|--patch] [--line LINE] [--temp|--ex|FILE[:LINE]|OBJECT|--in N]
12
+
13
+ Open a text editor. When no FILE is given, edits the pry input buffer.
14
+ When a method/module/command is given, the code is opened in an editor.
15
+ Ensure `Pry.config.editor` or `_pry_.config.editor` is set to your editor of choice.
16
+
17
+ edit sample.rb edit -p MyClass#my_method
18
+ edit sample.rb --line 105 edit MyClass
19
+ edit MyClass#my_method edit --ex
20
+ edit --method edit --ex -p
21
+
22
+ https://github.com/pry/pry/wiki/Editor-integration#wiki-Edit_command
23
+ BANNER
24
+
25
+ def options(opt)
26
+ opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
27
+ optional_argument: true, as: Integer
28
+ opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
29
+ optional_argument: true, as: Range, default: -1..-1
30
+ opt.on :t, :temp, "Open an empty temporary file"
31
+ opt.on :l, :line, "Jump to this line in the opened file",
32
+ argument: true, as: Integer
33
+ opt.on :n, :"no-reload", "Don't automatically reload the edited file"
34
+ opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
35
+ opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
36
+ opt.on :p, :patch, "Instead of editing the object's file, try to edit in a tempfile and apply as a monkey patch"
37
+ opt.on :m, :method, "Explicitly edit the _current_ method (when inside a method context)."
38
+ end
39
+
40
+ def process
41
+ if bad_option_combination?
42
+ raise CommandError, "Only one of --ex, --temp, --in, --method and FILE may be specified."
43
+ end
44
+
45
+ if repl_edit?
46
+ # code defined in pry, eval'd within pry.
47
+ repl_edit
48
+ elsif runtime_patch?
49
+ # patch code without persisting changes, implies future changes are patches
50
+ apply_runtime_patch
51
+ else
52
+ # code stored in actual files, eval'd at top-level
53
+ file_edit
54
+ end
55
+ end
56
+
57
+ def repl_edit?
58
+ !opts.present?(:ex) && !opts.present?(:current) && !opts.present?(:method) &&
59
+ filename_argument.empty?
60
+ end
61
+
62
+ def repl_edit
63
+ content = Pry::Editor.new(_pry_).edit_tempfile_with_content(initial_temp_file_content,
64
+ initial_temp_file_content.lines.count)
65
+ silence_warnings do
66
+ eval_string.replace content
67
+ end
68
+ Pry.history.push(content)
69
+ end
70
+
71
+ def file_based_exception?
72
+ opts.present?(:ex) && !opts.present?(:patch)
73
+ end
74
+
75
+ def runtime_patch?
76
+ !file_based_exception? && (opts.present?(:patch) || previously_patched?(code_object) || pry_method?(code_object))
77
+ end
78
+
79
+ def apply_runtime_patch
80
+ if patch_exception?
81
+ ExceptionPatcher.new(_pry_, state, file_and_line_for_current_exception).perform_patch
82
+ else
83
+ if code_object.is_a?(Pry::Method)
84
+ code_object.redefine Pry::Editor.new(_pry_).edit_tempfile_with_content(code_object.source)
85
+ else
86
+ raise NotImplementedError, "Cannot yet patch #{code_object} objects!"
87
+ end
88
+ end
89
+ end
90
+
91
+ def ensure_file_name_is_valid(file_name)
92
+ raise CommandError, "Cannot find a valid file for #{filename_argument}" if !file_name
93
+ raise CommandError, "#{file_name} is not a valid file name, cannot edit!" if not_a_real_file?(file_name)
94
+ end
95
+
96
+ def file_and_line_for_current_exception
97
+ FileAndLineLocator.from_exception(_pry_.last_exception, opts[:ex].to_i)
98
+ end
99
+
100
+ def file_and_line
101
+ file_name, line = if opts.present?(:current)
102
+ FileAndLineLocator.from_binding(target)
103
+ elsif opts.present?(:ex)
104
+ file_and_line_for_current_exception
105
+ elsif code_object
106
+ FileAndLineLocator.from_code_object(code_object, filename_argument)
107
+ else
108
+ # when file and line are passed as a single arg, e.g my_file.rb:30
109
+ FileAndLineLocator.from_filename_argument(filename_argument)
110
+ end
111
+
112
+ [file_name, opts.present?(:line) ? opts[:l].to_i : line]
113
+ end
114
+
115
+ def file_edit
116
+ file_name, line = file_and_line
117
+
118
+ ensure_file_name_is_valid(file_name)
119
+
120
+ Pry::Editor.new(_pry_).invoke_editor(file_name, line, reload?(file_name))
121
+ set_file_and_dir_locals(file_name)
122
+
123
+ if reload?(file_name)
124
+ silence_warnings do
125
+ load file_name
126
+ end
127
+ end
128
+ end
129
+
130
+ def filename_argument
131
+ args.join(' ')
132
+ end
133
+
134
+ def code_object
135
+ @code_object ||= !probably_a_file?(filename_argument) &&
136
+ Pry::CodeObject.lookup(filename_argument, _pry_)
137
+ end
138
+
139
+ def pry_method?(code_object)
140
+ code_object.is_a?(Pry::Method) &&
141
+ code_object.pry_method?
142
+ end
143
+
144
+ def previously_patched?(code_object)
145
+ code_object.is_a?(Pry::Method) && Pry::Method::Patcher.code_for(code_object.source_location.first)
146
+ end
147
+
148
+ def patch_exception?
149
+ opts.present?(:ex) && opts.present?(:patch)
150
+ end
151
+
152
+ def bad_option_combination?
153
+ [opts.present?(:ex), opts.present?(:temp),
154
+ opts.present?(:in), opts.present?(:method), !filename_argument.empty?].count(true) > 1
155
+ end
156
+
157
+ def input_expression
158
+ case opts[:i]
159
+ when Range
160
+ (_pry_.input_ring[opts[:i]] || []).join
161
+ when Integer
162
+ _pry_.input_ring[opts[:i]] || ""
163
+ else
164
+ raise Pry::CommandError, "Not a valid range: #{opts[:i]}"
165
+ end
166
+ end
167
+
168
+ def reloadable?
169
+ opts.present?(:reload) || opts.present?(:ex)
170
+ end
171
+
172
+ def never_reload?
173
+ opts.present?(:'no-reload') || _pry_.config.disable_auto_reload
174
+ end
175
+
176
+ def reload?(file_name = "")
177
+ (reloadable? || file_name.end_with?(".rb")) && !never_reload?
178
+ end
179
+
180
+ def initial_temp_file_content
181
+ case
182
+ when opts.present?(:temp)
183
+ ""
184
+ when opts.present?(:in)
185
+ input_expression
186
+ when eval_string.strip != ""
187
+ eval_string
188
+ else
189
+ _pry_.input_ring.to_a.reverse_each.find { |x| x && x.strip != "" } || ""
190
+ end
191
+ end
192
+
193
+ def probably_a_file?(str)
194
+ [".rb", ".c", ".py", ".yml", ".gemspec"].include?(File.extname(str)) ||
195
+ str =~ /\/|\\/
196
+ end
197
+ end
198
+
199
+ Pry::Commands.add_command(Pry::Command::Edit)
200
+ end