rake_docker 0.1.0 → 0.3.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: 920a8d5f5e985c853a8b1c83e61918a5b71429de
4
- data.tar.gz: 9a6087f99f297ae118aeb77c9812fbfc655887b0
3
+ metadata.gz: 7f0670d5964650486c71eef2618217cfdfa90e52
4
+ data.tar.gz: 744d08187889a515b2eabbc04fd14bb140ac5886
5
5
  SHA512:
6
- metadata.gz: b2849b6a6c17929bdd8f458173ae3ad095bbaddbb23b9de40529fc2bea89edb42ad4779d01a46a2b291abe0edfb884bb6d083f5ab5ad905efad481f4419cb421
7
- data.tar.gz: 9991c7c7b78fd072eaa8b0b9786cf2fad0090c92693f7fd2e5dcfc8558a1f69b9d3474514de60422c694de82a3065e6439f167cef10d316417806fb6d55f9de5
6
+ metadata.gz: b6c10b6a64a9934604db529720a4e59952c535e94a2d801627d4d7b7a43aa4b5d05ab033fa39ee80c92faeba06dd892da781eaf69ad5513b83658248bc289400
7
+ data.tar.gz: c0b3f1c626025c792446c6f221cfee72288de7d4cecf7fb9688916c1b55a675dcb20e4c4389f849ea69786f55f140b9613789f7d81c1a27bfaaa0dd40d559bc7
@@ -1,37 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_docker (0.1.0)
4
+ rake_docker (0.3.0)
5
+ docker-api (~> 1.33)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ activesupport (4.2.9)
11
+ i18n (~> 0.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
9
15
  diff-lcs (1.3)
16
+ docile (1.1.5)
17
+ docker-api (1.33.6)
18
+ excon (>= 0.38.0)
19
+ json
20
+ excon (0.57.1)
10
21
  gem-release (0.7.4)
22
+ i18n (0.8.4)
23
+ json (2.1.0)
24
+ memfs (1.0.0)
25
+ minitest (5.10.2)
11
26
  rake (10.5.0)
12
- rspec (3.5.0)
13
- rspec-core (~> 3.5.0)
14
- rspec-expectations (~> 3.5.0)
15
- rspec-mocks (~> 3.5.0)
16
- rspec-core (3.5.4)
17
- rspec-support (~> 3.5.0)
18
- rspec-expectations (3.5.0)
27
+ rspec (3.6.0)
28
+ rspec-core (~> 3.6.0)
29
+ rspec-expectations (~> 3.6.0)
30
+ rspec-mocks (~> 3.6.0)
31
+ rspec-core (3.6.0)
32
+ rspec-support (~> 3.6.0)
33
+ rspec-expectations (3.6.0)
19
34
  diff-lcs (>= 1.2.0, < 2.0)
20
- rspec-support (~> 3.5.0)
21
- rspec-mocks (3.5.0)
35
+ rspec-support (~> 3.6.0)
36
+ rspec-mocks (3.6.0)
22
37
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.5.0)
24
- rspec-support (3.5.0)
38
+ rspec-support (~> 3.6.0)
39
+ rspec-support (3.6.0)
40
+ simplecov (0.14.1)
41
+ docile (~> 1.1.0)
42
+ json (>= 1.8, < 3)
43
+ simplecov-html (~> 0.10.0)
44
+ simplecov-html (0.10.1)
45
+ thread_safe (0.3.6)
46
+ tzinfo (1.2.3)
47
+ thread_safe (~> 0.1)
25
48
 
26
49
  PLATFORMS
27
50
  ruby
28
51
 
29
52
  DEPENDENCIES
53
+ activesupport (~> 4.2)
30
54
  bundler (~> 1.14)
31
55
  gem-release (~> 0.7)
56
+ memfs (~> 1.0)
32
57
  rake (~> 10.0)
33
58
  rake_docker!
34
59
  rspec (~> 3.0)
60
+ simplecov (~> 0.13)
35
61
 
36
62
  BUNDLED WITH
37
63
  1.14.5
@@ -1,4 +1,5 @@
1
1
  require 'rake_docker/version'
2
+ require 'rake_docker/tasks'
2
3
 
3
4
  module RakeDocker
4
5
  end
@@ -0,0 +1,4 @@
1
+ module RakeDocker
2
+ class RequiredParameterUnset < ::StandardError
3
+ end
4
+ end
@@ -0,0 +1,98 @@
1
+ require 'rake/tasklib'
2
+ require_relative 'exceptions'
3
+
4
+ module RakeDocker
5
+ class TaskLib < ::Rake::TaskLib
6
+ class << self
7
+ def parameter_definitions
8
+ @parameter_definitions ||= {}
9
+ end
10
+
11
+ def parameter(name, options = {})
12
+ parameter_definition = ParameterDefinition.new(
13
+ name, options[:default], options[:required])
14
+ name = parameter_definition.name
15
+
16
+ attr_accessor(name)
17
+
18
+ parameter_definitions[name] = parameter_definition
19
+ end
20
+
21
+ def setup_defaults_for(instance)
22
+ parameter_definitions.values.each do |parameter_definition|
23
+ parameter_definition.apply_default_to(instance)
24
+ end
25
+ end
26
+
27
+ def check_required_for(instance)
28
+ dissatisfied = parameter_definitions.values.reject do |definition|
29
+ definition.satisfied_by?(instance)
30
+ end
31
+ unless dissatisfied.empty?
32
+ names = dissatisfied.map(&:name)
33
+ raise RequiredParameterUnset,
34
+ "Required parameter#{names.length > 1 ? 's' : ''} #{names.join(',')} unset."
35
+ end
36
+ end
37
+ end
38
+
39
+ def initialize(*args, &block)
40
+ setup_defaults
41
+ process_arguments(args)
42
+ process_block(block)
43
+ check_required
44
+ define
45
+ end
46
+
47
+ def setup_defaults
48
+ self.class.setup_defaults_for(self)
49
+ end
50
+
51
+ def process_arguments(_)
52
+ end
53
+
54
+ def process_block(block)
55
+ block.call(self) if block
56
+ end
57
+
58
+ def check_required
59
+ self.class.check_required_for(self)
60
+ end
61
+
62
+ def define
63
+ end
64
+
65
+ private
66
+
67
+ class ParameterDefinition
68
+ attr_reader :name
69
+
70
+ def initialize(name, default = nil, required = false)
71
+ @name = name.to_sym
72
+ @default = default
73
+ @required = required
74
+ end
75
+
76
+ def writer_method
77
+ "#{name}="
78
+ end
79
+
80
+ def reader_method
81
+ name
82
+ end
83
+
84
+ def apply_default_to(instance)
85
+ instance.__send__(writer_method, @default) if @default
86
+ end
87
+
88
+ def dissatisfied_by?(instance)
89
+ value = instance.__send__(reader_method)
90
+ @required && value.nil?
91
+ end
92
+
93
+ def satisfied_by?(instance)
94
+ !dissatisfied_by?(instance)
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'tasks/prepare'
2
+ require_relative 'tasks/build'
@@ -0,0 +1,30 @@
1
+ require 'docker'
2
+ require_relative '../tasklib'
3
+
4
+ module RakeDocker
5
+ module Tasks
6
+ class Build < TaskLib
7
+ parameter :name, :default => :build
8
+
9
+ parameter :image_name, :required => true
10
+ parameter :repository_name, :required => true
11
+
12
+ parameter :work_directory, :required => true
13
+
14
+ def process_arguments(args)
15
+ self.name = args[0] if args[0]
16
+ end
17
+
18
+ def define
19
+ desc "Build #{image_name} image"
20
+ task name do
21
+ Docker::Image.build_from_dir(
22
+ File.join(work_directory, image_name),
23
+ {t: repository_name}) do |chunk|
24
+ $stdout.puts chunk
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,53 @@
1
+ require_relative '../tasklib'
2
+
3
+ module RakeDocker
4
+ module Tasks
5
+ class Prepare < TaskLib
6
+ parameter :name, :default => :prepare
7
+
8
+ parameter :image_name, :required => true
9
+
10
+ parameter :work_directory, :required => true
11
+
12
+ parameter :copy_spec, :default => []
13
+ parameter :create_spec, :default => []
14
+
15
+ def process_arguments(args)
16
+ self.name = args[0] if args[0]
17
+ end
18
+
19
+ def define
20
+ desc "Prepare for build of #{image_name} image"
21
+ task name do
22
+ image_directory = File.join(work_directory, image_name)
23
+ mkdir_p image_directory
24
+
25
+ copy_spec.each do |entry|
26
+ from = entry.is_a?(Hash) ? entry[:from] : entry
27
+ to = entry.is_a?(Hash) ?
28
+ File.join(image_directory, entry[:to]) :
29
+ image_directory
30
+
31
+ if File.directory?(from)
32
+ mkdir_p to
33
+ cp_r from, to
34
+ else
35
+ cp from, to
36
+ end
37
+ end
38
+
39
+ create_spec.each do |entry|
40
+ content = entry[:content]
41
+ to = entry[:to]
42
+ file = File.join(image_directory, to)
43
+
44
+ mkdir_p(File.dirname(file))
45
+ File.open(file, 'w') do |f|
46
+ f.write(content)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module RakeDocker
2
- VERSION = '0.1.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -21,8 +21,15 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.required_ruby_version = '>= 2.0'
25
+
26
+ spec.add_dependency 'docker-api', '~> 1.33'
27
+
24
28
  spec.add_development_dependency 'bundler', '~> 1.14'
25
29
  spec.add_development_dependency 'rake', '~> 10.0'
26
30
  spec.add_development_dependency 'rspec', '~> 3.0'
27
31
  spec.add_development_dependency 'gem-release', '~> 0.7'
32
+ spec.add_development_dependency 'activesupport', '~> 4.2'
33
+ spec.add_development_dependency 'memfs', '~> 1.0'
34
+ spec.add_development_dependency 'simplecov', '~> 0.13'
28
35
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2017-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docker-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.33'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.33'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,48 @@ dependencies:
66
80
  - - ~>
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '4.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '4.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: memfs
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '0.13'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '0.13'
69
125
  description: Allows building, tagging and pushing images and creating, starting, stopping
70
126
  and removing containers from within rake tasks.
71
127
  email:
@@ -86,6 +142,11 @@ files:
86
142
  - bin/console
87
143
  - bin/setup
88
144
  - lib/rake_docker.rb
145
+ - lib/rake_docker/exceptions.rb
146
+ - lib/rake_docker/tasklib.rb
147
+ - lib/rake_docker/tasks.rb
148
+ - lib/rake_docker/tasks/build.rb
149
+ - lib/rake_docker/tasks/prepare.rb
89
150
  - lib/rake_docker/version.rb
90
151
  - rake_docker.gemspec
91
152
  homepage: https://github.com/tobyclemson/rake_docker
@@ -100,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
161
  requirements:
101
162
  - - '>='
102
163
  - !ruby/object:Gem::Version
103
- version: '0'
164
+ version: '2.0'
104
165
  required_rubygems_version: !ruby/object:Gem::Requirement
105
166
  requirements:
106
167
  - - '>='