contur 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +15 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +19 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +17 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +166 -0
- data/Rakefile +9 -0
- data/bin/console +8 -0
- data/bin/contur +172 -0
- data/bin/setup +8 -0
- data/contur-logo.png +0 -0
- data/contur.gemspec +40 -0
- data/lib/contur/bindable_hash.rb +16 -0
- data/lib/contur/config/before.rb +30 -0
- data/lib/contur/config/env.rb +29 -0
- data/lib/contur/config/errors.rb +7 -0
- data/lib/contur/config/use.rb +41 -0
- data/lib/contur/config/version.rb +34 -0
- data/lib/contur/config.rb +74 -0
- data/lib/contur/constants.rb +25 -0
- data/lib/contur/controller.rb +227 -0
- data/lib/contur/utils.rb +42 -0
- data/lib/contur/version.rb +4 -0
- data/lib/contur.rb +8 -0
- data/templates/base-docker-container.erb +104 -0
- data/templates/init.sh.erb +19 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bad06811aed7b745ee20052f281999fbcd20a167
|
4
|
+
data.tar.gz: 29a68d32449352c9b61d7074663ec1da2e37ae5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9fb48b4fdb9ff38f75c5de61f903cdafd7e3765628b20b3c4eabe01774b9a4b863736244c1c9c87269b446a3fffa8f2c78079c783b32a403f9417b547cd836f
|
7
|
+
data.tar.gz: ece91a164002d96803dd0f456debd60f3199ca64e0aad0d476314d98278b1d1fb840e95111c698b613f6f4a40c6525c5a85f3fe586c06e75a2312e84b1dae916
|
data/.editorconfig
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
indent_style = space
|
5
|
+
indent_size = 2
|
6
|
+
end_of_line = lf
|
7
|
+
charset = utf-8
|
8
|
+
trim_trailing_whitespace = true
|
9
|
+
insert_final_newline = true
|
10
|
+
|
11
|
+
[*.{sh,markdown,md}]
|
12
|
+
indent_size = 4
|
13
|
+
|
14
|
+
[*.{markdown,md}]
|
15
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'templates/**/*'
|
4
|
+
- 'vendor/**/*'
|
5
|
+
TargetRubyVersion: 2.3
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 100
|
9
|
+
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Max: 50
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Exclude:
|
15
|
+
- 'contur.gemspec'
|
16
|
+
|
17
|
+
Style/GuardClause:
|
18
|
+
Exclude:
|
19
|
+
- 'contur.gemspec'
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This CHANGELOG follows [Keep a CHANGELOG](http://keepachangelog.com/).
|
4
|
+
|
5
|
+
## [0.0.3] - 2016-10-24
|
6
|
+
### Added
|
7
|
+
- Travis support
|
8
|
+
- Accept config file with both `.yml` and `.yaml` extensions
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
- Project name changed to Contur
|
12
|
+
|
13
|
+
## [0.0.2] - 2016-10-20
|
14
|
+
### First open-source release
|
15
|
+
|
16
|
+
## [0.0.1] - 2016-10-10
|
17
|
+
### First internal release
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at gabor.takacs@cheppers.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Cheppers Ltd. <info@cheppers.com>
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
![Contur Logo](contur-logo.png)
|
2
|
+
|
3
|
+
# Contur
|
4
|
+
Contur is an open-source command line application simplifying your local web development environment. It hosts your site using Docker containers so you don't have to install Apache, MySQL, PHP and PHP extensions on your own machine. Contur is written in Ruby and uses the Docker HTTP API.
|
5
|
+
|
6
|
+
[![Build Status](https://travis-ci.org/Cheppers/contur.svg?branch=master)](https://travis-ci.org/Cheppers/contur)
|
7
|
+
|
8
|
+
## Requirements
|
9
|
+
* Ruby 2.3.0+ (recommended installation method [via rvm](https://rvm.io/rvm/install))
|
10
|
+
* Docker (for Mac see [this](https://docs.docker.com/engine/installation/mac/#/docker-for-mac))
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
1. Install requirements (see above)
|
14
|
+
2. `gem install contur`
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
1. Create a `.contur.yml` file in the root of your repository
|
18
|
+
2. Launch docker
|
19
|
+
3. Run `$ contur start` to build the image, launch the MySQL container and the Contur container
|
20
|
+
4. Run `$ contur restart` to restart the Contur container
|
21
|
+
|
22
|
+
When you run the `start` command the following will happen:
|
23
|
+
|
24
|
+
1. Contur builds a Docker image with apache, php-fpm and a couple of PHP extensions and configure them to work together
|
25
|
+
2. Contur downloads and starts a MySQL container (of your choice or the latest one if undefined in the YAML)
|
26
|
+
3. Contur starts the container
|
27
|
+
4. Contur runs the init script
|
28
|
+
5. You can access the site on `localhost:8088`
|
29
|
+
6. If your root directory is empty, Contur will create an index.php file with a phpinfo inside
|
30
|
+
|
31
|
+
When you run the `restart` command the following will happen:
|
32
|
+
|
33
|
+
1. Contur checks if your image is up-to-date and builds a new one if needed
|
34
|
+
2. Contur kills the currently running Contur container
|
35
|
+
3. Contur starts a new container and re-runs the init script
|
36
|
+
|
37
|
+
## The container
|
38
|
+
The following happens in the container when you start it:
|
39
|
+
|
40
|
+
1. Export the specified envrionment variables (`env` section)
|
41
|
+
2. Runs the commands from the `before` section
|
42
|
+
3. Starts apache
|
43
|
+
4. Starts php-fpm to keep alive the container
|
44
|
+
|
45
|
+
## The .contur.yml
|
46
|
+
The build file consists of sections: `version`, `use`, `before`, `env`.
|
47
|
+
The minimal YAML file for contur to work properly:
|
48
|
+
```yaml
|
49
|
+
---
|
50
|
+
version: 1.0
|
51
|
+
```
|
52
|
+
|
53
|
+
## Sections of the build file
|
54
|
+
### version - [required]
|
55
|
+
Version of the build file. Currently this is the only required section.
|
56
|
+
|
57
|
+
Allowed values: `1.0`
|
58
|
+
|
59
|
+
**Example**
|
60
|
+
```yaml
|
61
|
+
---
|
62
|
+
version: 1.0
|
63
|
+
```
|
64
|
+
|
65
|
+
### use - [optional]
|
66
|
+
Specify the MySQL and PHP versions you want to use.
|
67
|
+
|
68
|
+
#### PHP
|
69
|
+
Current default PHP version: **5.6.25**
|
70
|
+
|
71
|
+
At the moment specifying a PHP version is not working (to be implemented soon).
|
72
|
+
|
73
|
+
#### MySQL
|
74
|
+
Default is the latest from Dockerhub
|
75
|
+
|
76
|
+
To connect:
|
77
|
+
|
78
|
+
* no username
|
79
|
+
* password is 'admin'
|
80
|
+
* host address: $MYSQL_PORT_3306_TCP_ADDR
|
81
|
+
|
82
|
+
**Example**
|
83
|
+
```yaml
|
84
|
+
---
|
85
|
+
version: 1.0
|
86
|
+
use:
|
87
|
+
mysql: 5.6.20
|
88
|
+
```
|
89
|
+
|
90
|
+
### env - [optional]
|
91
|
+
Specify environment variables to use them in the `before` script or in your site
|
92
|
+
|
93
|
+
**Example**
|
94
|
+
```yaml
|
95
|
+
---
|
96
|
+
version: 1.0
|
97
|
+
env:
|
98
|
+
THE_ANSWER: 42
|
99
|
+
DOCTOR: Who
|
100
|
+
```
|
101
|
+
|
102
|
+
### before - [optional]
|
103
|
+
Run scrips before starting php-fpm.
|
104
|
+
|
105
|
+
**Example**
|
106
|
+
```yaml
|
107
|
+
---
|
108
|
+
version: 1.0
|
109
|
+
before:
|
110
|
+
- composer install
|
111
|
+
```
|
112
|
+
|
113
|
+
## Example .contur.yml
|
114
|
+
```yaml
|
115
|
+
---
|
116
|
+
version: 1.0
|
117
|
+
use:
|
118
|
+
mysql: 5.6.20
|
119
|
+
env:
|
120
|
+
YAML_DEFINED: envvar
|
121
|
+
ANOTHER_ENV_VAR: Contur
|
122
|
+
before:
|
123
|
+
- echo "Hello, $ANOTHER_ENV_VAR!<br />Generated at $(date)<br /> MySQL version $MYSQL_ENV_MYSQL_VERSION" > /www/index.php
|
124
|
+
```
|
125
|
+
|
126
|
+
## Commands
|
127
|
+
```bash
|
128
|
+
$ contur help
|
129
|
+
Commands:
|
130
|
+
contur --version, -V # Current version
|
131
|
+
contur delete [-CIM] # Delete container, image or MySQL container(s)
|
132
|
+
contur help [COMMAND] # Describe available commands or one specific command
|
133
|
+
contur log # Get container log
|
134
|
+
contur restart # Restart contur container
|
135
|
+
contur start # Build and start everything
|
136
|
+
contur validate # Validate build definition file
|
137
|
+
|
138
|
+
Options:
|
139
|
+
-v, [--verbose], [--no-verbose]
|
140
|
+
-f, [--force]
|
141
|
+
```
|
142
|
+
|
143
|
+
## Near-future goals and features to be implemented
|
144
|
+
- [ ] Selectable PHP version
|
145
|
+
- [ ] Configurable port mapping for MySQL and your site
|
146
|
+
- [ ] Multiple running environments
|
147
|
+
- [ ] Ability to choose between Apache and Nginx for server
|
148
|
+
- [ ] Ability to select/add PHP extensions
|
149
|
+
|
150
|
+
## Development
|
151
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
152
|
+
|
153
|
+
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).
|
154
|
+
|
155
|
+
## Contributing
|
156
|
+
1. Fork the repo
|
157
|
+
2. Commit your changes to your own repo on a separate branch
|
158
|
+
3. Submit pull request
|
159
|
+
|
160
|
+
If you can, please use the provided [EditorConfig](http://editorconfig.org/) file!
|
161
|
+
|
162
|
+
## Milestones
|
163
|
+
[List of Star Wars planets and moons](https://en.wikipedia.org/wiki/List_of_Star_Wars_planets_and_moons)
|
164
|
+
|
165
|
+
## License
|
166
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). See more in LICENSE.txt
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/contur
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'contur'
|
5
|
+
require 'colorize'
|
6
|
+
require 'pp'
|
7
|
+
require 'thor'
|
8
|
+
|
9
|
+
# rubocop:disable Metrics/AbcSize, Metrics/ClassLength
|
10
|
+
# Contur CLI
|
11
|
+
class ConturCLI < Thor
|
12
|
+
no_commands do # rubocop:disable Metrics/BlockLength
|
13
|
+
def build_image(options: {})
|
14
|
+
if Contur::Controller.image_exist?
|
15
|
+
puts 'Image already exists, skipping image build' if options[:verbose]
|
16
|
+
return
|
17
|
+
end
|
18
|
+
if options[:verbose]
|
19
|
+
Contur::Controller.build { |message| puts message }
|
20
|
+
else
|
21
|
+
start = Time.now
|
22
|
+
Contur::Controller.build do |message|
|
23
|
+
message.match(/step \d{1,2}/i) do |match|
|
24
|
+
num = match.to_s.split[1].to_i
|
25
|
+
step = '['.green + "#{(Time.now - start).round(2)}s".rjust(6) + ']'.green
|
26
|
+
text = "Building your image#{'.' * num}".green
|
27
|
+
print "#{step} #{text}\r"
|
28
|
+
$stdout.flush
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
print "\n"
|
33
|
+
$stdout.flush
|
34
|
+
puts 'Image build successfully'.green
|
35
|
+
end
|
36
|
+
|
37
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
38
|
+
def run_container(restart: false, options: {})
|
39
|
+
if (c = Contur::Controller.container?) && restart
|
40
|
+
Contur::Controller.delete_container
|
41
|
+
puts 'Container killed and deleted'.green
|
42
|
+
elsif c
|
43
|
+
puts "Container already exists, run 'contur restart' to relaunch it" if options[:verbose]
|
44
|
+
return
|
45
|
+
end
|
46
|
+
|
47
|
+
controller_run = Contur::Controller.run(webroot: Dir.pwd) do |log|
|
48
|
+
puts log if options[:verbose]
|
49
|
+
end
|
50
|
+
|
51
|
+
unless controller_run
|
52
|
+
puts 'Could not start container :('.red
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
56
|
+
puts 'Container started'.green
|
57
|
+
puts "Container id: #{Contur::Controller.container_id}" if options[:verbose]
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete_mysql_containers
|
61
|
+
if Contur::Controller.delete_mysql_containers
|
62
|
+
'MySQL container(s) killed and deleted'.green
|
63
|
+
else
|
64
|
+
'MySQL container(s) not found'.yellow
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def delete_image
|
69
|
+
if Contur::Controller.delete_image
|
70
|
+
'Image deleted'.green
|
71
|
+
else
|
72
|
+
'Image not found'.yellow
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete_container
|
77
|
+
if Contur::Controller.delete_container
|
78
|
+
'Container killed'.green
|
79
|
+
else
|
80
|
+
'Container not found'.yellow
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class_option :verbose, type: :boolean, aliases: '-v'
|
86
|
+
class_option :force, type: :boolean, aliases: '-f'
|
87
|
+
|
88
|
+
map %w(--version -V) => :__print_version
|
89
|
+
desc '--version, -V', 'Current version'
|
90
|
+
def __print_version
|
91
|
+
puts Contur::VERSION
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'start', 'Build and start everything'
|
95
|
+
def start
|
96
|
+
build_image(options: options)
|
97
|
+
|
98
|
+
run_container(options: options)
|
99
|
+
|
100
|
+
puts "Build environment up and running; run 'contur restart' to relaunch container".green
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'restart', 'Restart Contur container'
|
104
|
+
def restart
|
105
|
+
build_image(options: options)
|
106
|
+
|
107
|
+
run_container(restart: true, options: options)
|
108
|
+
|
109
|
+
puts "Build environment up and running; run 'contur restart' to relaunch container".green
|
110
|
+
end
|
111
|
+
|
112
|
+
desc 'log', 'Get container log'
|
113
|
+
def log
|
114
|
+
puts Contur::Controller.container_logs
|
115
|
+
end
|
116
|
+
|
117
|
+
desc 'delete [-C] [-I] [-M]', 'Delete container, image or MySQL container(s)'
|
118
|
+
method_option :container, aliases: '-C', type: :boolean, default: false, desc: 'Delete container'
|
119
|
+
method_option :image, aliases: '-I', type: :boolean, default: false, desc: 'Delete image'
|
120
|
+
method_option 'mysql-container',
|
121
|
+
aliases: '-M',
|
122
|
+
type: :boolean,
|
123
|
+
default: false,
|
124
|
+
desc: 'Delete MySQL container(s)'
|
125
|
+
def delete
|
126
|
+
puts delete_container if options[:container]
|
127
|
+
|
128
|
+
puts delete_image if options[:image]
|
129
|
+
|
130
|
+
puts delete_mysql_containers if options['mysql-container']
|
131
|
+
|
132
|
+
rescue => e
|
133
|
+
puts e.message.red
|
134
|
+
exit 1
|
135
|
+
end
|
136
|
+
|
137
|
+
desc 'validate', 'Validate build definition file'
|
138
|
+
method_option :path,
|
139
|
+
aliases: '-p',
|
140
|
+
default: File.join(Dir.pwd, Dir['.contur.y*ml'].first),
|
141
|
+
desc: 'Build definition file path'
|
142
|
+
def validate
|
143
|
+
begin
|
144
|
+
config = Contur::Controller.config(options[:path])
|
145
|
+
rescue Contur::Config::NotFoundError => e
|
146
|
+
puts "ERROR: #{e.message}".red
|
147
|
+
exit 1
|
148
|
+
end
|
149
|
+
|
150
|
+
puts "Config path: #{config.path}".green
|
151
|
+
|
152
|
+
if options[:verbose]
|
153
|
+
puts 'Config from file:'.yellow
|
154
|
+
pp config.raw
|
155
|
+
puts 'Final config:'.yellow
|
156
|
+
pp config
|
157
|
+
end
|
158
|
+
|
159
|
+
if config.errors.length.zero?
|
160
|
+
puts 'Looks good'.green
|
161
|
+
return
|
162
|
+
end
|
163
|
+
|
164
|
+
puts "Errors:\n".red
|
165
|
+
config.errors.each do |err|
|
166
|
+
puts err.red
|
167
|
+
end
|
168
|
+
exit 1
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
ConturCLI.start(ARGV)
|
data/bin/setup
ADDED
data/contur-logo.png
ADDED
Binary file
|
data/contur.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require_relative 'lib/contur/version.rb'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'contur'
|
9
|
+
spec.version = Contur::VERSION
|
10
|
+
spec.author = 'Cheppers Ltd.'
|
11
|
+
spec.email = 'info@cheppers.com'
|
12
|
+
spec.summary = 'Contur - Local Web Development Tool'
|
13
|
+
spec.homepage = 'https://github.com/Cheppers/contur'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.description = IO.read('README.md').match(/# Contur\n^(?<desc>.*)$/)[:desc]
|
16
|
+
|
17
|
+
spec.required_ruby_version = '>= 2.3.0'
|
18
|
+
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
26
|
+
spec.bindir = 'bin'
|
27
|
+
spec.executables = ['contur']
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'colorize', '~> 0.8'
|
31
|
+
spec.add_dependency 'excon', '~> 0.46', '>= 0.46'
|
32
|
+
spec.add_dependency 'docker-api', '~> 1.31', '>= 1.31'
|
33
|
+
spec.add_dependency 'thor', '~> 0.19'
|
34
|
+
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
36
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
37
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 0.44'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
40
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Contur module :D
|
3
|
+
module Contur
|
4
|
+
# BindableHash is for ERB templates
|
5
|
+
class BindableHash
|
6
|
+
def initialize(hash)
|
7
|
+
hash.each do |key, value|
|
8
|
+
singleton_class.send(:define_method, key) { value }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_binding # rubocop:disable Style/AccessorMethodName
|
13
|
+
binding
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Contur
|
3
|
+
class Config
|
4
|
+
# Before section
|
5
|
+
class Before < Array
|
6
|
+
# before_commands is required so no default value
|
7
|
+
def initialize(before_commands)
|
8
|
+
super([])
|
9
|
+
validate!(before_commands)
|
10
|
+
replace(before_commands) unless before_commands.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate!(before_commands)
|
14
|
+
@errors = []
|
15
|
+
@errors << 'Required' if before_commands.nil?
|
16
|
+
@errors << 'Cannot be empty' if before_commands == []
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :errors
|
20
|
+
|
21
|
+
def name
|
22
|
+
"Section 'before'"
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_bash_script
|
26
|
+
reduce('') { |a, e| a + "#{e}\n" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Contur
|
3
|
+
class Config
|
4
|
+
# Env section
|
5
|
+
class Env < Hash
|
6
|
+
def initialize(env = {})
|
7
|
+
validate!(env)
|
8
|
+
super
|
9
|
+
replace(env) unless env.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate!(_env)
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def errors
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
"Section 'env'"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_bash_script
|
25
|
+
reduce('') { |a, (k, v)| a + "export #{k}=\"#{v}\"\n" }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|