docker_core 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docker_core.rb +72 -7
  3. metadata +33 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a77f2201287c6af232ebeda6fe7fe0cd4d1bc301b86fb60caeca4e7387ee157
4
- data.tar.gz: ad6fba9eed456d1fa920ed7f546794fcf2565c3284bc31a57d90b12b9cf3b69f
3
+ metadata.gz: 371e1413099d4658b296b5714e83e06812fe15afaf01cbbe7d01f5ed24268a21
4
+ data.tar.gz: afc6b37af0efa2efcba144acd5da64e8cdb2713e9b35c915103c5de73fa54793
5
5
  SHA512:
6
- metadata.gz: 8ece0499929f77b55ade2b0b0e7b252a8125cb32f28649bdb58b03567274b58bdf70fe896363f64dfd0673dd820bd0d63da87596deb17e42856031093eabe6b0
7
- data.tar.gz: 843255729a75cc256828282a4657d86066d45946e249c6e86005f49c9bac31329929d444927f56c86becaac910f1cc1b3116a1b4443f45bef202593f71c70706
6
+ metadata.gz: dfb32fd0c0f6893dc79cbb37ad8b644d112d032a2183def70b903418346399369be0f1169ed4cb646bf1807f55f6fdadf6a4850916dd7cb3940977e21a0258c0
7
+ data.tar.gz: fdc17291808d10147b1b67aabd1ae202b12174fdb02bc661585e12cf9e8972a5a78be678e0c2393c97e9fa7ae4a44a470a2d14f6dc1ce3ef878f877807d82a27
data/lib/docker_core.rb CHANGED
@@ -1,6 +1,11 @@
1
+ require('fileutils')
2
+ require('open-uri')
3
+
1
4
  module DockerCore
2
5
  COLOR_CODE = { error: 31, info: 32, warn: 33 }
3
6
 
7
+ # @param [String] text
8
+ # @param [Integer] code
4
9
  def self.color(text, code)
5
10
  escape = "\033"
6
11
  prefix = "#{escape}[#{code}m"
@@ -8,17 +13,25 @@ module DockerCore
8
13
  return "#{prefix}#{text}#{suffix}"
9
14
  end
10
15
 
16
+ # @param [String] text
17
+ # @param [Integer] code
11
18
  def self.echo(text, code = self::COLOR_CODE[:info])
12
19
  puts(self.color(text, code))
13
20
  end
14
21
 
15
- def self.execute(text, run, *argumets)
22
+ # @param [String] title
23
+ # @param [Method] run
24
+ # @param [Array] argumets
25
+ def self.execute(title, run, *argumets)
16
26
  code = self::COLOR_CODE[:warn]
17
- self.echo("> Begin: #{text}", code)
18
- self.send(run, *argumets)
19
- self.echo("> End: #{text}", code)
27
+ self.echo("> #{title}", code)
28
+ run.call(*argumets)
29
+ self.echo("< #{title}", code)
20
30
  end
21
31
 
32
+ # @param [String] command
33
+ # @param [Boolean] echo
34
+ # @param [Boolean] throw
22
35
  def self.run(command, echo = true, throw = true)
23
36
  if echo
24
37
  self.echo("+ #{command}")
@@ -33,12 +46,64 @@ module DockerCore
33
46
  end
34
47
  end
35
48
 
36
- def self.update_user
37
- uid = ENV.fetch('DOCKER_CORE_UID', '500')
38
- gid = ENV.fetch('DOCKER_CORE_GID', '500')
49
+ # @param [Integer] uid
50
+ # @param [Integer] gid
51
+ def self.update_user(uid = 500, gid = 500)
52
+ uid = ENV.fetch('DOCKER_CORE_UID', uid)
53
+ gid = ENV.fetch('DOCKER_CORE_GID', gid)
39
54
  self.run('deluser core')
40
55
  self.run('delgroup core')
41
56
  self.run("addgroup --system --gid=#{gid} core")
42
57
  self.run("adduser --system --disabled-password --no-create-home --ingroup=core --gecos=core --shell=/bin/bash --uid=#{uid} core")
43
58
  end
59
+
60
+ # @param [Array<String>] arguments
61
+ def self.chown(*arguments)
62
+ arguments.each do |list|
63
+ FileUtils.chown_R('core', 'core', list)
64
+ end
65
+ return
66
+ end
67
+
68
+ # @param [Array<String>] arguments
69
+ def self.mkdir(*arguments)
70
+ arguments.each do |list|
71
+ FileUtils.mkdir_p(list)
72
+ end
73
+ self.chown(*arguments)
74
+ end
75
+
76
+ # @param [String] value
77
+ def self.to_boolean(value)
78
+ return %w[true yes on].include?(value.strip.downcase)
79
+ end
80
+
81
+ # @param [String] stdout
82
+ # @param [String] stderr
83
+ def self.link_log(stdout = '', stderr = '')
84
+ if '' != stdout
85
+ File.symlink('/dev/stdout', stdout)
86
+ end
87
+
88
+ if '' != stderr
89
+ File.symlink('/dev/stderr', stderr)
90
+ end
91
+ return
92
+ end
93
+
94
+ # @param [String] uri
95
+ # @param [String] file
96
+ def self.download(uri, file)
97
+ IO.copy_stream(URI.open(uri), file)
98
+ end
99
+
100
+ # @param [Array<String>] arguments
101
+ def self.clear_path(*arguments)
102
+ arguments.each do |list|
103
+ FileUtils.rm_rf(list)
104
+ end
105
+
106
+ self.mkdir(*arguments)
107
+ end
108
+
44
109
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - agrozyme
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fileutils
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: open-uri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  description:
14
42
  email:
15
43
  executables: []
@@ -17,7 +45,7 @@ extensions: []
17
45
  extra_rdoc_files: []
18
46
  files:
19
47
  - lib/docker_core.rb
20
- homepage:
48
+ homepage: https://gitlab.com/agrozyme-package/ruby/docker_core
21
49
  licenses: []
22
50
  metadata: {}
23
51
  post_install_message:
@@ -28,7 +56,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
28
56
  requirements:
29
57
  - - ">="
30
58
  - !ruby/object:Gem::Version
31
- version: '0'
59
+ version: 2.5.0
32
60
  required_rubygems_version: !ruby/object:Gem::Requirement
33
61
  requirements:
34
62
  - - ">="