capistrano-lazy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/lib/capistrano/lazy.rb +1 -1
- data/lib/capistrano/lazy/tasks/database_yml.rake +4 -0
- data/lib/capistrano/lazy/yaml_file_tasks.rb +5 -0
- data/lib/capistrano/lazy/yaml_files.rb +36 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aa1ca4b4796d75c753ec60a4ab7b4bdb959d3ec
|
4
|
+
data.tar.gz: ef98bf8f7ec2673777728a495f08a7861695a1ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c08e3044250617bc82a3048f535bb01aa0b2453e98e5f8edd8eac7659751958017ecfdbc85616679ca6435ebc0294aa87ce6ce264058e088de0684f048e889e5
|
7
|
+
data.tar.gz: 757109f8c6edd3e55386e50d6052bd6c2009203f3179cd18f447e095ad0295e11c7213af87d3944f8b972980f83310aff337d251efc776fdf0d03188133b5be3
|
data/README.md
CHANGED
@@ -18,6 +18,29 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
### Bootstrapping YAML configuration files
|
22
|
+
|
23
|
+
This task is used together with the remote file task.
|
24
|
+
It will bootstrap remote YAML configuration files based on `.yml.example` templates.
|
25
|
+
It will parse the file asking for values, save and upload the file remote.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'capistrano/lazy/yaml_file_tasks'
|
29
|
+
```
|
30
|
+
|
31
|
+
Loads the default task to bootstrap the `database.yml`.
|
32
|
+
|
33
|
+
To add more files to be managed, add those to the `linked_files` list and create a task based on this:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
remote_file 'config/database.yml' => './config/database.yml', :roles => :db
|
37
|
+
file './config/database.yml' do |f|
|
38
|
+
yaml_file(f.name)
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
To recreate the file. Just remove the local and remote files you want to be recreated.
|
43
|
+
|
21
44
|
### Rbenv and Ruby build tasks
|
22
45
|
|
23
46
|
I added a couple of tasks to manage rbenv and ruby-build remote setup, update and rubies installation.
|
data/lib/capistrano/lazy.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module ::Capistrano::DSL::YamlFiles
|
4
|
+
# Its like `ask` but stateless
|
5
|
+
def ask_for_value(key, default)
|
6
|
+
question = ::Capistrano::Configuration::Question.new(self, key, default)
|
7
|
+
yield question
|
8
|
+
end
|
9
|
+
|
10
|
+
# Creates the file based on existing example YAML file
|
11
|
+
def yaml_file(file_path)
|
12
|
+
file_name = File.basename(file_path)
|
13
|
+
example_file = File.expand_path(file_name + '.example', 'config')
|
14
|
+
|
15
|
+
puts 'Creating file %s using %s' % [file_name, example_file]
|
16
|
+
puts '...'
|
17
|
+
|
18
|
+
reading_example(example_file) do |hash|
|
19
|
+
File.write(file_path, hash.to_yaml)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Reads an example file and asks if its values need to be changed
|
24
|
+
def reading_example(yml_example_file)
|
25
|
+
yml_env = fetch(:stage).to_s
|
26
|
+
yml_hash = YAML.load_file(yml_example_file.to_s)
|
27
|
+
yml_hash[yml_env].each do |key, val|
|
28
|
+
unless val.is_a? Hash
|
29
|
+
ask_for_value(key, val) do |answer|
|
30
|
+
yml_hash[yml_env][key] = answer.call
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
yield yml_hash.slice(yml_env)
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-lazy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stas SUȘCOV
|
@@ -66,6 +66,9 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- capistrano-lazy.gemspec
|
68
68
|
- lib/capistrano/lazy.rb
|
69
|
+
- lib/capistrano/lazy/tasks/database_yml.rake
|
70
|
+
- lib/capistrano/lazy/yaml_file_tasks.rb
|
71
|
+
- lib/capistrano/lazy/yaml_files.rb
|
69
72
|
- lib/capistrano/rbenv/lazy.rb
|
70
73
|
- lib/capistrano/rbenv/tasks/lazy.rake
|
71
74
|
homepage: https://github.com/stas/capistrano-lazy
|