capistrano-twelvefactor 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 529815d75094ffa658929d940e6d679da3d62ce9
4
+ data.tar.gz: 46aa25ab59f10700d44158c996ba79e0a257fac5
5
+ SHA512:
6
+ metadata.gz: e4405f835a45debf9a90e11155f7f1af838d02bf77209d5fe9932f6381fe67e3f3101baa6292959866fa1ecfc69053e93b255236b3f998ea1283a8357f1b9847
7
+ data.tar.gz: 3953623382a18cb80f7872c59f6db997c9561b98cc36ad09809ae6aae38e82c2490ee763811301ea3a5383ba686688aceac6b9d19780e7ff5e263ddf00eef990
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-twelvefactor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Yanted
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,56 @@
1
+ # Capistrano::Twelvefactor
2
+
3
+ Simple capistrano tasks to change environment variables like you would on Heroku.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-twelvefactor'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-twelvefactor
18
+
19
+ ## Usage
20
+
21
+ ### In your $stage.rb
22
+
23
+ Set the file you want to be written to, in order to change environment
24
+ variables. Usually this would be `.bashrc`, `/etc/environment` or something
25
+ similar, depending on your linux OS. The default is `.bashrc`.
26
+
27
+ ```ruby
28
+ set :environment_file, '.bashrc'
29
+ ```
30
+
31
+ ### On your command line
32
+
33
+ #### Setting a value
34
+
35
+ ```bash
36
+ $ cap production config:set FOO=bar
37
+ ```
38
+
39
+ #### Removing a value
40
+
41
+ ```bash
42
+ $ cap production config:unset FOO
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
52
+
53
+
54
+ ## License
55
+
56
+ MIT
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/twelvefactor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'capistrano-twelvefactor'
8
+ spec.version = Capistrano::Twelvefactor::VERSION
9
+ spec.authors = ['Mario Behrendt']
10
+ spec.email = ['info@yanted.com']
11
+ spec.summary = 'Capistrano tasks to change environment config on remote hosts'
12
+ spec.description = 'Capistrano tasks to change environment config on remote hosts'
13
+ spec.homepage = 'http://www.github.com/yanted/capistrano-twelvefactor'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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.4'
22
+ spec.add_development_dependency 'rake'
23
+
24
+ spec.add_runtime_dependency 'capistrano'
25
+ end
@@ -0,0 +1 @@
1
+ set :environment_file, '.bashrc'
@@ -0,0 +1,31 @@
1
+ namespace :config do
2
+ def file_name
3
+ fetch(:environment_file)
4
+ end
5
+
6
+ desc 'Set config value by key'
7
+ task :set do
8
+ config = Hash[[:key, :value].zip(ARGV.last.split('='))]
9
+ cmd = Capistrano::Twelvefactor::Command.new(file_name, config)
10
+
11
+ on release_roles :all do
12
+ execute cmd.set_command
13
+ end
14
+ end
15
+
16
+ desc 'Remove config by key'
17
+ task :unset do
18
+ cmd = Capistrano::Twelvefactor::Command.new(file_name, key: ARGV.last)
19
+
20
+ on release_roles :all do
21
+ begin
22
+ execute cmd.unset_command
23
+ exit 0
24
+ rescue => e
25
+ exit 0 if e.message =~ /Nothing written/
26
+ error e
27
+ exit 1
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Twelvefactor
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ require 'capistrano/twelvefactor/version'
2
+ require 'capistrano/twelvefactor/defaults'
3
+ load File.expand_path('../twelvefactor/tasks/capistrano-twelvefactor.rake', __FILE__)
4
+
5
+ module Capistrano
6
+ module Twelvefactor
7
+ class Command
8
+ def initialize(file, config)
9
+ @file = file
10
+ @config = config
11
+ end
12
+
13
+ def set_command
14
+ [grep_cmd, '&&', replace_cmd, '||', append_cmd].join(' ')
15
+ end
16
+
17
+ def unset_command
18
+ [grep_cmd, '&&', unset_cmd].join(' ')
19
+ end
20
+
21
+ private
22
+
23
+ def grep_cmd
24
+ sprintf 'grep -Fq "%s" %s', key_set_string, @file
25
+ end
26
+
27
+ def key_set_string
28
+ @config[:key] + '='
29
+ end
30
+
31
+ def replace_cmd
32
+ sprintf 'sed -i "s/%s.*/%s%s/" %s', key_set_string, key_set_string, @config[:value], @file
33
+ end
34
+
35
+ def append_cmd
36
+ sprintf 'echo "%s%s" >> %s', key_set_string, @config[:value], @file
37
+ end
38
+
39
+ def unset_cmd
40
+ sprintf 'sed -i /%s/d %s', key_set_string, @file
41
+ end
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-twelvefactor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mario Behrendt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-24 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.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: capistrano
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Capistrano tasks to change environment config on remote hosts
56
+ email:
57
+ - info@yanted.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - capistrano-twelvefactor.gemspec
68
+ - lib/capistrano/twelvefactor.rb
69
+ - lib/capistrano/twelvefactor/defaults.rb
70
+ - lib/capistrano/twelvefactor/tasks/capistrano-twelvefactor.rake
71
+ - lib/capistrano/twelvefactor/version.rb
72
+ homepage: http://www.github.com/yanted/capistrano-twelvefactor
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Capistrano tasks to change environment config on remote hosts
96
+ test_files: []
97
+ has_rdoc: