pups 1.2.1 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d00f89445e8997c6549211ca5670b8eda9e4a9ebbb5d1900467b35c6bfb045f2
4
- data.tar.gz: 7c8ec179c0b2efdbff2e46036efac28286afb41a1c04c1beb4e92451c9729bb7
3
+ metadata.gz: 3a3b8f3717bb917e039d84ec656835ce1c4b213d481de705244bb15fa58e8f1a
4
+ data.tar.gz: f104c2f76abccafc9705c08a1619dd1a0351ad91a19ddf5c29cb4f9bc283a91d
5
5
  SHA512:
6
- metadata.gz: 2785911c74f74d7fc0104d143bcd0d4d64a2af4b110d18096171c85d1ab98d6c024918dc615de670d2d8d9fc634ad6081a5333fb31dc4ecaf39f71f3b03387de
7
- data.tar.gz: 0dee75b5356f3341588bab687e584418df14ed262b3c67a541756d9e5725170321a2fa4c32763165078e0bf452200bf53d596cf9a314adebf377c0371999254e
6
+ metadata.gz: de7bd31e09e421f3a2ff172199694cc19e757a4be8fde50188cde889f8ca788c15f9733d354ad6ee0b8ef6551f804bdf470ab8175059a5b66be05d9c73cadf5f
7
+ data.tar.gz: 8b704e22e578e48870733a8c3925afff1dc7773cf17fe5a5c9182fa1a464fc2ca97c80a0bed174393e54ff5f2e3071d9c4abb2eee8086c07a9c96da0c44267b1
@@ -16,10 +16,10 @@ jobs:
16
16
  fail-fast: true
17
17
  matrix:
18
18
  os: [ubuntu-latest]
19
- ruby: ["3.2"]
19
+ ruby: ["3.3"]
20
20
 
21
21
  steps:
22
- - uses: actions/checkout@v3
22
+ - uses: actions/checkout@v4
23
23
  - uses: ruby/setup-ruby@v1
24
24
  with:
25
25
  ruby-version: ${{ matrix.ruby }}
@@ -34,10 +34,10 @@ jobs:
34
34
  fail-fast: true
35
35
  matrix:
36
36
  os: [ubuntu-latest]
37
- ruby: ["3.2"]
37
+ ruby: ["3.3"]
38
38
 
39
39
  steps:
40
- - uses: actions/checkout@v3
40
+ - uses: actions/checkout@v4
41
41
  - uses: ruby/setup-ruby@v1
42
42
  with:
43
43
  ruby-version: ${{ matrix.ruby }}
@@ -52,7 +52,7 @@ jobs:
52
52
  runs-on: ubuntu-latest
53
53
 
54
54
  steps:
55
- - uses: actions/checkout@v3
55
+ - uses: actions/checkout@v4
56
56
 
57
57
  - name: Release Gem
58
58
  uses: discourse/publish-rubygems-action@v2
data/.rubocop.yml CHANGED
@@ -1,3 +1,2 @@
1
1
  inherit_gem:
2
2
  rubocop-discourse: default.yml
3
-
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 1.3.0 - 07-08-2025
2
+
3
+ - Add --params option
4
+
1
5
  1.2.0 - 10-22-2023
2
6
 
3
7
  - Add --tags and --skip-tags options
data/README.md CHANGED
@@ -25,10 +25,10 @@ Usage: pups [options] [FILE|--stdin]
25
25
  --stdin Read input from stdin.
26
26
  --quiet Don't print any logs.
27
27
  --ignore <elements> Ignore specific configuration elements, multiple elements can be provided (comma-delimited).
28
- --tags <elements> Only run tagged commands.
29
- --skip-tags <elements> Run all but listed tagged commands.
30
28
  Useful if you want to skip over config in a pups execution.
31
29
  e.g. `--ignore env,params`.
30
+ --tags <elements> Only run tagged commands.
31
+ --skip-tags <elements> Run all but listed tagged commands.
32
32
  --gen-docker-run-args Output arguments from the pups configuration for input into a docker run command. All other pups config is ignored.
33
33
  -h, --help
34
34
  ```
@@ -76,6 +76,26 @@ Running: `pups --tags="sometag,anothertag" somefile.yaml` will not run the echo
76
76
 
77
77
  Running: `pups --skip-tags="sometag,anothertag" somefile.yaml` will ONLY run the echo goodbye statement.
78
78
 
79
+ #### Parameter overriding
80
+
81
+ The `--params` argument allows pups to dynamically override params set within a configuration for the single pups run.
82
+
83
+ Note, it is expected to be of the form `key=value`. If it is malformed, a warning will be thrown.
84
+
85
+ Example:
86
+
87
+ ```
88
+ # somefile.yaml
89
+
90
+ params:
91
+ param1: false_prophet
92
+ param2: also overridden
93
+ run:
94
+ - exec:
95
+ cmd: /bin/bash -c 'echo $param1 $param2 >> hello'
96
+ ```
97
+ Running `pups --params="param1=true_value,param2=other_true_value" somefile.yaml` will overwrite param1 and param2 with true_value and other_true_value respectively
98
+
79
99
  #### Docker run argument generation
80
100
 
81
101
  The `--gen-docker-run-args` argument is used to make pups output arguments be in the format of `docker run <arguments output>`. Specifically, pups
data/lib/pups/cli.rb CHANGED
@@ -24,6 +24,11 @@ module Pups
24
24
  Array,
25
25
  "Run all but listed tagged commands."
26
26
  )
27
+ opts.on(
28
+ "--params <param(s)>",
29
+ Array,
30
+ "Replace params in the config with params listed."
31
+ )
27
32
  opts.on("-h", "--help") do
28
33
  puts opts
29
34
  exit
@@ -69,7 +74,8 @@ module Pups
69
74
  conf,
70
75
  options[:ignore],
71
76
  tags: options[:tags],
72
- skip_tags: options[:"skip-tags"]
77
+ skip_tags: options[:"skip-tags"],
78
+ extra_params: options[:params]
73
79
  )
74
80
  else
75
81
  config =
@@ -77,7 +83,8 @@ module Pups
77
83
  input_file,
78
84
  options[:ignore],
79
85
  tags: options[:tags],
80
- skip_tags: options[:"skip-tags"]
86
+ skip_tags: options[:"skip-tags"],
87
+ extra_params: options[:params]
81
88
  )
82
89
  end
83
90
 
data/lib/pups/config.rb CHANGED
@@ -7,8 +7,9 @@ module Pups
7
7
  def initialize(
8
8
  config,
9
9
  ignored = nil,
10
- tags: tags = nil,
11
- skip_tags: skip_tags = nil
10
+ tags: nil,
11
+ skip_tags: nil,
12
+ extra_params: nil
12
13
  )
13
14
  @config = config
14
15
 
@@ -41,6 +42,16 @@ module Pups
41
42
  )
42
43
 
43
44
  @params = @config["params"]
45
+ if extra_params
46
+ extra_params.each do |val|
47
+ key_val = val.split("=", 2)
48
+ if key_val.length == 2
49
+ @params[key_val[0]] = key_val[1]
50
+ else
51
+ warn "Malformed param #{val}. Expected param to be of the form `key=value`"
52
+ end
53
+ end
54
+ end
44
55
  ENV.each { |k, v| @params["$ENV_#{k}"] = v }
45
56
  inject_hooks
46
57
  end
@@ -48,14 +59,16 @@ module Pups
48
59
  def self.load_file(
49
60
  config_file,
50
61
  ignored = nil,
51
- tags: tags = nil,
52
- skip_tags: skip_tags = nil
62
+ tags: nil,
63
+ skip_tags: nil,
64
+ extra_params: nil
53
65
  )
54
66
  Config.new(
55
67
  YAML.load_file(config_file),
56
68
  ignored,
57
69
  tags: tags,
58
- skip_tags: skip_tags
70
+ skip_tags: skip_tags,
71
+ extra_params: extra_params
59
72
  )
60
73
  rescue Exception
61
74
  warn "Failed to parse #{config_file}"
@@ -67,14 +80,16 @@ module Pups
67
80
  def self.load_config(
68
81
  config,
69
82
  ignored = nil,
70
- tags: tags = nil,
71
- skip_tags: skip_tags = nil
83
+ tags: nil,
84
+ skip_tags: nil,
85
+ extra_params: nil
72
86
  )
73
87
  Config.new(
74
88
  YAML.safe_load(config),
75
89
  ignored,
76
90
  tags: tags,
77
- skip_tags: skip_tags
91
+ skip_tags: skip_tags,
92
+ extra_params: extra_params
78
93
  )
79
94
  end
80
95
 
@@ -108,10 +123,7 @@ module Pups
108
123
 
109
124
  # Filter run commands by tag: by default, keep all commands that contain tags.
110
125
  # If skip_tags argument is true, keep all commands that DO NOT contain tags.
111
- def filter_tags(
112
- include_tags: include_tags = nil,
113
- exclude_tags: exclude_tags = nil
114
- )
126
+ def filter_tags(include_tags: nil, exclude_tags: nil)
115
127
  if include_tags
116
128
  @config["run"] = @config["run"].select do |row|
117
129
  keep = false
@@ -87,7 +87,6 @@ module Pups
87
87
  Pups.log.info("> #{command}")
88
88
  pid = spawn(command)
89
89
  Pups.log.info(@result.readlines.join("\n")) if @result
90
- pid
91
90
  end
92
91
  rescue StandardError
93
92
  raise if @raise_on_fail
@@ -20,8 +20,6 @@ module Pups
20
20
  @type = :bash
21
21
  end
22
22
 
23
- attr_writer :params
24
-
25
23
  def run
26
24
  path = interpolate_params(@path)
27
25
 
data/lib/pups/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pups
4
- VERSION = "1.2.1"
4
+ VERSION = "1.3.0"
5
5
  end
data/pups.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
5
5
  require 'pups/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
data/test/cli_test.rb CHANGED
@@ -140,6 +140,7 @@ module Pups
140
140
  Cli.run(["--tags", "1,3", cf.path])
141
141
  assert_equal("1\n3", File.read(f.path).strip)
142
142
  end
143
+
143
144
  def test_cli_skip_tags
144
145
  # for testing output
145
146
  f = Tempfile.new("test_output")
@@ -164,5 +165,28 @@ module Pups
164
165
  Cli.run(["--skip-tags", "1,3", cf.path])
165
166
  assert_equal("2", File.read(f.path).strip)
166
167
  end
168
+
169
+ def test_cli_params
170
+ # for testing output
171
+ f = Tempfile.new("test_output")
172
+ f.close
173
+
174
+ # for testing input
175
+ cf = Tempfile.new("test_config")
176
+ cf.puts <<~YAML
177
+ params:
178
+ one: 0
179
+ two: 0
180
+ run:
181
+ - exec:
182
+ cmd: echo $one >> #{f.path}
183
+ - exec:
184
+ cmd: echo $two >> #{f.path}
185
+ YAML
186
+ cf.close
187
+
188
+ Cli.run(["--params", "one=1,two=2", cf.path])
189
+ assert_equal("1\n2", File.read(f.path).strip)
190
+ end
167
191
  end
168
192
  end
data/test/config_test.rb CHANGED
@@ -283,5 +283,15 @@ module Pups
283
283
  config["run"][1]
284
284
  )
285
285
  end
286
+
287
+ def test_extra_params
288
+ config = <<~YAML
289
+ params:
290
+ one: 1
291
+ YAML
292
+ config = Config.new(YAML.safe_load(config), extra_params: %w[one=2 two=2])
293
+ assert_equal("2", config.params["one"])
294
+ assert_equal("2", config.params["two"])
295
+ end
286
296
  end
287
297
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pups
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-23 00:00:00.000000000 Z
11
+ date: 2025-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler