infobar 0.0.0 → 0.0.1

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
  SHA1:
3
- metadata.gz: efa40cb4c4b4763c56296e96a24358e46cef3a73
4
- data.tar.gz: 3350e61f29a337276e17b84d1f3ee81eb91fc78f
3
+ metadata.gz: 2b394ca03e7b4a64c6c3aaa730c05727fc33bb4c
4
+ data.tar.gz: f0d57d7647a4c43decf21a3b001a14fa46fa321b
5
5
  SHA512:
6
- metadata.gz: '079be8e48a1234be9d2e018939cb34fba2b87b84ad1c55e78ccee3ee7c19c67d93dad11f31c1117e8a5151671bd1e8d5eb7965c3c5aeedd898c88b775f9d9b81'
7
- data.tar.gz: 00fc996234f4c637db4b1f0c79cd193e54eb49a3f6d2032f4bc8dd4b837753ba9619cf1aa4bfeab59f3c6e3c35c93fbed073bf6c8a1f281a0bc8909c1c403465
6
+ metadata.gz: 1b575a6725e49e44556b4866fb45985ca19790b51321d10cc5e0581df57f71ce8f55c7b4b598bd7dfd7f3d5cffd76558c5d5da46ac1d7d8cdfeff94644ff36a2
7
+ data.tar.gz: 1793197d1e8b73ae6a611824d946c634fcc3fb2abce3ccc422de02da00568009b5daec63b19088571f8a5202d3adc39af97a97e5898f1e8940dab1cf94f7ccb0
data/README.md CHANGED
@@ -21,7 +21,11 @@ Display progress of computations and additional information to the terminal.
21
21
 
22
22
  ## Changes
23
23
 
24
+ * 2017-02-08 Release 0.0.1
25
+ - Allow disabling of delegated output via infobar.show = false
26
+
24
27
  * 2017-02-08 Release 0.0.0
28
+ - Initial release
25
29
 
26
30
  ## Download
27
31
 
data/TODO.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  - add color gradients?
4
4
  - cumulative counters to summarize several progress bars
5
+ - categorize do progress and display accordingly
6
+ - add trend arrow to rate
5
7
  - more documentation, lol
6
8
 
7
9
  ## DONE
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/infobar.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: infobar 0.0.0 ruby lib
2
+ # stub: infobar 0.0.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "infobar".freeze
6
- s.version = "0.0.0"
6
+ s.version = "0.0.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
data/lib/infobar.rb CHANGED
@@ -38,17 +38,17 @@ class Infobar
38
38
 
39
39
  attr_accessor :label
40
40
 
41
- delegate :started?, to: :@counter
41
+ delegate :started?, to: :counter
42
42
 
43
- delegate :done?, to: :@counter
43
+ delegate :done?, to: :counter
44
44
 
45
- delegate :finished?, to: :@counter
45
+ delegate :finished?, to: :counter
46
46
 
47
- delegate :show?, to: :@display
47
+ delegate :show?, to: :display
48
48
 
49
- delegate :show=, to: :@display
49
+ delegate :show=, to: :display
50
50
 
51
- delegate :style=, to: :@display
51
+ delegate :style=, to: :display
52
52
 
53
53
  def call(
54
54
  total:,
@@ -62,13 +62,13 @@ class Infobar
62
62
  finish: nil
63
63
  )
64
64
  self.label = label
65
- @counter.reset(total: total, current: current)
65
+ counter.reset(total: total, current: current)
66
66
  @message = convert_to_message(message)
67
67
  show.nil? or self.show = show
68
68
  if update
69
69
  update(message: @message)
70
70
  else
71
- @display.reset
71
+ display.reset
72
72
  end
73
73
  frequency.nil? or display.frequency = frequency
74
74
  style.nil? or self.style = style
@@ -77,29 +77,29 @@ class Infobar
77
77
 
78
78
  def reset
79
79
  @message = convert_to_message('%l %c/%t in %te, ETA %e @%E %s')
80
- @counter.reset(total: 0, current: 0)
81
- @display.reset
80
+ counter.reset(total: 0, current: 0)
81
+ display.reset
82
82
  self
83
83
  end
84
84
 
85
85
  def update(message: nil)
86
86
  @message = convert_to_message(message)
87
- @display.update(message: @message, progressed: @counter.progressed)
87
+ display.update(message: @message, progressed: counter.progressed)
88
88
  self
89
89
  end
90
90
 
91
91
  def progress(by: 1, message: nil, finish: true, force: false)
92
- @counter.progress(by: by)
92
+ counter.progress(by: by)
93
93
  @message = convert_to_message(message)
94
- @display.update(message: @message, force: force, progressed: @counter.progressed)
95
- finish && @counter.done? and finish(message: finish)
94
+ display.update(message: @message, force: force, progressed: counter.progressed)
95
+ finish && counter.done? and finish(message: finish)
96
96
  self
97
97
  end
98
98
 
99
99
  def finish(message: nil)
100
- @counter.finish
100
+ counter.finish
101
101
  @message = convert_to_message(message)
102
- @display.update(message: @message, force: true, progressed: @counter.progressed)
102
+ display.update(message: @message, force: true, progressed: counter.progressed)
103
103
  self
104
104
  end
105
105
 
@@ -1,25 +1,29 @@
1
1
  module Infobar::InputOutput
2
2
  def newline
3
- @display.newline
3
+ display.newline
4
4
  self
5
5
  end
6
6
 
7
7
  def clear
8
- @display.clear
8
+ display.clear
9
9
  self
10
10
  end
11
11
 
12
12
  %i[ print printf putc puts ].each do |method|
13
13
  define_method(method) do |*a, &b|
14
- @display.clear
15
- @display.output.__send__(method, *a, &b)
14
+ display.clear
15
+ if display.output.respond_to?(method)
16
+ display.output.public_send(method, *a, &b)
17
+ end
16
18
  end
17
19
  end
18
20
 
19
21
  %i[ gets readline readlines ].each do |method|
20
22
  define_method(method) do |*a, &b|
21
- @display.clear
22
- @display.input.__send__(method, *a, &b)
23
+ display.clear
24
+ if display.input.respond_to?(method)
25
+ display.input.public_send(method, *a, &b)
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -1,6 +1,6 @@
1
1
  class Infobar
2
2
  # Infobar version
3
- VERSION = '0.0.0'
3
+ VERSION = '0.0.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -1,9 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Infobar::InputOutput do
4
+ io_double = -> {
5
+ Class.new do
6
+ def puts(*) end
7
+
8
+ def gets(*) end
9
+ end.new
10
+ }
11
+
4
12
  around do |example|
5
- infobar.display.output = Object.new
6
- infobar.display.input = Object.new
13
+ infobar.display.output = io_double.()
14
+ infobar.display.input = io_double.()
7
15
  example.run
8
16
  infobar.display.output = $stdout
9
17
  infobar.display.input = $stdin
@@ -31,4 +39,14 @@ describe Infobar::InputOutput do
31
39
  expect(infobar.display).to receive(:clear)
32
40
  infobar.clear
33
41
  end
42
+
43
+ it 'does not puts if not showing' do
44
+ begin
45
+ expect(infobar.display.output).not_to receive(:puts)
46
+ infobar.show = false
47
+ infobar.puts 'hello'
48
+ rescue
49
+ infobar.show = true
50
+ end
51
+ end
34
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infobar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank