ludwig 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ludwig/cli.rb +7 -7
- data/lib/ludwig/service.rb +34 -27
- data/lib/ludwig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08cbeeb28adc2c14fff362d279c6b0c171b6558e
|
4
|
+
data.tar.gz: bc8bd272d8e319b3ecaedb2d56698fb19bb19db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbb49bef423ec620cf3db17e999e2765210cc844d73511232b0647eae3fe98af94943f83199d3c77c2f9c31c71b502ac62606c575e0e764ea4421b392f37cde
|
7
|
+
data.tar.gz: 5e65e62e116101a295553a1503a4d718a0f90e993672f9f22d05688c6962c54a2a5669169aea28876ac6a2328a7c7740addde51a9e72803825faff9103f2327d
|
data/lib/ludwig/cli.rb
CHANGED
@@ -13,20 +13,20 @@ module Ludwig
|
|
13
13
|
global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
|
14
14
|
global_option('-c', '--config filename', String, 'Set config filename') { |config_file| @config_file = config_file }
|
15
15
|
|
16
|
-
command :
|
17
|
-
c.syntax = 'ludwig
|
18
|
-
c.summary = 'Generate docker-compose.yml
|
16
|
+
command :compose do |c|
|
17
|
+
c.syntax = 'ludwig compose [options]'
|
18
|
+
c.summary = 'Generate docker-compose.yml'
|
19
19
|
c.action do |args, options|
|
20
20
|
generate_compose_file
|
21
|
-
system 'docker-compose up'
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
command :
|
26
|
-
c.syntax = 'ludwig
|
27
|
-
c.summary = 'Generate docker-compose.yml'
|
24
|
+
command :up do |c|
|
25
|
+
c.syntax = 'ludwig up [options]'
|
26
|
+
c.summary = 'Generate docker-compose.yml and launch docker-compose'
|
28
27
|
c.action do |args, options|
|
29
28
|
generate_compose_file
|
29
|
+
system 'docker-compose up'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/lib/ludwig/service.rb
CHANGED
@@ -1,44 +1,37 @@
|
|
1
1
|
module Ludwig
|
2
|
-
|
3
|
-
ACTION_MAP = {
|
4
|
-
volumes: :volumes_action,
|
5
|
-
links: :links_action,
|
6
|
-
env_file: :prefix_path,
|
7
|
-
build: :prefix_path
|
8
|
-
}
|
9
|
-
|
2
|
+
Service = Struct.new(:project, :name, :data, :config) do
|
10
3
|
def generate_yaml
|
11
|
-
|
12
|
-
|
13
|
-
|
4
|
+
transform_data
|
5
|
+
merge_extra_links
|
6
|
+
new_data
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
14
10
|
|
11
|
+
def merge_extra_links
|
15
12
|
if extra_links = config["extra_links"][name]
|
16
13
|
new_data["links"] ||= []
|
17
14
|
new_data["links"] += extra_links.map do |app|
|
18
15
|
"#{sanitize(app)}_#{config["default_app"]}:#{sanitize(app)}"
|
19
16
|
end
|
20
17
|
end
|
18
|
+
end
|
21
19
|
|
22
|
-
|
20
|
+
def new_data
|
21
|
+
@new_data ||= {}
|
23
22
|
end
|
24
23
|
|
25
|
-
def
|
26
|
-
|
27
|
-
action ? send(action, obj) : obj
|
24
|
+
def sanitize(input)
|
25
|
+
input.gsub(/-/, "_")
|
28
26
|
end
|
29
27
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
if local =~ /^\.\/?/
|
34
|
-
"#{prefix_path(local)}:#{remote}"
|
35
|
-
else
|
36
|
-
volume
|
37
|
-
end
|
28
|
+
def transform_data
|
29
|
+
data.each do |key, value|
|
30
|
+
new_data[key] = try("transform_#{key}", value) || value
|
38
31
|
end
|
39
32
|
end
|
40
33
|
|
41
|
-
def
|
34
|
+
def transform_links(links)
|
42
35
|
links.map do |link|
|
43
36
|
link_name, link_alias = link.split(":")
|
44
37
|
link_alias = link_name if link_alias.nil?
|
@@ -46,12 +39,26 @@ module Ludwig
|
|
46
39
|
end
|
47
40
|
end
|
48
41
|
|
49
|
-
def
|
42
|
+
def transform_path(path)
|
50
43
|
"../#{project}/#{path}"
|
51
44
|
end
|
45
|
+
alias_method :transform_build, :transform_path
|
46
|
+
alias_method :transform_env_file, :transform_path
|
52
47
|
|
53
|
-
def
|
54
|
-
|
48
|
+
def transform_ports(ports)
|
49
|
+
return ports if config['expose_ports'][name]
|
50
|
+
ports.map { |port| port.to_s.split(':').last }
|
51
|
+
end
|
52
|
+
|
53
|
+
def transform_volumes(volumes)
|
54
|
+
volumes.map do |volume|
|
55
|
+
local, remote = volume.split(":")
|
56
|
+
local =~ /^\.\/?/ ? "#{transform_path(local)}:#{remote}" : volume
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def try(*a, &b)
|
61
|
+
respond_to?(a.first, true) ? send(*a, &b) : nil
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
data/lib/ludwig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludwig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stolz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|