docker_compose_ruby 0.1.2 → 0.1.3
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 +4 -4
- data/README.md +27 -5
- data/lib/docker_compose_ruby/version.rb +1 -1
- data/lib/docker_compose_ruby.rb +56 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdc079e7c3844e1cd2ae057f63e32a50aa435897
|
4
|
+
data.tar.gz: e63b53363102127136f982252db24c632f56a5a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125f9a63063488d2ab8d14052bb544eca6b072e64dc33929e37117297dc71e5128bdcef9d0dcf28dfb3bece9d3210f3ff1c4fe0e74aa2f9bbf2e50680f7f6ce3
|
7
|
+
data.tar.gz: f955e5aa40920c714cd59dc3c098de6490fe287673b874a6cc5be03130b6f7f2e10c58896fcb1f822870e4f33e237d1525d41550d488f6145029f93924a0cdbb
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# DockerComposeRuby
|
2
2
|
|
3
|
-
|
3
|
+
Simple Ruby wrapper for the docker compose cli
|
4
4
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
+
You need to have the docker compose cli installed.
|
10
|
+
|
9
11
|
Add this line to your application's Gemfile:
|
10
12
|
|
11
13
|
```ruby
|
@@ -22,13 +24,33 @@ Or install it yourself as:
|
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
Set the path to your docker file.
|
26
28
|
|
27
|
-
|
29
|
+
$ DockerCompose.set_yaml_path('/path/to/docker-compose.yml')
|
30
|
+
|
31
|
+
Set the project name (if no name is set it will be tthe name of the compose file's directory).
|
32
|
+
|
33
|
+
$ DockerCompose.set_project_name('test_project')
|
34
|
+
|
35
|
+
Up the compose project containers.
|
36
|
+
|
37
|
+
$ DockerCompose.up
|
38
|
+
|
39
|
+
Delete the compose project containers.
|
28
40
|
|
29
|
-
|
41
|
+
$ DockerCompose.delete
|
42
|
+
|
43
|
+
Stop the compose project containers.
|
44
|
+
|
45
|
+
$ DockerCompose.stop
|
46
|
+
|
47
|
+
Start the compose project containers.
|
48
|
+
|
49
|
+
$ DockerCompose.start
|
50
|
+
|
51
|
+
## Development
|
30
52
|
|
31
|
-
|
53
|
+
I wanted something to use in a project I'm building, and there really wasn't anything out there that gives me the simplicity of the cli, but without having to repeat myself.
|
32
54
|
|
33
55
|
## Contributing
|
34
56
|
|
data/lib/docker_compose_ruby.rb
CHANGED
@@ -7,36 +7,91 @@ module DockerCompose
|
|
7
7
|
class << self
|
8
8
|
attr_accessor :project_name, :yaml_path, :yaml
|
9
9
|
|
10
|
+
|
11
|
+
# Set Path to Docker Compose Yaml File.
|
12
|
+
#
|
13
|
+
# @param path [String]
|
14
|
+
# @return [String]
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# DockerCompose.set_yaml_path('/Users/test/projects/docker-compose.yml')
|
10
18
|
def set_yaml_path(path)
|
11
19
|
@yaml_path = "-f #{path}"
|
12
20
|
@yaml = YAML.load_file(path)
|
13
21
|
end
|
14
22
|
|
23
|
+
# Set Specific compose project name.
|
24
|
+
#
|
25
|
+
# @param name [String]
|
26
|
+
# @return [String]
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# DockerCompose.set_project_name('test_project')
|
15
30
|
def set_project_name(name)
|
16
31
|
@project_name = "-p #{name}"
|
17
32
|
name
|
18
33
|
end
|
19
34
|
|
35
|
+
# Ups the set of containers listed in your compose file.
|
36
|
+
#
|
37
|
+
# @param options [Hash]
|
38
|
+
# @return [String]
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# DockerCompose.up
|
20
42
|
def up(options = {})
|
21
43
|
options = nil if options.empty?
|
22
44
|
compose('up',options)
|
23
45
|
end
|
24
46
|
|
47
|
+
# Deletes the set of containers listed in your compose file.
|
48
|
+
#
|
49
|
+
# @param options [Hash]
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# DockerCompose.delete
|
25
54
|
def delete(options = {})
|
26
55
|
options = nil if options.empty?
|
27
56
|
compose('delete',options)
|
28
57
|
end
|
29
58
|
|
59
|
+
# Stops the set of containers listed in your compose file.
|
60
|
+
#
|
61
|
+
# @param options [Hash]
|
62
|
+
# @return [String]
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# DockerCompose.stop
|
30
66
|
def stop(options = {})
|
31
67
|
options = nil if options.empty?
|
32
68
|
compose('stop', options)
|
33
69
|
end
|
34
70
|
|
71
|
+
# Starts the set of containers listed in your compose file.
|
72
|
+
#
|
73
|
+
# @param options [Hash]
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# DockerCompose.up
|
35
78
|
def start(options = {})
|
36
79
|
options = nil if options.empty?
|
37
80
|
compose('start', options)
|
38
81
|
end
|
39
82
|
|
83
|
+
# Displays the current version of Docker compose
|
84
|
+
#
|
85
|
+
# @param options [Hash]
|
86
|
+
# @return [String]
|
87
|
+
#
|
88
|
+
# @example
|
89
|
+
# DockerCompose.version
|
90
|
+
def version
|
91
|
+
compose('-v')
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
40
95
|
def compose(command, options)
|
41
96
|
case command
|
42
97
|
when 'up'
|
@@ -44,13 +99,9 @@ module DockerCompose
|
|
44
99
|
when 'delete'
|
45
100
|
`docker-compose #{options} #{@yaml_path} #{@project_name} kill`
|
46
101
|
`docker-compose #{options} #{@yaml_path} #{@project_name} rm -f`
|
47
|
-
when 'stop', 'start'
|
102
|
+
when 'stop', 'start', 'version'
|
48
103
|
`docker-compose #{options} #{@yaml_path} #{@project_name} #{command}`
|
49
104
|
end
|
50
105
|
end
|
51
|
-
|
52
|
-
def version
|
53
|
-
compose('-v')
|
54
|
-
end
|
55
106
|
end
|
56
107
|
end
|