pry-auto_benching.rb 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 753fe74a59e736a2a2dcd5c4bbcddb12c4ec9fccca50ff75ebe71c4945b8026d
4
- data.tar.gz: a9d4125ddb6433f9e10bc212eb9faecd7bb964fa3dfd6361a068da5ff9a2532e
3
+ metadata.gz: 044da9140719553bfd2237e1ad32811a163a0b2674c51b95549943e442712be3
4
+ data.tar.gz: 63ac4fbd7ceb70b976092d2f076b3b9993a46039e10242e6cd47683fe40ca7c5
5
5
  SHA512:
6
- metadata.gz: 935e069ba94dcc3ad60e8fa6b91a0578d77554357a9049557254d0df5a493ca13e54f0a17d82b099ab1ba450c92ba1f1f829f1f2317aa98b1990e97402a8890a
7
- data.tar.gz: 5d22c660869cea64666734740718ab0a8f98342b3a746cdbde0e89b125cce3af234b410751cb138cc6d89397289f39578db76abdbdeef3b969803a07e98f836d
6
+ metadata.gz: 9952b83e1eb104a6866814d534a8025e371002ea46e8b9e6f67ea03a8263baf29a62a290aea60a0a3982500664141fec65b2f01826e8ea802fe44a888baede9a
7
+ data.tar.gz: 8bdbe59fc8f36e04927f06977bdfc94b2570942ae3dedfa6126c7383872572f7a1c343928c6dc303e4d2473fdcfe23511f5375ffc91cfd935441ebc38dcac011
data/README.md CHANGED
@@ -5,7 +5,8 @@ pry-auto_benching.rb automatically benchmarks input entered into Pry.
5
5
  ## Configuration (optional)
6
6
 
7
7
  Configuration isn't required unless you want to change a default.
8
- To change a default, open up `~/.pryrc` and add something like:
8
+ To change a default, open `~/.pryrc` and add code along the lines
9
+ of:
9
10
 
10
11
  ```ruby
11
12
  Pry.configure do |config|
@@ -46,31 +47,52 @@ __1.__
46
47
 
47
48
  Show help by running `auto-benching -h`:
48
49
 
49
- ![s3](./s3.png)
50
+ [3] pry(main)> auto-benching -h-h
51
+ Usage: auto-benching [enable|disable]
52
+
53
+ Enable or disable benchmarking code and Pry commands.
54
+
55
+ -v, --version Display version.
56
+ -h, --help Show this message.
50
57
 
51
58
  __2.__
52
59
 
53
60
  Disable auto benchmarking by running `auto-benching disable`:
54
61
 
55
- ![s4](./s4.png)
62
+ [5] pry(main)> auto-benching disable
63
+ pry-auto_benching.rb: stopped benchmarking.
64
+ [6] pry(main)>
56
65
 
57
66
  __3.__
58
67
 
59
- A screenshot, using `:prompt` as the target_display.
60
- The prompt name (by default 'pry') is replaced with the benchmark results
61
- for the previous expression. This is the default target_display since it is subtle,
62
- yet easy to spot in a sea of output.
68
+ A screenshot, with `_pry_.config.auto_benching.target_display` set to `:prompt` (the default).
63
69
 
64
- ![s7](./s7.png)
70
+ [7] pry(main)> sleep 0.2
71
+ => 0
72
+ [8] 0.2s (main)> Net::HTTP.get_response URI.parse('https://github.com')
73
+ => #<Net::HTTPOK 200 OK readbody=true>
74
+ [9] 1.34s (main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
75
+ => #<Net::HTTPOK 200 OK readbody=true>
76
+ [10] 1.53s (main)>
65
77
 
66
78
  __4.__
67
79
 
68
- A screenshot, using `:output` as the target_display.
69
- To switch to using this display, run `_pry_.config.auto_benching.target_display = :output`
70
- inside the repl or set `Pry.config.auto_benching.target_display = :output` from your .pryrc
71
- for a permanent change.
80
+ A screenshot, with `_pry_.config.auto_benching.target_display` set to `:output`.
81
+ To switch to this display, run `_pry_.config.auto_benching.target_display = :output`
82
+ inside the repl or set `Pry.config.auto_benching.target_display = :output` from your
83
+ `.pryrc` for a permanent change.
72
84
 
73
- ![s2](./s2.png)
85
+ [6] pry(main)> _pry_.config.auto_benching.target_display = :output
86
+ => :output
87
+ [7] pry(main)> sleep 0.1
88
+ pry-auto_benching.rb: 0.10s
89
+ => 0
90
+ [8] pry(main)> Net::HTTP.get_response URI.parse('https://github.com')
91
+ pry-auto_benching.rb: 0.85s
92
+ => #<Net::HTTPOK 200 OK readbody=true>
93
+ [9] pry(main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
94
+ pry-auto_benching.rb: 0.31s
95
+ => #<Net::HTTPOK 200 OK readbody=true>
74
96
 
75
97
  ## Accuracy
76
98
 
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module AutoBenching
3
- VERSION = "2.5.0"
3
+ VERSION = "2.6.0"
4
4
  end
5
5
  end
@@ -4,6 +4,7 @@ module Pry::AutoBenching
4
4
  if auto_benching.target_display == :prompt
5
5
  pry.config.prompt_name = Pry.lazy { "#{Pry::Helpers::Text.send(auto_benching.prompt_color, duration.to_s + 's')} " }
6
6
  elsif auto_benching.target_display == :output
7
+ pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
7
8
  pry.pager.page auto_benching.output_string.call(pry, duration)
8
9
  else
9
10
  pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
@@ -27,13 +28,15 @@ module Pry::AutoBenching
27
28
  if auto_benching.benchmark_commands and
28
29
  auto_benching.display_duration_if.call(pry, duration)
29
30
  write_duration.call(pry, duration)
30
- elsif auto_benching.target_display != :output
31
+ elsif [:output, :prompt].include?(auto_benching.target_display) ||
32
+ auto_benching.target_display != :output
31
33
  pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
32
34
  end
33
35
  else # Ruby code
34
36
  if auto_benching.display_duration_if.call(pry, duration)
35
37
  write_duration.call(pry, duration)
36
- elsif auto_benching.target_display != :output
38
+ elsif [:output, :prompt].include?(auto_benching.target_display) ||
39
+ auto_benching.target_display != :output
37
40
  pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
38
41
  end
39
42
  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.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson