capistrano-env_config 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dec343550dfd2b3654978a89e53149fa139ca27
4
- data.tar.gz: 26058a4ef80721f3c3cdbdfc5b57b306140abed8
3
+ metadata.gz: 454e578c8df69f1d96d4a40af745ff98851cb0d3
4
+ data.tar.gz: 20b0f51bc9b841657a427f486d4fd547bb187bc2
5
5
  SHA512:
6
- metadata.gz: af3c204fb185a1bbb94918962f6643e67c999e6788f2920c32c0d34986fcd4f949d4ff3e4f37ce28b47bd9e8938a4088e7e04e534ecdf27fda5a362a24574b57
7
- data.tar.gz: ca1260e663d042e711b692901367768ab880e601b2d2907d06dc98fff0f1ecbba4173a3f3e69990721556680b662c8d758e0186f55c3ccf0def392f36f546c52
6
+ metadata.gz: 8d818244b23cf883f33832537bbeffdb485e64cd1bc652953754c6846be0a3c926c0c1ad4e3f32155c83143c07ecd54fa668fa2db1b51cf8a1e53428b13341b4
7
+ data.tar.gz: 90d158945825fd34a1f4612f6594b937279449994015b12e18bf2837e3d36ef8497f4a454b2db4b4f8ddcb6eafdb1d6ea90bfa5c90289560647dc312d4ec8450
data/CHANGELOG.md CHANGED
@@ -7,7 +7,8 @@ v0.0.2
7
7
  environment variables from.
8
8
  * Added an argument for specifically setting roles when using the `Environment`
9
9
  class programatically.
10
-
10
+ * Note: Implemented using the potentially unstable and subject to change
11
+ `Capistrano::Plugin` API.
11
12
 
12
13
  v0.0.1
13
14
  ------
data/README.md CHANGED
@@ -11,9 +11,9 @@ Usage
11
11
  -----
12
12
 
13
13
  * `cap env:list` – To list current environment configuration
14
- * `cap env:get[VARIABLE_NAME]` – To get the value of specific variable
15
- * `cap env:unset[VARIABLE_NAME]` – To delete an environment variable
16
- * `cap env:set[VARIABLE_NAME=VALUE]` – To set an environment variable
14
+ * `cap env:get[VARIABLE_NAME,VARIABLE_NAME]` – To get the value of specific variable
15
+ * `cap env:unset[VARIABLE_NAME,VARIABLE_NAME]` – To delete an environment variable
16
+ * `cap env:set[VARIABLE_NAME=VALUE,VARIABLE_NAME=VALUE]` – To set an environment variable
17
17
  * `cap env:sync` – To synchronise the environment configuration across servers
18
18
 
19
19
  If you need to programatically manipulate the environment you can use the
@@ -22,25 +22,46 @@ If you need to programatically manipulate the environment you can use the
22
22
  ```ruby
23
23
  require 'capistrano/env_config/environment'
24
24
 
25
- environment = Capistrano::EnvConfig::Environment.new
26
- environment.list
27
- environment.get( 'VARIABLE' )
28
- environment.set( 'VARIABLE', 'VALUE' )
29
- environment.delete( 'VARIABLE' )
30
- environment.sync
25
+ environment = Capistrano::EnvConfig::Environment.new # Reads and loads /etc/environment from all servers
26
+ environment.list # Returns a hash of all environment variables
27
+ environment.get( 'VARIABLE' ) # Gets a variable by name
28
+ environment.set( 'VARIABLE', 'VALUE' ) # Sets a variable
29
+ environment.delete( 'VARIABLE' ) # Deletes a variable
30
+ environment.sync # Uploads current confifuration to all servers
31
+ ```
32
+
33
+ By default capistrano sets and reads the `/etc/environment` of all roles. This
34
+ behaviour can be changed by setting:
35
+
36
+ ```ruby
37
+ set :env_config_roles, [ :web, :app ]
38
+ ```
39
+
40
+ The `new` and `sync` methods also accept an optional argument for specifying
41
+ roles explicitly (overriding the value set in `:env_config_roles`):
42
+
43
+ ```ruby
44
+ environment.list( :app )
45
+ environment.sync( [ :web, :app ] )
31
46
  ```
32
47
 
33
48
  Installation
34
49
  ------------
35
50
 
36
- Add the gem to your Gemfile:
51
+ Add the gem to your `Gemfile`:
37
52
 
38
- ```gemfile
53
+ ```ruby
39
54
  group :development do
40
55
  gem 'capistrano-env_config'
41
56
  end
42
57
  ```
43
58
 
59
+ And the following line to your `Capfile`:
60
+
61
+ ```ruby
62
+ require 'capistrano/env_config'
63
+ ```
64
+
44
65
  In your server provisioning script, make sure the deploy user has write access
45
66
  to the `/etc/environment` file, which is used to store the configured variables.
46
67
 
@@ -57,4 +78,4 @@ License
57
78
  Copyright Itay Grudev (c) 2017.
58
79
 
59
80
  This gem and all associated documentation is distributed under the terms of the
60
- GNU GPL v3 license.
81
+ GNU GPL v3 license.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'capistrano/env_config/version'
3
+ require_relative 'lib/capistrano/env_config/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'capistrano-env_config'
@@ -28,4 +28,4 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency 'rspec', '~> 3.6'
30
30
  spec.add_development_dependency 'simplecov', '~> 0.14'
31
- end
31
+ end
@@ -1,2 +1,2 @@
1
- require 'capistrano/env_config/version'
2
- require 'capistrano/env_config/environment'
1
+ require_relative 'capistrano/env_config/version'
2
+ require_relative 'capistrano/env_config/environment'
@@ -15,5 +15,5 @@ end
15
15
 
16
16
  install_plugin Capistrano::EnvConfig
17
17
 
18
- require 'capistrano/env_config/environment'
19
- require 'capistrano/env_config/version'
18
+ require_relative 'env_config/environment'
19
+ require_relative 'env_config/version'
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  class EnvConfig
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
- require 'capistrano/env_config/environment'
1
+ require 'byebug'
2
+ require_relative '../env_config/environment'
2
3
 
3
4
  namespace :env do
4
5
  desc 'Lists the environment variables set across servers'
@@ -16,33 +17,39 @@ namespace :env do
16
17
  end
17
18
 
18
19
  desc 'Sets an environment variable'
19
- task :set, :variable do |task, args|
20
- abort 'No key-value pair specified.' if args[:variable].nil?
21
- key, value = args[:variable].split( '=', 2 )
20
+ task :set do |task, args|
21
+ abort 'No key-value pair specified.' if args.extras.empty?
22
22
  environment = Capistrano::EnvConfig::Environment.new
23
- environment.set( key, value )
23
+ args.extras.each do |variable|
24
+ key, value = variable.split( '=', 2 )
25
+ environment.set( key, value )
26
+ end
24
27
  environment.sync
25
28
  end
26
29
 
27
30
  desc 'Prints an environment variable'
28
- task :get, :variable do |task, args|
31
+ task :get do |task, args|
29
32
  environment = Capistrano::EnvConfig::Environment.new
30
- variable = environment.get( args[:variable] )
31
- if variable.nil?
32
- abort "No such variable: #{args[:variable].upcase}"
33
- else
34
- puts "#{args[:variable].upcase}=#{variable}"
33
+ args.extras.each do |variable|
34
+ value = environment.get( variable )
35
+ if value.nil?
36
+ STDERR.puts "No such variable: #{variable.upcase}"
37
+ else
38
+ puts "#{variable.upcase}=#{value}"
39
+ end
35
40
  end
36
41
  end
37
42
 
38
43
  desc 'Removes a environment variable'
39
- task :unset, :variable do |task, args|
44
+ task :unset do |task, args|
40
45
  environment = Capistrano::EnvConfig::Environment.new
41
- if environment.get( args[:variable].upcase ).nil?
42
- abort "No such variable: #{args[:variable].upcase}"
43
- else
44
- environment.delete( args[:variable].upcase )
45
- environment.sync
46
+ args.extras.each do |variable|
47
+ if environment.get( variable.upcase ).nil?
48
+ abort "No such variable: #{variable.upcase}"
49
+ else
50
+ environment.delete( variable.upcase )
51
+ end
46
52
  end
53
+ environment.sync
47
54
  end
48
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-env_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Itay Grudev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-23 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano