baha 0.1.1 → 0.2.0

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
- ZjdhNDQ0OGVkNzBlMzZiNGYyMTEyNDNlNmYzZWM5YjEwMDA5MDJlNQ==
5
- data.tar.gz: !binary |-
6
- YWMwZmM3MmZkZjY5OThlZjA1MWNlZWQ0NzYyZmM1NDg0MTkxZjk2MQ==
2
+ SHA1:
3
+ metadata.gz: ba8affb543e198dab103735a8532129b4f665467
4
+ data.tar.gz: 157902c703a3a0a23235357ae5a4ca452ba45140
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MDRkZTdkNmM5MTdmOGRhMGMyNDIzOTJmMzRmYzI2Mjk3MTQwYWE5ZjlmYTNm
10
- MjAzZTc2YmM1N2JjMTFhNjYzODI2MzZkM2NlNjgyMzEyOGUyYTk4ZTQ3MzA3
11
- YTk2YjY5Zjg5Yjk2ODg1OGU5YmM0YjZiNTI4NDM0YTM2NTcxMTM=
12
- data.tar.gz: !binary |-
13
- NDM1YTRhYWI5YTIxZTI1MjlmMDNiM2I4YzI3ZDBhZmQwZmZhMGMwYWUxM2Zj
14
- ZTY5NWU4Mjc3NDkzYjBhYTA4MDdhYTBkMTFjY2VkODVhYTAxODJkZTY0MDU5
15
- ZDg2OWU5MzFkMzU0ZTM3MjA5ODAyMjhhNWNkNmEwMDQ2ZDU1MmQ=
6
+ metadata.gz: 73584d341c995c1342d132a4f3a0cb9113e788563418585a66328e3900211d45fdd8d7cd343c26844a68f58e5fccad1064fc48d553235eecb799bfc361bbb13b
7
+ data.tar.gz: 7000c9c1aa3a59905bcfbcf58406bba7bf20c4b7455fbb819bda789f85ceacb8118fa1b3706ed634f01df3b1e7c1c9a7ee244c2dbf30377c62d16e7c6cb4affc
@@ -5,10 +5,10 @@ before_install:
5
5
  - gem update
6
6
  script: bundle exec rake spec
7
7
  rvm:
8
- - 1.9.2
9
- - 1.9.3
10
8
  - 2.0.0
11
9
  - 2.1.0
10
+ - 2.1.2
11
+ - ruby-head
12
12
  addons:
13
13
  code_climate:
14
14
  repo_token: 3356d0b9dcd4f188c9ac115df5e27359c336a0db8fb36f79cf8859688d564ac6
@@ -0,0 +1,9 @@
1
+ FROM ruby:2.1
2
+ RUN bundle config --global frozen 1
3
+ RUN mkdir -p /usr/src/app && mkdir -p /baha && mkdir -p /workspace
4
+ COPY . /usr/src/app
5
+ WORKDIR /usr/src/app
6
+ RUN bundle install && bundle exec rake install
7
+ COPY docker-entrypoint.sh /entrypoint.sh
8
+ WORKDIR /baha
9
+ ENTRYPOINT ["/bin/bash","/entrypoint.sh"]
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
+ #ruby=2.1.0
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in Baha.gemspec
4
5
  gemspec
5
6
 
6
- gem "codeclimate-test-reporter", group: :test, require: nil
7
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Baha
1
+ Baha
2
2
  =======
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/baha.png)](http://badge.fury.io/rb/baha)
@@ -24,7 +24,7 @@ Baha attempts to address the shortcomings of Dockerfiles by factoring out redund
24
24
  ### 1. Baha forbids more than 1 layer per image
25
25
 
26
26
  If you split statements across multiple `RUN` statements, each of these results in a new layer.
27
- The more commands you run, the more layers you create. If you want to *minimize the number of layers* (See [Official Recommendations](https://docs.docker.com/articles/dockerfile_best-practices/))
27
+ The more commands you run, the more layers you create. If you want to *minimize the number of layers* (See [Official Recommendations](https://docs.docker.com/articles/dockerfile_best-practices/))
28
28
  then you must ensure that all statements can be condensed into one line - sacrificing maintainability in the process.
29
29
 
30
30
  Baha encourages using scripts instead of `RUN` statements to ensure that only one layer is created per image.
@@ -32,7 +32,7 @@ Baha encourages using scripts instead of `RUN` statements to ensure that only on
32
32
  ### 2. Baha encourages smaller images
33
33
 
34
34
  The nature of the way the dockerfiles are processed means that each command you run commits a new image.
35
- This means, that if you have a `RUN` statement that downloads packages for installation.
35
+ This means, that if you have a `RUN` statement that downloads packages for installation.
36
36
  This will commit a layer with the installation files. Later on if you clean up these files with further `RUN` commands, they will still exist in your image lineage - thus having no space savings. Without proper precautions, you'll end up having unnecessarily large images.
37
37
 
38
38
  Baha ensures that all setup tasks happen in a single commit - so you can write cleanup statements and be assured that they will indeed be absent in the resulting images.
@@ -48,10 +48,10 @@ Baha will rebuild your entire lineage if the base image changes, but will not re
48
48
 
49
49
  **Caveat**
50
50
 
51
- Baha relies on tagging your releases, noticing when the tag has changed, and treating tags as immutable.
51
+ Baha relies on tagging your releases, noticing when the tag has changed, and treating tags as immutable.
52
52
  This is analogous to how **git** treats tags.
53
53
 
54
- Tagging your images is another best-practice ([2](http://crosbymichael.com/dockerfile-best-practices-take-2.html): #5) anyway, so this is encouraged by design.
54
+ Tagging your images is another best-practice ([2](http://crosbymichael.com/dockerfile-best-practices-take-2.html): #5) anyway, so this is encouraged by design.
55
55
 
56
56
  Bottom line is: If you change your image, you should change the tag/version.
57
57
 
@@ -128,7 +128,7 @@ Options:
128
128
  # Default: STDOUT
129
129
 
130
130
  Description:
131
- Reads the given Dockerfile and outputs a Baha-compatible image.yml
131
+ Reads the given Dockerfile and outputs a Baha-compatible image.yml
132
132
  which can be included or embedded within a CONFIG
133
133
  ```
134
134
 
@@ -180,6 +180,52 @@ It will build each image in the order they appear by doing the following.
180
180
  ### Tags the resulting image
181
181
  Adds the appropriate tags to the image as defined in the image config for both the remote registry and local repository.
182
182
 
183
+ Baha inside Docker
184
+ ------------------
185
+
186
+ If you'd like to use baha completely inside docker, you can follow these additional instructions.
187
+
188
+
189
+ ### 1. Build baha as a docker image
190
+
191
+ Included with this git repository is a `Dockerfile`. Run the following command inside your working-copy to create a new local container called 'baha'
192
+
193
+ ```
194
+ docker build -t baha .
195
+ ```
196
+
197
+ ### 2. Copy docker-baha.sh to somewhere in your $PATH and make it executable
198
+ ```
199
+ cp docker-baha.sh /usr/local/bin/baha
200
+ chmod 755 /usr/local/bin/baha
201
+ ```
202
+
203
+ ### 3. Set up your environment
204
+
205
+ There are a few environment variables that Baha needs in order to work within docker.
206
+
207
+ **BAHA_MOUNT** is the location on the docker host that contains the config files. By default, this is the current working directory: `$PWD`
208
+
209
+ **BAHA_WORKSPACE_MOUNT** is the location where files generated by the build process will be stored and also where Baha will instruct docker to mount volumes from. By default, this is `$BAHA_MOUNT/workspace`
210
+
211
+ **DOCKER_SOCKET** is the location of the unix socket for communicating with docker. baha-docker.sh mounts this inside the container so that it can interact with docker directly. By default, this is `/var/run/docker.sock` which should be correct for **boot2docker** and Linux, unless you've modified the path.
212
+
213
+ *Note*: **boot2docker** only mounts `/Users`, so setting `BAHA_MOUNT` or `BAHA_WORKSPACE_MOUNT` outside this setting will not work.
214
+
215
+ #### Example
216
+
217
+ ```
218
+ export BAHA_MOUNT=/Users/myself/baha
219
+ export BAHA_WORKSPACE_MOUNT=/Users/mysql/baha/workspace
220
+ export DOCKER_SOCKET=/var/run/docker.sock
221
+ ```
222
+
223
+ ### Run baha as you would normally
224
+
225
+ ```
226
+ baha build example.yml
227
+ ```
228
+
183
229
  How to Contribute
184
230
  -----------------
185
231
 
@@ -0,0 +1,13 @@
1
+ #! /bin/bash
2
+ BAHA_MOUNT=${BAHA_MOUNT:-$PWD}
3
+ BAHA_WORKSPACE_MOUNT=${BAHA_WORKSPACE_MOUNT:-"$BAHA_MOUNT/workspace"}
4
+ DOCKER_SOCKET=${DOCKER_SOCK:-"/var/run/docker.sock"}
5
+
6
+ docker run --rm \
7
+ -v $BAHA_MOUNT:/baha \
8
+ -v $BAHA_WORKSPACE_MOUNT:/workspace \
9
+ -v $DOCKER_SOCKET:/var/run/docker.sock \
10
+ -e BAHA_MOUNT=$BAHA_MOUNT \
11
+ -e BAHA_WORKSPACE_MOUNT=$BAHA_WORKSPACE_MOUNT \
12
+ -e DOCKER_HOST=unix:///var/run/docker.sock \
13
+ baha "$@"
@@ -0,0 +1,11 @@
1
+ #! /bin/bash
2
+
3
+ echo "===================================="
4
+ echo "==== Removing old baha docker image"
5
+ echo "===================================="
6
+ docker rmi baha
7
+
8
+ echo "===================================="
9
+ echo "==== Building image"
10
+ echo "===================================="
11
+ docker build -t baha .
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+ cd /baha
3
+ baha "$@"
@@ -42,7 +42,7 @@ class Builder
42
42
  build_log.info { "Skipped image #{image.name} - No update needed" }
43
43
  next
44
44
  end
45
-
45
+
46
46
  ## Prepare Workspace
47
47
  workspace = Pathname.new(@config.workspace) + image.name
48
48
  unless workspace.exist?
@@ -54,7 +54,7 @@ class Builder
54
54
  ## Image Run Config
55
55
  if image.run
56
56
  build_log.debug { "Image has RUN commands"}
57
- run = '.init.sh'
57
+ run = '.init.sh'
58
58
  File.open(workspace + run,'w') do |f|
59
59
  f.write("#!/bin/sh\n")
60
60
  f.write("set -xe\n")
@@ -97,7 +97,7 @@ class Builder
97
97
 
98
98
  build_log.debug { "Running container for #{image.name}: #{command}" }
99
99
  container.start({
100
- 'Binds' => "#{image.workspace.expand_path}:#{image.bind}"
100
+ 'Binds' => "#{image.host_mount.expand_path}:#{image.bind}"
101
101
  })
102
102
 
103
103
  begin
@@ -107,7 +107,7 @@ class Builder
107
107
  when :stdout
108
108
  build_log.info { "++ #{msg.chomp}" }
109
109
  when :stderr
110
- build_log.warn { "++ #{msg.chomp}" }
110
+ build_log.warn { "++ #{msg.chomp}" }
111
111
  end
112
112
  end
113
113
  ## Wait for finish
@@ -2,9 +2,11 @@ require 'yaml'
2
2
  require 'pathname'
3
3
  require 'baha/log'
4
4
  require 'baha/dockerfile'
5
+ require 'baha/refinements'
5
6
 
6
7
  module Baha
7
8
  class Config
9
+ using Baha::Refinements
8
10
  DEFAULTS = {
9
11
  :parent => 'ubuntu:14.04.1',
10
12
  :bind => '/.baha',
@@ -18,6 +20,7 @@ class Config
18
20
  def load(file)
19
21
  LOG.debug { "Loading file #{file}"}
20
22
  filepath = Pathname.new(file)
23
+ LOG.debug { "Loading file #{filepath.expand_path}"}
21
24
  raise ArgumentError.new("Cannot read config file #{file}") unless filepath.readable?
22
25
  config = YAML.load_file(filepath)
23
26
  config['configdir'] ||= filepath.dirname
@@ -30,49 +33,20 @@ class Config
30
33
 
31
34
  def initialize(config)
32
35
  @config = config
33
-
36
+ config_workspace
37
+
34
38
  # Defaults
35
39
  defaults = config['defaults'] || {}
36
40
  raise ArgumentError.new("Expected Hash for defaults") unless defaults.is_a?(Hash)
37
41
  @defaults = {}
38
42
  DEFAULTS.keys.each do |k|
39
- @defaults[k] = defaults[k] || defaults[k.to_s] || DEFAULTS[k]
43
+ @defaults[k] = defaults[k] || DEFAULTS[k]
40
44
  end
41
-
42
- @configdir = Pathname.new(config['configdir'] || Pathname.pwd)
43
- @workspace = Pathname.new(config['workspace'] || @configdir + 'workspace')
44
45
  @secure = false
45
46
  @options = {}
46
47
  init_security if ENV.has_key?('DOCKER_CERT_PATH') || config.has_key?('ssl')
47
48
  end
48
49
 
49
- def init_security
50
- @secure = true
51
- cert_path = ''
52
- ssl_options = { }
53
- if ENV['DOCKER_CERT_PATH']
54
- cert_path = Pathname.new(ENV['DOCKER_CERT_PATH'])
55
- ssl_options[:ssl_verify_peer] = (ENV['DOCKER_TLS_VERIFY'] == '1')
56
- ssl_options[:client_cert] = (cert_path + 'cert.pem').expand_path.to_s
57
- ssl_options[:client_key] = (cert_path + 'key.pem').expand_path.to_s
58
- ssl_options[:ssl_ca_file] = (cert_path + 'ca.pem').expand_path.to_s
59
- elsif @config.has_key?('ssl')
60
- ssl = @config['ssl']
61
- ssl_options[:ssl_verify_peer] = ssl['verify'] || false
62
- if ssl.has_key?('cert_path')
63
- cert_path = Pathname.new(ssl['cert_path'])
64
- ssl_options[:client_cert] = (cert_path + 'cert.pem').expand_path.to_s
65
- ssl_options[:client_key] = (cert_path + 'key.pem').expand_path.to_s
66
- ssl_options[:ssl_ca_file] = (cert_path + 'ca.pem').expand_path.to_s
67
- else
68
- ssl_options[:client_cert] = ssl['cert']
69
- ssl_options[:client_key] = ssl['key']
70
- ssl_options[:ssl_ca_file] = ssl['ca']
71
- end
72
- end
73
- @options.merge!(ssl_options)
74
- end
75
-
76
50
  def each_image
77
51
  return unless @config.has_key?('images')
78
52
  @config['images'].each do |image|
@@ -104,10 +78,18 @@ class Config
104
78
  end
105
79
  end
106
80
 
81
+ def workspace_for(image)
82
+ if @ws_mount
83
+ @ws_mount + image
84
+ else
85
+ @workspace + image
86
+ end
87
+ end
88
+
107
89
  def resolve_file(file)
108
90
  filepath = Pathname.new(file)
109
91
  LOG.debug { "resolve_file(#{file})" }
110
- paths = [
92
+ paths = [
111
93
  filepath, # 0. Absolute path
112
94
  @workspace + file, # 1. Workspace
113
95
  @configdir + file, # 2. Config
@@ -121,7 +103,7 @@ class Config
121
103
  else
122
104
  LOG.debug("did not find file at: #{path}")
123
105
  end
124
- end
106
+ end
125
107
  result
126
108
  end
127
109
  end
@@ -129,13 +111,7 @@ class Config
129
111
  # Initialize Docker Client
130
112
  def init_docker!
131
113
  Docker.options = @options
132
- if @config.has_key?('docker_url')
133
- url = @config['docker_url']
134
- Docker.url = url
135
- end
136
- if @secure
137
- Docker.url = Docker.url.gsub(/^tcp:/,'https:')
138
- end
114
+ set_docker_url
139
115
  LOG.debug { "Docker URL: #{Docker.url}"}
140
116
  LOG.debug { "Docker Options: #{Docker.options.inspect}"}
141
117
  Docker.validate_version!
@@ -153,5 +129,75 @@ class Config
153
129
  >
154
130
  eos
155
131
  end
132
+
133
+ private
134
+
135
+ def config_workspace
136
+ def nonnil(*args)
137
+ args.find{ |x| not x.nil? }
138
+ end
139
+
140
+ if ENV['BAHA_MOUNT']
141
+ @ws_mount = Pathname.new(ENV['BAHA_WORKSPACE_MOUNT'])
142
+ @cfg_mount = Pathname.new(ENV['BAHA_MOUNT'])
143
+ @configdir = Pathname.new('/baha')
144
+ @workspace = Pathname.new('/workspace')
145
+ else
146
+ cfgdir = @config['configdir'] || Pathname.pwd.to_s
147
+ @configdir = Pathname.new(cfgdir)
148
+
149
+ work = @config['workspace'] || (@configdir + 'workspace').to_s
150
+ @workspace = Pathname.new(work)
151
+ end
152
+ end
153
+
154
+ def set_docker_url
155
+ if @config.has_key?('docker_url')
156
+ Docker.url = @config['docker_url']
157
+ end
158
+ if @secure
159
+ Docker.url = Docker.url.gsub(/^tcp:/,'https:')
160
+ end
161
+ end
162
+
163
+ def ssl_from_env
164
+ ssl_options = {}
165
+ cert_path = Pathname.new(ENV['DOCKER_CERT_PATH'])
166
+ ssl_options[:ssl_verify_peer] = (ENV['DOCKER_TLS_VERIFY'] == '1')
167
+ ssl_options[:client_cert] = (cert_path + 'cert.pem').expand_path.to_s
168
+ ssl_options[:client_key] = (cert_path + 'key.pem').expand_path.to_s
169
+ ssl_options[:ssl_ca_file] = (cert_path + 'ca.pem').expand_path.to_s
170
+ ssl_options
171
+ end
172
+
173
+ def ssl_from_config
174
+ ssl = @config['ssl']
175
+ ssl_options = {}
176
+ ssl_options[:ssl_verify_peer] = ssl['verify'] || false
177
+ if ssl.has_key?('cert_path')
178
+ cert_path = Pathname.new(ssl['cert_path'])
179
+ ssl_options[:client_cert] = (cert_path + 'cert.pem').expand_path.to_s
180
+ ssl_options[:client_key] = (cert_path + 'key.pem').expand_path.to_s
181
+ ssl_options[:ssl_ca_file] = (cert_path + 'ca.pem').expand_path.to_s
182
+ else
183
+ ssl_options[:client_cert] = ssl['cert']
184
+ ssl_options[:client_key] = ssl['key']
185
+ ssl_options[:ssl_ca_file] = ssl['ca']
186
+ end
187
+ ssl_options
188
+ end
189
+
190
+ def init_security
191
+ @secure = true
192
+ cert_path = ''
193
+ ssl = { }
194
+ if ENV['DOCKER_CERT_PATH']
195
+ ssl = ssl_from_env
196
+ elsif @config.has_key?('ssl')
197
+ ssl = ssl_from_config
198
+ end
199
+ @options.merge!(ssl)
200
+ end
201
+
156
202
  end
157
203
  end
@@ -45,7 +45,7 @@ module Baha
45
45
  LOG.debug { "get_image!(#{image.inspect})" }
46
46
  tag = image[:tag] || 'latest'
47
47
  repo = "#{image[:ns]}/#{image[:name]}"
48
- img = [
48
+ img = [
49
49
  lambda { Docker::Image.get("#{image[:name]}:#{image[:tag]}") },
50
50
  lambda { Docker::Image.create('fromImage'=> image[:name], 'tag' => tag) },
51
51
  lambda { Docker::Image.create('fromImage' => repo, 'tag' => tag) }
@@ -65,9 +65,10 @@ module Baha
65
65
  end
66
66
 
67
67
  end
68
- attr_reader :parent, :image, :maintainer, :options, :pre_build, :bind, :command, :timeout, :workspace, :name, :tags, :run
68
+ attr_reader :parent, :image, :maintainer, :options, :pre_build, :bind, :command, :timeout, :name, :tags, :run
69
69
 
70
70
  def initialize(config,image)
71
+ @config = config
71
72
  @parent = Baha::Image.parse_with_default(image['parent'] || config.defaults[:parent], config.defaults[:repository])
72
73
  @image = Baha::Image.parse_with_default(image['name'], config.defaults[:repository])
73
74
  @image[:tag] = image['tag'] if image.has_key?('tag')
@@ -78,7 +79,7 @@ module Baha
78
79
  @command = image['command'] || config.defaults[:command]
79
80
  @run = image['run']
80
81
  @timeout = image['timeout'] || config.defaults[:timeout]
81
- @workspace = config.workspace + (image['workspace'] || @image[:name])
82
+ @workspace = image['workspace'] || @image[:name]
82
83
  @name = @image[:name]
83
84
  @tags = Set.new [
84
85
  "#{@image[:name]}:#{@image[:tag]}",
@@ -90,6 +91,14 @@ module Baha
90
91
  end
91
92
  end
92
93
 
94
+ def host_mount
95
+ @config.workspace_for(@workspace)
96
+ end
97
+
98
+ def workspace
99
+ @config.workspace + @workspace
100
+ end
101
+
93
102
  def env
94
103
  {
95
104
  :parent => @parent,
@@ -97,7 +106,7 @@ module Baha
97
106
  :bind => @bind,
98
107
  :name => @image[:name],
99
108
  :tag => @image[:tag],
100
- :workspace => @workspace.expand_path.to_s
109
+ :workspace => workspace.expand_path.to_s
101
110
  }
102
111
  end
103
112
 
@@ -152,4 +161,4 @@ module Baha
152
161
  eos
153
162
  end
154
163
  end
155
- end
164
+ end
@@ -0,0 +1,18 @@
1
+ module Baha::Refinements
2
+ refine Hash do
3
+ # Allow hash to use symbol keys or string keys
4
+ def [](key)
5
+ super(key.to_s) || super(key.to_sym)
6
+ end
7
+ # Pick the first key that exists in the hash
8
+ # If none of them exist, return the default
9
+ def pick(keys,default = nil)
10
+ k = keys.find { |x| self.has_key?(x) }
11
+ if not k.nil?
12
+ self[k]
13
+ else
14
+ default
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Baha
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -8,6 +8,16 @@ module Baha
8
8
  @options = {}
9
9
  @options.merge!(options)
10
10
  @directory = @options['directory'] || Dir.pwd
11
+ @mount_dir = @options['mount_dir'] || @directory
12
+ @image = @options['image']
13
+ end
14
+
15
+ def +(file)
16
+ Pathname.new(@mount_dir) + @image + file
17
+ end
18
+
19
+ def directory
20
+ Pathname.new(@workspace)
11
21
  end
12
22
  end
13
23
  end
@@ -10,7 +10,7 @@ images:
10
10
  name: base
11
11
  tag: 1.0.0
12
12
  maintainer: '"Captain Ahab" <ahab@example.com>'
13
- - dockerfile: Dockerfile
13
+ - dockerfile: Dockerfile.example
14
14
  name: dockerfile
15
15
  tag: 1.0.0
16
16
  - dockerfile: no such dockerfile
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'baha/refinements'
3
+
4
+ describe "Baha::Refinements" do
5
+ using Baha::Refinements
6
+ describe "Hash#[]" do
7
+ let(:h) {
8
+ {
9
+ :symkey => 100,
10
+ "strkey" => 200
11
+ }
12
+ }
13
+ it { expect(h[:symkey]).to eq(100) }
14
+ it { expect(h['symkey']).to eq(100) }
15
+ it { expect(h[:strkey]).to eq(200) }
16
+ it { expect(h['strkey']).to eq(200) }
17
+ end
18
+ describe "Hash#pick" do
19
+ let(:h) {
20
+ {
21
+ :a => 'a',
22
+ :z => 'z'
23
+ }
24
+ }
25
+ it { expect(h.pick([:a,:b,:c])).to eq('a') }
26
+ it { expect(h.pick([:x,:y,:z])).to eq('z') }
27
+ it { expect(h.pick([:x,:y])).to be_nil }
28
+ it { expect(h.pick([:x,:y],'z')).to eq('z') }
29
+ end
30
+ end
metadata CHANGED
@@ -1,146 +1,144 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justen Walker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.19.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.19.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: docker-api
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.14.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.14.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.8.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.8.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '10.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 3.1.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.1.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-mocks
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 3.1.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 3.1.3
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec-its
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.1.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 0.9.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.9.1
139
- description: ! 'Baha is a command-line utility that assists in the creation of docker
140
- images.
141
-
142
- It addresses some of Dockerfiles shortcomings and encourages smaller, reusable,
143
- tagged images.'
139
+ description: |-
140
+ Baha is a command-line utility that assists in the creation of docker images.
141
+ It addresses some of Dockerfiles shortcomings and encourages smaller, reusable, tagged images.
144
142
  email:
145
143
  - justen.walker+github@gmail.com
146
144
  executables:
@@ -148,15 +146,19 @@ executables:
148
146
  extensions: []
149
147
  extra_rdoc_files: []
150
148
  files:
151
- - .gitignore
152
- - .travis.yml
149
+ - ".gitignore"
150
+ - ".travis.yml"
153
151
  - CHANGELOG.md
152
+ - Dockerfile
154
153
  - Gemfile
155
154
  - LICENSE.txt
156
155
  - README.md
157
156
  - Rakefile
158
157
  - baha.gemspec
159
158
  - bin/baha
159
+ - docker-baha.sh
160
+ - docker-build.sh
161
+ - docker-entrypoint.sh
160
162
  - example/.gitignore
161
163
  - example/base/init.sh.erb
162
164
  - example/base/test-template.erb
@@ -183,6 +185,7 @@ files:
183
185
  - lib/baha/pre_build/command.rb
184
186
  - lib/baha/pre_build/download.rb
185
187
  - lib/baha/pre_build/template.rb
188
+ - lib/baha/refinements.rb
186
189
  - lib/baha/version.rb
187
190
  - lib/baha/workspace.rb
188
191
  - spec/builder_spec.rb
@@ -213,6 +216,7 @@ files:
213
216
  - spec/pre_build/download_spec.rb
214
217
  - spec/pre_build/template_spec.rb
215
218
  - spec/pre_build_spec.rb
219
+ - spec/refinements_spec.rb
216
220
  - spec/spec_helper.rb
217
221
  homepage: https://github.com/justenwalker/baha
218
222
  licenses:
@@ -224,17 +228,17 @@ require_paths:
224
228
  - lib
225
229
  required_ruby_version: !ruby/object:Gem::Requirement
226
230
  requirements:
227
- - - ! '>='
231
+ - - ">="
228
232
  - !ruby/object:Gem::Version
229
233
  version: '0'
230
234
  required_rubygems_version: !ruby/object:Gem::Requirement
231
235
  requirements:
232
- - - ! '>='
236
+ - - ">="
233
237
  - !ruby/object:Gem::Version
234
238
  version: '0'
235
239
  requirements: []
236
240
  rubyforge_project:
237
- rubygems_version: 2.1.11
241
+ rubygems_version: 2.2.0.rc.1
238
242
  signing_key:
239
243
  specification_version: 4
240
244
  summary: Baha is a command-line utility that assists in the creation of docker images.
@@ -267,4 +271,5 @@ test_files:
267
271
  - spec/pre_build/download_spec.rb
268
272
  - spec/pre_build/template_spec.rb
269
273
  - spec/pre_build_spec.rb
274
+ - spec/refinements_spec.rb
270
275
  - spec/spec_helper.rb