vete 0.6.5 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vete.rb +18 -13
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3b218ba1e2c6d9d7c66167c0f1e15b07a0dafeacfeacb2810f16636b50f4e42
4
- data.tar.gz: 0a62e8259399064a0f20d1679afccdaf935f0e518caa01ad102b543929a926e4
3
+ metadata.gz: 96b64fc68cb1332add0e65d46131d363ac1723c9b70f0f814382c29efeecb65f
4
+ data.tar.gz: 2601b593a3ca14b98576cde84de8dc40abd79cb3a6243784099ec8e4298baf7d
5
5
  SHA512:
6
- metadata.gz: 4e0ff4061b2e7e930bf9dd7195b957874368cd17b07bd7a2b650d9af5c4a3e087a1963d905186445bbf23ddf02d23f0f45815e152026046bdfbc9f443e5d67cf
7
- data.tar.gz: e6b58f1834bc6039c442f85356511a5d4769d080246ec6479ece58e8b39b89cbce9e5491b4f93bf25dc3b77e6391b50b4e329c1fd05aded977b36bdaed7e0b65
6
+ metadata.gz: fb245248250c901de9ca611e4aa424fb7376fae97a96a71f448879cda58852632c6d7f98437ec271431ffa23cb8fc66fbcd09254850192480e3fe8d16032c7f7
7
+ data.tar.gz: c9e88e46d546b8ea63ef92f71b2684db2c114e1303cac1380a7e43a574d3bd45fb79a01ba53f8909d1dbef8e893506b7f00dfc5be1f40549f5fd62ae01788faa
data/lib/vete.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # vete - Ruby CLI to spawn processes to get work done
3
3
  #
4
4
  # Author: Steve Shreeve (steve.shreeve@gmail.com)
5
- # Date: Mar 22, 2023
5
+ # Date: June 29, 2023
6
6
  # ============================================================================
7
7
 
8
8
  STDOUT.sync = true
@@ -19,7 +19,7 @@ trap("INT" ) { print clear + go; abort "\n" }
19
19
  trap("WINCH") { print clear or draw if @pid == Process.pid }
20
20
 
21
21
  OptionParser.new.instance_eval do
22
- @version = "0.6.5"
22
+ @version = "0.6.7"
23
23
  @banner = "usage: #{program_name} [options]"
24
24
 
25
25
  on "-b", "--bar <width>" , "Progress bar width, in characters", Integer
@@ -53,7 +53,6 @@ end
53
53
  # define job directories
54
54
  @vete = File.expand_path(".vete")
55
55
  @todo = File.join(@vete, "todo")
56
- @live = File.join(@vete, "live")
57
56
  @done = File.join(@vete, "done")
58
57
  @died = File.join(@vete, "died")
59
58
 
@@ -73,13 +72,13 @@ end
73
72
 
74
73
  def vete_init
75
74
  nuke
76
- list = [@todo, @live, @done, @died]
75
+ list = [@todo, @done, @died]
77
76
  list.each {|path| FileUtils.mkdir_p(path) }
78
77
  end
79
78
 
80
79
  def vete_retry
81
80
  list = Dir.glob(File.join(@died, "*")).sort.each {|path| FileUtils.touch(path) }
82
- move(list, @todo)
81
+ list.empty? ? false : !!move(list, @todo)
83
82
  end
84
83
 
85
84
  def vete_todo(path, data=nil)
@@ -96,13 +95,19 @@ def cursor(on) ; print on ? "\e[?25h": "\e[?25l"; end
96
95
  def go(r=1,c=1) ; "\e[#{r};#{c}H" ; end
97
96
  def go!(...) ; print go(...) ; end
98
97
 
99
- def fg(rgb=nil); rgb ? "\e[38;2;#{hx(rgb)}m" : "\e[39m"; end
100
- def bg(rgb=nil); rgb ? "\e[48;2;#{hx(rgb)}m" : "\e[49m"; end
101
- def hx(str=nil); str =~ /\A#?(?:(\h\h)(\h\h)(\h\h)|(\h)(\h)(\h))\z/ or return
102
- r, g, b = $1 ? [$1, $2, $3] : [$4*2, $5*2, $6*2]
103
- [r.hex, g.hex, b.hex] * ";"
98
+ @hex={}
99
+
100
+ def hex(str=nil)
101
+ @hex[str] ||= begin
102
+ str =~ /\A#?(?:(\h\h)(\h\h)(\h\h)|(\h)(\h)(\h))\z/ or return
103
+ r, g, b = $1 ? [$1, $2, $3] : [$4*2, $5*2, $6*2]
104
+ [r.hex, g.hex, b.hex] * ";"
105
+ end
104
106
  end
105
107
 
108
+ def fg(rgb=nil); rgb ? "\e[38;2;#{hex(rgb)}m" : "\e[39m"; end
109
+ def bg(rgb=nil); rgb ? "\e[48;2;#{hex(rgb)}m" : "\e[49m"; end
110
+
106
111
  def draw(live=0, done=0, died=0, jobs=0, info=nil)
107
112
 
108
113
  # outer box
@@ -122,7 +127,7 @@ def draw(live=0, done=0, died=0, jobs=0, info=nil)
122
127
  info.each do |slot, this|
123
128
  tpct = this.to_f / most
124
129
  cols = ppct * tpct * @wide
125
- print go(slot + 1, @len + 5) + bg("5383ec") + @char * cols
130
+ print go(slot + 1, @len + 5) + bg("5383ec") + @char * cols # fg("fff")
126
131
  end
127
132
 
128
133
  # summary bar
@@ -138,8 +143,8 @@ def draw(live=0, done=0, died=0, jobs=0, info=nil)
138
143
  bg("d85140") + " " * (@wide - gcol - ycol).ceil, # red (rest)
139
144
  go(@work + 3, @len + 5 + @wide + 3),
140
145
  bg("5383ec") + " %.1f%% " % [ppct * 100], # blue (done + died)
141
- done > 0 ? (bg + " " + bg("58a65c") + " #{done} done ") : nil,
142
- died > 0 ? (bg + " " + bg("d85140") + " #{died} died ") : nil,
146
+ done > 0 ? (bg + " " + bg("58a65c") + " #{done}/#{jobs} done ") : nil,
147
+ died > 0 ? (bg + " " + bg("d85140") + " #{died} died ") : nil,
143
148
  ].join
144
149
 
145
150
  # clear colors
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-06-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby CLI to spawn processes to get work done
14
14
  email: steve.shreeve@gmail.com
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubygems_version: 3.4.9
47
+ rubygems_version: 3.4.14
48
48
  signing_key:
49
49
  specification_version: 4
50
50
  summary: Ruby CLI to spawn processes to get work done