donce 0.2.0 → 0.2.2

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: '09901a711fba51137272827d67c175803769b4e3c019771c283d596d1d54b27a'
4
- data.tar.gz: 59de5a9b21733ee965595d2ea500dcf5a2c55e32fdf6dd732871ae30d452de0d
3
+ metadata.gz: ff61e01863f8590b3541ca6edecbf96c4a0ee9d5fe28fbe8e30b4a001c578101
4
+ data.tar.gz: 800c5ae24c1dd36a9484ec800b6c40217b9491e61b1d89f8d170faf1e4d58471
5
5
  SHA512:
6
- metadata.gz: 54cd3837888a7dc868381c839220acf271e5e823214838cfd59804c9fd4dfcd648f8748ec327669c4b78661a5ecb257c05c0117e537f353c9230d826e6d391ba
7
- data.tar.gz: 5e1639092860793750a3066167898cee12b53116e139e33bb9db8f4685ca2911bd9de4261940599bb9c38f6e6c289bee9637af78c10bfeb5e4e2ac6bc0e3b550
6
+ metadata.gz: b7164f6f5372ff0a0fd0fff126f11d48e7fd1db042404316fa5d430113a2cd8564a249ef7c6da02a489c627b218ab224cb0d0e4174f5cde3d7ef575945f7d607
7
+ data.tar.gz: 62e270b7eeee5e3e857c2ee64cdbf7c5aa9fd476ca6a7a0f1d3d011597414d2448a840ea2e0802d672a2197e9c113d670c4ea41135b3024d48dcf1150fb9aaf5
data/.rubocop.yml CHANGED
@@ -30,4 +30,3 @@ Metrics/PerceivedComplexity:
30
30
  Enabled: false
31
31
  Layout/EmptyLineAfterGuardClause:
32
32
  Enabled: false
33
- require: []
data/Gemfile CHANGED
@@ -15,7 +15,6 @@ gem 'rubocop', '~>1.75', require: false
15
15
  gem 'rubocop-minitest', '>0', require: false
16
16
  gem 'rubocop-performance', '>0', require: false
17
17
  gem 'rubocop-rake', '>0', require: false
18
- gem 'rubocop-rspec', '>0', require: false
19
18
  gem 'simplecov', '~>0.22', require: false
20
19
  gem 'simplecov-cobertura', '~>2.1', require: false
21
20
  gem 'yard', '~>0.9', require: false
data/Gemfile.lock CHANGED
@@ -30,8 +30,8 @@ GEM
30
30
  minitest-retry (0.2.5)
31
31
  minitest (>= 5.0)
32
32
  os (1.1.4)
33
- parallel (1.26.3)
34
- parser (3.3.7.4)
33
+ parallel (1.27.0)
34
+ parser (3.3.8.0)
35
35
  ast (~> 2.4.1)
36
36
  racc
37
37
  prism (1.4.0)
@@ -45,7 +45,7 @@ GEM
45
45
  rake (13.2.1)
46
46
  regexp_parser (2.10.0)
47
47
  rexml (3.4.1)
48
- rubocop (1.75.2)
48
+ rubocop (1.75.3)
49
49
  json (~> 2.3)
50
50
  language_server-protocol (~> 3.17.0.2)
51
51
  lint_roller (~> 1.1.0)
@@ -56,7 +56,7 @@ GEM
56
56
  rubocop-ast (>= 1.44.0, < 2.0)
57
57
  ruby-progressbar (~> 1.7)
58
58
  unicode-display_width (>= 2.4.0, < 4.0)
59
- rubocop-ast (1.44.0)
59
+ rubocop-ast (1.44.1)
60
60
  parser (>= 3.3.7.2)
61
61
  prism (~> 1.4)
62
62
  rubocop-minitest (0.38.0)
@@ -70,9 +70,6 @@ GEM
70
70
  rubocop-rake (0.7.1)
71
71
  lint_roller (~> 1.1)
72
72
  rubocop (>= 1.72.1)
73
- rubocop-rspec (3.5.0)
74
- lint_roller (~> 1.1)
75
- rubocop (~> 1.72, >= 1.72.1)
76
73
  ruby-progressbar (1.13.0)
77
74
  simplecov (0.22.0)
78
75
  docile (~> 1.1)
@@ -106,7 +103,6 @@ DEPENDENCIES
106
103
  rubocop-minitest (> 0)
107
104
  rubocop-performance (> 0)
108
105
  rubocop-rake (> 0)
109
- rubocop-rspec (> 0)
110
106
  simplecov (~> 0.22)
111
107
  simplecov-cobertura (~> 2.1)
112
108
  yard (~> 0.9)
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Builds Docker image, runs it, and kills
2
2
 
3
- [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/donce)](http://www.rultor.com/p/yegor256/donce)
3
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/donce)](https://www.rultor.com/p/yegor256/donce)
4
4
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
5
 
6
6
  [![rake](https://github.com/yegor256/donce/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/donce/actions/workflows/rake.yml)
7
- [![PDD status](http://www.0pdd.com/svg?name=yegor256/donce)](http://www.0pdd.com/p?name=yegor256/donce)
8
- [![Gem Version](https://badge.fury.io/rb/donce.svg)](http://badge.fury.io/rb/donce)
7
+ [![PDD status](https://www.0pdd.com/svg?name=yegor256/donce)](https://www.0pdd.com/p?name=yegor256/donce)
8
+ [![Gem Version](https://badge.fury.io/rb/donce.svg)](https://badge.fury.io/rb/donce)
9
9
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/donce.svg)](https://codecov.io/github/yegor256/donce?branch=master)
10
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/donce/master/frames)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/donce/master/frames)
11
11
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/donce)](https://hitsofcode.com/view/github/yegor256/donce)
12
12
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/donce/blob/master/LICENSE.txt)
13
13
 
@@ -42,18 +42,18 @@ end
42
42
 
43
43
  Here's a list of the available parameters for `donce`:
44
44
 
45
- - `dockerfile`: Content of the Dockerfile (string or array of strings)
46
- - `home`: Directory with Dockerfile and all other necessary files
47
- - `image`: Name of a Docker image to use (e.g. "ubuntu:22.04")
48
- - `log`: Logging destination (defaults to $stdout)
49
- - `args`: Extra arguments for the docker command
50
- - `env`: Environment variables mapping for the container
51
- - `volumes`: Local to container volumes mapping
52
- - `ports`: Local to container port mapping
53
- - `build_args`: Arguments for docker build (--build-arg)
54
- - `root`: Let user inside the container be "root" (default: false)
55
- - `command`: The command to execute in the container
56
- - `timeout`: Maximum seconds to spend on each docker call (default: 10)
45
+ * `dockerfile`: Content of the Dockerfile (string or array of strings)
46
+ * `home`: Directory with Dockerfile and all other necessary files
47
+ * `image`: Name of a Docker image to use (e.g. "ubuntu:22.04")
48
+ * `log`: Logging destination (defaults to $stdout)
49
+ * `args`: Extra arguments for the docker command
50
+ * `env`: Environment variables mapping for the container
51
+ * `volumes`: Local to container volumes mapping
52
+ * `ports`: Local to container port mapping
53
+ * `build_args`: Arguments for docker build (--build-arg)
54
+ * `root`: Let user inside the container be "root" (default: false)
55
+ * `command`: The command to execute in the container
56
+ * `timeout`: Maximum seconds to spend on each docker call (default: 10)
57
57
 
58
58
  The function `donce_host()` returns the hostname of the host machine that
59
59
  can be used from within the container.
data/Rakefile CHANGED
@@ -37,5 +37,4 @@ require 'rubocop/rake_task'
37
37
  desc 'Run RuboCop on all directories'
38
38
  RuboCop::RakeTask.new(:rubocop) do |task|
39
39
  task.fail_on_error = true
40
- task.requires << 'rubocop-rspec'
41
40
  end
data/donce.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
10
  s.required_ruby_version = '>=3.0'
11
11
  s.name = 'donce'
12
- s.version = '0.2.0'
12
+ s.version = '0.2.2'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Builds and starts temporary Docker containers'
15
15
  s.description =
data/lib/donce.rb CHANGED
@@ -73,6 +73,21 @@ module Kernel
73
73
  raise 'Either use "image" or "home"' if home && image
74
74
  raise 'Either "dockerfile", or "home", or "image" must be provided' if !dockerfile && !home && !image
75
75
  raise 'The "timeout" must be an integer or nil' unless timeout.nil? || timeout.is_a?(Integer)
76
+ raise 'The "volumes" is nil' if volumes.nil?
77
+ raise 'The "volumes" must be a Hash' unless volumes.is_a?(Hash)
78
+ raise 'The "log" is nil' if log.nil?
79
+ raise 'The "args" is nil' if args.nil?
80
+ raise 'The "args" must be a String' unless args.is_a?(String)
81
+ raise 'The "env" is nil' if env.nil?
82
+ raise 'The "env" must be a Hash' unless env.is_a?(Hash)
83
+ raise 'The "command" is nil' if command.nil?
84
+ raise 'The "command" must be a String' unless command.is_a?(String)
85
+ raise 'The "timeout" is nil' if timeout.nil?
86
+ raise 'The "timeout" must be a number' unless timeout.is_a?(Integer) || timeout.is_a?(Float)
87
+ raise 'The "ports" is nil' if ports.nil?
88
+ raise 'The "ports" must be a Hash' unless ports.is_a?(Hash)
89
+ raise 'The "build_args" is nil' if build_args.nil?
90
+ raise 'The "build_args" must be a Hash' unless build_args.is_a?(Hash)
76
91
  docker = ENV['DONCE_SUDO'] ? 'sudo docker' : 'docker'
77
92
  img =
78
93
  if image
@@ -82,7 +97,7 @@ module Kernel
82
97
  a = [
83
98
  "--tag #{i}",
84
99
  build_args.map { |k, v| "--build-arg #{Shellwords.escape("#{k}=#{v}")}" }.join(' ')
85
- ].join(' ')
100
+ ].compact.join(' ')
86
101
  if dockerfile
87
102
  Dir.mktmpdir do |tmp|
88
103
  dockerfile = dockerfile.join("\n") if dockerfile.is_a?(Array)
@@ -97,23 +112,23 @@ module Kernel
97
112
  i
98
113
  end
99
114
  container = "donce-#{SecureRandom.hex(6)}"
115
+ stdout = nil
116
+ code = 0
117
+ cmd = [
118
+ docker, 'run',
119
+ ('--detach' if block_given?),
120
+ '--name', Shellwords.escape(container),
121
+ ("--add-host #{donce_host}:host-gateway" if OS.linux?),
122
+ args,
123
+ env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
124
+ ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
125
+ volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
126
+ ("--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}" if root),
127
+ Shellwords.escape(img),
128
+ command
129
+ ].compact.join(' ')
100
130
  begin
101
- stdout = nil
102
- code = 0
103
131
  begin
104
- cmd = [
105
- docker, 'run',
106
- block_given? ? '--detach' : nil,
107
- '--name', Shellwords.escape(container),
108
- OS.linux? ? nil : "--add-host #{donce_host}:host-gateway",
109
- args,
110
- env.map { |k, v| "--env #{Shellwords.escape("#{k}=#{v}")}" }.join(' '),
111
- ports.map { |k, v| "--publish #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
112
- volumes.map { |k, v| "--volume #{Shellwords.escape("#{k}:#{v}")}" }.join(' '),
113
- root ? nil : "--user=#{Shellwords.escape("#{Process.uid}:#{Process.gid}")}",
114
- Shellwords.escape(img),
115
- command
116
- ].compact.join(' ')
117
132
  stdout, code =
118
133
  Timeout.timeout(timeout) do
119
134
  qbash(
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: donce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-07 00:00:00.000000000 Z
10
+ date: 2025-04-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backtrace