my-ruby-deployer 1.3.2 → 1.3.3

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/lib/my-ruby-deployer.rb +17 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef00655eb4d5b3eaa058507b433a81fab7f0432da89d5d550f8bd53f775227a5
4
- data.tar.gz: 3ed2a11457d8d35c6bbc833837ca9864087a3f4bff4ca3d3b8ef13da3d29e9fa
3
+ metadata.gz: cd0330fe5840899f6a649f4e5e9ce04039ba883b599d76de530fafea9f703a80
4
+ data.tar.gz: 4ac3a19b11c83ffefe2f266b991eff09b1e46a3a349a2e46e6bf65360cd9bac1
5
5
  SHA512:
6
- metadata.gz: 9773fb43423bb8e03515a35f3e16f13042949f0c9fbc933dfb5f87da4103e218e0a2a4175f8f1f8a4afce9b9f1dd20591cf03c3f62192652ba3d1a94a3fa36da
7
- data.tar.gz: 8f03028e43dfb830a1f786fc48439242740b5840623a761a4f6ededed1c7c3251217d92b066e8c9bde1477a908c5c1d01ac509c80c6924d7ccb1cb22a352c93f
6
+ metadata.gz: 0a6d27889df5a4b81fefc6ef188f21aba08147e903bee5da21fa50ae746bf59af275a932b8b0a63e6763d9640c3a1545680dc8c3214c014dbb764a703059544f
7
+ data.tar.gz: 3f553255065000e8cd4aaed5b9cdb1d85698ab5dd634f13dd39eb3283c802516b96488e24c44641b25ecd45dad55b1ac591b429dd0642542edd4c404df914882
@@ -147,14 +147,14 @@ module BlackStack
147
147
  h
148
148
  end
149
149
 
150
- def run(node, l=nil)
150
+ def run(node, l=nil, params={})
151
151
  l = BlackStack::DummyLogger.new(nil) if l.nil?
152
152
  l.logs "Running routine #{self.name.blue} on node #{node.name.blue}... "
153
153
  i = 0
154
154
  self.commands.each do |c|
155
155
  i += 1
156
156
  l.logs "Command #{i.to_s.blue}... "
157
- c.run(node, l)
157
+ c.run(node, l, params)
158
158
  l.logf 'done'.green
159
159
  end
160
160
  l.logf 'done'.green
@@ -210,7 +210,7 @@ module BlackStack
210
210
  # running pre-defined commands: :root
211
211
  # calling to other routines: :'change-name'
212
212
  # calling
213
- def run(n, l=nil)
213
+ def run(n, l=nil, params={})
214
214
  l = BlackStack::DummyLogger.new(nil) if l.nil?
215
215
 
216
216
  # if self.command is a symbol
@@ -224,7 +224,7 @@ module BlackStack
224
224
  # look for a routine with this name
225
225
  r = BlackStack::Deployer.routines.select { |r| r.name == self.command.to_s }.first
226
226
  if !r.nil?
227
- r.run(n)
227
+ r.run(n, l, params)
228
228
  else
229
229
  raise "The routine #{self.command.to_s} does not exist"
230
230
  end
@@ -234,22 +234,26 @@ module BlackStack
234
234
  elsif self.command.is_a?(String)
235
235
  s = self.command.dup
236
236
 
237
- l.logs "Replacing merge-tags... "
237
+ #l.logs "Replacing merge-tags... "
238
238
  s.scan(/%[a-zA-Z0-9\_]+%/).uniq.each do |p|
239
- l.logs "Replacing #{p.blue}... "
239
+ #l.logs "Replacing #{p.blue}... "
240
240
  if p == '%timestamp%' # reserved parameter
241
241
  # TODO: move this to a timestamp function on blackstack-core
242
242
  s.gsub!(p, Time.now.to_s.gsub(/\D/, ''))
243
243
  else
244
+ # replace node parameters
244
245
  if n.parameters.has_key?(p.gsub(/%/, '').to_sym)
245
246
  s.gsub!(p, n.parameters[p.gsub(/%/, '').to_sym].to_s)
247
+ # replace routine-call parameters
248
+ elsif params.has_key?(p.gsub(/%/, '').to_sym)
249
+ s.gsub!(p, params[p.gsub(/%/, '').to_sym].to_s)
246
250
  else
247
251
  raise "The parameter #{p} does not exist in the node descriptor #{n.parameters.to_s}"
248
252
  end
249
253
  end
250
- l.logf 'done'.green
254
+ #l.logf 'done'.green
251
255
  end
252
- l.logf 'done'.green
256
+ #l.logf 'done'.green
253
257
 
254
258
  l.logs "Running command... "
255
259
  n.ssh.exec!(s)
@@ -318,7 +322,7 @@ module BlackStack
318
322
  end # def
319
323
 
320
324
  # running a routine on a node
321
- def self.run_routine(node_name, routine_name, l=nil)
325
+ def self.run_routine(node_name, routine_name, l=nil, params={})
322
326
  l = BlackStack::DummyLogger.new(nil) if l.nil?
323
327
  errors = []
324
328
 
@@ -344,7 +348,7 @@ module BlackStack
344
348
 
345
349
  # run the routine
346
350
  l.logs "Running routine #{r.name}... "
347
- r.run(n, l)
351
+ r.run(n, l, params)
348
352
  l.done
349
353
 
350
354
  # disconnect the node
@@ -354,7 +358,7 @@ module BlackStack
354
358
  end # def self.run_routine
355
359
 
356
360
  module DB
357
- LOCKFILE = './blackstack-deployer.lock'
361
+ LOCKFILE = './my-ruby-deployer.lock'
358
362
  @@checkpoint = nil
359
363
  @@superhuser = nil
360
364
  @@ndb = nil
@@ -418,7 +422,7 @@ module BlackStack
418
422
  # This method should not be called directly by user code.
419
423
  def self.execute_sentences(sql, chunk_size=200, l=nil)
420
424
  l = BlackStack::DummyLogger.new(nil) if l.nil?
421
-
425
+
422
426
  # Fix issue: Ruby `split': invalid byte sequence in UTF-8 (ArgumentError)
423
427
  # Reference: https://stackoverflow.com/questions/11065962/ruby-split-invalid-byte-sequence-in-utf-8-argumenterror
424
428
  #
@@ -462,6 +466,7 @@ module BlackStack
462
466
  def self.deploy(save_checkpoints=false, lockfilename=BlackStack::Deployer::DB::LOCKFILE, l=nil)
463
467
  l = BlackStack::DummyLogger.new(nil) if l.nil?
464
468
  # get list of `.sql` files in the directory `sql_path`, with a name higher than `last_filename`, sorted by name.
469
+
465
470
  Dir.entries(@@folder).select {
466
471
  |filename| filename =~ /\.sql$/ && filename > @@checkpoint.to_s
467
472
  }.uniq.sort.each { |filename|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my-ruby-deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-18 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blackstack-nodes