rego 4.2.0 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -7
  3. data/bin/rego +40 -21
  4. data/lib/rego/_lib.rb +4 -4
  5. data/rego.gemspec +4 -4
  6. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e704eca7b7db48e6d200a33befa0da637e5942cb1d1d3765130e1ec5f57be8d5
4
- data.tar.gz: 720ab9f7447d22e03099694269c6ae807e25132ee332b7ef6771cb2c8fa7ba80
3
+ metadata.gz: 5937ded18cabcdb05d4f5dbe275d259c7745d5c112056a72cbc97fc7484c2ef6
4
+ data.tar.gz: fe4409461089289456b7c6e1f9334424f76c0c27985698e0ec7e70f340d42ed2
5
5
  SHA512:
6
- metadata.gz: 8db96fac13956e14aadffc198c760d7767b6eae548c15eea15be554589709a4ea8f6a8b9953f778695319cb96b94a960becd2503d3d45be65552cc6a2eef7e0b
7
- data.tar.gz: 507f3755d8235fc4107380461a106bc44bb5d9be7d7062137486298fb4db74b9ffade5719bf44359e5945a72935766cf4572d04133312182249195e603606775
6
+ metadata.gz: c31ab16a824f9fa83c3adf05aee70ba6e138a6b5e3a50a8da7e0714fe9d04fb340653315926a4d0cf086725510a3dca142502c8874902da7a14f18d87d72e90c
7
+ data.tar.gz: 54302f9c2a46e7691d626cf83abac7eb7789e10457df67dd189bcc0c6cc6c07eb03b5b660a2817d504c28cc92de325624a1203cf7f3dbd653bfa082e59a86358
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  NAME
2
2
  ---------------
3
-
3
+
4
4
  rego
5
5
 
6
6
  SYNOPSIS
7
7
  ---------------
8
-
8
+
9
9
  rego ./files ./to ./watch -- command-to-run
10
10
 
11
11
  INSTALL
@@ -15,28 +15,28 @@ gem install rego
15
15
 
16
16
  DESCRIPTION
17
17
  ---------------
18
-
18
+
19
19
  run arbitrary commands easily when files change
20
20
 
21
21
  PARAMETERS
22
22
  ---------------
23
23
 
24
- --help, -h
24
+ --help, -h
25
25
 
26
26
  EXAMPLES
27
27
  ---------------
28
-
28
+
29
29
  ```bash
30
30
 
31
31
  # say hai whenever the file foo.txt changes
32
32
  #
33
33
  ~> rego foo.txt -- echo hai
34
34
 
35
- # say hai whenever any file (recursively) in bar changes
35
+ # say hai whenever any file (recursively) in bar changes
36
36
  #
37
37
  ~> rego ./bar/ -- echo hai
38
38
 
39
- # echo *the file that changed* when any file (recursively) in bar changes
39
+ # echo *the file that changed* when any file (recursively) in bar changes
40
40
  #
41
41
  ~> rego ./bar/ -- echo "@ was changed"
42
42
 
@@ -48,4 +48,8 @@ EXAMPLES
48
48
  #
49
49
  ~> rego ./test -- ruby -Itest @
50
50
 
51
+ # run a server, killing it gracefully whenever files change
52
+ #
53
+ ~> rego --killer -- ./dev/server
54
+
51
55
  ```
data/bin/rego CHANGED
@@ -40,6 +40,7 @@ Main do
40
40
  option('--command=command', '-c')
41
41
  option('--version', '-v')
42
42
  option('--killer', '-k')
43
+ option('--retry', '-r')
43
44
 
44
45
  def run
45
46
  if params[:version].given?
@@ -93,34 +94,50 @@ Main do
93
94
  def loop_watching_files_and_running_commands!
94
95
  @cmdno = '0'
95
96
  @killer = params[:killer].given?
97
+ @retry = params[:retry].given?
96
98
  @pid = nil
99
+ @killed = false
97
100
 
98
101
  rego =
99
102
  proc do
100
- puts
101
- Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> #{@pretty[:command]}", color: :yellow)
102
-
103
- @pid = Process.spawn(*@command)
104
- Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> pid=#{@pid}", color: :cyan)
105
- status = Process.wait(@pid)
106
- @pid = nil
107
-
108
- success = (@killer || (status==0))
109
-
110
- puts
111
- Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> #{status}", color: (success ? :green : :red))
103
+ loop do
104
+ puts
105
+ Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> #{@pretty[:command]}", color: :yellow)
106
+
107
+ @killed = false
108
+ @pid = Process.spawn(*@command)
109
+ Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> pid=#{@pid}", color: :cyan)
110
+ status = Process.wait(@pid)
111
+ @pid = nil
112
+
113
+ success = (@killer || (status==0))
114
+
115
+ puts
116
+ Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> #{status}", color: (success ? :green : :red))
117
+
118
+ @cmdno.succ!
119
+ puts
120
+
121
+ if @retry and not @killed
122
+ puts 'retrying...'
123
+ sleep(rand)
124
+ puts '...'
125
+ else
126
+ break
127
+ end
128
+ end
112
129
 
113
- @cmdno.succ!
114
- puts
130
+ status
115
131
  end
116
132
 
117
- listener = Listen.to(*@paths) do |_modified, _added, _removed|
118
- if @killer && @pid
119
- kill!(@pid)
120
- end
133
+ listener =
134
+ Listen.to(*@paths) do |_modified, _added, _removed|
135
+ if @killer && @pid
136
+ @killed = kill!(@pid)
137
+ end
121
138
 
122
- rego.call
123
- end
139
+ rego.call unless @retry
140
+ end
124
141
 
125
142
  begin
126
143
  listener.start
@@ -132,7 +149,7 @@ Main do
132
149
  end
133
150
 
134
151
  def kill!(pid)
135
- Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> kill=#{@pid}", color: :magenta)
152
+ Rego.say("#=> rego.#{@cmdno} @ #{Time.now.strftime('%H:%M:%S')} -> kill=#{@pid}", color: :magenta)
136
153
 
137
154
  3.times do
138
155
  %w[
@@ -153,6 +170,8 @@ Main do
153
170
  end
154
171
 
155
172
  abort("failed to kill pid=#{ pid }!") if alive?(pid)
173
+
174
+ pid
156
175
  end
157
176
 
158
177
  def alive?(pid)
data/lib/rego/_lib.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rego
2
- Version = '4.2.0' unless defined?(Version)
2
+ Version = '4.2.2' unless defined?(Version)
3
3
 
4
4
  def self.version
5
5
  Rego::Version
@@ -7,9 +7,9 @@ module Rego
7
7
 
8
8
  def self.dependencies
9
9
  {
10
- 'main' => ['main', ' ~> 6.3.0'],
11
- 'map' => ['map', ' ~> 6.6.0'],
12
- 'listen' => ['listen', ' ~> 3.9.0']
10
+ 'main' => ['main', ' ~> 6'],
11
+ 'map' => ['map', ' ~> 6'],
12
+ 'listen' => ['listen', ' ~> 3.9']
13
13
  }
14
14
  end
15
15
 
data/rego.gemspec CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "rego"
6
- spec.version = "4.2.0"
6
+ spec.version = "4.2.2"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "rego"
9
9
  spec.description = "description: rego kicks the ass"
@@ -18,11 +18,11 @@ Gem::Specification::new do |spec|
18
18
  spec.test_files = nil
19
19
 
20
20
 
21
- spec.add_dependency(*["main", " ~> 6.3.0"])
21
+ spec.add_dependency(*["main", " ~> 6"])
22
22
 
23
- spec.add_dependency(*["map", " ~> 6.6.0"])
23
+ spec.add_dependency(*["map", " ~> 6"])
24
24
 
25
- spec.add_dependency(*["listen", " ~> 3.9.0"])
25
+ spec.add_dependency(*["listen", " ~> 3.9"])
26
26
 
27
27
 
28
28
  spec.extensions.push(*[])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rego
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: main
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 6.3.0
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 6.3.0
26
+ version: '6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: map
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.6.0
33
+ version: '6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.6.0
40
+ version: '6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: listen
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.9.0
47
+ version: '3.9'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.9.0
54
+ version: '3.9'
55
55
  description: 'description: rego kicks the ass'
56
56
  email: ara.t.howard@gmail.com
57
57
  executables: