pause_output 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: e4bf4d23cd1bc4ad32ab0bf9ef6b16c55854a3ad
4
- data.tar.gz: 4a48dc6a1dd7c55f3e26452ec97d6b4b8044eed0
3
+ metadata.gz: f07a728fb17d8650be3191bc00a3dda19e48d9db
4
+ data.tar.gz: 2480a692ce205401748633a48b820ec5300e8494
5
5
  SHA512:
6
- metadata.gz: dfb1628b3399782cda367aa30b0c050e80f1b07b3769a21b0ef6834d0d652cdf2a1f8ce3945d49b66e2c6e984b7917e67981fa457a44b5862396a8dfe8e2d030
7
- data.tar.gz: 7a567d20923d3716f12baf13f13dfb37d2a1db6337689b0bfa65ef5e02315a52e07e71198a656c3f1c5e9313821d38222d1a6d48148c81c1003f8e02e20220dc
6
+ metadata.gz: 94d81e38f5bf8938d7094081b503d760b2b5964bd1397dec9f9759108671ceeda5503d9f1c5832da6f718a1658b13a32fb39f810a6c4efc019f21812b3d2d255
7
+ data.tar.gz: d234de7852054060c8529a1d001434aa2df161a4f0cc0e25c0cb9739111c1d31d9647c88b862a20c04dd6c4ad4bde1c4592404814228bf251cd39fcca077c9b7
data/README.md CHANGED
@@ -50,14 +50,19 @@ Option | Values | Default | Description
50
50
  :page_pause | boolean | true | Is page pause enabled?
51
51
  :page_height| integer | console height| The height of the page.
52
52
  :page_width | integer | console width | The width of the page.
53
- :page_msg | string | "Press enter, space or q:" | The paused prompt message.
53
+ :page_msg | string | "Press space (line), n (no pause), q(uit) or other (page):" | The paused prompt message.
54
+ :one_line | string | " " | The key to progress by one line.
55
+ :skip_all | string | "q" | The key to skip the rest of the output.
56
+ :no_pause | string | "n" | The key to display the rest with no pauses.
54
57
 
55
58
  The default value is used if the option is absent from the hash. Unsupported
56
59
  option values are ignored and have no effect.
57
60
 
58
61
  Notes:
62
+
59
63
  * Setting page_pause to false can allow a block of code to run without pausing
60
- at page breaks, if that is desired.
64
+ at page breaks, if that is desired. Since, Ruby has no boolean type, this can
65
+ be any object. The values false, "false", "off", or "no" will disable pauses.
61
66
  * If the :page_height and :page_width values are not valid, the default values
62
67
  will be used instead.
63
68
  * Nesting of "more" blocks is allowed. However, only the options of the outermost
@@ -10,10 +10,10 @@ class Object
10
10
  saved = $stdout
11
11
  outer = $stdout.equal?($pause_output_out)
12
12
 
13
- disabled = options[:page_pause]
14
- disabled = disabled.downcase if disabled.is_a?(String)
13
+ enabled = options[:page_pause]
14
+ enabled = enabled.downcase if enabled.is_a?(String)
15
15
 
16
- unless [false, 'false', 'off', 'no'].include?(disabled)
16
+ unless [false, 'false', 'off', 'no'].include?(enabled)
17
17
  $stdout = ::PauseOutput::OutputPager.new(options) if outer
18
18
  end
19
19
 
@@ -62,11 +62,13 @@ module PauseOutput
62
62
 
63
63
  if @lines >= (lines_per_page - 1)
64
64
  case pause.downcase
65
- when " "
65
+ when one_line
66
66
  @lines -= 1
67
- when "q"
67
+ when skip_all
68
68
  @lines = 0
69
69
  raise PauseOutputStop
70
+ when no_pause
71
+ @lines = -1_000_000
70
72
  else
71
73
  @lines = 0
72
74
  end
@@ -104,7 +106,23 @@ module PauseOutput
104
106
 
105
107
  # Get the text of the pause message.
106
108
  def pause_message
107
- @options.key?(:page_msg) ? @options[:page_msg] : "Press enter, space or q:"
109
+ @options.key?(:page_msg) ? @options[:page_msg] :
110
+ "Press space (line), n (no pause), q(uit) or other (page):"
111
+ end
112
+
113
+ # Keystroke to advance one line.
114
+ def one_line
115
+ @options.key?(:one_line) ? @options[:one_line] : " "
116
+ end
117
+
118
+ # Keystroke to quit processing.
119
+ def skip_all
120
+ @options.key?(:skip_all) ? @options[:skip_all] : "q"
121
+ end
122
+
123
+ # Keystroke to disable pauses.
124
+ def no_pause
125
+ @options.key?(:no_pause) ? @options[:no_pause] : "n"
108
126
  end
109
127
 
110
128
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Pause console output so that it can be read before scrolling off the screen.
4
4
  module PauseOutput
5
- VERSION = "0.1.2".freeze
5
+ VERSION = "0.2.0".freeze
6
6
 
7
7
  DESCRIPTION = "pause_output: A simple facility to pause output on the console terminal.".freeze
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pause_output
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PeterCamilleri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-05 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler