docker-api 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ require 'cgi'
2
2
  require 'json'
3
3
  require 'excon'
4
4
  require 'tempfile'
5
+ require 'rubygems/package'
5
6
  require 'archive/tar/minitar'
6
7
 
7
8
  # The top-level module for this gem. It's purpose is to hold global
@@ -12,19 +12,19 @@ class Docker::Container
12
12
  end
13
13
 
14
14
  # Get more information about the Container.
15
- get :json
15
+ request :get, :json
16
16
  # Wait for the current command to finish executing.
17
- post :wait
17
+ request :post, :wait
18
18
  # Start the Container.
19
- post :start
19
+ request :post, :start
20
20
  # Inspect the Container's changes to the filesysetem
21
- get :changes
21
+ request :get, :changes
22
22
  # Stop the Container.
23
- post :stop
23
+ request :post, :stop
24
24
  # Kill the Container.
25
- post :kill
25
+ request :post, :kill
26
26
  # Restart the Container
27
- post :restart
27
+ request :post, :restart
28
28
 
29
29
  # Export the Container as a tar.
30
30
  def export(&block)
@@ -14,11 +14,11 @@ class Docker::Image
14
14
  end
15
15
 
16
16
  # Tag the Image.
17
- post :tag
17
+ request :post, :tag
18
18
  # Get more information about the Image.
19
- get :json
19
+ request :get, :json
20
20
  # Get the history of the Image.
21
- get :history
21
+ request :get, :history
22
22
 
23
23
  # Given a command and optional list of streams to attach to, run a command on
24
24
  # an Image. This will not modify the Image, but rather create a new Container
@@ -104,19 +104,11 @@ class Docker::Image
104
104
  end
105
105
 
106
106
  def create_tar(input)
107
- cwd = FileUtils.pwd
108
- path = "/tmp/docker/tar-#{rand(10000)}"
109
- string = StringIO.new
110
- tar = Archive::Tar::Minitar::Output.new(string)
111
- FileUtils.mkdir_p(path)
112
- FileUtils.cd(path)
113
- file = File.new('Dockerfile', 'w')
114
- file.write(input)
115
- file.close
116
- Archive::Tar::Minitar.pack_file("Dockerfile", tar)
117
- FileUtils.cd(cwd)
118
- FileUtils.rm_rf(path)
119
- string.tap(&:rewind)
107
+ output = StringIO.new
108
+ Gem::Package::TarWriter.new(output) do |tar|
109
+ tar.add_file('Dockerfile', '640') { |tar_file| tar_file.write(input) }
110
+ end
111
+ output.tap(&:rewind)
120
112
  end
121
113
 
122
114
  def create_dir_tar(directory)
@@ -8,8 +8,8 @@ module Docker::Model
8
8
  def self.included(base)
9
9
  base.class_eval do
10
10
  extend ClassMethods
11
- private_class_method :new, :request, :get, :put, :post, :delete,
12
- :set_create_request, :set_resource_prefix
11
+ private_class_method :new, :request, :set_create_request,
12
+ :set_resource_prefix
13
13
  end
14
14
  end
15
15
 
@@ -58,10 +58,6 @@ module Docker::Model
58
58
  end
59
59
  end
60
60
 
61
- [:get, :put, :post, :delete].each do |method|
62
- define_method(method) { |*args, &block| request(method, *args, &block) }
63
- end
64
-
65
61
  # Create a Model with the specified body. Raises a
66
62
  # Docker::Error::ArgumentError if the argument is not a Hash. Otherwise,
67
63
  # instances execs the Class's #create_request method with the single
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.1.0'
3
+ VERSION = '1.1.1'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: