pry-auto_benching.rb 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 237980bf9d213d1a40df42c9fa3b78a7920ad90f6bf0e2115ea7fc27e47a1c7e
4
- data.tar.gz: 93206785da40f07e91cead03bd5c75fb90969e65ddce7131ed5f73525fe8c9f3
3
+ metadata.gz: '086d0b0371cbbff9c5cb93ac7ef4536fdf3bde5776dd44cd7cb6f0b404866b74'
4
+ data.tar.gz: 692d1991ab9d61b6c31a7c2fd26135b8fa03cc0a5902b46ef92da88125714ce1
5
5
  SHA512:
6
- metadata.gz: 5484e2012f9ebb124ae4954022f174fc537ead567a31fd71cc29ce04e2abff6b9b820c5992106434c5e7575be53dab5b6e17b58d0ecf0d6532a6901dab645060
7
- data.tar.gz: de3c42d2facb770932b0cbde3d588ef494135d035ae66cbee97329085041e195760394599d8b87a48311ba7ddb21d97189f2a54930d310a0f33b9d6fd4edb8cf
6
+ metadata.gz: 00d204f115402bd359a66ad6e005c3cb689010c5c9870bc1cdf917ed44888c9eca37c885ffadc0fb0698802bdce01b39f318462b86d6c5484abb7c905502abe8
7
+ data.tar.gz: f3f2a9461823ce515ce1bd1e3971ffc2d74d2889a4ac0c6daa8f4999b8d8c6df73c41ef87c2da67a27e0e4d7cb12f5f7fa060d604fddccd2918538f3323ffab0
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # CHANGELOG
2
+
3
+ ## v2.9.0
4
+
5
+ * Add '--target-display' option (shorthand: '-t') to the `auto-benching` command.
6
+ The option is for changing where benchmark results are written to.
7
+
8
+ * Accept 'output' and 'prompt' as valid values for `Pry.config.auto_benching.target_display`,
9
+ in addition to the already accepted values `:output` and `:prompt`.
data/README.md CHANGED
@@ -47,15 +47,15 @@ __1.__
47
47
 
48
48
  Show help by running `auto-benching -h`:
49
49
 
50
- [11] pry(main)> auto-benching -h
51
50
  Usage: auto-benching [options] [enable|disable]
52
51
 
53
52
  The auto-benching command can enable, disable, and
54
53
  provide other features related to pry-auto_benching.rb
55
54
 
56
- -v, --version Display version.
57
- -p, --past Display past benchmark results.
58
- -h, --help Show this message.
55
+ -v, --version Display version.
56
+ -p, --past Display past benchmark results.
57
+ -t, --target-display Choose the target display for results. Valid options are: stdout, prompt
58
+ -h, --help Show this message.
59
59
 
60
60
  __2.__
61
61
 
@@ -79,10 +79,10 @@ An example showing the prompt being updated with benchmark results.
79
79
 
80
80
  __4.__
81
81
 
82
- An example with `_pry_.config.auto_benching.target_display` set to `:output`.
82
+ An example with `:output` set as the `target_display`.
83
83
 
84
- [6] pry(main)> _pry_.config.auto_benching.target_display = :output
85
- => :output
84
+ [6] pry(main)> auto-benching --target-display output
85
+ Display changed to 'output'
86
86
  [7] pry(main)> sleep 0.1
87
87
  pry-auto_benching.rb: 0.10s
88
88
  => 0
@@ -95,7 +95,7 @@ An example with `_pry_.config.auto_benching.target_display` set to `:output`.
95
95
 
96
96
  __5.__
97
97
 
98
- Display benchmark results from the current Pry session using `auto-benching --past`:
98
+ Display a history of benchmark results for the current Pry session using `auto-benching --past`:
99
99
 
100
100
  [6] 0.5s (main)> auto-benching --past
101
101
  1. Net::HTTP.get_response URI.parse('https://github.com') (0.88s)
@@ -14,12 +14,18 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
14
14
  def options(o)
15
15
  o.on :v, :version, 'Display version.'
16
16
  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',
20
+ argument: :required
17
21
  end
18
22
 
19
23
  def process(command)
20
24
  case
21
25
  when opts.version?
22
26
  _pry_.output.puts "pry-auto_benching.rb v#{Pry::AutoBenching::VERSION}"
27
+ when opts.t?
28
+ change_target_display(opts[:t])
23
29
  when opts.past?
24
30
  process_past
25
31
  else
@@ -39,9 +45,9 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
39
45
  def process_past
40
46
  moments = Pry::AutoBenching.moments[_pry_.hash]
41
47
  if moments.empty?
42
- _pry_.pager.page "No benchmark results are currently stored for this session."
48
+ page "No benchmark results are currently stored for this session."
43
49
  else
44
- _pry_.pager.page moments.map.with_index { |moment, i|
50
+ page moments.map.with_index { |moment, i|
45
51
  format "%{index}. %{code} (%{duration})",
46
52
  index: blue(i + 1),
47
53
  code: moment.input.chomp,
@@ -49,4 +55,17 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
49
55
  }.join("\n")
50
56
  end
51
57
  end
58
+
59
+ def change_target_display(target_display)
60
+ if %w(prompt output).include?(target_display)
61
+ _pry_.config.auto_benching.target_display = target_display
62
+ page "Display changed to '#{target_display}'"
63
+ else
64
+ raise Pry::CommandError, "'#{target_display}' is an invalid option, valid options are: prompt, output."
65
+ end
66
+ end
67
+
68
+ def page(str)
69
+ _pry_.pager.page str
70
+ end
52
71
  }
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module AutoBenching
3
- VERSION = "2.8.0"
3
+ VERSION = "2.9.0"
4
4
  end
5
5
  end
@@ -49,9 +49,10 @@ module Pry::AutoBenching
49
49
 
50
50
  write_duration = -> (pry, duration) {
51
51
  auto_benching = pry.config.auto_benching
52
- if auto_benching.target_display == :prompt
52
+ target_display = auto_benching.target_display.to_s
53
+ if target_display == 'prompt'
53
54
  pry.config.prompt_name = "#{Pry::Helpers::Text.send(auto_benching.prompt_color, duration.to_s + 's')} "
54
- elsif auto_benching.target_display == :output
55
+ elsif target_display == 'output'
55
56
  pry.config.forget(:prompt_name)
56
57
  pry.pager.page auto_benching.output_string.call(pry, duration)
57
58
  else
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.8.0
4
+ version: 2.9.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-11-19 00:00:00.000000000 Z
11
+ date: 2018-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -30,6 +30,7 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - CHANGELOG.md
33
34
  - LICENSE.txt
34
35
  - README.md
35
36
  - lib/pry-auto_benching.rb