docker_core 0.0.22 → 0.0.23
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 +4 -4
- data/lib/docker_core.rb +40 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80affaf62801f9396342f5e34a9b4d7d9c60cbb7734eb072c53fd639a0128795
|
4
|
+
data.tar.gz: fb93776e06070bcf7633f4307d0c2fb16e0c1c447c1548dd57618319c61dd7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357c0774652360108f2a5cc9773b482999a3f454b0af977ab609b80618fbe8a2157af83d8bc1041afa1e0056f2aa7e7b61ec2f5fa60b56a7caff996296b07d8e
|
7
|
+
data.tar.gz: 861b83b14df2c399f64a5a580dc61281414c0c581528118d38cbcdd044e09c79387fb334930c170b0197b3bd7f6c84a2739efb064112f60011131d26d034e926
|
data/lib/docker_core.rb
CHANGED
@@ -56,15 +56,20 @@ module DockerCore
|
|
56
56
|
|
57
57
|
if hash.is_a?(Hash)
|
58
58
|
hash.each do |key, value|
|
59
|
-
|
59
|
+
short = 1 == key.length
|
60
|
+
prefix = short ? '-' : '--'
|
61
|
+
separator = short ? ' ' : '='
|
62
|
+
name = prefix + self.kebab(key)
|
60
63
|
|
61
64
|
if true == value
|
62
65
|
items << name
|
63
66
|
next
|
64
67
|
end
|
65
68
|
|
66
|
-
value
|
67
|
-
|
69
|
+
[value].flatten.each do |item|
|
70
|
+
item = "#{item}".gsub(/\\/, '\&\&').gsub('"', '\"')
|
71
|
+
items << %(#{name}#{separator}"#{item}")
|
72
|
+
end
|
68
73
|
next
|
69
74
|
end
|
70
75
|
end
|
@@ -96,22 +101,39 @@ module DockerCore
|
|
96
101
|
end
|
97
102
|
|
98
103
|
module Process
|
104
|
+
# @param [Numeric] duration
|
105
|
+
def self.wait(duration = 0)
|
106
|
+
if duration.is_a?(Numeric)
|
107
|
+
if 0 > duration
|
108
|
+
return sleep
|
109
|
+
end
|
110
|
+
if 0 < duration
|
111
|
+
return sleep(duration)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
99
116
|
# @param [Array] arguments
|
100
|
-
# @param [Boolean] substitute
|
117
|
+
# @param [Boolean, String] substitute
|
101
118
|
def self.command(*arguments, substitute: false)
|
102
|
-
if substitute
|
103
|
-
arguments.unshift('
|
119
|
+
if true == substitute
|
120
|
+
arguments.unshift('sudo')
|
121
|
+
end
|
122
|
+
|
123
|
+
if substitute.is_a?(String) && false == "#{substitute}".empty?
|
124
|
+
arguments.unshift('su-exec', substitute)
|
104
125
|
end
|
105
126
|
|
106
127
|
return Paser.arguments(*arguments).join(' ')
|
107
128
|
end
|
108
129
|
|
109
130
|
# @param [Array] arguments
|
110
|
-
# @param [Boolean] substitute
|
131
|
+
# @param [Boolean, String] substitute
|
111
132
|
# @param [Boolean] exception
|
133
|
+
# @param [Numeric] duration
|
112
134
|
# @param [Boolean] strip
|
113
135
|
# @param [Boolean] verbose
|
114
|
-
def self.capture(*arguments, substitute: false, exception: false, strip: true, verbose: false)
|
136
|
+
def self.capture(*arguments, substitute: false, exception: false, duration: 0, strip: true, verbose: false)
|
115
137
|
begin
|
116
138
|
command = self.command(*arguments, substitute: substitute)
|
117
139
|
|
@@ -120,7 +142,9 @@ module DockerCore
|
|
120
142
|
end
|
121
143
|
|
122
144
|
data = `#{command}`
|
123
|
-
|
145
|
+
result = strip ? "#{data}".strip : data
|
146
|
+
self.wait(duration)
|
147
|
+
return result
|
124
148
|
rescue
|
125
149
|
raise unless exception
|
126
150
|
return ''
|
@@ -128,16 +152,19 @@ module DockerCore
|
|
128
152
|
end
|
129
153
|
|
130
154
|
# @param [Array] arguments
|
131
|
-
# @param [Boolean] substitute
|
155
|
+
# @param [Boolean, String] substitute
|
132
156
|
# @param [Boolean] exception
|
133
|
-
|
157
|
+
# @param [Numeric] duration
|
158
|
+
def self.run(*arguments, substitute: false, exception: true, duration: 0)
|
134
159
|
command = self.command(*arguments, substitute: substitute)
|
135
160
|
Color.echo("+ #{command}", Color::GREEN)
|
136
|
-
|
161
|
+
result = system(command, exception: exception)
|
162
|
+
self.wait(duration)
|
163
|
+
return result
|
137
164
|
end
|
138
165
|
|
139
166
|
# @param [Array] arguments
|
140
|
-
# @param [Boolean] substitute
|
167
|
+
# @param [Boolean, String] substitute
|
141
168
|
def self.execute(*arguments, substitute: false)
|
142
169
|
command = self.command(*arguments, substitute: substitute)
|
143
170
|
Color.echo("= #{command}", Color::CYAN)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agrozyme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|