run_tasks 1.6.1 → 1.7.1

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 +32 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8ca5b6161049b4ab439ac2f9138d50bcea418c8
4
- data.tar.gz: '0929497d99ff80c07b4dcc434ca10322321653fb'
3
+ metadata.gz: 4d912c814601289934a2471492548e2ee035c4b8
4
+ data.tar.gz: '081ac573f9c65a8438a4a29b80014f7280c3a611'
5
5
  SHA512:
6
- metadata.gz: 38b289ecbb3e0a0bb3cd0fa6fc0dc7872a6d9d2331bd9c3584f18a3eeaa220c5a3f9d2649b3ce0b1808c323b674329614e68342ecc5e12d3eb78cb142c883db2
7
- data.tar.gz: a2aff1ef595a7e9e3d16417c25314a3bb9a452795f807f13e6dda09e5eb0b9baaa62ce45bdf0136d07787de1b4597ea992052baa6c429f0af302b3c54ca0116e
6
+ metadata.gz: f49f2ab04d2b205a209e1202762055133576d52cb5d9c9a323745c45b112c4309dc8c3bc39b53d24502d87a54a1127309cb01fc992469f13091916ca68302be5
7
+ data.tar.gz: 406c174d72ab2608f55ab7e1977ea1b76ead887c8d7a95992916d8df68e50409d181197da4586719ca005771a349185bdcf4e999697760050251a832037f7fba
data/src/run.rb CHANGED
@@ -98,10 +98,39 @@ def are_you_sure?(text = "Are you sure?")
98
98
  exit 9 unless answer == "y"
99
99
  end
100
100
 
101
+ def menu(text, choices)
102
+ labels = nil
103
+ values = nil
104
+ choice = nil
105
+
106
+ if choices.is_a?(Array)
107
+ labels = choices
108
+ values = choices
109
+ elsif choices.is_a?(Hash)
110
+ labels = choices.keys
111
+ values = choices.values
112
+ else
113
+ puts "menu() 'choices' parameter must be an Array or an Hash".red
114
+ exit 10
115
+ end
116
+
117
+ loop do
118
+ labels.each_with_index do |label, index|
119
+ puts "#{index + 1}. #{label}"
120
+ end
121
+ puts text
122
+ choice = STDIN.gets.chomp.to_i
123
+ break if !values[choice - 1].nil?
124
+ end
125
+ puts
126
+
127
+ values[choice - 1]
128
+ end
129
+
101
130
  # @param uri [String]
102
131
  def require_remote(uri)
103
132
  cache_path = "/tmp/run_cache_#{Digest::MD5.hexdigest(uri)}"
104
- if !File.exists? cache_path
133
+ if !File.exist? cache_path
105
134
  File.write(cache_path, URI.parse(uri).open.read)
106
135
  end
107
136
  eval File.read(cache_path)
@@ -122,7 +151,7 @@ end
122
151
 
123
152
  RUNFILE = "Runfile.rb"
124
153
 
125
- if !File.exists?(RUNFILE)
154
+ if !File.exist?(RUNFILE)
126
155
  puts
127
156
  puts "#{RUNFILE} does not exist".red
128
157
  exit 7
@@ -180,7 +209,7 @@ if VERSION && HOMEPAGE
180
209
  .read
181
210
  version = /^\s*s.version\s*=\s*"(.+?)"\s*$/.match(contents)
182
211
  if !version.nil?
183
- next if File.exists?("/tmp/run_dismiss_#{version}")
212
+ next if File.exist?("/tmp/run_dismiss_#{version}")
184
213
  current = VERSION.split "."
185
214
  latest = version[1].split "."
186
215
  if current[0].to_i < latest[0].to_i ||
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.6.1
4
+ version: 1.7.1
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-07-27 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: aurelien.delogu@gmail.com