miniexec 0.1.0 → 0.1.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/lib/util.rb +19 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8678ef2aa21bd66fbe29563f4621c2a1656b2c6fbcf0a1a3e231b750d65f9707
4
- data.tar.gz: a946564ca4922eb7b0d55432e83e5827d310753ca4ebae0d150852db8eb269ec
3
+ metadata.gz: 23d8470c6289646978702f3c917e7a8d6e98df6aef7b2a6d8c810eecbaf9e797
4
+ data.tar.gz: bb5725ff2ff691bce7c0a2aa55860889efcd8300bb39add2347415ef4dff516c
5
5
  SHA512:
6
- metadata.gz: 534199cfb3d7ff71b05d2a6bc55591e9a259090375bc0e120c55a93de6ffcaf14aed7f147672543442a250ba165abaa0a41925530008491fae4e831c524953df
7
- data.tar.gz: 7ce0d9cb62a9c7f0241376c79cbaa393846afd7a8995f22790fe7bb1ed932170eaa555ac8547c8babf3d71306f1e07f9218e89e6e30466870dfc5022f389628f
6
+ metadata.gz: cc22648aa2042168eab09e192e89ad140ae188f20da8250e5817da3218019a580d5b7140320720bd212fbc44d2323c6f41aa1e722d7eb8973be877b6a5727c10
7
+ data.tar.gz: 6a4365689aa47b7be9272d8f6297c939159df7de03862965aa39e2b10c6fa07860d951b208c10b938cfa9b6c2d9b7a5b0660ff46859e732e565cfaa179b9cfea
data/lib/util.rb ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MiniExec
4
+ module Util
5
+ # Given a string and an env, replace any instance of shell-style variables
6
+ # with their value in the env. NOT POSIX COMPLIANT, just mostly hacky so
7
+ # I can get gitlab-ci.yml parsing to work properly. Required in MiniExec
8
+ # because of https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#gitlab-internal-variable-expansion-mechanism
9
+ def self.expand_var(string, env)
10
+ # Match group 1 = the text to replace
11
+ # Match group 2 = the key from env we want to replace it with
12
+ regex = /(\${?(\w+)}?)/
13
+ string.scan(regex).uniq.each do |match|
14
+ string.gsub! match[0], env[match[1]].to_s
15
+ end
16
+ string
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miniexec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Pugh
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/miniexec
21
21
  - lib/miniexec.rb
22
+ - lib/util.rb
22
23
  homepage: https://github.com/s3krit/miniexec
23
24
  licenses:
24
25
  - AGPL-3.0-or-later