docker-template 0.7.0 → 0.8.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
  SHA1:
3
- metadata.gz: 66e1d29c866e7782965389da6801b3976f8c8334
4
- data.tar.gz: 0a720ebb9dfd3cba920347471a9fefb0e7872fec
3
+ metadata.gz: 65d8ac03dfdfff807d45042ee8ef216ab95ed5e9
4
+ data.tar.gz: 5880b1219f93034e09a4aa2e1883b21613ceebcd
5
5
  SHA512:
6
- metadata.gz: bd655e2e1a910899c3167638c1bd02ba7f4b552a5a90eeacc655f523073b1a3939ad579ee8633ab3c4bac37695307b7e3d9f965b54727075e35384c2eae14030
7
- data.tar.gz: 0e36ded8704fe93fdb64bb0bfe6758a50fd108727b793866d3529b10759c33294da746870ffcd7008fc750bab776b4c4b3093b98318a740c8884d5bb79eac04f
6
+ metadata.gz: db84df63be77fc58635612412aad480149256d0bfe7d0c1091fe48e63c06b1253847992753ba8246f2e7f4c6060afc75406fe084ae493ecc07e9db930903a89a
7
+ data.tar.gz: 11fd17eb806960784b721c4b66f0849d484c924384a47b6fa539f4f5d5cdc253c3be37f8adfc3a30941faf8e0122c6cadb563cce4013949157b1054d8d0faa13
@@ -28,20 +28,18 @@ module Docker
28
28
  option :mocking, :type => :boolean, :desc => "Disable Certain Actions."
29
29
  option :clean, :type => :boolean, :desc => "Cleanup your caches."
30
30
 
31
+ # ----------------------------------------------------------------------
32
+ # rubocop:disable Lint/RescueException
31
33
  # ----------------------------------------------------------------------
32
34
 
33
35
  def build(*args)
34
36
  Build.new(args, options).start
37
+
35
38
  rescue Docker::Template::Error::StandardError => e
36
39
  $stderr.puts Simple::Ansi.red(e.message)
37
40
  exit e.respond_to?(:status) ? \
38
41
  e.status : 1
39
42
 
40
- rescue Excon::Errors::SocketError
41
- $stderr.puts "Unable to connect to your Docker Instance."
42
- $stderr.puts "Are you absolutely sure that you have the Docker installed?"
43
- abort "Unable to build your images."
44
-
45
43
  rescue Exception
46
44
  raise unless $ERROR_POSITION
47
45
  $ERROR_POSITION.delete_if do |source|
@@ -52,13 +50,12 @@ module Docker
52
50
  end
53
51
 
54
52
  # ----------------------------------------------------------------------
53
+ # rubocop:enable Lint/RescueException
55
54
  # docker-template list [options]
56
55
  # ----------------------------------------------------------------------
57
56
 
58
57
  desc "list [OPTS]", "List all possible builds."
59
58
 
60
- # ----------------------------------------------------------------------
61
- # rubocop:disable Metrics/AbcSize
62
59
  # ----------------------------------------------------------------------
63
60
 
64
61
  def list
@@ -19,23 +19,20 @@ module Docker
19
19
  end
20
20
  end
21
21
 
22
+ # --------------------------------------------------------------------
23
+ # rubocop:disable Metrics/AbcSize
22
24
  # --------------------------------------------------------------------
23
25
 
24
26
  def reselect_repos
25
27
  Template._require "rugged" do
26
- git = Rugged::Repository.new(".")
27
- repos_dir = Template.root.join(@opts.repos_dir)
28
- walker = Rugged::Walker.new(git)
29
- walker.push(git.last_commit)
30
-
31
- repos = git.last_commit.parents.each_with_object(Set.new) do |parent, set|
32
- git.last_commit.diff(parent).each_delta do |delta, file = delta.new_file[:path]|
33
- if Pathutil.new(file).expand_path(Template.root).in_path?(repos_dir)
34
- set.merge(file.split("/").values_at(
35
- 1
36
- ))
37
- end
38
- end
28
+ git = Rugged::Repository.new(Template.root.to_s)
29
+ dir = Template.root.join(@opts.repos_dir)
30
+
31
+ repos = git.last_commit.diff.each_delta.each_with_object(Set.new) do |delta, set|
32
+ next unless Pathutil.new(delta.new_file[:path]).expand_path(Template.root).in_path?(dir)
33
+ set.merge(delta.new_file[:path].split("/").values_at(
34
+ 1
35
+ ))
39
36
  end
40
37
 
41
38
  @repos = @repos.select do |repo|
@@ -46,6 +43,8 @@ module Docker
46
43
  end
47
44
  end
48
45
 
46
+ # --------------------------------------------------------------------
47
+ # rubocop:enable Metrics/AbcSize
49
48
  # --------------------------------------------------------------------
50
49
 
51
50
  private
@@ -3,9 +3,7 @@ module Docker
3
3
  class CLI
4
4
  class List
5
5
  def self.build
6
- return (
7
- new.build
8
- )
6
+ return new.build
9
7
  end
10
8
 
11
9
  # --------------------------------------------------------------------
@@ -19,7 +17,7 @@ module Docker
19
17
  def build
20
18
  out = ""
21
19
 
22
- @images.group_by { |image| image.user }.each do |user, images|
20
+ @images.group_by(&:user).each do |user, images|
23
21
  out += "[user] " + Simple::Ansi.blue(user) + "\n" + repos(
24
22
  user, images
25
23
  )
@@ -33,7 +31,7 @@ module Docker
33
31
  def repos(user, images)
34
32
  out = ""
35
33
 
36
- images.group_by { |image| image.name }.each do |name, image|
34
+ images.group_by(&:name).each do |name, _|
37
35
  out += " ├─ [repo] " + Simple::Ansi.green(name) + "\n"
38
36
  out += tags(user, name, images)
39
37
  out += remote_aliases(
@@ -49,9 +47,7 @@ module Docker
49
47
  def tags(user, name, images)
50
48
  out = ""
51
49
 
52
- images.select { |image| image.name == name && image.user == user \
53
- && !image.alias? }.each do |image|
54
-
50
+ images.select { |image| image.name == name && image.user == user && !image.alias? }.each do |image|
55
51
  out += " │ ├─ [tag] " + Simple::Ansi.magenta(image.tag) + "\n"
56
52
  out += aliases(
57
53
  user, name, image.tag, images
@@ -63,19 +59,22 @@ module Docker
63
59
 
64
60
  # --------------------------------------------------------------------
65
61
 
66
- def remote_aliases(user, name, images)
62
+ def remote_aliases(*args)
67
63
  out = ""
68
64
 
69
- images.select { |image| aliased_remote?(image) && image.user == user \
70
- && image.name == name }.group_by { |image| image.metadata[:aliases][image.tag] \
71
- }.each do |remote, images_|
65
+ remotes = _remote_aliases(*args).group_by do |image|
66
+ image.metadata[:aliases][
67
+ image.tag
68
+ ]
69
+ end
72
70
 
71
+ remotes.each do |remote, images_|
73
72
  out += " │ ├─ [remote] "
74
73
  out += Simple::Ansi.yellow(remote)
75
74
  out += "\n"
76
75
 
77
76
  images_.each do |image|
78
- out += " │ │ ├─ [alias] "
77
+ out += " │ │ ├─ [alias] "
79
78
  out += Simple::Ansi.yellow(
80
79
  image.tag
81
80
  )
@@ -89,20 +88,31 @@ module Docker
89
88
 
90
89
  # --------------------------------------------------------------------
91
90
 
91
+ def _remote_aliases(user, name, images)
92
+ images.select do |image|
93
+ image.user == user && image.name == name && aliased_remote?(
94
+ image
95
+ )
96
+ end
97
+ end
98
+
99
+ # --------------------------------------------------------------------
100
+
92
101
  def aliases(user, name, tag, images, depth: 0)
93
102
  out = ""
94
103
 
95
104
  _aliases(user, name, tag, images).each do |alias_|
96
- if alias_.name == name
97
- name_ = Simple::Ansi.yellow(
98
- alias_.tag
99
- )
100
-
101
- else
102
- name_ = Simple::Ansi.yellow(
103
- "#{alias_.name}:#{alias_.tag}"
104
- )
105
- end
105
+ name_ = \
106
+ if alias_.name == name
107
+ Simple::Ansi.yellow(
108
+ alias_.tag
109
+ )
110
+
111
+ else
112
+ Simple::Ansi.yellow(
113
+ "#{alias_.name}:#{alias_.tag}"
114
+ )
115
+ end
106
116
 
107
117
  out += " │ │ #{"│ " * depth}├─ [alias] #{name_}\n"
108
118
  out += aliases(user, name, alias_.tag, images, {
@@ -596,21 +596,23 @@ module Docker
596
596
 
597
597
  private
598
598
  def method_missing(method, *args, shell: false, &block)
599
- key = method.to_s.gsub(/\?$/, "")
600
- val = self[key] || self[key.singularize] \
601
- || self[key.pluralize]
599
+ key = method.to_s.gsub(/\?$/, "")
600
+ val = self[key] || self[key.singularize] \
601
+ || self[key.pluralize]
602
602
 
603
603
  if !args.empty? || block_given?
604
604
  super
605
605
 
606
606
  elsif method !~ /\?$/
607
- string_wrapper(
608
- val, :shell => shell
609
- )
607
+ string_wrapper(val, {
608
+ :shell => shell
609
+ })
610
610
 
611
611
  else
612
- val != false && !val.nil? && (val == true || (val \
613
- && val.is_a?(String) && !val.empty?))
612
+ [true, false].include?(val) ? val : \
613
+ if val.respond_to?(:empty?)
614
+ then !val.empty? else !!val
615
+ end
614
616
  end
615
617
  end
616
618
 
@@ -6,6 +6,6 @@
6
6
 
7
7
  module Docker
8
8
  module Template
9
- VERSION = "0.7.0"
9
+ VERSION = "0.8.0"
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell