run_tasks 1.2.4 → 1.2.5
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 +13 -46
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d33344273bf69d30a515c7be054d2d632dc6d63a831c372295094d0fc0dc65b2
|
4
|
+
data.tar.gz: 672c35d17ebb78bdd72124b4f1715bec97b3584e99da7aca1df89c5235c11d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db4c416898027366cef8005860fe37fc991171c82261a8a6da87d84e5901d49d1b16ede4922dad779bac4e6cf92139531873b6b43bbfecc77eda91c417082160
|
7
|
+
data.tar.gz: 5b9fd0ba3a31390e473708cb2b804f57e777101f975561b8192ac5e68437fcf3e160e12ea6b3270846a37f5a1cb25479f910d84ec9aed202db8dd831dcf7e2ff
|
data/src/run.rb
CHANGED
@@ -9,6 +9,11 @@ require "securerandom"
|
|
9
9
|
|
10
10
|
##########################################################################################
|
11
11
|
|
12
|
+
require_relative "./run/markdown"
|
13
|
+
require_relative "./run/string"
|
14
|
+
|
15
|
+
##########################################################################################
|
16
|
+
|
12
17
|
GEMSPEC_PATH = "#{__dir__}/../run_tasks.gemspec"
|
13
18
|
GEM = if File.exist?(GEMSPEC_PATH)
|
14
19
|
Gem::Specification::load(GEMSPEC_PATH) # Development.
|
@@ -20,50 +25,6 @@ HOMEPAGE = GEM&.homepage
|
|
20
25
|
|
21
26
|
##########################################################################################
|
22
27
|
|
23
|
-
class String
|
24
|
-
@@colors = {
|
25
|
-
:black => "30",
|
26
|
-
:red => "31",
|
27
|
-
:green => "32",
|
28
|
-
:yellow => "33",
|
29
|
-
:blue => "34",
|
30
|
-
:magenta => "35",
|
31
|
-
:cyan => "36",
|
32
|
-
:white => "37",
|
33
|
-
:bright_black => "30;1",
|
34
|
-
:bright_red => "31;1",
|
35
|
-
:bright_green => "32;1",
|
36
|
-
:bright_yellow => "33;1",
|
37
|
-
:bright_blue => "34;1",
|
38
|
-
:bright_magenta => "35;1",
|
39
|
-
:bright_cyan => "36;1",
|
40
|
-
:bright_white => "37;1",
|
41
|
-
}
|
42
|
-
|
43
|
-
def colorize(color)
|
44
|
-
"\033[#{@@colors[color.to_sym]}m#{self}\033[0m"
|
45
|
-
end
|
46
|
-
|
47
|
-
def black; colorize(:black); end
|
48
|
-
def red; colorize(:red); end
|
49
|
-
def green; colorize(:green); end
|
50
|
-
def yellow; colorize(:yellow); end
|
51
|
-
def blue; colorize(:blue); end
|
52
|
-
def magenta; colorize(:magenta); end
|
53
|
-
def cyan; colorize(:cyan); end
|
54
|
-
def white; colorize(:white); end
|
55
|
-
def bright_black; colorize(:bright_black); end
|
56
|
-
def bright_red; colorize(:bright_red); end
|
57
|
-
def bright_green; colorize(:bright_green); end
|
58
|
-
def bright_yellow; colorize(:bright_yellow); end
|
59
|
-
def bright_blue; colorize(:bright_blue); end
|
60
|
-
def bright_magenta; colorize(:bright_magenta); end
|
61
|
-
def bright_cyan; colorize(:bright_cyan); end
|
62
|
-
def bright_white; colorize(:bright_white); end
|
63
|
-
end
|
64
|
-
|
65
|
-
##########################################################################################
|
66
|
-
|
67
28
|
@tasks = Hash.new
|
68
29
|
|
69
30
|
# Define a task.
|
@@ -80,7 +41,13 @@ def task(name, help = "", &block)
|
|
80
41
|
puts
|
81
42
|
exit 6
|
82
43
|
end
|
83
|
-
@tasks.store(
|
44
|
+
@tasks.store(
|
45
|
+
name,
|
46
|
+
{
|
47
|
+
:help => Markdown.new(help).to_ansi,
|
48
|
+
:block => block
|
49
|
+
}
|
50
|
+
)
|
84
51
|
end
|
85
52
|
|
86
53
|
# Call a task.
|
@@ -195,7 +162,7 @@ if VERSION && HOMEPAGE
|
|
195
162
|
end
|
196
163
|
|
197
164
|
# Run the requested task.
|
198
|
-
name = ARGV[0].to_sym
|
165
|
+
name = ARGV[0].gsub('-', '_').to_sym # Auto-fix hyphens to underscores.
|
199
166
|
if !@tasks.include?(name)
|
200
167
|
puts
|
201
168
|
puts "Unknown '#{name}' task".red
|