varfile 0.0.2 → 0.0.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.
- data/README.md +8 -5
- data/lib/varfile/capistrano.rb +48 -0
- data/lib/varfile/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -22,27 +22,30 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
Set a value for a key:
|
26
|
+
|
25
27
|
```bash
|
26
28
|
$ varfile set FOO bar --file=/u/app/shared/config/.env
|
27
29
|
```
|
28
30
|
|
31
|
+
Get the value of a key:
|
32
|
+
|
29
33
|
```bash
|
30
34
|
$ varfile get FOO --file=/u/app/shared/config/.env
|
31
35
|
bar
|
32
36
|
```
|
33
37
|
|
38
|
+
List all keys and values:
|
39
|
+
|
34
40
|
```bash
|
35
41
|
$ varfile list --file=/u/app/shared/config/.env
|
36
42
|
FOO=bar
|
37
43
|
```
|
38
44
|
|
39
|
-
|
40
|
-
$ varfile rm FOO --file=/u/app/shared/config/.env
|
41
|
-
```
|
45
|
+
Remove a key:
|
42
46
|
|
43
47
|
```bash
|
44
|
-
$ varfile
|
45
|
-
$
|
48
|
+
$ varfile rm FOO --file=/u/app/shared/config/.env
|
46
49
|
```
|
47
50
|
|
48
51
|
If `--file` option is missing, variables will be written to a file named
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
before "deploy:finalize_update", "varfile:release_config"
|
4
|
+
|
5
|
+
_cset(:varfile_roles) { [:app, :db] }
|
6
|
+
_cset(:varfile_shared_path) { File.join(fetch(:shared_path), 'config') }
|
7
|
+
_cset(:varfile_filename) { '.env' }
|
8
|
+
_cset(:varfile_source_path) { File.join(fetch(:varfile_shared_path), fetch(:varfile_filename)) }
|
9
|
+
_cset(:varfile_destination_path) { File.join(fetch(:release_path), fetch(:varfile_filename)) }
|
10
|
+
_cset(:varfile_command) { "varfile" }
|
11
|
+
_cset(:varfile_options) { "--file=#{fetch(:varfile_source_path)}" }
|
12
|
+
|
13
|
+
namespace :varfile do
|
14
|
+
# This one is supposed to be run during deploy, so I'm using release_path
|
15
|
+
task :release_config, roles: fetch(:varfile_roles) do
|
16
|
+
run "if test -f #{varfile_source_path} ; then cp #{varfile_source_path} #{release_path} ; fi "
|
17
|
+
end
|
18
|
+
|
19
|
+
# The following are supposed to be used on current_path, to set
|
20
|
+
# variables for a live applicaiton or prepare for the next deploy
|
21
|
+
desc "copy varfile to current path"
|
22
|
+
task :copy_config_to_current_path, roles: fetch(:varfile_roles) do
|
23
|
+
run "cp -f #{varfile_source_path} #{current_path}"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "list content of config vars in varfile"
|
27
|
+
task :list, roles: fetch(:varfile_roles) do
|
28
|
+
run "cd #{current_path} && #{varfile_command} list #{varfile_options}"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "set value for a key in varfile"
|
32
|
+
task :set, roles: fetch(:varfile_roles) do
|
33
|
+
key = ENV.fetch('KEY')
|
34
|
+
value = ENV.fetch('VALUE')
|
35
|
+
run "cd #{current_path} && #{varfile_command} set #{key} #{value} #{varfile_options}"
|
36
|
+
copy_config_to_current_path
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "remove a key from varfile"
|
40
|
+
task :rm, roles: fetch(:varfile_roles) do
|
41
|
+
key = ENV.fetch('KEY')
|
42
|
+
|
43
|
+
run "cd #{current_path} && #{varfile_command} rm #{key} #{varfile_options}"
|
44
|
+
copy_config_to_current_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
data/lib/varfile/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: varfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- Rakefile
|
44
44
|
- bin/varfile
|
45
45
|
- lib/varfile.rb
|
46
|
+
- lib/varfile/capistrano.rb
|
46
47
|
- lib/varfile/version.rb
|
47
48
|
- spec/spec_helper.rb
|
48
49
|
- spec/varfile/command_spec.rb
|