popro 0.2.1 → 0.2.2

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: 28d2afab9d53f8fa8ebf80ec36ee2d0e1529d150a6ffd2993409ba845a3f4c79
4
- data.tar.gz: 858dbf273be5fe62af6f0c74fbcfe51fd34f6491b344381f40fab71a053c50a1
3
+ metadata.gz: a790befdf497a693172bb0faf40561c1d7fd6e287a3b5c379f7ddd9496f33509
4
+ data.tar.gz: a015de37abef0c5769a5d786182319fb891e874124daa5503a7feb9b411438fe
5
5
  SHA512:
6
- metadata.gz: 337b2b031a41c3ba78e438b906fac942b98eaacff1e0c489d01e4811b5f676760cc8e0b9f2d6fbab27c1ec344c5f42d6c677546ce7fb43d52a17f89d0d38ac98
7
- data.tar.gz: 5d3b42ff7fb6ee26873afc35217daeb43b9f431f05e251c59e3b112ab13f14481fc0f0d108d3f3cb53f3c458a531af5ca55c5821f058d5941949bc59a0eeae51
6
+ metadata.gz: 0a2b3c066fe0a666537e40a2d63b81442e463c4b421a29d67722ad364453695fe17ea247a66c8d2e695e389b1482b56788dc03efff8836821a63f61d0592a5dd
7
+ data.tar.gz: 87151aae4f7c3ac0650960e5fdf646d4a373742dec759e3872fb8ea3be96c5b64b585401e6b6897c57ed7c86ed23987f1d33f426ffafbabf8e50558348046d3f
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ 0.2.2 add gonna and each_gonna, add Callback Indicator
1
2
  0.2.1 add support for estimation and re-use of default indicator with added concatted formatters
2
3
  0.2.0 various fixes and added unit tests
3
4
  0.0.1 initial version
@@ -22,6 +22,10 @@ module Popro
22
22
  new(0, **options).each_will(obj, titler, total, &block).done
23
23
  end
24
24
 
25
+ def self.each_gonna(obj, titler, total = nil, **options, &block)
26
+ new(0, **options).each_gonna(obj, titler, total, &block).done
27
+ end
28
+
25
29
  def self.command_line(*_args)
26
30
  raise 'TODO: implement a `ps` style progress indicator for command line'
27
31
  end
@@ -62,8 +62,20 @@ module Popro
62
62
  self
63
63
  end
64
64
 
65
+ def gonna(title)
66
+ @indicator.call(@info, title)
67
+ self
68
+ end
69
+
70
+ def each_gonna(obj, titler, total = nil, &block)
71
+ _each(obj, total) do |*args|
72
+ gonna(titler.call(*args))
73
+ block.call(*args, progress: @info) if block_given?
74
+ end
75
+ end
76
+
65
77
  def will(title = nil, step = nil, &block)
66
- did "#{WILL_CHECK_MARKS[0]} #{title}", 0
78
+ gonna "#{WILL_CHECK_MARKS[0]} #{title}"
67
79
 
68
80
  return self unless block_given?
69
81
 
@@ -45,6 +45,21 @@ module Popro
45
45
  end
46
46
  end
47
47
 
48
+ class Callback
49
+ def initialize(finish = nil, &block)
50
+ @finish = finish
51
+ @callback = block
52
+ end
53
+
54
+ def call(*args)
55
+ @callback.call(*args)
56
+ end
57
+
58
+ def finish
59
+ @finish&.call
60
+ end
61
+ end
62
+
48
63
  def self.default_formatter(*extra_formatters)
49
64
  ::Popro::Formatter::RewriteLine.new(
50
65
  ::Popro::Formatter::Concat.new(
@@ -43,7 +43,7 @@ module Popro
43
43
 
44
44
  def register_aliases
45
45
  class << self
46
- %i[each each_will to_proc did will formatter start done].each do |method_name|
46
+ %i[each each_will each_gonna to_proc gonna will did formatter start done].each do |method_name|
47
47
  define_method method_name do |*args, &block|
48
48
  @context.public_send(method_name, *args, &block)
49
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - MikeSmithEU