run_tasks 1.5.0 → 1.6.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 +4 -4
- data/src/run.rb +32 -9
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8ca5b6161049b4ab439ac2f9138d50bcea418c8
|
4
|
+
data.tar.gz: '0929497d99ff80c07b4dcc434ca10322321653fb'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b289ecbb3e0a0bb3cd0fa6fc0dc7872a6d9d2331bd9c3584f18a3eeaa220c5a3f9d2649b3ce0b1808c323b674329614e68342ecc5e12d3eb78cb142c883db2
|
7
|
+
data.tar.gz: a2aff1ef595a7e9e3d16417c25314a3bb9a452795f807f13e6dda09e5eb0b9baaa62ce45bdf0136d07787de1b4597ea992052baa6c429f0af302b3c54ca0116e
|
data/src/run.rb
CHANGED
@@ -25,26 +25,38 @@ HOMEPAGE = GEM&.homepage
|
|
25
25
|
|
26
26
|
##########################################################################################
|
27
27
|
|
28
|
-
@tasks =
|
28
|
+
@tasks = {}
|
29
29
|
|
30
30
|
# @param name [Symbol]
|
31
31
|
# @param help [String]
|
32
32
|
# @yield [*Array, **Hash]
|
33
|
-
def task(name, help =
|
33
|
+
def task(name, help = nil, &block)
|
34
34
|
if !name.is_a?(Symbol)
|
35
35
|
puts
|
36
|
-
puts "
|
36
|
+
puts "'name' parameter must be a symbol".red
|
37
37
|
exit 6
|
38
38
|
end
|
39
|
-
if !help.
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
if !help.nil?
|
40
|
+
if !help.is_a?(String)
|
41
|
+
puts
|
42
|
+
puts "'help' parameter must be a string".red
|
43
|
+
exit 6
|
44
|
+
end
|
45
|
+
else
|
46
|
+
# Load comments directly above the task as help verbatim.
|
47
|
+
caller = caller_locations[0]
|
48
|
+
lines = File.readlines(caller.absolute_path)
|
49
|
+
help = (0..(caller.lineno - 2)).to_a.reverse.reduce([]) do |comments, lineno|
|
50
|
+
match = /^\s*#\s*(?<comment>.+?)\s*$/.match(lines[lineno])
|
51
|
+
break comments if match.nil?
|
52
|
+
comments << match[:comment]
|
53
|
+
comments
|
54
|
+
end.reverse
|
43
55
|
end
|
44
56
|
@tasks.store(
|
45
57
|
name,
|
46
58
|
{
|
47
|
-
:help =>
|
59
|
+
:help => help.is_a?(String) ? [help] : help,
|
48
60
|
:block => block
|
49
61
|
}
|
50
62
|
)
|
@@ -143,7 +155,18 @@ if ARGV.size == 0 || (ARGV.size == 1 && ARGV[0] == "help")
|
|
143
155
|
end
|
144
156
|
# Display each task and their help.
|
145
157
|
@tasks.sort.to_h.each do |name, task|
|
146
|
-
|
158
|
+
if task[:help].size == 0
|
159
|
+
puts " #{name}".yellow
|
160
|
+
next
|
161
|
+
end
|
162
|
+
task[:help].each_with_index do |help, index|
|
163
|
+
help = Markdown::Engine.new(help).to_ansi
|
164
|
+
if index == 0
|
165
|
+
puts " #{name}".yellow + (" " * (max_size - name.size + 4)) + help
|
166
|
+
next
|
167
|
+
end
|
168
|
+
puts (" " * (max_size + 5)) + help
|
169
|
+
end
|
147
170
|
end
|
148
171
|
exit
|
149
172
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: run_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aurélien Delogu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description:
|
14
14
|
email: aurelien.delogu@gmail.com
|
15
15
|
executables:
|
16
16
|
- run
|
@@ -29,7 +29,7 @@ homepage: https://github.com/pyrsmk/run
|
|
29
29
|
licenses:
|
30
30
|
- MIT
|
31
31
|
metadata: {}
|
32
|
-
post_install_message:
|
32
|
+
post_install_message:
|
33
33
|
rdoc_options: []
|
34
34
|
require_paths:
|
35
35
|
- lib
|
@@ -44,9 +44,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
|
-
rubyforge_project:
|
47
|
+
rubyforge_project:
|
48
48
|
rubygems_version: 2.5.2
|
49
|
-
signing_key:
|
49
|
+
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Run project tasks with ease
|
52
52
|
test_files: []
|