pry-auto_benching.rb 2.6.4 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pry-auto_benching/pry_command.rb +31 -0
- data/lib/pry-auto_benching/version.rb +1 -1
- data/lib/pry-auto_benching.rb +7 -46
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ebc6bc90dcaae0756aca8ffe6156a7a51080df77d30c8b8df0d8a36eccb4a64
|
4
|
+
data.tar.gz: 88886722771cff694fa7c1703567a3833b6b0e7ebb89ecd9424881bfdb913157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c672e7e8572c7f1380ee5dc20cf97b15de73fea7ac4c5739a24c7a92108b5b98c91fcae715bc1ade13cdc41c181e70f93efdec699b094d907ee1c50e2ec61321
|
7
|
+
data.tar.gz: 8154a6a1bf2d71c172839b953b9edce185602dc56806b7587717f15a9460cfdf57c82c723f613826d1b42efdfa7203a645865c37c4fea8f41bbdd155179d7cfb
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pry' if not defined?(Pry::ClassCommand)
|
2
|
+
Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
3
|
+
match 'auto-benching'
|
4
|
+
command_options argument_required: true
|
5
|
+
group 'pry-auto_benching.rb'
|
6
|
+
description 'Enable or disable benchmarking.'
|
7
|
+
banner <<-CMDBANNER
|
8
|
+
Usage: auto-benching [enable|disable]
|
9
|
+
|
10
|
+
Enable or disable benchmarking code and Pry commands.
|
11
|
+
CMDBANNER
|
12
|
+
|
13
|
+
def options(o)
|
14
|
+
o.on :v, :version, 'Display version.'
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(command)
|
18
|
+
if opts.v?
|
19
|
+
return _pry_.output.puts "pry-auto_benching.rb v#{Pry::AutoBenching::VERSION}"
|
20
|
+
end
|
21
|
+
if command == 'enable'
|
22
|
+
Pry::AutoBenching.enable(_pry_)
|
23
|
+
_pry_.pager.page('pry-auto_benching.rb: benchmarking.')
|
24
|
+
elsif command == 'disable'
|
25
|
+
Pry::AutoBenching.disable(_pry_)
|
26
|
+
_pry_.pager.page('pry-auto_benching.rb: stopped benchmarking.')
|
27
|
+
else
|
28
|
+
raise Pry::CommandError, "'#{command}' is not implemented by this command, try -h for help."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
}
|
data/lib/pry-auto_benching.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Pry::AutoBenching
|
2
|
+
require 'pry-auto_benching/pry_command'
|
3
|
+
|
2
4
|
write_duration = -> (pry, duration) {
|
3
5
|
auto_benching = pry.config.auto_benching
|
4
6
|
if auto_benching.target_display == :prompt
|
@@ -24,19 +26,10 @@ module Pry::AutoBenching
|
|
24
26
|
AFTER_EVAL = ->(input, pry) do
|
25
27
|
auto_benching = pry.config.auto_benching
|
26
28
|
duration = (sprintf "%.2f", Process.clock_gettime(auto_benching.clock_type) - MEMORY[pry.hash].pop).to_f
|
27
|
-
if input
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
else
|
32
|
-
pry.config.forget(:prompt_name)
|
33
|
-
end
|
34
|
-
else # Ruby code
|
35
|
-
if auto_benching.display_duration_if.call(pry, duration)
|
36
|
-
write_duration.call(pry, duration)
|
37
|
-
else
|
38
|
-
pry.config.forget(:prompt_name)
|
39
|
-
end
|
29
|
+
if (input != nil or auto_benching.benchmark_commands) and auto_benching.display_duration_if.call(pry, duration)
|
30
|
+
write_duration.call(pry, duration)
|
31
|
+
else
|
32
|
+
pry.config.forget(:prompt_name)
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
@@ -64,38 +57,6 @@ module Pry::AutoBenching
|
|
64
57
|
end
|
65
58
|
end
|
66
59
|
|
67
|
-
require 'pry' if not defined?(Pry::ClassCommand)
|
68
|
-
Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
69
|
-
match 'auto-benching'
|
70
|
-
command_options argument_required: true
|
71
|
-
group 'pry-auto_benching.rb'
|
72
|
-
description 'Enable or disable benchmarking.'
|
73
|
-
banner <<-CMDBANNER
|
74
|
-
Usage: auto-benching [enable|disable]
|
75
|
-
|
76
|
-
Enable or disable benchmarking code and Pry commands.
|
77
|
-
CMDBANNER
|
78
|
-
|
79
|
-
def options(o)
|
80
|
-
o.on :v, :version, 'Display version.'
|
81
|
-
end
|
82
|
-
|
83
|
-
def process(command)
|
84
|
-
if opts.v?
|
85
|
-
return _pry_.output.puts "pry-auto_benching.rb v#{Pry::AutoBenching::VERSION}"
|
86
|
-
end
|
87
|
-
if command == 'enable'
|
88
|
-
Pry::AutoBenching.enable(_pry_)
|
89
|
-
_pry_.pager.page('pry-auto_benching.rb: benchmarking.')
|
90
|
-
elsif command == 'disable'
|
91
|
-
Pry::AutoBenching.disable(_pry_)
|
92
|
-
_pry_.pager.page('pry-auto_benching.rb: stopped benchmarking.')
|
93
|
-
else
|
94
|
-
raise Pry::CommandError, "'#{command}' is not implemented by this command, try -h for help."
|
95
|
-
end
|
96
|
-
end
|
97
|
-
}
|
98
|
-
|
99
60
|
Pry.configure do |config|
|
100
61
|
config.hooks.add_hook :before_session, Pry::AutoBenching::BEFORE_SESSION.hash,
|
101
62
|
Pry::AutoBenching::BEFORE_SESSION
|
@@ -114,5 +75,5 @@ Pry.configure do |config|
|
|
114
75
|
:Duration => sprintf("%.2f", duration)
|
115
76
|
})
|
116
77
|
}
|
117
|
-
}
|
78
|
+
})
|
118
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-auto_benching.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gleeson
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- LICENSE.txt
|
34
34
|
- README.md
|
35
35
|
- lib/pry-auto_benching.rb
|
36
|
+
- lib/pry-auto_benching/pry_command.rb
|
36
37
|
- lib/pry-auto_benching/version.rb
|
37
38
|
- pry-auto_benching.gemspec
|
38
39
|
homepage: https://github.com/r-obert/pry-auto_benching.rb
|