docker-helpers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d71f9d1a293be214403e1c6ee48aef5bc62b2a5b
4
+ data.tar.gz: a929b1c0b897677f9853d700d32a71c5bfe4f539
5
+ SHA512:
6
+ metadata.gz: 2d5c36b3f830f5329a103117a1aa6f60372bae559ae3dccc636a121b1e9585d10904b6e7b4a7e24264b71d1358059ca1ec1e0e65efe4a812663f4ecd2fce5d9e
7
+ data.tar.gz: 4e08c4de83d554ba122d3692e8aa3782d59e62763228d6e2a6dd1728397f4cc729bd9afcc3200d90c1bb1dfa26788ee8b6a4218f56409ff84cdc807d2ac5e800
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /vendor/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docker-helpers.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Manheim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # docker-helpers
2
+
3
+ [![Build Status](https://travis-ci.org/manheim/docker-helpers.svg?branch=master)](https://travis-ci.org/manheim/docker-helpers)
4
+
5
+ Collection of helpers to assist in testing/developing with the docker-api gem.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'docker-helpers'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install docker-helpers
22
+
23
+ ## Usage
24
+
25
+ You can use the Docker::Helpers.get_image method and the output stream will
26
+ be initialized automatically. Only the DEBUG ENV var is required to turn on
27
+ the docker build output.
28
+
29
+ # Example
30
+
31
+ ```
32
+ DEBUG=1 bundle exec your_thing
33
+ ```
34
+
35
+ ```ruby
36
+ #Manually setup a stream
37
+
38
+ output_stream = Docker::Helpers.output_stream
39
+ Docker::Image.build_from_dir('.', opts, &output_stream )
40
+
41
+ # or let .get_image set it up.
42
+
43
+ # Try to get an image that exists. Returns an instance of
44
+ # Docker::Image if found.
45
+
46
+ image = Docker::Helpers.get_image(image_id: 'asdf1234')
47
+
48
+ # No options passed will try to build a Dockerfile in the current dir.
49
+ image = Docker::Helpers.get_image()
50
+
51
+ # You can specifiy a build dir as well as
52
+ # options supported by Docker::Image.build_from_dir.
53
+
54
+ image = Docker::Helpers.get_image(build_dir: 'some_dir/')
55
+
56
+ opts = { build_dir: 'some_dir/', t: 'a_tag', nocache: 'true' }
57
+ image = Docker::Helpers.get_image(opts)
58
+
59
+ ```
60
+
61
+ ## Development
62
+
63
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
64
+
65
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/manheim/docker-helpers.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "docker/helpers"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ dependencies:
2
+ pre:
3
+ - gem install bundler
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'docker/helpers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docker-helpers"
8
+ spec.version = Docker::Helpers::VERSION
9
+ spec.authors = ["Reppard Walker", "Jonathan Niesen"]
10
+ spec.email = ["reppard.walker@manheim.com"]
11
+
12
+ spec.summary = 'Collection of helpers to supplement the docker-api gem'
13
+ spec.description = 'Provides some helpers to assist in testing/developing with the docker-api gem.'
14
+ spec.homepage = "https://github.com/manheim/docker-helpers"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3"
23
+ spec.add_runtime_dependency "docker-api", "~> 1.26", ">= 1.26.0"
24
+ end
@@ -0,0 +1,35 @@
1
+ require "docker/helpers/version"
2
+ require "docker"
3
+ require 'json'
4
+
5
+ module Docker
6
+ module Helpers
7
+ class << self
8
+ def output_stream
9
+ lambda { |v|
10
+ body, should_output = should_output?(v)
11
+ if should_output
12
+ $stdout.puts body["stream"]
13
+ end
14
+ }
15
+ end
16
+
17
+ def get_image(opts = {})
18
+ if opts[:image_id]
19
+ Docker::Image.get(opts[:image_id])
20
+ else
21
+ build_dir = opts[:build_dir] || '.'
22
+ Docker::Image.build_from_dir(build_dir, opts, &output_stream)
23
+ end
24
+ end
25
+
26
+ private
27
+ def should_output?( string )
28
+ parsed = JSON.parse(string)
29
+ worth_showing = parsed && parsed.has_key?("stream") && ENV['DEBUG']
30
+
31
+ [parsed, worth_showing]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module Docker
2
+ module Helpers
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docker-helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Reppard Walker
8
+ - Jonathan Niesen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-01-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.10'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3'
56
+ - !ruby/object:Gem::Dependency
57
+ name: docker-api
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.26'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.26.0
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.26'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.26.0
76
+ description: Provides some helpers to assist in testing/developing with the docker-api
77
+ gem.
78
+ email:
79
+ - reppard.walker@manheim.com
80
+ executables: []
81
+ extensions: []
82
+ extra_rdoc_files: []
83
+ files:
84
+ - ".gitignore"
85
+ - ".rspec"
86
+ - ".travis.yml"
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/console
92
+ - bin/setup
93
+ - circle.yml
94
+ - docker-helpers.gemspec
95
+ - lib/docker/helpers.rb
96
+ - lib/docker/helpers/version.rb
97
+ homepage: https://github.com/manheim/docker-helpers
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Collection of helpers to supplement the docker-api gem
121
+ test_files: []