docker-rainbow 0.1.5 → 0.1.6

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: 730c043f484f68f40d55db9b10a193f345e0b29e
4
- data.tar.gz: 4aff75bd0074a35c1e99d7c95277c811b8e8a007
3
+ metadata.gz: 746c45c4160ff3dfad98a8a1a8587e4aa5ffa0e6
4
+ data.tar.gz: 4e82aac522206cf8c791245db17659babeb1837c
5
5
  SHA512:
6
- metadata.gz: 885ac7ae6efadb0d61907f6f78ffdc40e4f74091c2d70dfabfffb1c4968a78686cb39d7d80bb8f13f4b7f79159b74a8c24984c2184fc171321c1fb4a46f3cc73
7
- data.tar.gz: 97897f515b6ed46e9d7a57f3ec8993c1e57f7f12fc4b8a0ddcaa905ce8f29f65ff7cf8051330ffbf7cf5a14174a5f91666f6100999cd91d690669aa585474b22
6
+ metadata.gz: 5de446b922c8f7590feb487d190c3bfe428b37fa86af79f2a82f02812206c151fa04fd5827b40452ae51b262abaa6bdadc558b7a19fc58c1beb2d4c28b9161af
7
+ data.tar.gz: b20e1eb174fc45f39ff1bb12f6bd7a22385d6156086a28819c14628f76156a22ab8f3b2d0ccaeff0dae43eda9db8c94afa9ccb3898f4667855fde3a784e1a49a
@@ -26,6 +26,10 @@ module Docker
26
26
  # of the world. (That's what `docker logs` is for...)
27
27
  PALETTE = ['blue', 'green', 'orange', 'red', 'yellow', 'violet'].freeze
28
28
 
29
+ # Pattern that matches useless pieces of image names, which we exclude
30
+ # from the resulting containers' names. _Everything_ is a service...
31
+ NOISE_WORDS = /[_.-]service$/.freeze
32
+
29
33
  # Pattern that matches any container name allowed by Docker.
30
34
  VALID_NAME = /^[a-zA-Z0-9][a-zA-Z0-9_.-]+$/.freeze
31
35
 
@@ -126,7 +130,7 @@ module Docker
126
130
  end
127
131
 
128
132
  # Strip noise-word suffixes from image name
129
- base.sub!(/_service$/, '')
133
+ base.sub!(NOISE_WORDS, '')
130
134
 
131
135
  base
132
136
  end
@@ -151,10 +155,11 @@ module Docker
151
155
  output.each { |dead| self.class.shell("docker rm #{dead}") }
152
156
  end
153
157
 
158
+ # @param [Array] containers list of String container names
159
+ # @return [Array] subset of containers that match a running container's name
154
160
  def find_in_use(containers)
155
- words = ['docker', 'ps', '--format={{.Names}}']
156
- containers.each { |cn| words << "--filter=name=#{cn}" }
157
- self.class.shell(words.join(' '))
161
+ in_use = Set.new(self.class.shell('docker ps --format={{.Names}}'))
162
+ containers.select { |cn| in_use.include?(cn) }
158
163
  end
159
164
 
160
165
  # Workalike for Object#present? but without dragging in activesupport
@@ -1,5 +1,5 @@
1
1
  module Docker
2
2
  class Rainbow
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-rainbow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Spataro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler