pry 0.11.3 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +346 -2
  3. data/LICENSE +1 -1
  4. data/README.md +351 -292
  5. data/bin/pry +1 -0
  6. data/lib/pry/basic_object.rb +8 -4
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +58 -76
  10. data/lib/pry/code/code_file.rb +33 -28
  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 +37 -33
  14. data/lib/pry/code_object.rb +41 -39
  15. data/lib/pry/color_printer.rb +47 -45
  16. data/lib/pry/command.rb +178 -374
  17. data/lib/pry/command_set.rb +89 -121
  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 +71 -59
  24. data/lib/pry/commands/cat/file_formatter.rb +55 -49
  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 -133
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +19 -30
  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 +184 -160
  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 +60 -43
  48. data/lib/pry/commands/ls/formatter.rb +42 -37
  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 -23
  60. data/lib/pry/commands/ls.rb +124 -105
  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 +56 -45
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +52 -51
  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 +192 -167
  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 -148
  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 +312 -9
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +13 -10
  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 +5 -1
  95. data/lib/pry/helpers/base_helpers.rb +58 -58
  96. data/lib/pry/helpers/command_helpers.rb +52 -62
  97. data/lib/pry/helpers/documentation_helpers.rb +21 -13
  98. data/lib/pry/helpers/options_helpers.rb +14 -7
  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 +20 -18
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +65 -60
  104. data/lib/pry/hooks.rb +24 -15
  105. data/lib/pry/indent.rb +72 -70
  106. data/lib/pry/input_completer.rb +251 -228
  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 +18 -5
  111. data/lib/pry/method/patcher.rb +14 -5
  112. data/lib/pry/method/weird_method_locator.rb +74 -51
  113. data/lib/pry/method.rb +175 -121
  114. data/lib/pry/object_path.rb +37 -28
  115. data/lib/pry/output.rb +122 -35
  116. data/lib/pry/pager.rb +187 -180
  117. data/lib/pry/prompt.rb +213 -25
  118. data/lib/pry/pry_class.rb +91 -96
  119. data/lib/pry/pry_instance.rb +258 -223
  120. data/lib/pry/repl.rb +49 -25
  121. data/lib/pry/repl_file_loader.rb +27 -22
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/commands.rb +164 -170
  124. data/lib/pry/slop/option.rb +172 -170
  125. data/lib/pry/slop.rb +567 -556
  126. data/lib/pry/syntax_highlighter.rb +26 -0
  127. data/lib/pry/system_command_handler.rb +17 -0
  128. data/lib/pry/testable/evalable.rb +21 -12
  129. data/lib/pry/testable/mockable.rb +18 -10
  130. data/lib/pry/testable/pry_tester.rb +71 -56
  131. data/lib/pry/testable/utility.rb +29 -21
  132. data/lib/pry/testable/variables.rb +49 -43
  133. data/lib/pry/testable.rb +59 -61
  134. data/lib/pry/version.rb +3 -1
  135. data/lib/pry/warning.rb +20 -0
  136. data/lib/pry/wrapped_module/candidate.rb +31 -23
  137. data/lib/pry/wrapped_module.rb +63 -59
  138. data/lib/pry.rb +132 -149
  139. metadata +39 -51
  140. data/lib/pry/commands/disabled_commands.rb +0 -2
  141. data/lib/pry/commands/gem_cd.rb +0 -26
  142. data/lib/pry/commands/gem_install.rb +0 -32
  143. data/lib/pry/commands/gem_list.rb +0 -33
  144. data/lib/pry/commands/gem_open.rb +0 -29
  145. data/lib/pry/commands/gem_readme.rb +0 -25
  146. data/lib/pry/commands/gem_search.rb +0 -40
  147. data/lib/pry/commands/gist.rb +0 -101
  148. data/lib/pry/commands/install_command.rb +0 -53
  149. data/lib/pry/commands/list_prompts.rb +0 -35
  150. data/lib/pry/commands/simple_prompt.rb +0 -22
  151. data/lib/pry/commands.rb +0 -6
  152. data/lib/pry/config/behavior.rb +0 -231
  153. data/lib/pry/config/convenience.rb +0 -25
  154. data/lib/pry/config/default.rb +0 -149
  155. data/lib/pry/config/memoization.rb +0 -44
  156. data/lib/pry/history_array.rb +0 -121
  157. data/lib/pry/platform.rb +0 -93
  158. data/lib/pry/plugins.rb +0 -118
  159. data/lib/pry/rbx_path.rb +0 -22
  160. data/lib/pry/rubygem.rb +0 -84
  161. data/lib/pry/terminal.rb +0 -90
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.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: 2017-11-14 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
@@ -18,47 +19,37 @@ dependencies:
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
+ version: '1.1'
29
30
  - !ruby/object:Gem::Dependency
30
31
  name: method_source
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: 0.9.0
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: 0.9.0
43
- - !ruby/object:Gem::Dependency
44
- name: bundler
45
32
  requirement: !ruby/object:Gem::Requirement
46
33
  requirements:
47
34
  - - "~>"
48
35
  - !ruby/object:Gem::Version
49
36
  version: '1.0'
50
- type: :development
37
+ type: :runtime
51
38
  prerelease: false
52
39
  version_requirements: !ruby/object:Gem::Requirement
53
40
  requirements:
54
41
  - - "~>"
55
42
  - !ruby/object:Gem::Version
56
43
  version: '1.0'
57
- 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.
58
48
  email:
59
49
  - jrmair@gmail.com
60
50
  - conrad.irwin@gmail.com
61
51
  - rwfitzge@gmail.com
52
+ - silin@kyrylo.org
62
53
  executables:
63
54
  - pry
64
55
  extensions: []
@@ -70,6 +61,8 @@ files:
70
61
  - bin/pry
71
62
  - lib/pry.rb
72
63
  - lib/pry/basic_object.rb
64
+ - lib/pry/block_command.rb
65
+ - lib/pry/class_command.rb
73
66
  - lib/pry/cli.rb
74
67
  - lib/pry/code.rb
75
68
  - lib/pry/code/code_file.rb
@@ -79,7 +72,7 @@ files:
79
72
  - lib/pry/color_printer.rb
80
73
  - lib/pry/command.rb
81
74
  - lib/pry/command_set.rb
82
- - lib/pry/commands.rb
75
+ - lib/pry/command_state.rb
83
76
  - lib/pry/commands/amend_line.rb
84
77
  - lib/pry/commands/bang.rb
85
78
  - lib/pry/commands/bang_pry.rb
@@ -91,9 +84,9 @@ files:
91
84
  - lib/pry/commands/cd.rb
92
85
  - lib/pry/commands/change_inspector.rb
93
86
  - lib/pry/commands/change_prompt.rb
87
+ - lib/pry/commands/clear_screen.rb
94
88
  - lib/pry/commands/code_collector.rb
95
89
  - lib/pry/commands/disable_pry.rb
96
- - lib/pry/commands/disabled_commands.rb
97
90
  - lib/pry/commands/easter_eggs.rb
98
91
  - lib/pry/commands/edit.rb
99
92
  - lib/pry/commands/edit/exception_patcher.rb
@@ -103,20 +96,11 @@ files:
103
96
  - lib/pry/commands/exit_program.rb
104
97
  - lib/pry/commands/find_method.rb
105
98
  - lib/pry/commands/fix_indent.rb
106
- - lib/pry/commands/gem_cd.rb
107
- - lib/pry/commands/gem_install.rb
108
- - lib/pry/commands/gem_list.rb
109
- - lib/pry/commands/gem_open.rb
110
- - lib/pry/commands/gem_readme.rb
111
- - lib/pry/commands/gem_search.rb
112
- - lib/pry/commands/gist.rb
113
99
  - lib/pry/commands/help.rb
114
100
  - lib/pry/commands/hist.rb
115
101
  - lib/pry/commands/import_set.rb
116
- - lib/pry/commands/install_command.rb
117
102
  - lib/pry/commands/jump_to.rb
118
103
  - lib/pry/commands/list_inspectors.rb
119
- - lib/pry/commands/list_prompts.rb
120
104
  - lib/pry/commands/ls.rb
121
105
  - lib/pry/commands/ls/constants.rb
122
106
  - lib/pry/commands/ls/formatter.rb
@@ -146,7 +130,6 @@ files:
146
130
  - lib/pry/commands/show_info.rb
147
131
  - lib/pry/commands/show_input.rb
148
132
  - lib/pry/commands/show_source.rb
149
- - lib/pry/commands/simple_prompt.rb
150
133
  - lib/pry/commands/stat.rb
151
134
  - lib/pry/commands/switch_to.rb
152
135
  - lib/pry/commands/toggle_color.rb
@@ -155,12 +138,15 @@ files:
155
138
  - lib/pry/commands/whereami.rb
156
139
  - lib/pry/commands/wtf.rb
157
140
  - lib/pry/config.rb
158
- - lib/pry/config/behavior.rb
159
- - lib/pry/config/convenience.rb
160
- - lib/pry/config/default.rb
161
- - lib/pry/config/memoization.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
162
146
  - lib/pry/core_extensions.rb
163
147
  - lib/pry/editor.rb
148
+ - lib/pry/env.rb
149
+ - lib/pry/exception_handler.rb
164
150
  - lib/pry/exceptions.rb
165
151
  - lib/pry/forwardable.rb
166
152
  - lib/pry/helpers.rb
@@ -168,10 +154,10 @@ files:
168
154
  - lib/pry/helpers/command_helpers.rb
169
155
  - lib/pry/helpers/documentation_helpers.rb
170
156
  - lib/pry/helpers/options_helpers.rb
157
+ - lib/pry/helpers/platform.rb
171
158
  - lib/pry/helpers/table.rb
172
159
  - lib/pry/helpers/text.rb
173
160
  - lib/pry/history.rb
174
- - lib/pry/history_array.rb
175
161
  - lib/pry/hooks.rb
176
162
  - lib/pry/indent.rb
177
163
  - lib/pry/input_completer.rb
@@ -185,20 +171,18 @@ files:
185
171
  - lib/pry/object_path.rb
186
172
  - lib/pry/output.rb
187
173
  - lib/pry/pager.rb
188
- - lib/pry/platform.rb
189
- - lib/pry/plugins.rb
190
174
  - lib/pry/prompt.rb
191
175
  - lib/pry/pry_class.rb
192
176
  - lib/pry/pry_instance.rb
193
- - lib/pry/rbx_path.rb
194
177
  - lib/pry/repl.rb
195
178
  - lib/pry/repl_file_loader.rb
196
- - lib/pry/rubygem.rb
179
+ - lib/pry/ring.rb
197
180
  - lib/pry/slop.rb
198
181
  - lib/pry/slop/LICENSE
199
182
  - lib/pry/slop/commands.rb
200
183
  - lib/pry/slop/option.rb
201
- - lib/pry/terminal.rb
184
+ - lib/pry/syntax_highlighter.rb
185
+ - lib/pry/system_command_handler.rb
202
186
  - lib/pry/testable.rb
203
187
  - lib/pry/testable/evalable.rb
204
188
  - lib/pry/testable/mockable.rb
@@ -206,13 +190,17 @@ files:
206
190
  - lib/pry/testable/utility.rb
207
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
195
  - lib/pry/wrapped_module/candidate.rb
211
- homepage: http://pryrepl.org
196
+ homepage: http://pry.github.io
212
197
  licenses:
213
198
  - MIT
214
- metadata: {}
215
- 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:
216
204
  rdoc_options: []
217
205
  require_paths:
218
206
  - lib
@@ -220,16 +208,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
208
  requirements:
221
209
  - - ">="
222
210
  - !ruby/object:Gem::Version
223
- version: 1.9.3
211
+ version: '2.0'
224
212
  required_rubygems_version: !ruby/object:Gem::Requirement
225
213
  requirements:
226
214
  - - ">="
227
215
  - !ruby/object:Gem::Version
228
216
  version: '0'
229
217
  requirements: []
230
- rubyforge_project:
231
- rubygems_version: 2.6.13
232
- signing_key:
218
+ rubygems_version: 3.4.1
219
+ signing_key:
233
220
  specification_version: 4
234
- summary: An IRB alternative and runtime developer console
221
+ summary: A runtime developer console and IRB alternative with powerful introspection
222
+ capabilities.
235
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.new(_pry_).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,25 +0,0 @@
1
- class Pry::Command::GemReadme < Pry::ClassCommand
2
- match 'gem-readme'
3
- description 'Show the readme bundled with a rubygem'
4
- group 'Gems'
5
- command_options argument_required: true
6
- banner <<-BANNER
7
- gem-readme gem
8
- Show the readme bundled with a rubygem
9
- BANNER
10
-
11
- def process(name)
12
- spec = Gem::Specification.find_by_name(name)
13
- glob = File.join(spec.full_gem_path, 'README*')
14
- readme = Dir[glob][0]
15
- if File.exist?(readme.to_s)
16
- _pry_.pager.page File.read(readme)
17
- else
18
- raise Pry::CommandError, "Gem '#{name}' doesn't appear to have a README"
19
- end
20
- rescue Gem::LoadError
21
- raise Pry::CommandError, "Gem '#{name}' wasn't found. Are you sure it is installed?"
22
- end
23
-
24
- Pry::Commands.add_command(self)
25
- end
@@ -1,40 +0,0 @@
1
- class Pry::Command::GemSearch < Pry::ClassCommand
2
- match 'gem-search'
3
- description 'Search for a gem with the rubygems.org JSON API'
4
- group 'Gems'
5
- command_options argument_required: true
6
- banner <<-BANNER
7
- gem-search [options] gem
8
- Search for a gem with the rubygems.org HTTP API
9
- BANNER
10
-
11
- API_ENDPOINT = 'https://rubygems.org/api/v1/search.json'
12
-
13
- def setup
14
- require 'json' unless defined?(JSON)
15
- require 'net/http' unless defined?(Net::HTTP)
16
- end
17
-
18
- def options(opt)
19
- opt.on :l, :limit, 'Limit the number of results (max: 30)',
20
- default: 10,
21
- as: Integer,
22
- argument: true
23
- end
24
-
25
- def process(str)
26
- uri = URI.parse(API_ENDPOINT)
27
- uri.query = URI.encode_www_form(query: str)
28
- gems = JSON.load Net::HTTP.get(uri)
29
- _pry_.pager.page list_as_string(gems, opts[:limit])
30
- end
31
-
32
- private
33
- def list_as_string(gems, limit = 10)
34
- gems[0..limit-1].map do |gem|
35
- name, version, info = gem.values_at 'name', 'version', 'info'
36
- "#{text.bold(name)} #{text.bold('v'+version)} \n#{info}\n\n"
37
- end.join
38
- end
39
- Pry::Commands.add_command(self)
40
- 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