pups 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'tempfile'
3
+ require "test_helper"
4
+ require "tempfile"
5
5
 
6
6
  module Pups
7
- class ExecCommandTest < MiniTest::Test
7
+ class ExecCommandTest < ::Minitest::Test
8
8
  def from_str(str, params = {})
9
9
  ExecCommand.from_str(str, params).commands
10
10
  end
@@ -14,52 +14,49 @@ module Pups
14
14
  end
15
15
 
16
16
  def test_simple_str_command
17
- assert_equal(['do_something'],
18
- from_str('do_something'))
17
+ assert_equal(["do_something"], from_str("do_something"))
19
18
  end
20
19
 
21
20
  def test_simple_str_command_with_param
22
- assert_equal(['hello world'],
23
- from_str('hello $bob', { 'bob' => 'world' }))
21
+ assert_equal(
22
+ ["hello world"],
23
+ from_str("hello $bob", { "bob" => "world" })
24
+ )
24
25
  end
25
26
 
26
27
  def test_nested_command
27
- assert_equal(['first'],
28
- from_hash('cmd' => 'first'))
28
+ assert_equal(["first"], from_hash("cmd" => "first"))
29
29
  end
30
30
 
31
31
  def test_multi_commands
32
- assert_equal(%w[first second],
33
- from_hash('cmd' => %w[first second]))
32
+ assert_equal(%w[first second], from_hash("cmd" => %w[first second]))
34
33
  end
35
34
 
36
35
  def test_multi_commands_with_home
37
- assert_equal(['cd /home/sam && first',
38
- 'cd /home/sam && second'],
39
- from_hash('cmd' => %w[first second],
40
- 'cd' => '/home/sam'))
36
+ assert_equal(
37
+ ["cd /home/sam && first", "cd /home/sam && second"],
38
+ from_hash("cmd" => %w[first second], "cd" => "/home/sam")
39
+ )
41
40
  end
42
41
 
43
42
  def test_exec_works
44
- ExecCommand.from_str('ls', {}).run
43
+ ExecCommand.from_str("ls", {}).run
45
44
  end
46
45
 
47
46
  def test_fails_for_bad_command
48
- assert_raises(Errno::ENOENT) do
49
- ExecCommand.from_str('boom', {}).run
50
- end
47
+ assert_raises(Errno::ENOENT) { ExecCommand.from_str("boom", {}).run }
51
48
  end
52
49
 
53
50
  def test_backgroud_task_do_not_fail
54
51
  cmd = ExecCommand.new({})
55
52
  cmd.background = true
56
- cmd.add('sleep 10 && exit 1')
53
+ cmd.add("sleep 10 && exit 1")
57
54
  cmd.run
58
55
  end
59
56
 
60
57
  def test_raise_on_fail
61
58
  cmd = ExecCommand.new({})
62
- cmd.add('chgrp -a')
59
+ cmd.add("chgrp -a")
63
60
  cmd.raise_on_fail = false
64
61
  cmd.run
65
62
  end
@@ -67,29 +64,27 @@ module Pups
67
64
  def test_stdin
68
65
  `touch test_file`
69
66
  cmd = ExecCommand.new({})
70
- cmd.add('read test ; echo $test > test_file')
71
- cmd.stdin = 'hello'
67
+ cmd.add("read test ; echo $test > test_file")
68
+ cmd.stdin = "hello"
72
69
  cmd.run
73
70
 
74
- assert_equal("hello\n", File.read('test_file'))
71
+ assert_equal("hello\n", File.read("test_file"))
75
72
  ensure
76
- File.delete('test_file')
73
+ File.delete("test_file")
77
74
  end
78
75
 
79
76
  def test_fails_for_non_zero_exit
80
77
  assert_raises(Pups::ExecError) do
81
- ExecCommand.from_str('chgrp -a', {}).run
78
+ ExecCommand.from_str("chgrp -a", {}).run
82
79
  end
83
80
  end
84
81
 
85
82
  def test_can_terminate_async
86
83
  cmd = ExecCommand.new({})
87
84
  cmd.background = true
88
- pid = cmd.spawn('sleep 10 && exit 1')
85
+ pid = cmd.spawn("sleep 10 && exit 1")
89
86
  ExecCommand.terminate_async
90
- assert_raises(Errno::ECHILD) do
91
- Process.waitpid(pid, Process::WNOHANG)
92
- end
87
+ assert_raises(Errno::ECHILD) { Process.waitpid(pid, Process::WNOHANG) }
93
88
  end
94
89
 
95
90
  def test_can_terminate_rogues
@@ -101,9 +96,7 @@ module Pups
101
96
 
102
97
  ExecCommand.terminate_async(wait: 0.1)
103
98
 
104
- assert_raises(Errno::ECHILD) do
105
- Process.waitpid(pid, Process::WNOHANG)
106
- end
99
+ assert_raises(Errno::ECHILD) { Process.waitpid(pid, Process::WNOHANG) }
107
100
  end
108
101
  end
109
102
  end
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'tempfile'
3
+ require "test_helper"
4
+ require "tempfile"
5
5
 
6
6
  module Pups
7
- class FileCommandTest < MiniTest::Test
7
+ class FileCommandTest < ::Minitest::Test
8
8
  def test_simple_file_creation
9
- tmp = Tempfile.new('test')
10
- tmp.write('x')
9
+ tmp = Tempfile.new("test")
10
+ tmp.write("x")
11
11
  tmp.close
12
12
 
13
13
  cmd = FileCommand.new
14
14
  cmd.path = tmp.path
15
- cmd.contents = 'hello $world'
16
- cmd.params = { 'world' => 'world' }
15
+ cmd.contents = "hello $world"
16
+ cmd.params = { "world" => "world" }
17
17
  cmd.run
18
18
 
19
- assert_equal('hello world',
20
- File.read(tmp.path))
19
+ assert_equal("hello world", File.read(tmp.path))
21
20
  ensure
22
21
  tmp.close
23
22
  tmp.unlink
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'tempfile'
3
+ require "test_helper"
4
+ require "tempfile"
5
5
 
6
6
  module Pups
7
- class MergeCommandTest < MiniTest::Test
7
+ class MergeCommandTest < ::Minitest::Test
8
8
  def test_deep_merge_arrays
9
- a = { a: { a: ['hi', 1] } }
10
- b = { a: { a: ['hi', 2] } }
9
+ a = { a: { a: ["hi", 1] } }
10
+ b = { a: { a: ["hi", 2] } }
11
11
  c = { a: {} }
12
12
 
13
13
  d = Pups::MergeCommand.deep_merge(a, b, :merge_arrays)
14
14
  d = Pups::MergeCommand.deep_merge(d, c, :merge_arrays)
15
15
 
16
- assert_equal(['hi', 1, 'hi', 2], d[:a][:a])
16
+ assert_equal(["hi", 1, "hi", 2], d[:a][:a])
17
17
  end
18
18
 
19
19
  def test_merges
@@ -23,7 +23,7 @@ module Pups
23
23
  password: "xyz"
24
24
  YAML
25
25
 
26
- f = Tempfile.new('test')
26
+ f = Tempfile.new("test")
27
27
  f.write source
28
28
  f.close
29
29
 
@@ -32,24 +32,27 @@ module Pups
32
32
  name: "bob2"
33
33
  YAML
34
34
 
35
- MergeCommand.from_str("#{f.path} $yaml", { 'yaml' => YAML.safe_load(merge) }).run
35
+ MergeCommand.from_str(
36
+ "#{f.path} $yaml",
37
+ { "yaml" => YAML.safe_load(merge) }
38
+ ).run
36
39
 
37
40
  changed = YAML.load_file(f.path)
38
41
 
39
- assert_equal({ 'user' => {
40
- 'name' => 'bob2',
41
- 'password' => 'xyz'
42
- } }, changed)
42
+ assert_equal(
43
+ { "user" => { "name" => "bob2", "password" => "xyz" } },
44
+ changed
45
+ )
43
46
 
44
47
  def test_deep_merge_nil
45
- a = { param: { venison: 'yes please' } }
48
+ a = { param: { venison: "yes please" } }
46
49
  b = { param: nil }
47
50
 
48
51
  r1 = Pups::MergeCommand.deep_merge(a, b)
49
52
  r2 = Pups::MergeCommand.deep_merge(b, a)
50
53
 
51
- assert_equal({ venison: 'yes please' }, r1[:param])
52
- assert_equal({ venison: 'yes please' }, r2[:param])
54
+ assert_equal({ venison: "yes please" }, r1[:param])
55
+ assert_equal({ venison: "yes please" }, r2[:param])
53
56
  end
54
57
  ensure
55
58
  f.unlink
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'test_helper'
4
- require 'tempfile'
3
+ require "test_helper"
4
+ require "tempfile"
5
5
 
6
6
  module Pups
7
- class ReplaceCommandTest < MiniTest::Test
7
+ class ReplaceCommandTest < ::Minitest::Test
8
8
  def test_simple
9
9
  command = ReplaceCommand.new({})
10
- command.text = 'hello world'
10
+ command.text = "hello world"
11
11
  command.from = /he[^o]+o/
12
- command.to = 'world'
12
+ command.to = "world"
13
13
 
14
- assert_equal('world world', command.replaced_text)
14
+ assert_equal("world world", command.replaced_text)
15
15
  end
16
16
 
17
17
  def test_reverse
@@ -21,20 +21,23 @@ module Pups
21
21
  1 one thousand 1
22
22
  SCR
23
23
 
24
- f = Tempfile.new('test')
24
+ f = Tempfile.new("test")
25
25
  f.write source
26
26
  f.close
27
27
 
28
28
  hash = {
29
- 'filename' => f.path,
30
- 'from' => '/one t.*d/',
31
- 'to' => 'hello world',
32
- 'direction' => 'reverse'
29
+ "filename" => f.path,
30
+ "from" => "/one t.*d/",
31
+ "to" => "hello world",
32
+ "direction" => "reverse"
33
33
  }
34
34
 
35
35
  command = ReplaceCommand.from_hash(hash, {})
36
36
 
37
- assert_equal("1 one thousand 1\n1 one thousand 1\n1 hello world 1\n", command.replaced_text)
37
+ assert_equal(
38
+ "1 one thousand 1\n1 one thousand 1\n1 hello world 1\n",
39
+ command.replaced_text
40
+ )
38
41
  ensure
39
42
  f.unlink
40
43
  end
@@ -46,15 +49,15 @@ module Pups
46
49
  one
47
50
  SCR
48
51
 
49
- f = Tempfile.new('test')
52
+ f = Tempfile.new("test")
50
53
  f.write source
51
54
  f.close
52
55
 
53
56
  hash = {
54
- 'filename' => f.path,
55
- 'from' => '/one/',
56
- 'to' => 'two',
57
- 'global' => 'true'
57
+ "filename" => f.path,
58
+ "from" => "/one/",
59
+ "to" => "two",
60
+ "global" => "true"
58
61
  }
59
62
 
60
63
  command = ReplaceCommand.from_hash(hash, {})
@@ -65,20 +68,16 @@ module Pups
65
68
  end
66
69
 
67
70
  def test_replace_with_env
68
- source = '123'
71
+ source = "123"
69
72
 
70
- f = Tempfile.new('test')
73
+ f = Tempfile.new("test")
71
74
  f.write source
72
75
  f.close
73
76
 
74
- hash = {
75
- 'filename' => f.path,
76
- 'from' => '123',
77
- 'to' => 'hello $hellos'
78
- }
77
+ hash = { "filename" => f.path, "from" => "123", "to" => "hello $hellos" }
79
78
 
80
- command = ReplaceCommand.from_hash(hash, { 'hello' => 'world' })
81
- assert_equal('hello worlds', command.replaced_text)
79
+ command = ReplaceCommand.from_hash(hash, { "hello" => "world" })
80
+ assert_equal("hello worlds", command.replaced_text)
82
81
  ensure
83
82
  f.unlink
84
83
  end
@@ -90,19 +89,19 @@ module Pups
90
89
  }
91
90
  SCR
92
91
 
93
- f = Tempfile.new('test')
92
+ f = Tempfile.new("test")
94
93
  f.write source
95
94
  f.close
96
95
 
97
96
  hash = {
98
- 'filename' => f.path,
99
- 'from' => "/this[^\}]+\}/m",
100
- 'to' => 'hello world'
97
+ "filename" => f.path,
98
+ "from" => "/this[^\}]+\}/m",
99
+ "to" => "hello world"
101
100
  }
102
101
 
103
102
  command = ReplaceCommand.from_hash(hash, {})
104
103
 
105
- assert_equal('hello world', command.replaced_text.strip)
104
+ assert_equal("hello world", command.replaced_text.strip)
106
105
  ensure
107
106
  f.unlink
108
107
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pups'
4
- require 'pups/cli'
5
- require 'minitest/autorun'
6
- require 'minitest/pride'
3
+ require "pups"
4
+ require "pups/cli"
5
+ require "minitest/autorun"
6
+ require "minitest/pride"
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.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-17 00:00:00.000000000 Z
11
+ date: 2023-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,7 +145,6 @@ extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
147
  - ".github/workflows/ci.yml"
148
- - ".github/workflows/lint.yml"
149
148
  - ".gitignore"
150
149
  - ".rubocop.yml"
151
150
  - CHANGELOG
@@ -179,7 +178,7 @@ homepage: ''
179
178
  licenses:
180
179
  - MIT
181
180
  metadata: {}
182
- post_install_message:
181
+ post_install_message:
183
182
  rdoc_options: []
184
183
  require_paths:
185
184
  - lib
@@ -194,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
193
  - !ruby/object:Gem::Version
195
194
  version: '0'
196
195
  requirements: []
197
- rubygems_version: 3.1.4
198
- signing_key:
196
+ rubygems_version: 3.1.6
197
+ signing_key:
199
198
  specification_version: 4
200
199
  summary: Toolkit for orchestrating a composed docker image
201
200
  test_files:
@@ -1,27 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request: {}
8
-
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: ["2.7"]
20
-
21
- steps:
22
- - uses: actions/checkout@v2
23
- - uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: ${{ matrix.ruby }}
26
- bundler-cache: true
27
- - run: bundle exec rubocop