dockerize 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Njg4NjU1MjBhNDkyMmFlMzMwYjhiODIzNDM3MzEwY2RiMzM2NDg2Mg==
5
- data.tar.gz: !binary |-
6
- Nzg0ZjUwNmE4YWUwZWY0MmFjYjczZDlkZmI2NTQwYzZkNGUwOTczMQ==
2
+ SHA1:
3
+ metadata.gz: 2fb873e9820733594e16b8c88b4d4603189ccc8c
4
+ data.tar.gz: d4ffb2154a773bdae945299ad18e0642d87a8ce5
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTg2OTdjMGJiZDJmYWRlYWJmNTMyYTgzNjczNjU0YjcyMzJmZTNlNzY0YmY2
10
- MTVkMjVlZDRjMGQwN2EzNGU4YTNhMDIxZWNiZmVhZDdmMjY0YWY2ZTJiZTZl
11
- YmVlMTViOWU0NThlNmMxOTkxMjczYjYyZjFhZGEzYTE0YzYyZDE=
12
- data.tar.gz: !binary |-
13
- ZTVmMTQ3ZmFhNGM5YWFjZjE2MzNmMGNkZWJmM2IyNjlkNzJkMGUzOTJhYjg1
14
- OTE2YTdkYjY4MTU5YjExYzhiMGNiYzc1YzdlNjA0ZGNhODcwYWVmMzU3N2I5
15
- MmFmNjRkZWU0Y2M2ODgxYTQxYTU1NDIxNWIyNjc2YTVhN2I5Mjc=
6
+ metadata.gz: 2fde2e35bea4bd76bbd9ce7f3ef5e3b7b7f9b2610400fe7407e366d1abf4338fb4797b5b5a8b88314883d890dc00642d6bf5fa184ade5d867ffa4a312b25ad2a
7
+ data.tar.gz: 77ecfa15da9c46fcb3372cb94f306dd6c295e1064e97a144671ec390a50c99ce849307de55d74bee638e328c950f1e00417ed1443d9336db5ce4f29ca94099e0
data/.rspec CHANGED
@@ -1,3 +1,4 @@
1
1
  --color
2
2
  --require spec_helper
3
3
  --require English
4
+ --order rand
data/.rubocop.yml CHANGED
@@ -1,8 +1,4 @@
1
1
  ---
2
- AllCops:
3
- Excludes:
4
- - vendor/**
5
-
6
2
  Documentation:
7
3
  Enabled: false
8
4
 
data/bin/dockerize CHANGED
@@ -2,14 +2,11 @@
2
2
  # coding: utf-8
3
3
 
4
4
  lib = File.expand_path('../../lib', __FILE__)
5
- vendor = File.expand_path('../../vendor', __FILE__)
6
5
 
7
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
- $LOAD_PATH.unshift(vendor) unless $LOAD_PATH.include?(vendor)
9
7
 
10
8
  require 'dockerize'
11
9
  require 'dockerize/cli'
12
- require 'colored'
13
10
 
14
11
  Dockerize::Cli.run(ARGV)
15
12
  exit 0
data/bin/dockerize-unpack CHANGED
@@ -41,7 +41,7 @@ function main() {
41
41
  }
42
42
 
43
43
  function fetch() {
44
- $DOCKER run -v /tmp/docker-bridge:/bridge "$ARGS" "$IMAGE" /docker/run/bridge
44
+ $DOCKER run -v /tmp/docker-bridge:/bridge $ARGS "$IMAGE" /docker/run/bridge
45
45
  tar -xzf /tmp/docker-bridge/run.tar.gz
46
46
  }
47
47
 
data/dockerize.gemspec CHANGED
@@ -1,9 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
- vendor = File.expand_path('../vendor', __FILE__)
4
3
 
5
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
- $LOAD_PATH.unshift(vendor) unless $LOAD_PATH.include?(vendor)
7
5
 
8
6
  require 'dockerize/version'
9
7
 
@@ -22,7 +20,7 @@ Gem::Specification.new do |gem|
22
20
  gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
21
  gem.bindir = 'bin'
24
22
  gem.test_files = gem.files.grep(%r{^spec/})
25
- gem.require_paths = %w(lib vendor)
23
+ gem.require_paths = %w(lib)
26
24
  gem.required_ruby_version = '>= 1.9.3'
27
25
 
28
26
  gem.add_development_dependency 'rake'
@@ -32,5 +30,5 @@ Gem::Specification.new do |gem|
32
30
  gem.add_development_dependency 'pry' unless RUBY_PLATFORM == 'java'
33
31
  gem.add_development_dependency 'simplecov' unless RUBY_PLATFORM == 'java'
34
32
 
35
- gem.add_runtime_dependency 'syck' if RUBY_VERSION.split('.').first.to_i >= 2
33
+ gem.add_runtime_dependency 'colorize'
36
34
  end
data/lib/dockerize/cli.rb CHANGED
@@ -28,8 +28,7 @@ module Dockerize
28
28
  end
29
29
 
30
30
  def all_templates
31
- Dir["#{Dockerize::Config.template_dir}/**/*.erb"] |
32
- Dir["#{Dockerize::Config.template_dir}/**/*.erb"]
31
+ Dir["#{Dockerize::Config.template_dir}/**/*.erb"]
33
32
  end
34
33
 
35
34
  def set_out_stream
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  # rubocop:disable MethodLength, ClassLength, CyclomaticComplexity
3
3
 
4
- require 'trollop'
4
+ require 'optparse'
5
5
 
6
6
  module Dockerize
7
7
  class Config
@@ -10,83 +10,88 @@ module Dockerize
10
10
  attr_accessor :opts
11
11
 
12
12
  def parse(args)
13
- config = self
14
-
15
- Trollop.options(args) do
16
- text "Usage: dockerize <project directory> [options]\nOptions:\n"
17
-
13
+ # defaults
14
+ @opts = {
15
+ quiet: false,
16
+ dry_run: false,
17
+ force: false,
18
+ backup: true,
19
+ registry: ENV['DOCKERIZE_REGISTRY'] || 'quay.io/modcloth',
20
+ template_dir: ENV['DOCKERIZE_TEMPLATE_DIR'] || "#{top}/templates",
21
+ maintainer: ENV['DOCKERIZE_MAINTAINER'] ||
22
+ "#{ENV['USER']} <#{ENV['USER']}@example.com>",
23
+ from: ENV['DOCKERIZE_FROM'] || 'ubuntu:12.04',
24
+ }
25
+
26
+ OptionParser.new do |opt|
18
27
  # -q/--quiet
19
- opt :quiet, 'Silence output', type: :flag, short: 'q', default: false
28
+ opt.on('-q', '--[no-]quiet', 'Silence output') do |q|
29
+ opts[:quiet] = q
30
+ end
20
31
 
21
32
  # -d/--dry-run
22
- opt :dry_run, 'Dry run, do not write any files',
23
- type: :flag,
24
- short: 'd',
25
- default: false
33
+ opt.on(
34
+ '-d', '--[no-]dry-run', 'Dry run, do not write any files'
35
+ ) do |d|
36
+ opts[:dry_run] = d
37
+ end
26
38
 
27
39
  # -f/--force
28
- opt :force, 'Force existing files to be overwritten',
29
- type: :flag,
30
- short: 'f',
31
- default: false
40
+ opt.on(
41
+ '-f', '--[no-]force', 'Force existing files to be overwritten'
42
+ ) { |f| opts[:force] = f }
32
43
 
33
44
  # -b/--backup
34
- opt :backup, 'Creates .bak version of files before overwriting them',
35
- type: :flag,
36
- short: 'b',
37
- default: true
45
+ opt.on(
46
+ '-b',
47
+ '--[no-]backup',
48
+ 'Creates .bak version of files before overwriting them',
49
+ ) { |b| opts[:backup] = b }
38
50
 
39
51
  # -r/--registry
40
- opt :registry, 'The Docker registry to use when writing files',
41
- type: :string,
42
- short: 'r',
43
- default: ENV['DOCKERIZE_REGISTRY'] || 'quay.io/modcloth'
52
+ opt.on(
53
+ '-r REGISTRY',
54
+ '--registry REGISTRY',
55
+ 'The Docker registry to use when writing files'
56
+ ) { |r| opts[:registry] = r }
44
57
 
45
58
  # -t/--template-dir
46
- opt :template_dir,
47
- 'The directory containing the templates to be written',
48
- type: :string,
49
- short: 't',
50
- default: ENV['DOCKERIZE_TEMPLATE_DIR'] ||
51
- "#{config.top}/templates"
59
+ opt.on(
60
+ '-t TEMPLATE_DIR',
61
+ '--template-dir TEMPLATE_DIR',
62
+ 'The directory containing the templates to be written',
63
+ ) { |t| opts[:template_dir] = t }
52
64
 
53
65
  # -m/--maintainer
54
- opt :maintainer,
55
- 'The default MAINTAINER to use for any Dockerfiles written',
56
- type: :string,
57
- short: 'm',
58
- default: ENV['DOCKERIZE_MAINTAINER'] ||
59
- "#{ENV['USER']} <#{ENV['USER']}@example.com>"
66
+ opt.on(
67
+ '-m MAINTAINER',
68
+ '--maintainer MAINTAINER',
69
+ 'The default MAINTAINER to use for any Dockerfiles written'
70
+ ) { |m| opts[:maintainer] = m }
60
71
 
61
72
  # -F/--from
62
- opt :from,
63
- 'The default base image to use for any Dockerfiles written',
64
- type: :string,
65
- short: 'F',
66
- default: ENV['DOCKERIZE_FROM'] || 'ubuntu:12.04'
67
-
68
- version "dockerize #{Dockerize::VERSION}"
69
-
70
- begin
71
- config.send(:opts=, parse(args))
72
- rescue Trollop::CommandlineError => e
73
- $stderr.puts "Error: #{e.message}."
74
- $stderr.puts 'Try --help for help.'
75
- exit 1
76
- rescue Trollop::HelpNeeded
77
- educate
78
- exit
79
- rescue Trollop::VersionNeeded
80
- $stderr.puts version
73
+ opt.on(
74
+ '-F FROM',
75
+ '--from FROM',
76
+ 'The default base image to use for any Dockerfiles written'
77
+ ) { |f| opts[:from] = f }
78
+
79
+ # -h/--help
80
+ opt.on_tail('-h', '--help', 'Display this message') do
81
+ $stderr.puts opt.help
81
82
  exit
82
83
  end
83
84
 
84
- config.send(:opts)[:top] = config.top
85
- config.send(:generate_accessor_methods, self)
86
- end
85
+ # -v/--version
86
+ opt.on_tail('-v', '--version', 'Show version and exit') do
87
+ $stderr.puts "dockerize #{Dockerize::VERSION}"
88
+ exit
89
+ end
90
+ end.parse!(args)
87
91
 
88
92
  self.project_dir = args[0]
89
93
  set_project_name unless opts[:project_name]
94
+ generate_accessor_methods
90
95
  end
91
96
 
92
97
  def project_dir=(dir)
@@ -126,13 +131,15 @@ module Dockerize
126
131
  klass.send(:define_method, name.to_sym, &block)
127
132
  end
128
133
 
129
- def generate_accessor_methods(parser)
130
- parser.specs.map do |k, v|
131
- case v[:type]
132
- when *Trollop::Parser::FLAG_TYPES
133
- add_method("#{k}?") { @opts[k] }
134
- when :string
135
- add_method("#{k}") { @opts[k] }
134
+ def generate_accessor_methods
135
+ opts.each do |k, v|
136
+ case v
137
+ when TrueClass, FalseClass
138
+ add_method("#{k}?") { opts[k] }
139
+ when String
140
+ add_method("#{k}") { opts[k] }
141
+ else
142
+ fail OptionParser::InvalidOption, "Invalid option #{k}"
136
143
  end
137
144
  end
138
145
  end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'fileutils'
4
- require 'colored'
4
+ require 'colorize'
5
5
 
6
6
  module Dockerize
7
7
  class DocumentWriter
@@ -2,6 +2,6 @@
2
2
 
3
3
  unless defined?(Dockerize::VERSION)
4
4
  module Dockerize
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -144,6 +144,42 @@ describe Dockerize::Config do
144
144
  run '.'
145
145
  config.template_dir.should == "#{top}/templates"
146
146
  end
147
+
148
+ it 'sets the template dir correctly' do
149
+ tmpdir do |tmp|
150
+ run %W(. --template-dir #{tmp})
151
+ config.template_dir.should == tmp
152
+ end
153
+ end
154
+ end
155
+
156
+ describe 'maintainer' do
157
+ let(:maintainer) { 'Foo Bar <foobar@example.com>' }
158
+
159
+ it 'sets the correct default maintainer' do
160
+ run '.'
161
+ config.maintainer.should ==
162
+ "#{ENV['USER']} <#{ENV['USER']}@example.com>"
163
+ end
164
+
165
+ it 'sets the maintainer as specified' do
166
+ run %W(. --maintainer #{maintainer})
167
+ config.maintainer.should == maintainer
168
+ end
169
+ end
170
+
171
+ describe 'from' do
172
+ let(:from) { 'base_image' }
173
+
174
+ it 'sets the correct default base image' do
175
+ run '.'
176
+ config.from.should == 'ubuntu:12.04'
177
+ end
178
+
179
+ it 'sets the base image as specified' do
180
+ run %W(. --from #{from})
181
+ config.from.should == from
182
+ end
147
183
  end
148
184
  end
149
185
 
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,6 @@ require 'bundler/setup'
5
5
  require 'simplecov' unless RUBY_PLATFORM == 'java'
6
6
  require 'pry' unless RUBY_PLATFORM == 'java'
7
7
  require 'tmpdir'
8
- require 'colored'
9
8
 
10
9
  def tmpdir(&block)
11
10
  Dir.mktmpdir('dockerize-spec') do |tmp|
metadata CHANGED
@@ -1,85 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafe Colton
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
15
  version_requirements: !ruby/object:Gem::Requirement
23
16
  requirements:
24
- - - ! '>='
17
+ - - '>='
25
18
  - !ruby/object:Gem::Version
26
19
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
20
  requirement: !ruby/object:Gem::Requirement
30
21
  requirements:
31
- - - ! '>='
22
+ - - '>='
32
23
  - !ruby/object:Gem::Version
33
24
  version: '0'
34
- type: :development
35
25
  prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
36
29
  version_requirements: !ruby/object:Gem::Requirement
37
30
  requirements:
38
- - - ! '>='
31
+ - - '>='
39
32
  - !ruby/object:Gem::Version
40
33
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rubocop
43
34
  requirement: !ruby/object:Gem::Requirement
44
35
  requirements:
45
- - - ! '>='
36
+ - - '>='
46
37
  - !ruby/object:Gem::Version
47
38
  version: '0'
48
- type: :development
49
39
  prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
50
43
  version_requirements: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ! '>='
45
+ - - '>='
53
46
  - !ruby/object:Gem::Version
54
47
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
48
  requirement: !ruby/object:Gem::Requirement
58
49
  requirements:
59
- - - ! '>='
50
+ - - '>='
60
51
  - !ruby/object:Gem::Version
61
52
  version: '0'
62
- type: :development
63
53
  prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
64
57
  version_requirements: !ruby/object:Gem::Requirement
65
58
  requirements:
66
- - - ! '>='
59
+ - - '>='
67
60
  - !ruby/object:Gem::Version
68
61
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
62
  requirement: !ruby/object:Gem::Requirement
72
63
  requirements:
73
- - - ! '>='
64
+ - - '>='
74
65
  - !ruby/object:Gem::Version
75
66
  version: '0'
76
- type: :development
77
67
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ! '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ type: :runtime
83
69
  description: Dockerizes your application
84
70
  email:
85
71
  - r.colton@modcloth.com
@@ -122,34 +108,30 @@ files:
122
108
  - templates/run_makefile_run.erb
123
109
  - templates/vagrant_provision_sh.erb
124
110
  - templates/vagrantfile.erb
125
- - vendor/colored.rb
126
- - vendor/trollop.rb
127
111
  homepage: https://github.com/modcloth-labs/dockerize
128
112
  licenses:
129
113
  - MIT
130
114
  metadata: {}
131
- post_install_message:
115
+ post_install_message:
132
116
  rdoc_options: []
133
117
  require_paths:
134
118
  - lib
135
- - vendor
136
119
  required_ruby_version: !ruby/object:Gem::Requirement
137
120
  requirements:
138
- - - ! '>='
121
+ - - '>='
139
122
  - !ruby/object:Gem::Version
140
123
  version: 1.9.3
141
124
  required_rubygems_version: !ruby/object:Gem::Requirement
142
125
  requirements:
143
- - - ! '>='
126
+ - - '>='
144
127
  - !ruby/object:Gem::Version
145
128
  version: '0'
146
129
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.1.11
149
- signing_key:
130
+ rubyforge_project:
131
+ rubygems_version: 2.1.9
132
+ signing_key:
150
133
  specification_version: 4
151
- summary: Creates a templated Dockerfile and corresponding support files for easy deployment
152
- with docker.
134
+ summary: Creates a templated Dockerfile and corresponding support files for easy deployment with docker.
153
135
  test_files:
154
136
  - spec/lib/dockerize/cli_spec.rb
155
137
  - spec/lib/dockerize/config_spec.rb
@@ -157,4 +139,3 @@ test_files:
157
139
  - spec/lib/dockerize/template_parser_spec.rb
158
140
  - spec/lib/dockerize_spec.rb
159
141
  - spec/spec_helper.rb
160
- has_rdoc:
data/vendor/colored.rb DELETED
@@ -1,93 +0,0 @@
1
- require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
2
-
3
- # Source: https://github.com/defunkt/colored
4
-
5
- ##
6
- # cute.
7
- #
8
- # >> "this is red".red
9
- #
10
- # >> "this is red with a blue background (read: ugly)".red_on_blue
11
- #
12
- # >> "this is red with an underline".red.underline
13
- #
14
- # >> "this is really bold and really blue".bold.blue
15
- #
16
- # >> Colored.red "This is red" # but this part is mostly untested
17
- module Colored
18
- extend self
19
-
20
- COLORS = {
21
- 'black' => 30,
22
- 'red' => 31,
23
- 'green' => 32,
24
- 'yellow' => 33,
25
- 'blue' => 34,
26
- 'magenta' => 35,
27
- 'cyan' => 36,
28
- 'white' => 37
29
- }
30
-
31
- EXTRAS = {
32
- 'clear' => 0,
33
- 'bold' => 1,
34
- 'underline' => 4,
35
- 'reversed' => 7
36
- }
37
-
38
- COLORS.each do |color, value|
39
- define_method(color) do
40
- colorize(self, :foreground => color)
41
- end
42
-
43
- define_method("on_#{color}") do
44
- colorize(self, :background => color)
45
- end
46
-
47
- COLORS.each do |highlight, value|
48
- next if color == highlight
49
- define_method("#{color}_on_#{highlight}") do
50
- colorize(self, :foreground => color, :background => highlight)
51
- end
52
- end
53
- end
54
-
55
- EXTRAS.each do |extra, value|
56
- next if extra == 'clear'
57
- define_method(extra) do
58
- colorize(self, :extra => extra)
59
- end
60
- end
61
-
62
- define_method(:to_eol) do
63
- tmp = sub(/^(\e\[[\[\e0-9;m]+m)/, "\\1\e[2K")
64
- if tmp == self
65
- return "\e[2K" << self
66
- end
67
- tmp
68
- end
69
-
70
- def colorize(string, options = {})
71
- colored = [color(options[:foreground]), color("on_#{options[:background]}"), extra(options[:extra])].compact * ''
72
- colored << string
73
- colored << extra(:clear)
74
- end
75
-
76
- def colors
77
- @@colors ||= COLORS.keys.sort
78
- end
79
-
80
- def extra(extra_name)
81
- extra_name = extra_name.to_s
82
- "\e[#{EXTRAS[extra_name]}m" if EXTRAS[extra_name]
83
- end
84
-
85
- def color(color_name)
86
- background = color_name.to_s =~ /on_/
87
- color_name = color_name.to_s.sub('on_', '')
88
- return unless color_name && COLORS[color_name]
89
- "\e[#{COLORS[color_name] + (background ? 10 : 0)}m"
90
- end
91
- end unless Object.const_defined? :Colored
92
-
93
- String.send(:include, Colored)