pry 0.12.0-java → 0.12.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +10 -0
- data/lib/pry.rb +2 -3
- data/lib/pry/cli.rb +2 -2
- data/lib/pry/command.rb +11 -16
- data/lib/pry/commands/change_prompt.rb +1 -1
- data/lib/pry/commands/ls/jruby_hacks.rb +1 -1
- data/lib/pry/commands/ls/local_vars.rb +1 -1
- data/lib/pry/commands/show_info.rb +1 -1
- data/lib/pry/commands/wtf.rb +1 -1
- data/lib/pry/config/behavior.rb +2 -2
- data/lib/pry/helpers/base_helpers.rb +0 -128
- data/lib/pry/hooks.rb +4 -4
- data/lib/pry/indent.rb +1 -1
- data/lib/pry/method.rb +0 -9
- data/lib/pry/pager.rb +192 -185
- data/lib/pry/prompt.rb +26 -19
- data/lib/pry/pry_instance.rb +0 -30
- data/lib/pry/repl_file_loader.rb +1 -1
- data/lib/pry/slop.rb +1 -1
- data/lib/pry/slop/option.rb +1 -1
- data/lib/pry/version.rb +1 -1
- metadata +13 -14
- data/lib/pry/platform.rb +0 -91
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c06d154a395ec987e638547f2b8ce90dc14a1cc3
|
4
|
+
data.tar.gz: a8e7456b6a7f99da4f8666acfa22b11482d61367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aff28cfde825f238963ab0acba931bf5308301239b2080ec1b1bf5488e189bd6edb5988bc1abe29fea25ca53833861122bcefd380bf0bf15acbceadab557c11
|
7
|
+
data.tar.gz: 3751b02678ca29fa153e83277d370880c6043ab463ce3634a3ddcb6bf5f476cb73e3d363778c32404fdd447a7988609419223317b8c8a5642368d851b5456dd3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
### HEAD
|
2
2
|
|
3
|
+
### [v0.12.1][v0.12.1] (November 12, 2018)
|
4
|
+
|
5
|
+
#### Bug fixes
|
6
|
+
|
7
|
+
* Stopped creating a new hash each time `Pry::Prompt#[]` is invoked
|
8
|
+
([#1855](https://github.com/pry/pry/pull/1855))
|
9
|
+
* Fixed `less` pager not working when it's available
|
10
|
+
([#1861](https://github.com/pry/pry/pull/1861))
|
11
|
+
|
3
12
|
### [v0.12.0][v0.12.0] (November 5, 2018)
|
4
13
|
|
5
14
|
#### Major changes
|
@@ -933,3 +942,4 @@ complete CHANGELOG:
|
|
933
942
|
* release!
|
934
943
|
|
935
944
|
[v0.12.0]: https://github.com/pry/pry/releases/tag/v0.12.0
|
945
|
+
[v0.12.1]: https://github.com/pry/pry/releases/tag/v0.12.1
|
data/lib/pry.rb
CHANGED
@@ -2,20 +2,19 @@ require 'pp'
|
|
2
2
|
require 'pry/forwardable'
|
3
3
|
require 'pry/input_lock'
|
4
4
|
require 'pry/exceptions'
|
5
|
-
require 'pry/platform'
|
6
5
|
require 'pry/helpers/base_helpers'
|
7
6
|
require 'pry/hooks'
|
8
7
|
|
9
8
|
class Pry
|
10
9
|
# The default hooks - display messages when beginning and ending Pry sessions.
|
11
|
-
DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |
|
10
|
+
DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |_out, _target, _pry_|
|
12
11
|
next if _pry_.quiet?
|
13
12
|
|
14
13
|
_pry_.run_command("whereami --quiet")
|
15
14
|
end
|
16
15
|
|
17
16
|
# The default print
|
18
|
-
DEFAULT_PRINT = proc do |
|
17
|
+
DEFAULT_PRINT = proc do |_output, value, _pry_|
|
19
18
|
_pry_.pager.open do |pager|
|
20
19
|
pager.print _pry_.config.output_prefix
|
21
20
|
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
|
data/lib/pry/cli.rb
CHANGED
@@ -191,7 +191,7 @@ Pry::CLI.add_options do
|
|
191
191
|
Pry.config.requires << file
|
192
192
|
end
|
193
193
|
|
194
|
-
on
|
194
|
+
on(:I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":") do
|
195
195
|
load_path.map! do |path|
|
196
196
|
/\A\.\// =~ path ? path : File.expand_path(path)
|
197
197
|
end
|
@@ -199,7 +199,7 @@ Pry::CLI.add_options do
|
|
199
199
|
$LOAD_PATH.unshift(*load_path)
|
200
200
|
end
|
201
201
|
|
202
|
-
on "gem", "Shorthand for -I./lib -rgemname" do |
|
202
|
+
on "gem", "Shorthand for -I./lib -rgemname" do |_load_path|
|
203
203
|
$LOAD_PATH.unshift("./lib")
|
204
204
|
Dir["./lib/*.rb"].each do |file|
|
205
205
|
Pry.config.requires << file
|
data/lib/pry/command.rb
CHANGED
@@ -252,18 +252,6 @@ class Pry
|
|
252
252
|
command_set.to_hash
|
253
253
|
end
|
254
254
|
|
255
|
-
#
|
256
|
-
# @deprecated
|
257
|
-
# Please use black(), white(), etc directly instead (as you would with helper
|
258
|
-
# functions from BaseHelpers and CommandHelpers)
|
259
|
-
#
|
260
|
-
# @return [Module]
|
261
|
-
# Returns Pry::Helpers::Text
|
262
|
-
#
|
263
|
-
def text
|
264
|
-
Pry::Helpers::Text
|
265
|
-
end
|
266
|
-
|
267
255
|
def void
|
268
256
|
VOID_VALUE
|
269
257
|
end
|
@@ -319,7 +307,10 @@ class Pry
|
|
319
307
|
collision_type ||= 'local-variable' if arg_string.match(%r{\A\s*[-+*/%&|^]*=})
|
320
308
|
|
321
309
|
if collision_type
|
322
|
-
output.puts
|
310
|
+
output.puts(
|
311
|
+
"#{Helpers::Text.bold('WARNING:')} Calling Pry command '#{command_match}', " \
|
312
|
+
"which conflicts with a #{collision_type}.\n\n"
|
313
|
+
)
|
323
314
|
end
|
324
315
|
rescue Pry::RescuableException
|
325
316
|
end
|
@@ -425,9 +416,13 @@ class Pry
|
|
425
416
|
unless dependencies_met?
|
426
417
|
gems_needed = Array(command_options[:requires_gem])
|
427
418
|
gems_not_installed = gems_needed.select { |g| !Rubygem.installed?(g) }
|
428
|
-
output.puts
|
429
|
-
|
430
|
-
|
419
|
+
output.puts(<<WARN)
|
420
|
+
The command #{Helpers::Text.bold(command_name)} is unavailable because it requires the following
|
421
|
+
gems to be installed: #{(gems_not_installed.join(", "))}
|
422
|
+
|
423
|
+
Type #{Helpers::Text.bold('install-command ' + command_name)} to install the required gems
|
424
|
+
and activate this command.
|
425
|
+
WARN
|
431
426
|
return void
|
432
427
|
end
|
433
428
|
|
@@ -28,7 +28,7 @@ class Pry::Command::ChangePrompt < Pry::ClassCommand
|
|
28
28
|
"#{bold(name)}#{red(' (selected)') if _pry_.prompt == prompt[:value]}\n" +
|
29
29
|
prompt[:description]
|
30
30
|
end
|
31
|
-
output.puts(prompts.join("\n"))
|
31
|
+
output.puts(prompts.join("\n" * 2))
|
32
32
|
end
|
33
33
|
|
34
34
|
def change_prompt(prompt)
|
@@ -155,7 +155,7 @@ class Pry
|
|
155
155
|
owner: "\n#{bold("Owner:")} #{code_object.owner || "N/A"}\n",
|
156
156
|
visibility: "#{bold("Visibility:")} #{code_object.visibility}",
|
157
157
|
signature: "\n#{bold("Signature:")} #{code_object.signature}"
|
158
|
-
}.merge(header_options) { |
|
158
|
+
}.merge(header_options) { |_key, old, new| (new && old).to_s }
|
159
159
|
end
|
160
160
|
|
161
161
|
def header_options
|
data/lib/pry/commands/wtf.rb
CHANGED
@@ -36,7 +36,7 @@ class Pry
|
|
36
36
|
if exception.respond_to? :cause
|
37
37
|
cause = exception.cause
|
38
38
|
while cause
|
39
|
-
output.puts "#{
|
39
|
+
output.puts "#{bold('Caused by:')} #{cause.class}: #{cause}\n--"
|
40
40
|
if opts.verbose?
|
41
41
|
output.puts with_line_numbers(cause.backtrace)
|
42
42
|
else
|
data/lib/pry/config/behavior.rb
CHANGED
@@ -163,8 +163,8 @@ class Pry
|
|
163
163
|
|
164
164
|
def eager_load!
|
165
165
|
default = @default
|
166
|
-
while default
|
167
|
-
default.memoized_methods.each {
|
166
|
+
while default && default.respond_to?(:memoized_methods)
|
167
|
+
default.memoized_methods.each { self[key] = default.public_send(key) }
|
168
168
|
default = @default.default
|
169
169
|
end
|
170
170
|
end
|
@@ -1,135 +1,8 @@
|
|
1
1
|
module Pry::Helpers; end
|
2
2
|
|
3
|
-
# rubocop:disable Metrics/ModuleLength
|
4
3
|
module Pry::Helpers::BaseHelpers
|
5
4
|
extend self
|
6
5
|
|
7
|
-
@mac_osx_warn = false
|
8
|
-
# @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.
|
9
|
-
def mac_osx?
|
10
|
-
unless @mac_osx_warn
|
11
|
-
loc = caller_locations(1..1).first
|
12
|
-
warn(
|
13
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
14
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
15
|
-
)
|
16
|
-
@mac_osx_warn = true
|
17
|
-
end
|
18
|
-
Pry::Helpers::Platform.mac_osx?
|
19
|
-
end
|
20
|
-
|
21
|
-
@linux_warn = false
|
22
|
-
# @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.
|
23
|
-
def linux?
|
24
|
-
unless @linux_warn
|
25
|
-
loc = caller_locations(1..1).first
|
26
|
-
warn(
|
27
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
28
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
29
|
-
)
|
30
|
-
@linux_warn = true
|
31
|
-
end
|
32
|
-
Pry::Helpers::Platform.linux?
|
33
|
-
end
|
34
|
-
|
35
|
-
@windows_warn = false
|
36
|
-
# @deprecated Use {Pry::Helpers::Platform.windows?} instead.
|
37
|
-
def windows?
|
38
|
-
unless @windows_warn
|
39
|
-
loc = caller_locations(1..1).first
|
40
|
-
warn(
|
41
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
42
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
43
|
-
)
|
44
|
-
@windows_warn = true
|
45
|
-
end
|
46
|
-
Pry::Helpers::Platform.windows?
|
47
|
-
end
|
48
|
-
|
49
|
-
@windows_ansi_warn = false
|
50
|
-
# @deprecated Use {Pry::Helpers::Platform.windows_ansi?} instead.
|
51
|
-
def windows_ansi?
|
52
|
-
unless @windows_ansi_warn
|
53
|
-
loc = caller_locations(1..1).first
|
54
|
-
warn(
|
55
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
56
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
57
|
-
)
|
58
|
-
@windows_ansi_warn = true
|
59
|
-
end
|
60
|
-
Pry::Helpers::Platform.windows_ansi?
|
61
|
-
end
|
62
|
-
|
63
|
-
@jruby_warn = false
|
64
|
-
# @deprecated Use {Pry::Helpers::Platform.jruby?} instead.
|
65
|
-
def jruby?
|
66
|
-
unless @jruby_warn
|
67
|
-
loc = caller_locations(1..1).first
|
68
|
-
warn(
|
69
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
70
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
71
|
-
)
|
72
|
-
@jruby_warn = true
|
73
|
-
end
|
74
|
-
Pry::Helpers::Platform.jruby?
|
75
|
-
end
|
76
|
-
|
77
|
-
@jruby19_warn = false
|
78
|
-
# @deprecated Use {Pry::Helpers::Platform.jruby_19?} instead.
|
79
|
-
def jruby_19?
|
80
|
-
unless @jruby19_warn
|
81
|
-
loc = caller_locations(1..1).first
|
82
|
-
warn(
|
83
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
84
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
85
|
-
)
|
86
|
-
@jruby19_warn = true
|
87
|
-
end
|
88
|
-
Pry::Helpers::Platform.jruby_19?
|
89
|
-
end
|
90
|
-
|
91
|
-
@mri_warn = false
|
92
|
-
# @deprecated Use {Pry::Helpers::Platform.mri?} instead.
|
93
|
-
def mri?
|
94
|
-
unless @mri_warn
|
95
|
-
loc = caller_locations(1..1).first
|
96
|
-
warn(
|
97
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
98
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
99
|
-
)
|
100
|
-
@mri_warn = true
|
101
|
-
end
|
102
|
-
Pry::Helpers::Platform.mri?
|
103
|
-
end
|
104
|
-
|
105
|
-
@mri19_warn = false
|
106
|
-
# @deprecated Use {Pry::Helpers::Platform.mri_19?} instead.
|
107
|
-
def mri_19?
|
108
|
-
unless @mri19_warn
|
109
|
-
loc = caller_locations(1..1).first
|
110
|
-
warn(
|
111
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
112
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
113
|
-
)
|
114
|
-
@mri19_warn = true
|
115
|
-
end
|
116
|
-
Pry::Helpers::Platform.mri_19?
|
117
|
-
end
|
118
|
-
|
119
|
-
@mri2_warn = false
|
120
|
-
# @deprecated Use {Pry::Helpers::Platform.mri_2?} instead.
|
121
|
-
def mri_2?
|
122
|
-
unless @mri2_warn
|
123
|
-
loc = caller_locations(1..1).first
|
124
|
-
warn(
|
125
|
-
"#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \
|
126
|
-
"is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"
|
127
|
-
)
|
128
|
-
@mri2_warn = true
|
129
|
-
end
|
130
|
-
Pry::Helpers::Platform.mri_2?
|
131
|
-
end
|
132
|
-
|
133
6
|
def silence_warnings
|
134
7
|
old_verbose = $VERBOSE
|
135
8
|
$VERBOSE = nil
|
@@ -197,4 +70,3 @@ module Pry::Helpers::BaseHelpers
|
|
197
70
|
end
|
198
71
|
end
|
199
72
|
end
|
200
|
-
# rubocop:enable Metrics/ModuleLength
|
data/lib/pry/hooks.rb
CHANGED
@@ -34,7 +34,7 @@ class Pry
|
|
34
34
|
# @return [Pry:Hooks] The receiver.
|
35
35
|
# @see #merge
|
36
36
|
def merge!(other)
|
37
|
-
@hooks.merge!(other.dup.hooks) do |
|
37
|
+
@hooks.merge!(other.dup.hooks) do |_key, array, other_array|
|
38
38
|
temp_hash, output = {}, []
|
39
39
|
|
40
40
|
(array + other_array).reverse_each do |pair|
|
@@ -79,7 +79,7 @@ class Pry
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# ensure we only have one anonymous hook
|
82
|
-
@hooks[event_name].delete_if { |h,
|
82
|
+
@hooks[event_name].delete_if { |h, _k| h.nil? } if hook_name.nil?
|
83
83
|
|
84
84
|
if block
|
85
85
|
@hooks[event_name] << [hook_name, block]
|
@@ -95,7 +95,7 @@ class Pry
|
|
95
95
|
# @param [Array] args The arguments to pass to each hook function.
|
96
96
|
# @return [Object] The return value of the last executed hook.
|
97
97
|
def exec_hook(event_name, *args, &block)
|
98
|
-
@hooks[event_name.to_s].map do |
|
98
|
+
@hooks[event_name.to_s].map do |_hook_name, callable|
|
99
99
|
begin
|
100
100
|
callable.call(*args, &block)
|
101
101
|
rescue RescuableException => e
|
@@ -115,7 +115,7 @@ class Pry
|
|
115
115
|
# @param [Symbol] hook_name The name of the hook
|
116
116
|
# @return [#call] a specific hook for a given event.
|
117
117
|
def get_hook(event_name, hook_name)
|
118
|
-
hook = @hooks[event_name.to_s].find do |current_hook_name,
|
118
|
+
hook = @hooks[event_name.to_s].find do |current_hook_name, _callable|
|
119
119
|
current_hook_name == hook_name
|
120
120
|
end
|
121
121
|
hook.last if hook
|
data/lib/pry/indent.rb
CHANGED
@@ -145,7 +145,7 @@ class Pry
|
|
145
145
|
input.lines.each do |line|
|
146
146
|
if in_string?
|
147
147
|
tokens = tokenize("#{open_delimiters_line}\n#{line}")
|
148
|
-
tokens = tokens.drop_while { |token,
|
148
|
+
tokens = tokens.drop_while { |token, _type| !(String === token && token.include?("\n")) }
|
149
149
|
previously_in_string = true
|
150
150
|
else
|
151
151
|
tokens = tokenize(line)
|
data/lib/pry/method.rb
CHANGED
@@ -161,15 +161,6 @@ class Pry
|
|
161
161
|
all_from_class(singleton_class_of(obj), include_super)
|
162
162
|
end
|
163
163
|
|
164
|
-
#
|
165
|
-
# @deprecated
|
166
|
-
# please use {all_from_obj} instead.
|
167
|
-
# the `method_type` argument is ignored.
|
168
|
-
#
|
169
|
-
def all_from_common(obj, _method_type = nil, include_super = true)
|
170
|
-
all_from_obj(obj, include_super)
|
171
|
-
end
|
172
|
-
|
173
164
|
# Get every `Class` and `Module`, in order, that will be checked when looking
|
174
165
|
# for an instance method to call on this object.
|
175
166
|
# @param [Object] obj
|
data/lib/pry/pager.rb
CHANGED
@@ -3,241 +3,248 @@ require 'pry/terminal'
|
|
3
3
|
# A pager is an `IO`-like object that accepts text and either prints it
|
4
4
|
# immediately, prints it one page at a time, or streams it to an external
|
5
5
|
# program to print one page at a time.
|
6
|
-
class Pry
|
7
|
-
class
|
8
|
-
|
9
|
-
|
10
|
-
attr_reader :_pry_
|
11
|
-
|
12
|
-
def initialize(_pry_)
|
13
|
-
@_pry_ = _pry_
|
14
|
-
end
|
15
|
-
|
16
|
-
# Send the given text through the best available pager (if `Pry.config.pager` is
|
17
|
-
# enabled). If you want to send text through in chunks as you generate it, use `open`
|
18
|
-
# to get a writable object instead.
|
19
|
-
#
|
20
|
-
# @param [String] text
|
21
|
-
# Text to run through a pager.
|
22
|
-
#
|
23
|
-
def page(text)
|
24
|
-
open do |pager|
|
25
|
-
pager << text
|
6
|
+
class Pry
|
7
|
+
class Pager
|
8
|
+
class StopPaging < StandardError
|
26
9
|
end
|
27
|
-
end
|
28
10
|
|
29
|
-
|
30
|
-
# pagers accept output with `#puts`, `#print`, `#write`, and `#<<`.
|
31
|
-
def open
|
32
|
-
pager = best_available
|
33
|
-
yield pager
|
34
|
-
rescue StopPaging
|
35
|
-
ensure
|
36
|
-
pager.close if pager
|
37
|
-
end
|
11
|
+
attr_reader :_pry_
|
38
12
|
|
39
|
-
|
40
|
-
|
41
|
-
def enabled?; !!@enabled; end
|
42
|
-
|
43
|
-
def output; @output; end
|
44
|
-
|
45
|
-
# Return an instance of the "best" available pager class -- `SystemPager` if
|
46
|
-
# possible, `SimplePager` if `SystemPager` isn't available, and `NullPager`
|
47
|
-
# if the user has disabled paging. All pagers accept output with `#puts`,
|
48
|
-
# `#print`, `#write`, and `#<<`. You must call `#close` when you're done
|
49
|
-
# writing output to a pager, and you must rescue `Pry::Pager::StopPaging`.
|
50
|
-
# These requirements can be avoided by using `.open` instead.
|
51
|
-
def best_available
|
52
|
-
if !_pry_.config.pager
|
53
|
-
NullPager.new(_pry_.output)
|
54
|
-
elsif !SystemPager.available? || Helpers::Platform.jruby?
|
55
|
-
SimplePager.new(_pry_.output)
|
56
|
-
else
|
57
|
-
SystemPager.new(_pry_.output)
|
13
|
+
def initialize(_pry_)
|
14
|
+
@_pry_ = _pry_
|
58
15
|
end
|
59
|
-
end
|
60
16
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
17
|
+
# Send the given text through the best available pager (if
|
18
|
+
# `Pry.config.pager` is enabled). If you want to send text through in
|
19
|
+
# chunks as you generate it, use `open` to get a writable object
|
20
|
+
# instead.
|
21
|
+
#
|
22
|
+
# @param [String] text
|
23
|
+
# Text to run through a pager.
|
24
|
+
#
|
25
|
+
def page(text)
|
26
|
+
open do |pager|
|
27
|
+
pager << text
|
28
|
+
end
|
66
29
|
end
|
67
30
|
|
68
|
-
|
69
|
-
|
31
|
+
# Yields a pager object (`NullPager`, `SimplePager`, or `SystemPager`).
|
32
|
+
# All pagers accept output with `#puts`, `#print`, `#write`, and `#<<`.
|
33
|
+
def open
|
34
|
+
pager = best_available
|
35
|
+
yield pager
|
36
|
+
rescue StopPaging
|
37
|
+
ensure
|
38
|
+
pager.close if pager
|
70
39
|
end
|
71
40
|
|
72
|
-
|
73
|
-
write str
|
74
|
-
end
|
75
|
-
alias << print
|
41
|
+
private
|
76
42
|
|
77
|
-
def
|
78
|
-
|
43
|
+
def enabled?; !!@enabled; end
|
44
|
+
|
45
|
+
def output; @output; end
|
46
|
+
|
47
|
+
# Return an instance of the "best" available pager class --
|
48
|
+
# `SystemPager` if possible, `SimplePager` if `SystemPager` isn't
|
49
|
+
# available, and `NullPager` if the user has disabled paging. All
|
50
|
+
# pagers accept output with `#puts`, `#print`, `#write`, and `#<<`. You
|
51
|
+
# must call `#close` when you're done writing output to a pager, and
|
52
|
+
# you must rescue `Pry::Pager::StopPaging`. These requirements can be
|
53
|
+
# avoided by using `.open` instead.
|
54
|
+
def best_available
|
55
|
+
if !_pry_.config.pager
|
56
|
+
NullPager.new(_pry_.output)
|
57
|
+
elsif !SystemPager.available? || Helpers::Platform.jruby?
|
58
|
+
SimplePager.new(_pry_.output)
|
59
|
+
else
|
60
|
+
SystemPager.new(_pry_.output)
|
61
|
+
end
|
79
62
|
end
|
80
63
|
|
81
|
-
|
82
|
-
|
64
|
+
# `NullPager` is a "pager" that actually just prints all output as it
|
65
|
+
# comes in. Used when `Pry.config.pager` is false.
|
66
|
+
class NullPager
|
67
|
+
def initialize(out)
|
68
|
+
@out = out
|
69
|
+
end
|
83
70
|
|
84
|
-
|
71
|
+
def puts(str)
|
72
|
+
print "#{str.chomp}\n"
|
73
|
+
end
|
85
74
|
|
86
|
-
|
87
|
-
|
88
|
-
|
75
|
+
def print(str)
|
76
|
+
write str
|
77
|
+
end
|
78
|
+
alias << print
|
89
79
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
80
|
+
def write(str)
|
81
|
+
@out.write str
|
82
|
+
end
|
94
83
|
|
95
|
-
|
96
|
-
|
97
|
-
class SimplePager < NullPager
|
98
|
-
def initialize(*)
|
99
|
-
super
|
100
|
-
@tracker = PageTracker.new(height - 3, width)
|
101
|
-
end
|
84
|
+
def close
|
85
|
+
end
|
102
86
|
|
103
|
-
|
104
|
-
str.lines.each do |line|
|
105
|
-
@out.print line
|
106
|
-
@tracker.record line
|
87
|
+
private
|
107
88
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
@out.print "<page break> --- Press enter to continue " \
|
112
|
-
"( q<enter> to break ) --- <page break>\n"
|
113
|
-
raise StopPaging if Readline.readline("").chomp == "q"
|
89
|
+
def height
|
90
|
+
@height ||= Pry::Terminal.height!
|
91
|
+
end
|
114
92
|
|
115
|
-
|
116
|
-
|
93
|
+
def width
|
94
|
+
@width ||= Pry::Terminal.width!
|
117
95
|
end
|
118
96
|
end
|
119
|
-
end
|
120
97
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
# Default to less, and make sure less is being passed the correct options
|
129
|
-
if pager.strip.empty? or pager =~ /^less\b/
|
130
|
-
pager = "less -R -F -X"
|
98
|
+
# `SimplePager` is a straightforward pure-Ruby pager. We use it on
|
99
|
+
# JRuby and when we can't find a usable external pager.
|
100
|
+
class SimplePager < NullPager
|
101
|
+
def initialize(*)
|
102
|
+
super
|
103
|
+
@tracker = PageTracker.new(height - 3, width)
|
131
104
|
end
|
132
105
|
|
133
|
-
|
134
|
-
|
106
|
+
def write(str)
|
107
|
+
str.lines.each do |line|
|
108
|
+
@out.print line
|
109
|
+
@tracker.record line
|
135
110
|
|
136
|
-
|
111
|
+
if @tracker.page?
|
112
|
+
@out.print "\n"
|
113
|
+
@out.print "\e[0m"
|
114
|
+
@out.print "<page break> --- Press enter to continue " \
|
115
|
+
"( q<enter> to break ) --- <page break>\n"
|
116
|
+
raise StopPaging if Readline.readline("").chomp == "q"
|
137
117
|
|
138
|
-
|
139
|
-
if @system_pager.nil?
|
140
|
-
@system_pager = begin
|
141
|
-
pager_executable = default_pager.split(' ').first
|
142
|
-
if Helpers::Platform.windows? || Helpers::Platform.windows_ansi?
|
143
|
-
`where /Q #{pager_executable}`
|
144
|
-
else
|
145
|
-
`which #{pager_executable}`
|
118
|
+
@tracker.reset
|
146
119
|
end
|
147
|
-
$?.success?
|
148
|
-
rescue
|
149
|
-
false
|
150
120
|
end
|
151
|
-
else
|
152
|
-
@system_pager
|
153
121
|
end
|
154
122
|
end
|
155
123
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
124
|
+
# `SystemPager` buffers output until we're pretty sure it's at least a
|
125
|
+
# page long, then invokes an external pager and starts streaming output
|
126
|
+
# to it. If `#close` is called before then, it just prints out the
|
127
|
+
# buffered content.
|
128
|
+
class SystemPager < NullPager
|
129
|
+
def self.default_pager
|
130
|
+
pager = ENV["PAGER"] || ""
|
162
131
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
132
|
+
# Default to less, and make sure less is being passed the correct
|
133
|
+
# options
|
134
|
+
if pager.strip.empty? or pager =~ /^less\b/
|
135
|
+
pager = "less -R -F -X"
|
136
|
+
end
|
137
|
+
|
138
|
+
pager
|
139
|
+
end
|
169
140
|
|
170
|
-
|
171
|
-
|
141
|
+
@system_pager = nil
|
142
|
+
|
143
|
+
def self.available?
|
144
|
+
if @system_pager.nil?
|
145
|
+
@system_pager = begin
|
146
|
+
pager_executable = default_pager.split(' ').first
|
147
|
+
if Helpers::Platform.windows? || Helpers::Platform.windows_ansi?
|
148
|
+
`where /Q #{pager_executable}`
|
149
|
+
else
|
150
|
+
`which #{pager_executable}`
|
151
|
+
end
|
152
|
+
$?.success?
|
153
|
+
rescue
|
154
|
+
false
|
155
|
+
end
|
156
|
+
else
|
157
|
+
@system_pager
|
172
158
|
end
|
173
159
|
end
|
174
|
-
rescue Errno::EPIPE
|
175
|
-
raise StopPaging
|
176
|
-
end
|
177
160
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
@
|
161
|
+
def initialize(*)
|
162
|
+
super
|
163
|
+
@tracker = PageTracker.new(height, width)
|
164
|
+
@buffer = ""
|
165
|
+
@pager = nil
|
183
166
|
end
|
184
|
-
end
|
185
167
|
|
186
|
-
|
168
|
+
def write(str)
|
169
|
+
if invoked_pager?
|
170
|
+
write_to_pager str
|
171
|
+
else
|
172
|
+
@tracker.record str
|
173
|
+
@buffer << str
|
187
174
|
|
188
|
-
|
189
|
-
|
190
|
-
|
175
|
+
if @tracker.page?
|
176
|
+
write_to_pager @buffer
|
177
|
+
end
|
178
|
+
end
|
179
|
+
rescue Errno::EPIPE
|
180
|
+
raise StopPaging
|
181
|
+
end
|
191
182
|
|
192
|
-
|
193
|
-
|
194
|
-
|
183
|
+
def close
|
184
|
+
if invoked_pager?
|
185
|
+
pager.close
|
186
|
+
else
|
187
|
+
@out.puts @buffer
|
188
|
+
end
|
189
|
+
end
|
195
190
|
|
196
|
-
|
197
|
-
@pager ||= IO.popen(self.class.default_pager, 'w')
|
198
|
-
end
|
199
|
-
end
|
191
|
+
private
|
200
192
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
reset
|
193
|
+
def write_to_pager(text)
|
194
|
+
pager.write @out.decolorize_maybe(text)
|
195
|
+
end
|
196
|
+
|
197
|
+
def invoked_pager?
|
198
|
+
@pager
|
199
|
+
end
|
200
|
+
|
201
|
+
def pager
|
202
|
+
@pager ||= IO.popen(self.class.default_pager, 'w')
|
203
|
+
end
|
213
204
|
end
|
214
205
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
206
|
+
# `PageTracker` tracks output to determine whether it's likely to take
|
207
|
+
# up a whole page. This doesn't need to be super precise, but we can
|
208
|
+
# use it for `SimplePager` and to avoid invoking the system pager
|
209
|
+
# unnecessarily.
|
210
|
+
#
|
211
|
+
# One simplifying assumption is that we don't need `#page?` to return
|
212
|
+
# `true` on the basis of an incomplete line. Long lines should be
|
213
|
+
# counted as multiple lines, but we don't have to transition from
|
214
|
+
# `false` to `true` until we see a newline.
|
215
|
+
class PageTracker
|
216
|
+
def initialize(rows, cols)
|
217
|
+
@rows, @cols = rows, cols
|
218
|
+
reset
|
219
|
+
end
|
220
|
+
|
221
|
+
def record(str)
|
222
|
+
str.lines.each do |line|
|
223
|
+
if line.end_with? "\n"
|
224
|
+
@row += ((@col + line_length(line) - 1) / @cols) + 1
|
225
|
+
@col = 0
|
226
|
+
else
|
227
|
+
@col += line_length(line)
|
228
|
+
end
|
222
229
|
end
|
223
230
|
end
|
224
|
-
end
|
225
231
|
|
226
|
-
|
227
|
-
|
228
|
-
|
232
|
+
def page?
|
233
|
+
@row >= @rows
|
234
|
+
end
|
229
235
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
236
|
+
def reset
|
237
|
+
@row = 0
|
238
|
+
@col = 0
|
239
|
+
end
|
234
240
|
|
235
|
-
|
241
|
+
private
|
236
242
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
243
|
+
# Approximation of the printable length of a given line, without the
|
244
|
+
# newline and without ANSI color codes.
|
245
|
+
def line_length(line)
|
246
|
+
line.chomp.gsub(/\e\[[\d;]*m/, '').length
|
247
|
+
end
|
241
248
|
end
|
242
249
|
end
|
243
250
|
end
|
data/lib/pry/prompt.rb
CHANGED
@@ -27,10 +27,6 @@ class Pry
|
|
27
27
|
# 1-line #inspect output suitable for prompt
|
28
28
|
SAFE_CONTEXTS = [String, Numeric, Symbol, nil, true, false].freeze
|
29
29
|
|
30
|
-
# @deprecated Use {Pry::Prompt.add} instead.
|
31
|
-
MAP = {}
|
32
|
-
deprecate_constant(:MAP) if respond_to?(:deprecate_constant)
|
33
|
-
|
34
30
|
# A Hash that holds all prompts. The keys of the Hash are prompt
|
35
31
|
# names, the values are Hash instances of the format {:description, :value}.
|
36
32
|
@prompts = {}
|
@@ -45,7 +41,7 @@ class Pry
|
|
45
41
|
# @return [Hash{Symbol=>Object}]
|
46
42
|
# @since v0.12.0
|
47
43
|
def [](prompt_name)
|
48
|
-
|
44
|
+
@prompts[prompt_name.to_s]
|
49
45
|
end
|
50
46
|
|
51
47
|
# @return [Hash{Symbol=>Hash}] the duplicate of the internal prompts hash
|
@@ -94,11 +90,10 @@ class Pry
|
|
94
90
|
end
|
95
91
|
end
|
96
92
|
|
97
|
-
add
|
98
|
-
The default Pry prompt. Includes information about the current expression
|
99
|
-
number, evaluation context, and nesting level, plus a reminder that you're
|
100
|
-
using Pry.
|
101
|
-
DESC
|
93
|
+
add 'default',
|
94
|
+
"The default Pry prompt. Includes information about the current expression \n" \
|
95
|
+
"number, evaluation context, and nesting level, plus a reminder that you're \n" \
|
96
|
+
'using Pry.' do |context, nesting, _pry_, sep|
|
102
97
|
format(
|
103
98
|
"[%<in_count>s] %<name>s(%<context>s)%<nesting>s%<separator>s ",
|
104
99
|
in_count: _pry_.input_ring.count,
|
@@ -109,14 +104,20 @@ DESC
|
|
109
104
|
)
|
110
105
|
end
|
111
106
|
|
112
|
-
add(
|
107
|
+
add(
|
108
|
+
'simple',
|
109
|
+
"A simple `>>`.",
|
110
|
+
['>> ', ' | ']
|
111
|
+
) do |_, _, _, sep|
|
113
112
|
sep
|
114
113
|
end
|
115
114
|
|
116
|
-
add(
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
add(
|
116
|
+
'nav',
|
117
|
+
"A prompt that displays the binding stack as a path and includes information \n" \
|
118
|
+
"about #{Helpers::Text.bold('_in_')} and #{Helpers::Text.bold('_out_')}.",
|
119
|
+
%w[> *]
|
120
|
+
) do |_context, _nesting, _pry_, sep|
|
120
121
|
tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval('self')) }
|
121
122
|
format(
|
122
123
|
"[%<in_count>s] (%<name>s) %<tree>s: %<stack_size>s%<separator>s ",
|
@@ -128,9 +129,11 @@ DESC
|
|
128
129
|
)
|
129
130
|
end
|
130
131
|
|
131
|
-
add(
|
132
|
-
|
133
|
-
|
132
|
+
add(
|
133
|
+
'shell',
|
134
|
+
'A prompt that displays `$PWD` as you change it.',
|
135
|
+
%w[$ *]
|
136
|
+
) do |context, _nesting, _pry_, sep|
|
134
137
|
format(
|
135
138
|
"%<name>s %<context>s:%<pwd>s %<separator>s ",
|
136
139
|
name: prompt_name(_pry_.config.prompt_name),
|
@@ -140,6 +143,10 @@ DESC
|
|
140
143
|
)
|
141
144
|
end
|
142
145
|
|
143
|
-
add(
|
146
|
+
add(
|
147
|
+
'none',
|
148
|
+
'Wave goodbye to the Pry prompt.',
|
149
|
+
Array.new(2)
|
150
|
+
) { '' }
|
144
151
|
end
|
145
152
|
end
|
data/lib/pry/pry_instance.rb
CHANGED
@@ -87,36 +87,6 @@ class Pry
|
|
87
87
|
exec_hook(:when_started, target, options, self)
|
88
88
|
end
|
89
89
|
|
90
|
-
@input_array_warn = false
|
91
|
-
# @deprecated Use {#input_ring} instead.
|
92
|
-
def input_array
|
93
|
-
unless @input_array_warn
|
94
|
-
loc = caller_locations(1..1).first
|
95
|
-
warn(
|
96
|
-
"#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
|
97
|
-
"is deprecated. Use #{self.class}#input_ring instead"
|
98
|
-
)
|
99
|
-
@input_array_warn = true
|
100
|
-
end
|
101
|
-
|
102
|
-
@input_ring
|
103
|
-
end
|
104
|
-
|
105
|
-
@output_array_warn = false
|
106
|
-
# @deprecated Use {#output_ring} instead.
|
107
|
-
def output_array
|
108
|
-
unless @output_array_warn
|
109
|
-
loc = caller_locations(1..1).first
|
110
|
-
warn(
|
111
|
-
"#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \
|
112
|
-
"is deprecated. Use #{self.class}#output_ring instead"
|
113
|
-
)
|
114
|
-
@output_array_warn = true
|
115
|
-
end
|
116
|
-
|
117
|
-
@output_ring
|
118
|
-
end
|
119
|
-
|
120
90
|
# This is the prompt at the top of the prompt stack.
|
121
91
|
# @return [Array<Proc>] the current prompt
|
122
92
|
def prompt
|
data/lib/pry/repl_file_loader.rb
CHANGED
@@ -34,7 +34,7 @@ class Pry
|
|
34
34
|
# @param [Pry] _pry_ the Pry instance to make non-interactive.
|
35
35
|
def non_interactive_mode(_pry_, content)
|
36
36
|
_pry_.print = proc {}
|
37
|
-
_pry_.exception_handler = proc do |o,
|
37
|
+
_pry_.exception_handler = proc do |o, _e, _p_|
|
38
38
|
_p_.run_command "cat --ex"
|
39
39
|
o.puts "...exception encountered, going interactive!"
|
40
40
|
interactive_mode(_pry_)
|
data/lib/pry/slop.rb
CHANGED
@@ -224,7 +224,7 @@ class Pry::Slop
|
|
224
224
|
autocreate(items, index) if config[:autocreate]
|
225
225
|
process_item(items, index, &block) unless @trash.include?(index)
|
226
226
|
end
|
227
|
-
items.reject!.with_index { |
|
227
|
+
items.reject!.with_index { |_item, index| @trash.include?(index) }
|
228
228
|
|
229
229
|
missing_options = options.select { |opt| opt.required? && opt.count < 1 }
|
230
230
|
if missing_options.any?
|
data/lib/pry/slop/option.rb
CHANGED
@@ -45,7 +45,7 @@ class Pry::Slop
|
|
45
45
|
integer: proc { |v| value_to_integer(v) },
|
46
46
|
float: proc { |v| value_to_float(v) },
|
47
47
|
range: proc { |v| value_to_range(v) },
|
48
|
-
count: proc {
|
48
|
+
count: proc { @count }
|
49
49
|
}
|
50
50
|
|
51
51
|
if long && long.size > @slop.config[:longest_flag]
|
data/lib/pry/version.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
8
8
|
- Conrad Irwin
|
9
9
|
- Ryan Fitzgerald
|
10
10
|
- Kyrylo Silin
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-11-
|
14
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
+
name: coderay
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
18
19
|
requirements:
|
19
20
|
- - "~>"
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 1.1.0
|
22
|
-
name: coderay
|
23
|
-
prerelease: false
|
24
23
|
type: :runtime
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.1.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
+
name: method_source
|
31
32
|
requirement: !ruby/object:Gem::Requirement
|
32
33
|
requirements:
|
33
34
|
- - "~>"
|
34
35
|
- !ruby/object:Gem::Version
|
35
36
|
version: 0.9.0
|
36
|
-
name: method_source
|
37
|
-
prerelease: false
|
38
37
|
type: :runtime
|
38
|
+
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 0.9.0
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
|
+
name: spoon
|
45
46
|
requirement: !ruby/object:Gem::Requirement
|
46
47
|
requirements:
|
47
48
|
- - "~>"
|
48
49
|
- !ruby/object:Gem::Version
|
49
50
|
version: '0.0'
|
50
|
-
name: spoon
|
51
|
-
prerelease: false
|
52
51
|
type: :runtime
|
52
|
+
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
@@ -187,7 +187,6 @@ files:
|
|
187
187
|
- lib/pry/object_path.rb
|
188
188
|
- lib/pry/output.rb
|
189
189
|
- lib/pry/pager.rb
|
190
|
-
- lib/pry/platform.rb
|
191
190
|
- lib/pry/plugins.rb
|
192
191
|
- lib/pry/prompt.rb
|
193
192
|
- lib/pry/pry_class.rb
|
@@ -214,7 +213,7 @@ homepage: http://pryrepl.org
|
|
214
213
|
licenses:
|
215
214
|
- MIT
|
216
215
|
metadata: {}
|
217
|
-
post_install_message:
|
216
|
+
post_install_message:
|
218
217
|
rdoc_options: []
|
219
218
|
require_paths:
|
220
219
|
- lib
|
@@ -229,9 +228,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
228
|
- !ruby/object:Gem::Version
|
230
229
|
version: '0'
|
231
230
|
requirements: []
|
232
|
-
rubyforge_project:
|
233
|
-
rubygems_version: 2.
|
234
|
-
signing_key:
|
231
|
+
rubyforge_project:
|
232
|
+
rubygems_version: 2.6.13
|
233
|
+
signing_key:
|
235
234
|
specification_version: 4
|
236
235
|
summary: An IRB alternative and runtime developer console
|
237
236
|
test_files: []
|
data/lib/pry/platform.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
module Platform
|
3
|
-
extend self
|
4
|
-
|
5
|
-
#
|
6
|
-
# @return [Boolean]
|
7
|
-
# Returns true if Pry is running on Mac OSX.
|
8
|
-
#
|
9
|
-
# @note
|
10
|
-
# Queries RbConfig::CONFIG['host_os'] with a best guess.
|
11
|
-
#
|
12
|
-
def mac_osx?
|
13
|
-
!!(RbConfig::CONFIG['host_os'] =~ /\Adarwin/i)
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# @return [Boolean]
|
18
|
-
# Returns true if Pry is running on Linux.
|
19
|
-
#
|
20
|
-
# @note
|
21
|
-
# Queries RbConfig::CONFIG['host_os'] with a best guess.
|
22
|
-
#
|
23
|
-
def linux?
|
24
|
-
!!(RbConfig::CONFIG['host_os'] =~ /linux/i)
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# @return [Boolean]
|
29
|
-
# Returns true if Pry is running on Windows.
|
30
|
-
#
|
31
|
-
# @note
|
32
|
-
# Queries RbConfig::CONFIG['host_os'] with a best guess.
|
33
|
-
#
|
34
|
-
def windows?
|
35
|
-
!!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/)
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# @return [Boolean]
|
40
|
-
# Returns true when Pry is running on Windows with ANSI support.
|
41
|
-
#
|
42
|
-
def windows_ansi?
|
43
|
-
return false if not windows?
|
44
|
-
|
45
|
-
!!(defined?(Win32::Console) or ENV['ANSICON'] or mri_2?)
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# @return [Boolean]
|
50
|
-
# Returns true when Pry is being run from JRuby.
|
51
|
-
#
|
52
|
-
def jruby?
|
53
|
-
RbConfig::CONFIG['ruby_install_name'] == 'jruby'
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# @return [Boolean]
|
58
|
-
# Returns true when Pry is being run from JRuby in 1.9 mode.
|
59
|
-
#
|
60
|
-
def jruby_19?
|
61
|
-
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# @return [Boolean]
|
66
|
-
# Returns true when Pry is being run from MRI (CRuby).
|
67
|
-
#
|
68
|
-
def mri?
|
69
|
-
RbConfig::CONFIG['ruby_install_name'] == 'ruby'
|
70
|
-
end
|
71
|
-
|
72
|
-
#
|
73
|
-
# @return [Boolean]
|
74
|
-
# Returns true when Pry is being run from MRI v1.9+ (CRuby).
|
75
|
-
#
|
76
|
-
def mri_19?
|
77
|
-
!!(mri? and RUBY_VERSION =~ /\A1\.9/)
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# @return [Boolean]
|
82
|
-
# Returns true when Pry is being run from MRI v2+ (CRuby).
|
83
|
-
#
|
84
|
-
def mri_2?
|
85
|
-
!!(mri? and RUBY_VERSION =~ /\A2/)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Not supported on MRI 2.2 and lower.
|
90
|
-
deprecate_constant(:Platform) if respond_to?(:deprecate_constant)
|
91
|
-
end
|