run_tasks 1.2.8 → 1.3.0

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/src/run.rb +16 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '080afe6e5a7c8c122e4c1df3df0e43f881294ea254735680d912a0c373dd3a0a'
4
- data.tar.gz: c54fcd1fac401c4b66ae21d3baa0e87dbe555201e4c3d0f389088f078729b7c8
3
+ metadata.gz: defef3f4c383f104dbdd29d887667fd4dc78ab7f6126df67f9c2a164273edb05
4
+ data.tar.gz: 82b310b715b998b76ff8269cc36760dfee621915796e736ff8850247c2aa427b
5
5
  SHA512:
6
- metadata.gz: 6125dfb0293f121608a217519e7b587b4a348fa2d986786e32aa3f6a0152a88aed07976f8c3485b84b4dd0b40ff2f2a672dacfca9f5838295134c4df388e62aa
7
- data.tar.gz: 56611fd8558b70f6a2e59cdf778fefadea99eb924a06b9e08a434b1cb23f7345e4fe44092c009fb35d983e957ed5c51082902ed8ae2f25d10d3967a2e9a7ca85
6
+ metadata.gz: 1db823df990b780814e452ec8911efaae7c9d80448d075cc1af5b342b4b09e7f3a46074d8b919d517846dfa91a0ae4fd35a670d6093a28384b1edccc9b9c815d
7
+ data.tar.gz: 94fab98a5b6d052bc225ba2c363e741a61d7b206f7bb9f50b0047ef830a72118599a9f5b8703d40530df1bbcbb6e1d3dba4580addb38b5301d5d27f284816614
data/src/run.rb CHANGED
@@ -27,7 +27,9 @@ HOMEPAGE = GEM&.homepage
27
27
 
28
28
  @tasks = Hash.new
29
29
 
30
- # Define a task.
30
+ # @param name [Symbol]
31
+ # @param help [String]
32
+ # @yield [*Array, **Hash]
31
33
  def task(name, help = "", &block)
32
34
  if !name.is_a?(Symbol)
33
35
  puts
@@ -50,16 +52,18 @@ def task(name, help = "", &block)
50
52
  )
51
53
  end
52
54
 
53
- # Call a task.
54
- def call(name, *arguments, **options)
55
- @tasks[name][:block].call *arguments, **options
56
- end
55
+ # @param task_name_or_command [Symbol, String]
56
+ # @param arguments [Array] Optional arguments sent to the task.
57
+ # @param options [Hash] Optional options sent to the task.
58
+ def run(task_name_or_command, *arguments, **options)
59
+ if task_name_or_command.is_a?(Symbol)
60
+ @tasks[task_name_or_command][:block].call *arguments, **options
61
+ return
62
+ end
57
63
 
58
- # Run a shell command.
59
- def shell(command)
60
- puts ">".bright_blue + " #{command}".bright_white
64
+ puts ">".bright_blue + " #{task_name_or_command}".bright_white
61
65
  puts
62
- case system(command)
66
+ case system(task_name_or_command)
63
67
  when false
64
68
  puts
65
69
  puts "The command has exited with return code: #{$?.exitstatus}.".magenta
@@ -74,6 +78,7 @@ def shell(command)
74
78
  puts
75
79
  end
76
80
 
81
+ # @param uri [String]
77
82
  def require_remote(uri)
78
83
  cache_path = "/tmp/run_cache_#{Digest::MD5.hexdigest(uri)}"
79
84
  if !File.exists? cache_path
@@ -88,6 +93,7 @@ rescue => error
88
93
  exit 8
89
94
  end
90
95
 
96
+ # @param name [String]
91
97
  def require_extension(name)
92
98
  require_remote "https://pyrsmk.fra1.cdn.digitaloceanspaces.com" \
93
99
  "/run_extensions/#{name}.rb"
@@ -171,7 +177,7 @@ if !@tasks.include?(name)
171
177
  exit 2
172
178
  end
173
179
  begin
174
- call name, *ARGV.slice(1..)
180
+ run(name, *ARGV.slice(1..))
175
181
  rescue Interrupt
176
182
  exit 3
177
183
  rescue => error
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurélien Delogu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-15 00:00:00.000000000 Z
11
+ date: 2023-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: aurelien.delogu@gmail.com