docker-porcelain 0.3.0 → 0.4.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: 9abf4d5591b1dc167a974d44a7b585ee079775a3
4
- data.tar.gz: a8e2a32ad64087d40f19be336350c26652662ccc
3
+ metadata.gz: acbbeaece88fb50e2ab2c5a09ac595c1744c98f4
4
+ data.tar.gz: 4b07eaf27c0a074b6b0f9cdd1605847eff342ed0
5
5
  SHA512:
6
- metadata.gz: 50f831bddf3502bf4e9684245d24e6c9437122aff4cc318b18d514dd3765fc04fbf05a32a39f937355f56ee2950b648ee89046005719770f09a7bf8cd8777ba7
7
- data.tar.gz: e32d4a549030bee551c600aaf0118dcd6cc005158fe20d9333628758b26a4674c7f84b6c87dffc23180815f1de1e2b19623c2d8ac48ebcc5fb2f0c82a2515c60
6
+ metadata.gz: 56a09b2edc22dd7187dce2e11091caefb0440035f482079ee8bc435af89093db3cf2c685f017c1ebf0e3f9c3fe2ba3e2c2c2a026261077089d236f17daa2302d
7
+ data.tar.gz: b8c0884746948fb3cf3c3da29c7f8bcabc34b80ecb4b9c9baffcf25a8f8b3f5d9797b1623610ef7e6140ec1693fed4fefd94f415d10f4496178c17364b25ee63
data/README.md CHANGED
@@ -65,6 +65,7 @@ container.write '/tmp/foo', 'This is the foo file!'
65
65
  ## Synopsis
66
66
 
67
67
  ```ruby
68
+ container = Docker::Container['my-container']
68
69
  container.write '/tmp/foo', 'This is the foo file!'
69
70
  container.system 'true' or fail "there's no truth in the container!"
70
71
  uptime = container.` 'uptime'
@@ -95,6 +95,20 @@ module Docker
95
95
  # @return [Fixnum] exit status of the last command ran with {#system}
96
96
  # or {#`}
97
97
  attr_reader :last_exitstatus
98
+
99
+ # Class-level container porcelain methods
100
+ module ClassMethods
101
+ # Get container specified by id or name
102
+ # @param id [String] identifier or name of the container to get
103
+ # @return [Docker::Container, nil] container or nil if not found
104
+ def [] id
105
+ Docker::Container.get id
106
+ rescue Docker::Error::NotFoundError
107
+ nil
108
+ end
109
+ end
110
+
111
+ extend ClassMethods
98
112
  end
99
113
  end
100
114
  end
@@ -7,6 +7,7 @@ require 'docker'
7
7
  module Docker
8
8
  class Container
9
9
  include Docker::Porcelain::Container
10
+ extend Docker::Porcelain::Container::ClassMethods
10
11
  end
11
12
 
12
13
  class Image
@@ -68,6 +68,7 @@ module Docker
68
68
  private
69
69
 
70
70
  def self.repo_tag_to_hash repo = nil, tag = nil
71
+ return {} unless repo
71
72
  repo, tag = repo.split ':' unless tag
72
73
  { 'repo' => repo, 'tag' => tag }
73
74
  end
@@ -9,6 +9,10 @@ module Docker
9
9
  include Docker::Porcelain::Container
10
10
  end
11
11
 
12
+ refine Docker::Container.singleton_class do
13
+ include Docker::Porcelain::Container::ClassMethods
14
+ end
15
+
12
16
  refine Docker::Image do
13
17
  include Docker::Porcelain::Image
14
18
  end
@@ -1,5 +1,5 @@
1
1
  module Docker
2
2
  module Porcelain
3
- VERSION = '0.3.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-porcelain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Rzepecki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-24 00:00:00.000000000 Z
11
+ date: 2015-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api