pry-auto_benching.rb 2.10.5 → 3.0.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: e7b0dc93c3c15661860a761a020191729d6e8f13df4d1c731b61fd1cdfc16fc0
4
- data.tar.gz: 1b9f167f1539ef38333f5b8eaeb4f9917669f194cf1269032184349f785ae362
3
+ metadata.gz: c018cd4eeb0e2b222b7c8ecee196e667d1189a4e22700ff60c2f73e831550fcd
4
+ data.tar.gz: bac2c715f28098373093d0c358dc5ed1cea4113a73bbb6ce2468d0742310bf8f
5
5
  SHA512:
6
- metadata.gz: ce5c18e18229ae2869e626aa8fc4365aee3e191a3ca7c83a4491ef9fa0d4c12a714ba43b1dfc6082b5f4f5e231cc420ec915e4b890f0e0a84bd91e81ac79f322
7
- data.tar.gz: 43bc389c8483039f6272b9835d8cc6ad8a388682440fd2bc6ac9f33247febcdbb9120d8e70ae9b74ac48b224172dabef0e9e93b4445a0d191f4420876fd45bf7
6
+ metadata.gz: aeedf31e5c738006c01766b53dffabeec79cfb5e1723f1db2217337081b4006f7fbf622272db1b8df69382bcc908ead3a260c580bbb46fff9667193ab5eb2293
7
+ data.tar.gz: 58629e77f790a806a60b4febb8bf1f34627f618a5a9770a360a3507a63ee79669b2dc5e6650a02d28623c9012b20d3a31ff76b080814a09d8b37de20bcb3957e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v3.0.0
4
+
5
+ * Remove `:output` as a target display, and the related code that supported
6
+ `:output` as a target display.
7
+
3
8
  ## v2.10.5
4
9
 
5
10
  * Doc updates
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright 2017
3
+ Copyright 2019
4
4
  Robert Gleeson
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
data/README.md CHANGED
@@ -9,18 +9,18 @@
9
9
 
10
10
  ## <a id='introduction'>Introduction</a>
11
11
 
12
- pry-auto_benching.rb automates benchmarking inside the Pry REPL.
12
+ Automatic benchmarking inside the Pry REPL.
13
13
 
14
14
  ## <a id='configuration'>Configuration (optional)</a>
15
15
 
16
- Configuration can be skipped unless you want to change the defaults. <br>
16
+ Configuration can be skipped unless you want to change the defaults.
17
17
  To change the defaults, open `~/.pryrc` in your editor of choice and change
18
18
  one or more of the following:
19
19
 
20
20
  ```ruby
21
21
  Pry.configure do |config|
22
22
  #
23
- # Start benchmarking as soon as Pry starts?
23
+ # Start benchmarking when Pry starts?
24
24
  # The default is true.
25
25
  #
26
26
  config.auto_benching.enabled = false
@@ -44,14 +44,11 @@ Pry.configure do |config|
44
44
  # * prompt
45
45
  # The default, results are written to the prompt.
46
46
  #
47
- # * output
48
- # Results are written directly to `_pry_.output`
49
- #
50
47
  # * none
51
48
  # Results are not displayed but are still recorded and can be
52
49
  # viewed on demand by running 'auto-benching --past'.
53
50
  #
54
- config.auto_benching.target_display = ':prompt | :output | :none'
51
+ config.auto_benching.target_display = ':prompt | :none'
55
52
 
56
53
  #
57
54
  # Define a Proc that decides whether or not to record or display benchmark
@@ -64,15 +61,6 @@ Pry.configure do |config|
64
61
  # The default is :green.
65
62
  #
66
63
  config.auto_benching.prompt_color = :red
67
-
68
- #
69
- # A lambda that returns a string for display on `_pry_.output` (usually $stdout).
70
- # This lambda is used when `target_display` is equal to `:output`.
71
- # Default is: "pry-auto_benching.rb: %.2fs".
72
- #
73
- config.auto_benching.output_string = ->(pry, duration) {
74
- sprintf("elapsed time: %.2fs", duration)
75
- }
76
64
  end
77
65
  ```
78
66
 
@@ -82,6 +70,7 @@ __1.__
82
70
 
83
71
  Get started by reading the help menu:
84
72
 
73
+ [1] pry(main)> auto-benching -h
85
74
  Usage: auto-benching [options] [enable|disable]
86
75
 
87
76
  The auto-benching command can enable, disable, and
@@ -89,57 +78,40 @@ Get started by reading the help menu:
89
78
 
90
79
  -v, --version Display version.
91
80
  -p, --past Display past benchmark results.
92
- -t, --target-display Choose the target display for results. Valid options are: stdout, prompt, none
81
+ -t, --target-display Choose the target display for results. Valid options are: prompt, none
93
82
  -h, --help Show this message.
94
83
 
95
84
  __2.__
96
85
 
97
- In this example, the prompt is updated with benchmark results.
98
- This also happens to be the default behavior.
86
+ The prompt is updated with benchmark results, this happens to be the default:
99
87
 
100
- [7] pry(main)> sleep 0.2
101
- => 0
102
- [8] 0.2s (main)> Net::HTTP.get_response URI.parse('https://github.com')
103
- => #<Net::HTTPOK 200 OK readbody=true>
104
- [9] 1.34s (main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
105
- => #<Net::HTTPOK 200 OK readbody=true>
106
- [10] 1.53s (main)>
88
+ [1] pry(main)> sleep 0.2
89
+ => 0
90
+ [2] 0.2s (main)> Net::HTTP.get_response URI.parse('https://github.com')
91
+ => #<Net::HTTPOK 200 OK readbody=true>
92
+ [3] 1.34s (main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
93
+ => #<Net::HTTPOK 200 OK readbody=true>
94
+ [4] 1.53s (main)>
107
95
 
108
96
  __3.__
109
97
 
110
- In this example, `_pry_.output` is updated with benchmark results.
98
+ `auto-benching --past` shows past benchmark results:
111
99
 
112
- [6] pry(main)> auto-benching --target-display output
113
- Display changed to 'output'
114
- [7] pry(main)> sleep 0.1
115
- pry-auto_benching.rb: 0.10s
116
- => 0
117
- [8] pry(main)> Net::HTTP.get_response URI.parse('https://github.com')
118
- pry-auto_benching.rb: 0.85s
119
- => #<Net::HTTPOK 200 OK readbody=true>
120
- [9] pry(main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
121
- pry-auto_benching.rb: 0.31s
122
- => #<Net::HTTPOK 200 OK readbody=true>
123
-
124
- __4.__
125
-
126
- In this example, `auto-benching --past` is used to view past benchmark
127
- results.
128
-
129
- [6] 0.5s (main)> auto-benching --past
100
+ [1] 0.5s (main)> auto-benching --past
130
101
  1. Net::HTTP.get_response URI.parse('https://github.com') (0.88s)
131
102
  2. Net::HTTP.get_response URI.parse('https://www.youtube.com') (2.18s)
132
103
  3. Net::HTTP.get_response URI.parse('https://www.github.com/ruby/ruby') (0.59s)
133
104
  4. sleep 0.5 (0.5s)
134
- [7] pry(main)>
105
+ [2] pry(main)>
135
106
 
136
- __5.__
107
+ __4.__
137
108
 
138
- In this example, benchmarking is disabled for the current Pry session:
109
+ Benchmarking can be temporarily disabled then enabled again:
139
110
 
140
- [5] pry(main)> auto-benching disable
111
+ [1] pry(main)> auto-benching disable
141
112
  pry-auto_benching.rb: stopped benchmarking.
142
- [6] pry(main)>
113
+ [2] pry(main)> auto-benching enable
114
+ pry-auto_benching.rb: started benchmarking.
143
115
 
144
116
  ## <a id='accuracy'>Accuracy</a>
145
117
 
@@ -1,5 +1,13 @@
1
- require 'pry' if not defined?(Pry::ClassCommand)
2
- Pry::Commands.add_command Class.new(Pry::ClassCommand) {
1
+ class Pry::AutoBenching::PryCommand < Pry::ClassCommand
2
+ extend Pry::Helpers::Text
3
+ VALID_TARGET_DISPLAYS = %w[prompt none]
4
+ VERSION_STRING = <<-VERSION.each_line.map(&:strip).join("\n")
5
+ #{bold('pry-auto_benching.rb')} #{bold("v#{Pry::AutoBenching::VERSION}")}
6
+ --
7
+ If you found a bug, have a suggestion or an improvement to make please open an
8
+ issue / pull request at https://github.com/r-obert/pry-auto_benching.rb
9
+ VERSION
10
+
3
11
  match 'auto-benching'
4
12
  command_options argument_required: true
5
13
  group 'pry-auto_benching.rb'
@@ -14,24 +22,19 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
14
22
  def options(o)
15
23
  o.on :v, :version, 'Display version.'
16
24
  o.on :p, :past, 'Display past benchmark results.'
17
- o.on :t,
18
- :'target-display',
19
- 'Choose the target display for results. Valid options are: stdout, prompt, none',
20
- argument: :required
25
+ o.on :t=,
26
+ :'target-display=',
27
+ 'Choose the target display for results. Valid options are: ' +
28
+ VALID_TARGET_DISPLAYS.join(', ')
21
29
  end
22
30
 
23
31
  def process(command)
24
32
  case
25
33
  when opts.version?
26
- page <<-VERSION
27
- #{bold('pry-auto_benching.rb')} #{bold("v#{Pry::AutoBenching::VERSION}")}
28
- --
29
- If you found a bug, have a suggestion or an improvement to make please open an
30
- issue / pull request at https://github.com/r-obert/pry-auto_benching.rb
31
- VERSION
32
- when opts.t?
33
- change_target_display(opts[:t])
34
- when opts.past?
34
+ page(VERSION_STRING)
35
+ when opts.present?('target-display')
36
+ change_target_display(opts[:'target-display'])
37
+ when opts.present?('past')
35
38
  process_past
36
39
  else
37
40
  if command == 'enable'
@@ -41,16 +44,18 @@ VERSION
41
44
  Pry::AutoBenching.disable(_pry_)
42
45
  page('pry-auto_benching.rb: stopped benchmarking.')
43
46
  else
44
- raise Pry::CommandError, "'#{command}' is not implemented by this command, try -h for help."
47
+ raise Pry::CommandError,
48
+ "'#{command}' is not implemented by this command, add -h for help."
45
49
  end
46
50
  end
47
51
  end
48
52
 
49
53
  private
54
+
50
55
  def process_past
51
56
  moments = Pry::AutoBenching.moments[_pry_.hash]
52
57
  if moments.empty?
53
- page "No benchmark results are currently stored for this session."
58
+ page "No benchmark results are stored for this session."
54
59
  else
55
60
  page moments.map.with_index { |moment, i|
56
61
  format "%{index}. %{code} (%{duration})",
@@ -62,15 +67,18 @@ VERSION
62
67
  end
63
68
 
64
69
  def change_target_display(target_display)
65
- if %w[prompt output none].include?(target_display)
70
+ if VALID_TARGET_DISPLAYS.include?(target_display)
66
71
  _pry_.config.auto_benching.target_display = target_display
67
72
  page "Display changed to '#{target_display}'"
68
73
  else
69
- raise Pry::CommandError, "'#{target_display}' is an invalid option, valid options are: prompt, output."
74
+ raise Pry::CommandError, "'#{target_display}' is an invalid, " \
75
+ "valid options are: #{VALID_TARGET_DISPLAYS.join(', ')}"
70
76
  end
71
77
  end
72
78
 
73
79
  def page(str)
74
80
  _pry_.pager.page str
75
81
  end
76
- }
82
+
83
+ Pry.commands.add_command(self)
84
+ end
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module AutoBenching
3
- VERSION = "2.10.5"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  module Pry::AutoBenching
2
+ require 'pry'
2
3
  require 'pry-auto_benching/version'
3
4
  require 'pry-auto_benching/pry_command'
4
5
 
@@ -58,8 +59,6 @@ module Pry::AutoBenching
58
59
  pry.config.forget(:prompt_name)
59
60
  if target_display == 'prompt'
60
61
  pry.config.prompt_name = "#{Pry::Helpers::Text.send(auto_benching.prompt_color, duration.to_s + 's')} "
61
- elsif target_display == 'output'
62
- pry.pager.page auto_benching.output_string.call(pry, duration)
63
62
  elsif target_display == 'none'
64
63
  # no op
65
64
  else
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  spec.version = Pry::AutoBenching::VERSION
5
5
  spec.authors = ["Robert Gleeson"]
6
6
  spec.email = "trebor.g@protonmail.com"
7
- spec.summary = "Automates benchmarking inside the Pry REPL"
7
+ spec.summary = "Automatic benchmarking inside the Pry REPL"
8
8
  spec.description = spec.summary
9
9
  spec.homepage = "https://github.com/r-obert/pry-auto_benching.rb"
10
10
  spec.licenses = ["MIT"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-auto_benching.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-25 00:00:00.000000000 Z
11
+ date: 2019-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.12'
27
- description: Automates benchmarking inside the Pry REPL
27
+ description: Automatic benchmarking inside the Pry REPL
28
28
  email: trebor.g@protonmail.com
29
29
  executables: []
30
30
  extensions: []
@@ -57,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project:
60
- rubygems_version: 2.7.7
60
+ rubygems_version: 2.7.8
61
61
  signing_key:
62
62
  specification_version: 4
63
- summary: Automates benchmarking inside the Pry REPL
63
+ summary: Automatic benchmarking inside the Pry REPL
64
64
  test_files: []