pry 0.10.3 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +439 -16
  3. data/LICENSE +1 -1
  4. data/README.md +362 -302
  5. data/bin/pry +4 -7
  6. data/lib/pry/basic_object.rb +10 -0
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +84 -97
  10. data/lib/pry/code/code_file.rb +37 -26
  11. data/lib/pry/code/code_range.rb +7 -5
  12. data/lib/pry/code/loc.rb +26 -13
  13. data/lib/pry/code.rb +42 -31
  14. data/lib/pry/code_object.rb +53 -28
  15. data/lib/pry/color_printer.rb +46 -35
  16. data/lib/pry/command.rb +197 -369
  17. data/lib/pry/command_set.rb +89 -114
  18. data/lib/pry/command_state.rb +31 -0
  19. data/lib/pry/commands/amend_line.rb +86 -82
  20. data/lib/pry/commands/bang.rb +18 -14
  21. data/lib/pry/commands/bang_pry.rb +15 -11
  22. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  23. data/lib/pry/commands/cat/exception_formatter.rb +85 -72
  24. data/lib/pry/commands/cat/file_formatter.rb +56 -46
  25. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  26. data/lib/pry/commands/cat.rb +62 -54
  27. data/lib/pry/commands/cd.rb +40 -35
  28. data/lib/pry/commands/change_inspector.rb +29 -22
  29. data/lib/pry/commands/change_prompt.rb +48 -23
  30. data/lib/pry/commands/clear_screen.rb +20 -0
  31. data/lib/pry/commands/code_collector.rb +148 -131
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +23 -34
  34. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  35. data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
  36. data/lib/pry/commands/edit.rb +185 -157
  37. data/lib/pry/commands/exit.rb +40 -35
  38. data/lib/pry/commands/exit_all.rb +24 -20
  39. data/lib/pry/commands/exit_program.rb +20 -16
  40. data/lib/pry/commands/find_method.rb +168 -162
  41. data/lib/pry/commands/fix_indent.rb +16 -12
  42. data/lib/pry/commands/help.rb +140 -133
  43. data/lib/pry/commands/hist.rb +151 -149
  44. data/lib/pry/commands/import_set.rb +20 -15
  45. data/lib/pry/commands/jump_to.rb +25 -21
  46. data/lib/pry/commands/list_inspectors.rb +35 -28
  47. data/lib/pry/commands/ls/constants.rb +59 -31
  48. data/lib/pry/commands/ls/formatter.rb +42 -36
  49. data/lib/pry/commands/ls/globals.rb +38 -36
  50. data/lib/pry/commands/ls/grep.rb +17 -15
  51. data/lib/pry/commands/ls/instance_vars.rb +29 -28
  52. data/lib/pry/commands/ls/interrogatable.rb +18 -12
  53. data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
  54. data/lib/pry/commands/ls/local_names.rb +26 -24
  55. data/lib/pry/commands/ls/local_vars.rb +38 -30
  56. data/lib/pry/commands/ls/ls_entity.rb +47 -52
  57. data/lib/pry/commands/ls/methods.rb +49 -51
  58. data/lib/pry/commands/ls/methods_helper.rb +46 -42
  59. data/lib/pry/commands/ls/self_methods.rb +23 -21
  60. data/lib/pry/commands/ls.rb +124 -103
  61. data/lib/pry/commands/nesting.rb +21 -17
  62. data/lib/pry/commands/play.rb +92 -82
  63. data/lib/pry/commands/pry_backtrace.rb +22 -17
  64. data/lib/pry/commands/pry_version.rb +15 -11
  65. data/lib/pry/commands/raise_up.rb +33 -27
  66. data/lib/pry/commands/reload_code.rb +60 -48
  67. data/lib/pry/commands/reset.rb +16 -12
  68. data/lib/pry/commands/ri.rb +57 -42
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +56 -29
  71. data/lib/pry/commands/shell_mode.rb +22 -18
  72. data/lib/pry/commands/show_doc.rb +80 -70
  73. data/lib/pry/commands/show_info.rb +194 -155
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +110 -42
  76. data/lib/pry/commands/stat.rb +35 -31
  77. data/lib/pry/commands/switch_to.rb +21 -15
  78. data/lib/pry/commands/toggle_color.rb +20 -16
  79. data/lib/pry/commands/watch_expression/expression.rb +32 -27
  80. data/lib/pry/commands/watch_expression.rb +89 -84
  81. data/lib/pry/commands/whereami.rb +156 -141
  82. data/lib/pry/commands/wtf.rb +78 -40
  83. data/lib/pry/config/attributable.rb +22 -0
  84. data/lib/pry/config/lazy_value.rb +29 -0
  85. data/lib/pry/config/memoized_value.rb +34 -0
  86. data/lib/pry/config/value.rb +24 -0
  87. data/lib/pry/config.rb +310 -20
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +22 -9
  90. data/lib/pry/editor.rb +56 -34
  91. data/lib/pry/env.rb +18 -0
  92. data/lib/pry/exception_handler.rb +43 -0
  93. data/lib/pry/exceptions.rb +13 -18
  94. data/lib/pry/forwardable.rb +27 -0
  95. data/lib/pry/helpers/base_helpers.rb +20 -62
  96. data/lib/pry/helpers/command_helpers.rb +52 -62
  97. data/lib/pry/helpers/documentation_helpers.rb +21 -12
  98. data/lib/pry/helpers/options_helpers.rb +15 -8
  99. data/lib/pry/helpers/platform.rb +55 -0
  100. data/lib/pry/helpers/table.rb +44 -32
  101. data/lib/pry/helpers/text.rb +96 -85
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +81 -55
  104. data/lib/pry/hooks.rb +60 -110
  105. data/lib/pry/indent.rb +74 -68
  106. data/lib/pry/input_completer.rb +199 -158
  107. data/lib/pry/input_lock.rb +7 -10
  108. data/lib/pry/inspector.rb +36 -24
  109. data/lib/pry/last_exception.rb +45 -45
  110. data/lib/pry/method/disowned.rb +19 -5
  111. data/lib/pry/method/patcher.rb +14 -8
  112. data/lib/pry/method/weird_method_locator.rb +79 -45
  113. data/lib/pry/method.rb +178 -124
  114. data/lib/pry/object_path.rb +37 -28
  115. data/lib/pry/output.rb +102 -16
  116. data/lib/pry/pager.rb +187 -174
  117. data/lib/pry/prompt.rb +213 -25
  118. data/lib/pry/pry_class.rb +119 -98
  119. data/lib/pry/pry_instance.rb +261 -224
  120. data/lib/pry/repl.rb +83 -29
  121. data/lib/pry/repl_file_loader.rb +27 -22
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/LICENSE +20 -0
  124. data/lib/pry/slop/commands.rb +190 -0
  125. data/lib/pry/slop/option.rb +210 -0
  126. data/lib/pry/slop.rb +672 -0
  127. data/lib/pry/syntax_highlighter.rb +26 -0
  128. data/lib/pry/system_command_handler.rb +17 -0
  129. data/lib/pry/testable/evalable.rb +24 -0
  130. data/lib/pry/testable/mockable.rb +22 -0
  131. data/lib/pry/testable/pry_tester.rb +88 -0
  132. data/lib/pry/testable/utility.rb +34 -0
  133. data/lib/pry/testable/variables.rb +52 -0
  134. data/lib/pry/testable.rb +68 -0
  135. data/lib/pry/version.rb +3 -1
  136. data/lib/pry/warning.rb +20 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +35 -32
  138. data/lib/pry/wrapped_module.rb +68 -63
  139. data/lib/pry.rb +133 -149
  140. metadata +58 -69
  141. data/lib/pry/commands/disabled_commands.rb +0 -2
  142. data/lib/pry/commands/gem_cd.rb +0 -26
  143. data/lib/pry/commands/gem_install.rb +0 -32
  144. data/lib/pry/commands/gem_list.rb +0 -33
  145. data/lib/pry/commands/gem_open.rb +0 -29
  146. data/lib/pry/commands/gist.rb +0 -101
  147. data/lib/pry/commands/install_command.rb +0 -53
  148. data/lib/pry/commands/list_prompts.rb +0 -35
  149. data/lib/pry/commands/simple_prompt.rb +0 -22
  150. data/lib/pry/commands.rb +0 -6
  151. data/lib/pry/config/behavior.rb +0 -139
  152. data/lib/pry/config/convenience.rb +0 -25
  153. data/lib/pry/config/default.rb +0 -161
  154. data/lib/pry/history_array.rb +0 -121
  155. data/lib/pry/plugins.rb +0 -103
  156. data/lib/pry/rbx_path.rb +0 -22
  157. data/lib/pry/rubygem.rb +0 -82
  158. data/lib/pry/terminal.rb +0 -79
  159. data/lib/pry/test/helper.rb +0 -170
metadata CHANGED
@@ -1,78 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
8
8
  - Conrad Irwin
9
9
  - Ryan Fitzgerald
10
- autorequire:
10
+ - Kyrylo Silin
11
+ autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-10-15 00:00:00.000000000 Z
14
+ date: 2023-01-09 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: coderay
17
18
  requirement: !ruby/object:Gem::Requirement
18
19
  requirements:
19
- - - ~>
20
+ - - "~>"
20
21
  - !ruby/object:Gem::Version
21
- version: 1.1.0
22
+ version: '1.1'
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
26
  requirements:
26
- - - ~>
27
+ - - "~>"
27
28
  - !ruby/object:Gem::Version
28
- version: 1.1.0
29
- - !ruby/object:Gem::Dependency
30
- name: slop
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: '3.4'
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- version: '3.4'
29
+ version: '1.1'
43
30
  - !ruby/object:Gem::Dependency
44
31
  name: method_source
45
32
  requirement: !ruby/object:Gem::Requirement
46
33
  requirements:
47
- - - ~>
48
- - !ruby/object:Gem::Version
49
- version: 0.8.1
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 0.8.1
57
- - !ruby/object:Gem::Dependency
58
- name: bundler
59
- requirement: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ~>
34
+ - - "~>"
62
35
  - !ruby/object:Gem::Version
63
36
  version: '1.0'
64
- type: :development
37
+ type: :runtime
65
38
  prerelease: false
66
39
  version_requirements: !ruby/object:Gem::Requirement
67
40
  requirements:
68
- - - ~>
41
+ - - "~>"
69
42
  - !ruby/object:Gem::Version
70
43
  version: '1.0'
71
- description: An IRB alternative and runtime developer console
44
+ description: |
45
+ Pry is a runtime developer console and IRB alternative with powerful
46
+ introspection capabilities. Pry aims to be more than an IRB replacement. It is
47
+ an attempt to bring REPL driven programming to the Ruby language.
72
48
  email:
73
49
  - jrmair@gmail.com
74
50
  - conrad.irwin@gmail.com
75
51
  - rwfitzge@gmail.com
52
+ - silin@kyrylo.org
76
53
  executables:
77
54
  - pry
78
55
  extensions: []
@@ -83,6 +60,9 @@ files:
83
60
  - README.md
84
61
  - bin/pry
85
62
  - lib/pry.rb
63
+ - lib/pry/basic_object.rb
64
+ - lib/pry/block_command.rb
65
+ - lib/pry/class_command.rb
86
66
  - lib/pry/cli.rb
87
67
  - lib/pry/code.rb
88
68
  - lib/pry/code/code_file.rb
@@ -92,7 +72,7 @@ files:
92
72
  - lib/pry/color_printer.rb
93
73
  - lib/pry/command.rb
94
74
  - lib/pry/command_set.rb
95
- - lib/pry/commands.rb
75
+ - lib/pry/command_state.rb
96
76
  - lib/pry/commands/amend_line.rb
97
77
  - lib/pry/commands/bang.rb
98
78
  - lib/pry/commands/bang_pry.rb
@@ -104,9 +84,9 @@ files:
104
84
  - lib/pry/commands/cd.rb
105
85
  - lib/pry/commands/change_inspector.rb
106
86
  - lib/pry/commands/change_prompt.rb
87
+ - lib/pry/commands/clear_screen.rb
107
88
  - lib/pry/commands/code_collector.rb
108
89
  - lib/pry/commands/disable_pry.rb
109
- - lib/pry/commands/disabled_commands.rb
110
90
  - lib/pry/commands/easter_eggs.rb
111
91
  - lib/pry/commands/edit.rb
112
92
  - lib/pry/commands/edit/exception_patcher.rb
@@ -116,18 +96,11 @@ files:
116
96
  - lib/pry/commands/exit_program.rb
117
97
  - lib/pry/commands/find_method.rb
118
98
  - lib/pry/commands/fix_indent.rb
119
- - lib/pry/commands/gem_cd.rb
120
- - lib/pry/commands/gem_install.rb
121
- - lib/pry/commands/gem_list.rb
122
- - lib/pry/commands/gem_open.rb
123
- - lib/pry/commands/gist.rb
124
99
  - lib/pry/commands/help.rb
125
100
  - lib/pry/commands/hist.rb
126
101
  - lib/pry/commands/import_set.rb
127
- - lib/pry/commands/install_command.rb
128
102
  - lib/pry/commands/jump_to.rb
129
103
  - lib/pry/commands/list_inspectors.rb
130
- - lib/pry/commands/list_prompts.rb
131
104
  - lib/pry/commands/ls.rb
132
105
  - lib/pry/commands/ls/constants.rb
133
106
  - lib/pry/commands/ls/formatter.rb
@@ -157,7 +130,6 @@ files:
157
130
  - lib/pry/commands/show_info.rb
158
131
  - lib/pry/commands/show_input.rb
159
132
  - lib/pry/commands/show_source.rb
160
- - lib/pry/commands/simple_prompt.rb
161
133
  - lib/pry/commands/stat.rb
162
134
  - lib/pry/commands/switch_to.rb
163
135
  - lib/pry/commands/toggle_color.rb
@@ -166,21 +138,26 @@ files:
166
138
  - lib/pry/commands/whereami.rb
167
139
  - lib/pry/commands/wtf.rb
168
140
  - lib/pry/config.rb
169
- - lib/pry/config/behavior.rb
170
- - lib/pry/config/convenience.rb
171
- - lib/pry/config/default.rb
141
+ - lib/pry/config/attributable.rb
142
+ - lib/pry/config/lazy_value.rb
143
+ - lib/pry/config/memoized_value.rb
144
+ - lib/pry/config/value.rb
145
+ - lib/pry/control_d_handler.rb
172
146
  - lib/pry/core_extensions.rb
173
147
  - lib/pry/editor.rb
148
+ - lib/pry/env.rb
149
+ - lib/pry/exception_handler.rb
174
150
  - lib/pry/exceptions.rb
151
+ - lib/pry/forwardable.rb
175
152
  - lib/pry/helpers.rb
176
153
  - lib/pry/helpers/base_helpers.rb
177
154
  - lib/pry/helpers/command_helpers.rb
178
155
  - lib/pry/helpers/documentation_helpers.rb
179
156
  - lib/pry/helpers/options_helpers.rb
157
+ - lib/pry/helpers/platform.rb
180
158
  - lib/pry/helpers/table.rb
181
159
  - lib/pry/helpers/text.rb
182
160
  - lib/pry/history.rb
183
- - lib/pry/history_array.rb
184
161
  - lib/pry/hooks.rb
185
162
  - lib/pry/indent.rb
186
163
  - lib/pry/input_completer.rb
@@ -191,44 +168,56 @@ files:
191
168
  - lib/pry/method/disowned.rb
192
169
  - lib/pry/method/patcher.rb
193
170
  - lib/pry/method/weird_method_locator.rb
194
- - lib/pry/module_candidate.rb
195
171
  - lib/pry/object_path.rb
196
172
  - lib/pry/output.rb
197
173
  - lib/pry/pager.rb
198
- - lib/pry/plugins.rb
199
174
  - lib/pry/prompt.rb
200
175
  - lib/pry/pry_class.rb
201
176
  - lib/pry/pry_instance.rb
202
- - lib/pry/rbx_path.rb
203
177
  - lib/pry/repl.rb
204
178
  - lib/pry/repl_file_loader.rb
205
- - lib/pry/rubygem.rb
206
- - lib/pry/terminal.rb
207
- - lib/pry/test/helper.rb
179
+ - lib/pry/ring.rb
180
+ - lib/pry/slop.rb
181
+ - lib/pry/slop/LICENSE
182
+ - lib/pry/slop/commands.rb
183
+ - lib/pry/slop/option.rb
184
+ - lib/pry/syntax_highlighter.rb
185
+ - lib/pry/system_command_handler.rb
186
+ - lib/pry/testable.rb
187
+ - lib/pry/testable/evalable.rb
188
+ - lib/pry/testable/mockable.rb
189
+ - lib/pry/testable/pry_tester.rb
190
+ - lib/pry/testable/utility.rb
191
+ - lib/pry/testable/variables.rb
208
192
  - lib/pry/version.rb
193
+ - lib/pry/warning.rb
209
194
  - lib/pry/wrapped_module.rb
210
- homepage: http://pryrepl.org
195
+ - lib/pry/wrapped_module/candidate.rb
196
+ homepage: http://pry.github.io
211
197
  licenses:
212
198
  - MIT
213
- metadata: {}
214
- post_install_message:
199
+ metadata:
200
+ changelog_uri: https://github.com/pry/pry/blob/master/CHANGELOG.md
201
+ source_code_uri: https://github.com/pry/pry
202
+ bug_tracker_uri: https://github.com/pry/pry/issues
203
+ post_install_message:
215
204
  rdoc_options: []
216
205
  require_paths:
217
206
  - lib
218
207
  required_ruby_version: !ruby/object:Gem::Requirement
219
208
  requirements:
220
- - - '>='
209
+ - - ">="
221
210
  - !ruby/object:Gem::Version
222
- version: '0'
211
+ version: '2.0'
223
212
  required_rubygems_version: !ruby/object:Gem::Requirement
224
213
  requirements:
225
- - - '>='
214
+ - - ">="
226
215
  - !ruby/object:Gem::Version
227
216
  version: '0'
228
217
  requirements: []
229
- rubyforge_project:
230
- rubygems_version: 2.0.14
231
- signing_key:
218
+ rubygems_version: 3.4.1
219
+ signing_key:
232
220
  specification_version: 4
233
- summary: An IRB alternative and runtime developer console
221
+ summary: A runtime developer console and IRB alternative with powerful introspection
222
+ capabilities.
234
223
  test_files: []
@@ -1,2 +0,0 @@
1
- Pry::Commands.disabled_command("edit-method", "Use `edit` instead.")
2
- Pry::Commands.disabled_command("show-command", "Use show-source [command_name] instead.")
@@ -1,26 +0,0 @@
1
- class Pry
2
- class Command::GemCd < Pry::ClassCommand
3
- match 'gem-cd'
4
- group 'Gems'
5
- description "Change working directory to specified gem's directory."
6
- command_options :argument_required => true
7
-
8
- banner <<-'BANNER'
9
- Usage: gem-cd GEM_NAME
10
-
11
- Change the current working directory to that in which the given gem is
12
- installed.
13
- BANNER
14
-
15
- def process(gem)
16
- Dir.chdir(Rubygem.spec(gem).full_gem_path)
17
- output.puts(Dir.pwd)
18
- end
19
-
20
- def complete(str)
21
- Rubygem.complete(str)
22
- end
23
- end
24
-
25
- Pry::Commands.add_command(Pry::Command::GemCd)
26
- end
@@ -1,32 +0,0 @@
1
- class Pry
2
- class Command::GemInstall < Pry::ClassCommand
3
- match 'gem-install'
4
- group 'Gems'
5
- description 'Install a gem and refresh the gem cache.'
6
- command_options :argument_required => true
7
-
8
- banner <<-'BANNER'
9
- Usage: gem-install GEM_NAME
10
-
11
- Installs the given gem, refreshes the gem cache, and requires the gem for you
12
- based on a best guess from the gem name.
13
-
14
- gem-install pry-stack_explorer
15
- BANNER
16
-
17
- def setup
18
- require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
19
- end
20
-
21
- def process(gem)
22
- Rubygem.install(gem)
23
- output.puts "Gem `#{ text.green(gem) }` installed."
24
- require gem
25
- rescue LoadError
26
- require_path = gem.split('-').join('/')
27
- require require_path
28
- end
29
- end
30
-
31
- Pry::Commands.add_command(Pry::Command::GemInstall)
32
- end
@@ -1,33 +0,0 @@
1
- class Pry
2
- class Command::GemList < Pry::ClassCommand
3
- match 'gem-list'
4
- group 'Gems'
5
- description 'List and search installed gems.'
6
-
7
- banner <<-'BANNER'
8
- Usage: gem-list [REGEX]
9
-
10
- List all installed gems, when a regex is provided, limit the output to those
11
- that match the regex.
12
- BANNER
13
-
14
- def process(pattern = nil)
15
- pattern = Regexp.compile(pattern || '')
16
- gems = Rubygem.list(pattern).group_by(&:name)
17
-
18
- gems.each do |gem, specs|
19
- specs.sort! do |a,b|
20
- Gem::Version.new(b.version) <=> Gem::Version.new(a.version)
21
- end
22
-
23
- versions = specs.each_with_index.map do |spec, index|
24
- index == 0 ? text.bright_green(spec.version.to_s) : text.green(spec.version.to_s)
25
- end
26
-
27
- output.puts "#{text.default gem} (#{versions.join ', '})"
28
- end
29
- end
30
- end
31
-
32
- Pry::Commands.add_command(Pry::Command::GemList)
33
- end
@@ -1,29 +0,0 @@
1
- class Pry
2
- class Command::GemOpen < Pry::ClassCommand
3
- match 'gem-open'
4
- group 'Gems'
5
- description 'Opens the working directory of the gem in your editor.'
6
- command_options :argument_required => true
7
-
8
- banner <<-'BANNER'
9
- Usage: gem-open GEM_NAME
10
-
11
- Change the current working directory to that in which the given gem is
12
- installed, and then opens your text editor.
13
-
14
- gem-open pry-exception_explorer
15
- BANNER
16
-
17
- def process(gem)
18
- Dir.chdir(Rubygem.spec(gem).full_gem_path) do
19
- Pry::Editor.invoke_editor(".", 0, false)
20
- end
21
- end
22
-
23
- def complete(str)
24
- Rubygem.complete(str)
25
- end
26
- end
27
-
28
- Pry::Commands.add_command(Pry::Command::GemOpen)
29
- end
@@ -1,101 +0,0 @@
1
- class Pry
2
- class Command::Gist < Pry::ClassCommand
3
- match 'gist'
4
- group 'Misc'
5
- description 'Upload code, docs, history to https://gist.github.com/.'
6
- command_options :requires_gem => "gist"
7
-
8
- banner <<-'BANNER'
9
- Usage: gist [OPTIONS] [--help]
10
-
11
- The gist command enables you to gist code from files and methods to github.
12
-
13
- gist -i 20 --lines 1..3
14
- gist Pry#repl --lines 1..-1
15
- gist Rakefile --lines 5
16
- BANNER
17
-
18
- def setup
19
- require 'gist'
20
- end
21
-
22
- def options(opt)
23
- CodeCollector.inject_options(opt)
24
- opt.on :login, "Authenticate the gist gem with GitHub"
25
- opt.on :p, :public, "Create a public gist (default: false)", :default => false
26
- opt.on :clip, "Copy the selected content to clipboard instead, do NOT gist it", :default => false
27
- end
28
-
29
- def process
30
- return ::Gist.login! if opts.present?(:login)
31
- cc = CodeCollector.new(args, opts, _pry_)
32
-
33
- if cc.content =~ /\A\s*\z/
34
- raise CommandError, "Found no code to gist."
35
- end
36
-
37
- if opts.present?(:clip)
38
- clipboard_content(cc.content)
39
- else
40
- # we're overriding the default behavior of the 'in' option (as
41
- # defined on CodeCollector) with our local behaviour.
42
- content = opts.present?(:in) ? input_content : cc.content
43
- gist_content content, cc.file
44
- end
45
- end
46
-
47
- def clipboard_content(content)
48
- ::Gist.copy(content)
49
- output.puts "Copied content to clipboard!"
50
- end
51
-
52
- def input_content
53
- content = ""
54
- CodeCollector.input_expression_ranges.each do |range|
55
- input_expressions = _pry_.input_array[range] || []
56
- Array(input_expressions).each_with_index do |code, index|
57
- corrected_index = index + range.first
58
- if code && code != ""
59
- content << code
60
- if code !~ /;\Z/
61
- content << "#{comment_expression_result_for_gist(_pry_.config.gist.inspecter.call(_pry_.output_array[corrected_index]))}"
62
- end
63
- end
64
- end
65
- end
66
-
67
- content
68
- end
69
-
70
- def comment_expression_result_for_gist(result)
71
- content = ""
72
- result.lines.each_with_index do |line, index|
73
- if index == 0
74
- content << "# => #{line}"
75
- else
76
- content << "# #{line}"
77
- end
78
- end
79
-
80
- content
81
- end
82
-
83
- def gist_content(content, filename)
84
- response = ::Gist.gist(content, :filename => filename || "pry_gist.rb", :public => !!opts[:p])
85
- if response
86
- url = response['html_url']
87
- message = "Gist created at URL #{url}"
88
- begin
89
- ::Gist.copy(url)
90
- message << ", which is now in the clipboard."
91
- rescue ::Gist::ClipboardError
92
- end
93
-
94
- output.puts message
95
- end
96
- end
97
- end
98
-
99
- Pry::Commands.add_command(Pry::Command::Gist)
100
- Pry::Commands.alias_command 'clipit', 'gist --clip'
101
- end
@@ -1,53 +0,0 @@
1
- class Pry
2
- class Command::InstallCommand < Pry::ClassCommand
3
- match 'install-command'
4
- group 'Commands'
5
- description 'Install a disabled command.'
6
-
7
- banner <<-'BANNER'
8
- Usage: install-command COMMAND
9
-
10
- Installs the gems necessary to run the given COMMAND. You will generally not
11
- need to run this unless told to by an error message.
12
- BANNER
13
-
14
- def process(name)
15
- require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
16
- command = find_command(name)
17
-
18
- unless command
19
- output.puts "Command #{ text.green(name) } is not found"
20
- return
21
- end
22
-
23
- if command_dependencies_met?(command.options)
24
- output.puts "Dependencies for #{ text.green(name) } are met. Nothing to do"
25
- return
26
- end
27
-
28
- output.puts "Attempting to install #{ text.green(name) } command..."
29
- gems_to_install = Array(command.options[:requires_gem])
30
-
31
- gems_to_install.each do |g|
32
- next if Rubygem.installed?(g)
33
- output.puts "Installing #{ text.green(g) } gem..."
34
- Rubygem.install(g)
35
- end
36
-
37
- gems_to_install.each do |g|
38
- begin
39
- require g
40
- rescue LoadError
41
- fail_msg = "Required gem #{ text.green(g) } installed but not found."
42
- fail_msg += " Aborting command installation\n"
43
- fail_msg += 'Tips: 1. Check your PATH; 2. Run `bundle update`'
44
- raise CommandError, fail_msg
45
- end
46
- end
47
-
48
- output.puts "Installation of #{ text.green(name) } successful! Type `help #{name}` for information"
49
- end
50
- end
51
-
52
- Pry::Commands.add_command(Pry::Command::InstallCommand)
53
- end
@@ -1,35 +0,0 @@
1
- class Pry::Command::ListPrompts < Pry::ClassCommand
2
- match 'list-prompts'
3
- group 'Input and Output'
4
- description 'List the prompts available for use.'
5
- banner <<-BANNER
6
- Usage: list-prompts
7
-
8
- List the available prompts. You can use change-prompt to switch between
9
- them.
10
- BANNER
11
-
12
- def process
13
- output.puts heading("Available prompts") + "\n"
14
- prompt_map.each do |name, prompt|
15
- output.write "Name: #{text.bold(name)}"
16
- output.puts selected_prompt?(prompt) ? selected_text : ""
17
- output.puts prompt[:description]
18
- output.puts
19
- end
20
- end
21
-
22
- private
23
- def prompt_map
24
- Pry::Prompt::MAP
25
- end
26
-
27
- def selected_text
28
- text.red " (selected) "
29
- end
30
-
31
- def selected_prompt?(prompt)
32
- _pry_.prompt == prompt[:value]
33
- end
34
- Pry::Commands.add_command(self)
35
- end
@@ -1,22 +0,0 @@
1
- class Pry
2
- class Command::SimplePrompt < Pry::ClassCommand
3
- match 'simple-prompt'
4
- group 'prompts'
5
- description 'Toggle the simple prompt.'
6
-
7
- banner <<-'BANNER'
8
- Toggle the simple prompt.
9
- BANNER
10
-
11
- def process
12
- case _pry_.prompt
13
- when Pry::SIMPLE_PROMPT
14
- _pry_.pop_prompt
15
- else
16
- _pry_.push_prompt Pry::SIMPLE_PROMPT
17
- end
18
- end
19
- end
20
-
21
- Pry::Commands.add_command(Pry::Command::SimplePrompt)
22
- end
data/lib/pry/commands.rb DELETED
@@ -1,6 +0,0 @@
1
- # Default commands used by Pry.
2
- Pry::Commands = Pry::CommandSet.new
3
-
4
- Dir[File.expand_path('../commands', __FILE__) << '/*.rb'].each do |file|
5
- require file
6
- end