derb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ChangeLog.md +4 -0
- data/LICENSE.txt +20 -0
- data/README.md +21 -0
- data/bin/derb +46 -0
- data/derb.gemspec +17 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08058237c3e205e79f41e7f1b84c44dd30c37717
|
4
|
+
data.tar.gz: 8d6294d51898da277ef0fa95c17ffa0d16eb422b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 886ca979501fcbea53afc1369bd081eaf9b8cbada7cf9f7519ff1480ebd3d7dab873d587f7889dea051625ee2267d9b9e4e2976c2d55e960afea0c9b96bdca3b
|
7
|
+
data.tar.gz: 42c3a82600b38c11e8223fb489f56f46a4ab51d65768a290a590736aa9d9509d0cbab9e277c4cbb7a46de36d687a1a1534560f1dc387262144e2702f36f249ee
|
data/ChangeLog.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Jan Lelis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# derb
|
2
|
+
|
3
|
+
Allows you to have Dockerfile.erb templates.
|
4
|
+
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
`gem install derb` or directly use the script in *bin/ruby*.
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
In a directory with a `Dockerfile.erb` (and optionally a `Dockerfile.yml`), run:
|
14
|
+
|
15
|
+
$ derb
|
16
|
+
|
17
|
+
|
18
|
+
## License
|
19
|
+
|
20
|
+
Copyright (c) 2014 Jan Lelis. MIT-License.
|
21
|
+
|
data/bin/derb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
require 'yaml'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
class Derb
|
8
|
+
VERSION = '0.1.0'
|
9
|
+
|
10
|
+
def initialize(template_file = nil, data_file = nil)
|
11
|
+
template_file = template_file || 'Dockerfile.erb'
|
12
|
+
data_file = data_file || 'Dockerfile.yml'
|
13
|
+
|
14
|
+
unless File.exists? template_file
|
15
|
+
raise ArgumentError, "#{template_file} not found"
|
16
|
+
end
|
17
|
+
|
18
|
+
@template = File.read template_file
|
19
|
+
if File.exists? data_file
|
20
|
+
@data = YAML.load_file data_file if data_file
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
ERB.new(@template).result(
|
26
|
+
OpenStruct.new(@data).instance_eval { binding }
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def render_to_file(output_filename = 'Dockerfile')
|
31
|
+
if File.exists? output_filename
|
32
|
+
print "#{output_filename} already exists, overwrite? (y) "
|
33
|
+
return if gets.chomp.upcase != "Y"
|
34
|
+
end
|
35
|
+
|
36
|
+
File.open(output_filename, 'w+'){ |f|
|
37
|
+
f.write(render)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
Derb.new(ARGV[0], ARGV[1]).render_to_file
|
44
|
+
rescue ArgumentError => e
|
45
|
+
$stderr.puts e.message
|
46
|
+
end
|
data/derb.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
load File.expand_path('../bin/derb', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "derb"
|
7
|
+
gem.version = Derb::VERSION
|
8
|
+
gem.summary = 'Dockerfile.erb'
|
9
|
+
gem.description = ' Allows you to have Dockerfile.erb templates.'
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.authors = ["Jan Lelis"]
|
12
|
+
gem.email = "mail@janlelis.de"
|
13
|
+
gem.homepage = "https://github.com/janlelis/derb"
|
14
|
+
|
15
|
+
gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: derb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Lelis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: " Allows you to have Dockerfile.erb templates."
|
14
|
+
email: mail@janlelis.de
|
15
|
+
executables:
|
16
|
+
- derb
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ChangeLog.md
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.md
|
23
|
+
- bin/derb
|
24
|
+
- derb.gemspec
|
25
|
+
homepage: https://github.com/janlelis/derb
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.4.1
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Dockerfile.erb
|
49
|
+
test_files: []
|