runfile 0.12.0.pre.rc1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/runfile/compatibility.rb +84 -0
- data/lib/runfile/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79a1c61423d09207b687d93f98035c5ca6b5e9d36f7b4acc12d93ccaa817c873
|
4
|
+
data.tar.gz: 0d870a0f93a9add25113e8030a02ce99dd2ecb0ed8f42d5eddb69b520b998da0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 387383e744bac9dbd8ab89598df2a3217a4fa58f120b60ab7c31bbbfec074ae3fee0512cdee002b740af3aa85a6cd930ddfeefbe1d14deec182ebf77d57c8ab6
|
7
|
+
data.tar.gz: ca1b2962b157454842a0050cd3bf70826509362e7b18b9ebd2c1cc863480b0ac7f7556ad9e4fed27bad22b9c11238cf6b063e57e8b1d0459607fdb791c4ea1ae
|
data/README.md
CHANGED
@@ -84,6 +84,19 @@ Options:
|
|
84
84
|
- [User Guide](https://runfile.dannyb.co/)
|
85
85
|
- [Learn by Example](https://github.com/DannyBen/runfile/tree/master/examples#readme)
|
86
86
|
|
87
|
+
## Breaking changes in 0.12.0
|
88
|
+
|
89
|
+
Note that version 0.12.0 removes several commands from the DSL.
|
90
|
+
If you were using any of the Colsole commands (`say`, `resay`, etc.), or any of
|
91
|
+
the `run`, `run_bg` commands, you will have to adjust your Runfile since they are
|
92
|
+
no longer available.
|
93
|
+
|
94
|
+
For convenience, you can simply `require runfile/compatibility` at the top of
|
95
|
+
your Runfile, to still have this functionality included.
|
96
|
+
|
97
|
+
More info and alternative solutions in
|
98
|
+
[this pull request](https://github.com/DannyBen/runfile/pull/46).
|
99
|
+
|
87
100
|
## Contributing / Support
|
88
101
|
|
89
102
|
If you experience any issue, have a question or a suggestion, or if you wish
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# This file provides a compatibility layer for version 0.12.0 so that
|
2
|
+
# all the Colsole methods (say, resay...) and ExecHandler methods
|
3
|
+
# (run, run_bg...) are still available
|
4
|
+
# Simply require 'runfile/compatibility' to have the same functionality
|
5
|
+
# as older versions.
|
6
|
+
#
|
7
|
+
# Notes:
|
8
|
+
# - You need to have the colsole gem installed
|
9
|
+
# - Requiring this file also includes it (see the end of the file).
|
10
|
+
# - This functinality will be removed in future versions
|
11
|
+
# - More info: https://github.com/DannyBen/runfile/pull/46
|
12
|
+
require 'colsole'
|
13
|
+
|
14
|
+
module Runfile
|
15
|
+
module Compatibilty
|
16
|
+
include Colsole
|
17
|
+
|
18
|
+
# Run a command, wait until it is done and continue
|
19
|
+
def run(cmd)
|
20
|
+
cmd = @before_run_block.call(cmd) if @before_run_block
|
21
|
+
return false unless cmd
|
22
|
+
say "!txtgrn!> #{cmd}" unless Runfile.quiet
|
23
|
+
system cmd
|
24
|
+
@after_run_block.call(cmd) if @after_run_block
|
25
|
+
end
|
26
|
+
|
27
|
+
# Run a command, wait until it is done, then exit
|
28
|
+
def run!(cmd)
|
29
|
+
cmd = @before_run_block.call(cmd) if @before_run_block
|
30
|
+
return false unless cmd
|
31
|
+
say "!txtgrn!> #{cmd}" unless Runfile.quiet
|
32
|
+
exec cmd
|
33
|
+
end
|
34
|
+
|
35
|
+
# Run a command in the background, optionally log to a log file and save
|
36
|
+
# the process ID in a pid file
|
37
|
+
def run_bg(cmd, pid: nil, log: '/dev/null')
|
38
|
+
cmd = @before_run_block.call(cmd) if @before_run_block
|
39
|
+
return false unless cmd
|
40
|
+
full_cmd = "exec #{cmd} >#{log} 2>&1"
|
41
|
+
say "!txtgrn!> #{full_cmd}" unless Runfile.quiet
|
42
|
+
process = IO.popen "exec #{cmd} >#{log} 2>&1"
|
43
|
+
File.write pidfile(pid), process.pid if pid
|
44
|
+
@after_run_block.call(cmd) if @after_run_block
|
45
|
+
return process.pid
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stop a command started with 'run_bg'. Provide the name of he pid file you
|
49
|
+
# used in 'run_bg'
|
50
|
+
def stop_bg(pid)
|
51
|
+
file = pidfile(pid)
|
52
|
+
if File.exist? file
|
53
|
+
pid = File.read file
|
54
|
+
File.delete file
|
55
|
+
run "kill -s TERM #{pid}"
|
56
|
+
else
|
57
|
+
say "!txtred!PID file not found." unless Runfile.quiet
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Set a block to be called before each run
|
62
|
+
def before_run(&block)
|
63
|
+
@before_run_block = block
|
64
|
+
end
|
65
|
+
|
66
|
+
# Set a block to be called after each run
|
67
|
+
def after_run(&block)
|
68
|
+
@after_run_block = block
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def pid_dir
|
74
|
+
defined?(Runfile.pid_dir) ? Runfile.pid_dir : nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def pidfile(pid)
|
78
|
+
pid_dir ? "#{pid_dir}/#{pid}.pid" : "#{pid}.pid"
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
include Runfile::Compatibilty
|
data/lib/runfile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.0
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- bin/run!
|
39
39
|
- lib/runfile.rb
|
40
40
|
- lib/runfile/action.rb
|
41
|
+
- lib/runfile/compatibility.rb
|
41
42
|
- lib/runfile/docopt_helper.rb
|
42
43
|
- lib/runfile/dsl.rb
|
43
44
|
- lib/runfile/refinements.rb
|
@@ -67,9 +68,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
68
|
version: 2.4.0
|
68
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
70
|
requirements:
|
70
|
-
- - "
|
71
|
+
- - ">="
|
71
72
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
73
|
+
version: '0'
|
73
74
|
requirements: []
|
74
75
|
rubygems_version: 3.2.25
|
75
76
|
signing_key:
|