guard-fig 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/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +2 -0
- data/guard-fig.gemspec +23 -0
- data/lib/guard/fig/fig_proxy.rb +27 -0
- data/lib/guard/fig/version.rb +7 -0
- data/lib/guard/fig.rb +84 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d0a4fe257731ce9ad294f6c49f64c52ce6be27a3
|
4
|
+
data.tar.gz: 50a05466bec28bdfe6292805aa58c869d4483307
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ba02a53aa3793766099f2390eb848ca31469e64fabfd5842b6c96f4a9a68ad0221d99a5f824960d4164f5df0bc184ee114fec6cbcf5467bca59dc205e008cf9
|
7
|
+
data.tar.gz: 62137cafec167091f124504d6d21f96a0d35ad387ed741802ca1323af9217308075437742c2fade508bcb0b25debb8eef33c04c6d153ce26160c207dbbc52fd3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jorge Dias
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Guard::Fig
|
2
|
+
|
3
|
+
Guard::Fig helps you develop docker containers faster using [fig](http://fig.sh/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'guard-fig'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install guard-fig
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add the following to your Guardfile
|
24
|
+
|
25
|
+
```
|
26
|
+
guard :fig, boot2docker_start: true, build_on_start: true do
|
27
|
+
ignore %r{\.#}
|
28
|
+
watch %r{.*}
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/[my-github-username]/guard-fig/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/guard-fig.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'guard/fig/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "guard-fig"
|
8
|
+
spec.version = Guard::Fig::VERSION
|
9
|
+
spec.authors = ["Jorge Dias"]
|
10
|
+
spec.email = ["jorge.dias@xing.com"]
|
11
|
+
spec.summary = %q{Guard gem for Fig}
|
12
|
+
spec.description = %q{Guard::Fig helps you develop docker containers faster using fig}
|
13
|
+
spec.homepage = "https://rubygems.org/gems/guard-fig"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'guard/plugin'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class Fig < Plugin
|
5
|
+
class FigProxy
|
6
|
+
def build(service = nil)
|
7
|
+
system "fig build #{service}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def up recreate: true
|
11
|
+
cmd = "fig up -d"
|
12
|
+
unless recreate
|
13
|
+
cmd << " --no-recreate"
|
14
|
+
end
|
15
|
+
system cmd
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop(service = nil)
|
19
|
+
system "fig stop #{service}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove(service)
|
23
|
+
system "fig rm --force #{service}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/guard/fig.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/plugin'
|
3
|
+
require 'yaml'
|
4
|
+
require "guard/fig/version"
|
5
|
+
|
6
|
+
module ::Guard
|
7
|
+
class Fig < Plugin
|
8
|
+
def initialize(options = {})
|
9
|
+
super(options)
|
10
|
+
@config = YAML.load_file('fig.yml')
|
11
|
+
@fig = FigProxy.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
boot2docker_setup if @options[:boot2docker_start]
|
16
|
+
@fig.build if @options[:build_on_start]
|
17
|
+
@fig.up recreate: false
|
18
|
+
end
|
19
|
+
|
20
|
+
def stop
|
21
|
+
@fig.stop
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_all
|
25
|
+
@fig.up
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_on_changes(paths)
|
29
|
+
debug paths.inspect
|
30
|
+
|
31
|
+
if paths.any? { |x| x =~ /fig\.yml/ }
|
32
|
+
@fig.up
|
33
|
+
else
|
34
|
+
restart_services(paths)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def restart_services(paths)
|
41
|
+
directories = paths.flat_map { |p| p.split("/").first }.uniq
|
42
|
+
services = []
|
43
|
+
linked_services = []
|
44
|
+
@config.each do |service, options|
|
45
|
+
if directories.include? options['build']
|
46
|
+
services << service
|
47
|
+
end
|
48
|
+
end
|
49
|
+
@config.each do |service, options|
|
50
|
+
debug "SERVICE: #{service}. Links #{options['links'].inspect}"
|
51
|
+
if options['links'] && options['links'].any? { |l| services.include? l }
|
52
|
+
linked_services << service
|
53
|
+
end
|
54
|
+
end
|
55
|
+
debug services.inspect
|
56
|
+
services.each do |service|
|
57
|
+
@fig.stop service
|
58
|
+
@fig.remove service
|
59
|
+
@fig.build service
|
60
|
+
end
|
61
|
+
debug linked_services.inspect
|
62
|
+
linked_services.uniq.each do |service|
|
63
|
+
@fig.stop service
|
64
|
+
end
|
65
|
+
unless services.empty?
|
66
|
+
@fig.up recreate: false
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def boot2docker_setup
|
71
|
+
system "boot2docker up"
|
72
|
+
|
73
|
+
%x{boot2docker shellinit}.scan /export\s+(\S+)=(\S+)/ do |k, v|
|
74
|
+
ENV[k] = v
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def debug(msg)
|
79
|
+
puts msg if ENV['DEBUG']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
require "guard/fig/fig_proxy"
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-fig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jorge Dias
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Guard::Fig helps you develop docker containers faster using fig
|
42
|
+
email:
|
43
|
+
- jorge.dias@xing.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- guard-fig.gemspec
|
54
|
+
- lib/guard/fig.rb
|
55
|
+
- lib/guard/fig/fig_proxy.rb
|
56
|
+
- lib/guard/fig/version.rb
|
57
|
+
homepage: https://rubygems.org/gems/guard-fig
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.4
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Guard gem for Fig
|
81
|
+
test_files: []
|