pups 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5203de15040af48165295c4d93c85351b5995c137e9334566877a7875733f05
4
- data.tar.gz: 6337c83523bc6e0e17d9f3ba494d62e7a629415a4ce75f95db8e92e998837993
3
+ metadata.gz: 2474629aec1a6af05e0af5b4c87385bad16713e6fa86828f9233dd8140e5964f
4
+ data.tar.gz: 1bd85d9ed07b63633f9137aef9a7eae77537e05418eff260db5d1145ecbc999d
5
5
  SHA512:
6
- metadata.gz: 8a4e356fde18db799f68049198eac4195a46c3d73f1919a66f473f195676a322a1759050bb01dfa6c447a4d705d6dce583bd6215e6a3412a339ffe55e2f57a48
7
- data.tar.gz: 065473a360bac01f433757db10c513fc6790d49521218f6a3db5a55279386fa4ee89818c0aa16b07e37cc8f3375de705dae8fc9966191fabb2c17bf16675ad21
6
+ metadata.gz: 22d164fcb61b5e36da7893731bd51bf11ed9732ecd4540be6912a26c2ddbbeb7ded0c6f1f2d07abea66217d4d18d02e08aa365c73ed588b15d139978a6ed77f6
7
+ data.tar.gz: d45150d87661548887be59363d7de3b069f8ed094a5ebb71da89d920b449adf3002f21b0788a9b2e87bcfd40f6bd1852ef27eae3f53e36a9966530087ae88e5c
@@ -1,12 +1,30 @@
1
- name: Tests
1
+ name: CI
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - master
6
+ - main
7
7
  pull_request: {}
8
8
 
9
9
  jobs:
10
+ lint:
11
+ name: "pups lint"
12
+ runs-on: ${{ matrix.os }}
13
+ timeout-minutes: 5
14
+
15
+ strategy:
16
+ fail-fast: true
17
+ matrix:
18
+ os: [ubuntu-latest]
19
+ ruby: ["3.2"]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+ - uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+ bundler-cache: true
27
+ - run: bundle exec rubocop
10
28
  test:
11
29
  name: "pups tests"
12
30
  runs-on: ${{ matrix.os }}
@@ -16,10 +34,10 @@ jobs:
16
34
  fail-fast: true
17
35
  matrix:
18
36
  os: [ubuntu-latest]
19
- ruby: ["2.7"]
37
+ ruby: ["3.2"]
20
38
 
21
39
  steps:
22
- - uses: actions/checkout@v2
40
+ - uses: actions/checkout@v3
23
41
  - uses: ruby/setup-ruby@v1
24
42
  with:
25
43
  ruby-version: ${{ matrix.ruby }}
@@ -27,3 +45,18 @@ jobs:
27
45
  - name: Run minitest
28
46
  run: |
29
47
  rake test
48
+
49
+ publish:
50
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
51
+ needs: [test]
52
+ runs-on: ubuntu-latest
53
+
54
+ steps:
55
+ - uses: actions/checkout@v3
56
+
57
+ - name: Release Gem
58
+ uses: discourse/publish-rubygems-action@v2
59
+ env:
60
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
61
+ GIT_EMAIL: team@discourse.org
62
+ GIT_NAME: discoursebot
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 1.2.0 - 10-22-2023
2
+
3
+ - Add --tags and --skip-tags options
4
+
1
5
  1.0.3 - 09-04-2021
2
6
 
3
7
  - Started changelog - release to rubygems
data/README.md CHANGED
@@ -25,6 +25,8 @@ 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.
28
30
  Useful if you want to skip over config in a pups execution.
29
31
  e.g. `--ignore env,params`.
30
32
  --gen-docker-run-args Output arguments from the pups configuration for input into a docker run command. All other pups config is ignored.
@@ -48,6 +50,32 @@ Running: `pups somefile.yaml` will execute the shell script resulting in a file
48
50
 
49
51
  ### Features
50
52
 
53
+ #### Filtering run commands by tags
54
+
55
+ The `--tags` and `--skip-tags` argument allows pups to target a subset of commands listed in the somefile.yaml. To use this, you may tag your commands in the runblock. `--tags` will only run commands when commands have a matching tag. `--skip-tags` will skip when commands have a matching tag.
56
+
57
+ Note, hooks from tagged commands will be present or absent depending on if the tag is filtered out or not as well. A command filtered out by targeting tag will also filter out the command's `before_` and `after_` hooks.
58
+
59
+ Example:
60
+
61
+ ```
62
+ # somefile.yaml
63
+
64
+ run:
65
+ - exec:
66
+ cmd: /bin/bash -c 'echo hello >> hello'
67
+ tag: sometag
68
+ - exec:
69
+ cmd: /bin/bash -c 'echo hi >> hello'
70
+ tag: anothertag
71
+ - exec:
72
+ cmd: /bin/bash -c 'echo goodbye >> hello'
73
+ tag: thirdtag
74
+ ```
75
+ Running: `pups --tags="sometag,anothertag" somefile.yaml` will not run the echo goodbye statement.
76
+
77
+ Running: `pups --skip-tags="sometag,anothertag" somefile.yaml` will ONLY run the echo goodbye statement.
78
+
51
79
  #### Docker run argument generation
52
80
 
53
81
  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
@@ -1,17 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optparse'
3
+ require "optparse"
4
4
 
5
5
  module Pups
6
6
  class Cli
7
7
  def self.opts
8
8
  OptionParser.new do |opts|
9
- opts.banner = 'Usage: pups [FILE|--stdin]'
10
- opts.on('--stdin', 'Read input from stdin.')
11
- opts.on('--quiet', "Don't print any logs.")
12
- opts.on('--ignore <element(s)>', Array, "Ignore these template configuration elements, multiple elements can be provided (comma-delimited).")
13
- opts.on('--gen-docker-run-args', 'Output arguments from the pups configuration for input into a docker run command. All other pups config is ignored.')
14
- opts.on('-h', '--help') do
9
+ opts.banner = "Usage: pups [FILE|--stdin]"
10
+ opts.on("--stdin", "Read input from stdin.")
11
+ opts.on("--quiet", "Don't print any logs.")
12
+ opts.on(
13
+ "--ignore <element(s)>",
14
+ Array,
15
+ "Ignore these template configuration elements, multiple elements can be provided (comma-delimited)."
16
+ )
17
+ opts.on(
18
+ "--gen-docker-run-args",
19
+ "Output arguments from the pups configuration for input into a docker run command. All other pups config is ignored."
20
+ )
21
+ opts.on("--tags <tag(s)>", Array, "Only run tagged commands.")
22
+ opts.on(
23
+ "--skip-tags <tag(s)>",
24
+ Array,
25
+ "Run all but listed tagged commands."
26
+ )
27
+ opts.on("-h", "--help") do
15
28
  puts opts
16
29
  exit
17
30
  end
@@ -26,35 +39,46 @@ module Pups
26
39
 
27
40
  def self.run(args)
28
41
  options = parse_args(args)
29
- input_file = options[:stdin] ? 'stdin' : args.last
42
+ input_file = options[:stdin] ? "stdin" : args.last
30
43
  unless input_file
31
44
  puts opts.parse!(%w[--help])
32
45
  exit
33
46
  end
34
47
 
35
- if options[:quiet]
36
- Pups.silence
37
- end
48
+ Pups.silence if options[:quiet]
38
49
 
39
50
  Pups.log.info("Reading from #{input_file}")
40
51
 
41
52
  if options[:stdin]
42
53
  conf = $stdin.readlines.join
43
- split = conf.split('_FILE_SEPERATOR_')
54
+ split = conf.split("_FILE_SEPERATOR_")
44
55
 
45
56
  conf = nil
46
57
  split.each do |data|
47
58
  current = YAML.safe_load(data.strip)
48
- conf = if conf
49
- Pups::MergeCommand.deep_merge(conf, current, :merge_arrays)
50
- else
51
- current
52
- end
59
+ conf =
60
+ if conf
61
+ Pups::MergeCommand.deep_merge(conf, current, :merge_arrays)
62
+ else
63
+ current
64
+ end
53
65
  end
54
66
 
55
- config = Pups::Config.new(conf, options[:ignore])
67
+ config =
68
+ Pups::Config.new(
69
+ conf,
70
+ options[:ignore],
71
+ tags: options[:tags],
72
+ skip_tags: option[:"skip-tags"]
73
+ )
56
74
  else
57
- config = Pups::Config.load_file(input_file, options[:ignore])
75
+ config =
76
+ Pups::Config.load_file(
77
+ input_file,
78
+ options[:ignore],
79
+ tags: options[:tags],
80
+ skip_tags: options[:"skip-tags"]
81
+ )
58
82
  end
59
83
 
60
84
  if options[:"gen-docker-run-args"]
data/lib/pups/command.rb CHANGED
@@ -4,8 +4,10 @@ module Pups
4
4
  class Command
5
5
  def self.run(command, params)
6
6
  case command
7
- when String then from_str(command, params).run
8
- when Hash then from_hash(command, params).run
7
+ when String
8
+ from_str(command, params).run
9
+ when Hash
10
+ from_hash(command, params).run
9
11
  end
10
12
  end
11
13
 
data/lib/pups/config.rb CHANGED
@@ -4,33 +4,59 @@ module Pups
4
4
  class Config
5
5
  attr_reader :config, :params
6
6
 
7
- def initialize(config, ignored = nil)
7
+ def initialize(
8
+ config,
9
+ ignored = nil,
10
+ tags: tags = nil,
11
+ skip_tags: skip_tags = nil
12
+ )
8
13
  @config = config
9
14
 
10
15
  # remove any ignored config elements prior to any more processing
11
16
  ignored&.each { |e| @config.delete(e) }
12
17
 
18
+ filter_tags(include_tags: tags, exclude_tags: skip_tags)
19
+
13
20
  # set some defaults to prevent checks in various functions
14
- ['env_template', 'env', 'labels', 'params'].each { |key| @config[key] = {} unless @config.has_key?(key) }
21
+ %w[env_template env labels params].each do |key|
22
+ @config[key] = {} unless @config.has_key?(key)
23
+ end
15
24
 
16
25
  # Order here is important.
17
26
  Pups::Config.combine_template_and_process_env(@config, ENV)
18
- Pups::Config.prepare_env_template_vars(@config['env_template'], ENV)
27
+ Pups::Config.prepare_env_template_vars(@config["env_template"], ENV)
19
28
 
20
29
  # Templating is supported in env and label variables.
21
- Pups::Config.transform_config_with_templated_vars(@config['env_template'], ENV)
22
- Pups::Config.transform_config_with_templated_vars(@config['env_template'], @config['env'])
23
- Pups::Config.transform_config_with_templated_vars(@config['env_template'], @config['labels'])
30
+ Pups::Config.transform_config_with_templated_vars(
31
+ @config["env_template"],
32
+ ENV
33
+ )
34
+ Pups::Config.transform_config_with_templated_vars(
35
+ @config["env_template"],
36
+ @config["env"]
37
+ )
38
+ Pups::Config.transform_config_with_templated_vars(
39
+ @config["env_template"],
40
+ @config["labels"]
41
+ )
24
42
 
25
43
  @params = @config["params"]
26
- ENV.each do |k, v|
27
- @params["$ENV_#{k}"] = v
28
- end
44
+ ENV.each { |k, v| @params["$ENV_#{k}"] = v }
29
45
  inject_hooks
30
46
  end
31
47
 
32
- def self.load_file(config_file, ignored = nil)
33
- Config.new(YAML.load_file(config_file), ignored)
48
+ def self.load_file(
49
+ config_file,
50
+ ignored = nil,
51
+ tags: tags = nil,
52
+ skip_tags: skip_tags = nil
53
+ )
54
+ Config.new(
55
+ YAML.load_file(config_file),
56
+ ignored,
57
+ tags: tags,
58
+ skip_tags: skip_tags
59
+ )
34
60
  rescue Exception
35
61
  warn "Failed to parse #{config_file}"
36
62
  warn "This is probably a formatting error in #{config_file}"
@@ -38,15 +64,25 @@ module Pups
38
64
  raise
39
65
  end
40
66
 
41
- def self.load_config(config, ignored = nil)
42
- Config.new(YAML.safe_load(config), ignored)
67
+ def self.load_config(
68
+ config,
69
+ ignored = nil,
70
+ tags: tags = nil,
71
+ skip_tags: skip_tags = nil
72
+ )
73
+ Config.new(
74
+ YAML.safe_load(config),
75
+ ignored,
76
+ tags: tags,
77
+ skip_tags: skip_tags
78
+ )
43
79
  end
44
80
 
45
81
  def self.prepare_env_template_vars(env_template, env)
46
82
  # Merge env_template variables from env and templates.
47
83
  env.each do |k, v|
48
- if k.include?('env_template_')
49
- key = k.gsub('env_template_', '')
84
+ if k.include?("env_template_")
85
+ key = k.gsub("env_template_", "")
50
86
  env_template[key] = v.to_s
51
87
  end
52
88
  end
@@ -70,10 +106,41 @@ module Pups
70
106
  config["env"].each { |k, v| env[k] = v.to_s }
71
107
  end
72
108
 
109
+ # Filter run commands by tag: by default, keep all commands that contain tags.
110
+ # 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
+ )
115
+ if include_tags
116
+ @config["run"] = @config["run"].select do |row|
117
+ keep = false
118
+ command = row.first
119
+ if command[1].is_a?(Hash)
120
+ tag = command[1]["tag"]
121
+ keep = include_tags.include?(tag)
122
+ end
123
+ keep
124
+ end
125
+ end
126
+
127
+ if exclude_tags
128
+ @config["run"] = @config["run"].select do |row|
129
+ keep = true
130
+ command = row.first
131
+ if command[1].is_a?(Hash)
132
+ tag = command[1]["tag"]
133
+ keep = !exclude_tags.include?(tag)
134
+ end
135
+ keep
136
+ end
137
+ end
138
+ end
139
+
73
140
  def inject_hooks
74
- return unless hooks = @config['hooks']
141
+ return unless hooks = @config["hooks"]
75
142
 
76
- run = @config['run']
143
+ run = @config["run"]
77
144
 
78
145
  positions = {}
79
146
  run.each do |row|
@@ -81,7 +148,7 @@ module Pups
81
148
 
82
149
  command = row.first
83
150
  if command[1].is_a?(Hash)
84
- hook = command[1]['hook']
151
+ hook = command[1]["hook"]
85
152
  positions[hook] = row if hook
86
153
  end
87
154
  end
@@ -112,11 +179,11 @@ module Pups
112
179
 
113
180
  def generate_docker_run_arguments
114
181
  output = []
115
- output << Pups::Docker.generate_env_arguments(config['env'])
116
- output << Pups::Docker.generate_link_arguments(config['links'])
117
- output << Pups::Docker.generate_expose_arguments(config['expose'])
118
- output << Pups::Docker.generate_volume_arguments(config['volumes'])
119
- output << Pups::Docker.generate_label_arguments(config['labels'])
182
+ output << Pups::Docker.generate_env_arguments(config["env"])
183
+ output << Pups::Docker.generate_link_arguments(config["links"])
184
+ output << Pups::Docker.generate_expose_arguments(config["expose"])
185
+ output << Pups::Docker.generate_volume_arguments(config["volumes"])
186
+ output << Pups::Docker.generate_label_arguments(config["labels"])
120
187
  output.sort!.join(" ").strip
121
188
  end
122
189
 
@@ -128,25 +195,33 @@ module Pups
128
195
  unless exit_code == 77
129
196
  puts
130
197
  puts
131
- puts 'FAILED'
132
- puts '-' * 20
198
+ puts "FAILED"
199
+ puts "-" * 20
133
200
  puts "#{e.class}: #{e}"
134
201
  puts "Location of failure: #{e.backtrace[0]}"
135
- puts "#{@last_command[:command]} failed with the params #{@last_command[:params].inspect}" if @last_command
202
+ if @last_command
203
+ puts "#{@last_command[:command]} failed with the params #{@last_command[:params].inspect}"
204
+ end
136
205
  end
137
206
  exit exit_code
138
207
  end
139
208
 
140
209
  def run_commands
141
- @config['run']&.each do |item|
210
+ @config["run"]&.each do |item|
142
211
  item.each do |k, v|
143
- type = case k
144
- when 'exec' then Pups::ExecCommand
145
- when 'merge' then Pups::MergeCommand
146
- when 'replace' then Pups::ReplaceCommand
147
- when 'file' then Pups::FileCommand
148
- else raise SyntaxError, "Invalid run command #{k}"
149
- end
212
+ type =
213
+ case k
214
+ when "exec"
215
+ Pups::ExecCommand
216
+ when "merge"
217
+ Pups::MergeCommand
218
+ when "replace"
219
+ Pups::ReplaceCommand
220
+ when "file"
221
+ Pups::FileCommand
222
+ else
223
+ raise SyntaxError, "Invalid run command #{k}"
224
+ end
150
225
 
151
226
  @last_command = { command: k, params: v }
152
227
  type.run(v, @params)
@@ -162,9 +237,7 @@ module Pups
162
237
  return unless cmd
163
238
 
164
239
  processed = cmd.dup
165
- params.each do |k, v|
166
- processed.gsub!("$#{k}", v.to_s)
167
- end
240
+ params.each { |k, v| processed.gsub!("$#{k}", v.to_s) }
168
241
  processed
169
242
  end
170
243
  end
data/lib/pups/docker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'shellwords'
2
+ require "shellwords"
3
3
 
4
4
  class Pups::Docker
5
5
  class << self
@@ -16,7 +16,7 @@ class Pups::Docker
16
16
  def generate_link_arguments(config)
17
17
  output = []
18
18
  config&.each do |c|
19
- output << "--link #{c['link']['name']}:#{c['link']['alias']}"
19
+ output << "--link #{c["link"]["name"]}:#{c["link"]["alias"]}"
20
20
  end
21
21
  normalize_output(output)
22
22
  end
@@ -36,7 +36,7 @@ class Pups::Docker
36
36
  def generate_volume_arguments(config)
37
37
  output = []
38
38
  config&.each do |c|
39
- output << "--volume #{c['volume']['host']}:#{c['volume']['guest']}"
39
+ output << "--volume #{c["volume"]["host"]}:#{c["volume"]["guest"]}"
40
40
  end
41
41
  normalize_output(output)
42
42
  end
@@ -50,6 +50,7 @@ class Pups::Docker
50
50
  end
51
51
 
52
52
  private
53
+
53
54
  def escape_user_string_literal(str)
54
55
  # We need to escape the following strings as they are more likely to contain
55
56
  # special characters than any of the other config variables on a Linux system:
@@ -59,11 +60,7 @@ class Pups::Docker
59
60
  end
60
61
 
61
62
  def normalize_output(output)
62
- if output.empty?
63
- ""
64
- else
65
- output.join(" ")
66
- end
63
+ output.empty? ? "" : output.join(" ")
67
64
  end
68
65
  end
69
66
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'timeout'
4
- require 'English'
3
+ require "timeout"
4
+ require "English"
5
5
 
6
6
  module Pups
7
7
  class ExecCommand < Pups::Command
@@ -9,12 +9,14 @@ module Pups
9
9
  attr_accessor :background, :raise_on_fail, :stdin, :stop_signal
10
10
 
11
11
  def self.terminate_async(opts = {})
12
- return unless defined? @@asyncs
12
+ return unless defined?(@@asyncs)
13
13
 
14
- Pups.log.info('Terminating async processes')
14
+ Pups.log.info("Terminating async processes")
15
15
 
16
16
  @@asyncs.each do |async|
17
- Pups.log.info("Sending #{async[:stop_signal]} to #{async[:command]} pid: #{async[:pid]}")
17
+ Pups.log.info(
18
+ "Sending #{async[:stop_signal]} to #{async[:command]} pid: #{async[:pid]}"
19
+ )
18
20
  begin
19
21
  Process.kill(async[:stop_signal], async[:pid])
20
22
  rescue StandardError
@@ -22,37 +24,43 @@ module Pups
22
24
  end
23
25
  end
24
26
 
25
- @@asyncs.map do |async|
26
- Thread.new do
27
- Timeout.timeout(opts[:wait] || 10) do
28
- Process.wait(async[:pid])
29
- rescue StandardError
30
- nil
31
- end
32
- rescue Timeout::Error
33
- Pups.log.info("#{async[:command]} pid:#{async[:pid]} did not terminate cleanly, forcing termination!")
34
- begin
35
- Process.kill('KILL', async[:pid])
36
- Process.wait(async[:pid])
37
- rescue Errno::ESRCH
38
- rescue Errno::ECHILD
27
+ @@asyncs
28
+ .map do |async|
29
+ Thread.new do
30
+ Timeout.timeout(opts[:wait] || 10) do
31
+ Process.wait(async[:pid])
32
+ rescue StandardError
33
+ nil
34
+ end
35
+ rescue Timeout::Error
36
+ Pups.log.info(
37
+ "#{async[:command]} pid:#{async[:pid]} did not terminate cleanly, forcing termination!"
38
+ )
39
+ begin
40
+ Process.kill("KILL", async[:pid])
41
+ Process.wait(async[:pid])
42
+ rescue Errno::ESRCH
43
+ rescue Errno::ECHILD
44
+ end
39
45
  end
40
46
  end
41
- end.each(&:join)
47
+ .each(&:join)
42
48
  end
43
49
 
44
50
  def self.from_hash(hash, params)
45
- cmd = new(params, hash['cd'])
51
+ cmd = new(params, hash["cd"])
46
52
 
47
- case c = hash['cmd']
48
- when String then cmd.add(c)
49
- when Array then c.each { |i| cmd.add(i) }
53
+ case c = hash["cmd"]
54
+ when String
55
+ cmd.add(c)
56
+ when Array
57
+ c.each { |i| cmd.add(i) }
50
58
  end
51
59
 
52
- cmd.background = hash['background']
53
- cmd.stop_signal = hash['stop_signal'] || 'TERM'
54
- cmd.raise_on_fail = hash['raise_on_fail'] if hash.key? 'raise_on_fail'
55
- cmd.stdin = interpolate_params(hash['stdin'], params)
60
+ cmd.background = hash["background"]
61
+ cmd.stop_signal = hash["stop_signal"] || "TERM"
62
+ cmd.raise_on_fail = hash["raise_on_fail"] if hash.key? "raise_on_fail"
63
+ cmd.stdin = interpolate_params(hash["stdin"], params)
56
64
 
57
65
  cmd
58
66
  end
@@ -88,7 +96,11 @@ module Pups
88
96
  def spawn(command)
89
97
  if background
90
98
  pid = Process.spawn(command)
91
- (@@asyncs ||= []) << { pid: pid, command: command, stop_signal: (stop_signal || 'TERM') }
99
+ (@@asyncs ||= []) << {
100
+ pid: pid,
101
+ command: command,
102
+ stop_signal: (stop_signal || "TERM")
103
+ }
92
104
  Thread.new do
93
105
  begin
94
106
  Process.wait(pid)
@@ -100,7 +112,7 @@ module Pups
100
112
  return pid
101
113
  end
102
114
 
103
- IO.popen(command, 'w+') do |f|
115
+ IO.popen(command, "w+") do |f|
104
116
  if stdin
105
117
  # need a way to get stdout without blocking
106
118
  Pups.log.info(stdin)
@@ -112,7 +124,10 @@ module Pups
112
124
  end
113
125
 
114
126
  unless $CHILD_STATUS == 0
115
- err = Pups::ExecError.new("#{command} failed with return #{$CHILD_STATUS.inspect}")
127
+ err =
128
+ Pups::ExecError.new(
129
+ "#{command} failed with return #{$CHILD_STATUS.inspect}"
130
+ )
116
131
  err.exit_code = $CHILD_STATUS.exitstatus
117
132
  raise err
118
133
  end
@@ -6,10 +6,10 @@ module Pups
6
6
 
7
7
  def self.from_hash(hash, params)
8
8
  command = new
9
- command.path = hash['path']
10
- command.contents = hash['contents']
11
- command.chmod = hash['chmod']
12
- command.chown = hash['chown']
9
+ command.path = hash["path"]
10
+ command.contents = hash["contents"]
11
+ command.chmod = hash["chmod"]
12
+ command.chown = hash["chown"]
13
13
  command.params = params
14
14
 
15
15
  command
@@ -26,9 +26,7 @@ module Pups
26
26
  path = interpolate_params(@path)
27
27
 
28
28
  `mkdir -p #{File.dirname(path)}`
29
- File.open(path, 'w') do |f|
30
- f.write(interpolate_params(contents))
31
- end
29
+ File.open(path, "w") { |f| f.write(interpolate_params(contents)) }
32
30
  `chmod #{@chmod} #{path}` if @chmod
33
31
  `chown #{@chown} #{path}` if @chown
34
32
  Pups.log.info("File > #{path} chmod: #{@chmod} chown: #{@chown}")