capistrano-figaro-yml 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: acd8542d1af7042c405f56d0be4131db6d592f4b
4
+ data.tar.gz: 31e26c3b4feb60ec37de44795e4ada4750c3a490
5
+ SHA512:
6
+ metadata.gz: a44198b2827828e484323955e26494ab9273b6695aab66300e905ed3aed119f6c6c50e8522a5f4cd44a734dd72dec3fe6e8688efabbc4e9efb32d27c6300149c
7
+ data.tar.gz: f516bec0959ac2d41c8e46cb5c86a3847ab98ceb704f16db4b6c4cddab81eb924f7d0573ad8faee28cce7f8ee4466b8dbdfee29ec0f59d3e748cd3ce590f4a6b
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ### v1.0.0, 2015-01-24
4
+ - started the project
5
+ - first working version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in *.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright 2015 ChouAndy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ # Capistrano::FigaroYml
2
+
3
+ Capistrano tasks for handling figaro `application.yml` when deploying Rails 4+ apps.
4
+
5
+ ### Install
6
+
7
+ Add this to `Gemfile`:
8
+
9
+ group :development do
10
+ gem 'capistrano', '~> 3.2.1'
11
+ gem 'capistrano-figaro-yml', '~> 1.0.0'
12
+ end
13
+
14
+ And then:
15
+
16
+ $ bundle install
17
+
18
+ ### Setup and usage
19
+
20
+ - make sure your local `config/application.yml` is not git tracked. It **should be on
21
+ the disk**, but gitignored.
22
+
23
+ - populate production figaro settings in local `config/application.yml`:
24
+
25
+ production:
26
+ secret_key_base: "d6ced..."
27
+
28
+ - add to `Capfile`:
29
+
30
+ require 'capistrano/figaro_yml'
31
+
32
+ - create figaro `application.yml` file on the remote server by executing this task:
33
+
34
+ $ bundle exec cap production setup
35
+
36
+ You can now proceed with other deployment tasks.
37
+
38
+ #### What if a new config is added to figaro file?
39
+
40
+ - add it to local `config/application.yml`:
41
+
42
+ production:
43
+ secret_key_base: "d6ced..."
44
+ foobar: "some_other_secret"
45
+
46
+ - if you're working in a team where other people have the deploy rights, compare
47
+ you local `application.yml` with the one on the server. This is to ensure you
48
+ didn't miss an update.
49
+ - copy to the server:
50
+
51
+ $ bundle exec cap production setup
52
+
53
+ - notify your colleagues that have the deploy rights that the remote
54
+ `application.yml` has been updated so they can change their copy.
55
+
56
+
57
+ ### How it works
58
+
59
+ When you execute `$ bundle exec production setup`:
60
+
61
+ - figaro settings from your local `application.yml` are copied to the server.<br/>
62
+ - only "stage" secrets are copied: if you are deploying to `production`,
63
+ only production secrets are copied there
64
+ - on the server secrets file is located in `#{shared_path}/config/application.yml`
65
+
66
+ On deployment:
67
+
68
+ - secrets file is automatically symlinked to `#{current_path}/config/application.yml`
69
+
70
+ ### Configuration
71
+
72
+ None.
73
+
74
+ ### More Capistrano automation?
75
+
76
+ Check out [capistrano-plugins](https://github.com/capistrano-plugins) github org.
77
+
78
+ ### License
79
+
80
+ [MIT](LICENSE.md)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "capistrano/figaro_yml/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "capistrano-figaro-yml"
8
+ gem.version = Capistrano::FigaroYml::VERSION
9
+ gem.authors = ["Chia-Hui Chou"]
10
+ gem.email = ["chouandy625@gmail.com"]
11
+ gem.description = <<-EOF.gsub(/^\s+/, "")
12
+ Capistrano tasks for automating figaro `application.yml` file handling for Rails 4+ apps.
13
+
14
+ This plugins syncs contents of your local figaro file and copies that to
15
+ the remote server.
16
+ EOF
17
+ gem.summary = "Capistrano tasks for automating figaro `application.yml` file handling for Rails 4+ apps."
18
+ gem.homepage = "https://github.com/ChouAndy/capistrano-figaro-yml"
19
+ gem.license = "MIT"
20
+
21
+ gem.files = `git ls-files`.split($/)
22
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
+ gem.require_paths = ["lib"]
25
+
26
+ gem.add_runtime_dependency 'capistrano', '~> 3.1'
27
+ gem.add_runtime_dependency 'sshkit', '~> 1.2', '>= 1.2.0'
28
+
29
+ gem.add_development_dependency 'rake', '~> 0'
30
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require "capistrano/figaro_yml/paths"
2
+ require "capistrano/figaro_yml/helpers"
3
+ load File.expand_path("../tasks/figaro_yml.rake", __FILE__)
@@ -0,0 +1,49 @@
1
+ require "yaml"
2
+
3
+ module Capistrano
4
+ module FigaroYml
5
+ module Helpers
6
+
7
+ def local_figaro_yml(env)
8
+ @local_figaro_yml ||= YAML.load_file(figaro_yml_local_path)
9
+ @local_figaro_yml[env]
10
+ end
11
+
12
+ def figaro_yml_env
13
+ fetch(:figaro_yml_env).to_s
14
+ end
15
+
16
+ def figaro_yml_content
17
+ { figaro_yml_env => local_figaro_yml(figaro_yml_env) }.to_yaml
18
+ end
19
+
20
+ # error helpers
21
+
22
+ def check_git_tracking_error
23
+ puts
24
+ puts "Error - please remove '#{fetch(:figaro_yml_local_path)}' from git:"
25
+ puts
26
+ puts " $ git rm --cached #{fetch(:figaro_yml_local_path)}"
27
+ puts
28
+ puts "and gitignore it:"
29
+ puts
30
+ puts " $ echo '#{fetch(:figaro_yml_local_path)}' >> .gitignore"
31
+ puts
32
+ end
33
+
34
+ def check_config_present_error
35
+ puts
36
+ puts "Error - '#{figaro_yml_env}' config not present in '#{fetch(:figaro_yml_local_path)}'."
37
+ puts "Please populate it."
38
+ puts
39
+ end
40
+
41
+ def check_figaro_file_exists_error
42
+ puts
43
+ puts "Error - '#{fetch(:figaro_yml_local_path)}' file does not exists, and it's required."
44
+ puts
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ require "pathname"
2
+
3
+ module Capistrano
4
+ module FigaroYml
5
+ module Paths
6
+
7
+ def figaro_yml_local_path
8
+ Pathname.new fetch(:figaro_yml_local_path)
9
+ end
10
+
11
+ def figaro_yml_remote_path
12
+ shared_path.join fetch(:figaro_yml_remote_path)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module FigaroYml
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,60 @@
1
+ include Capistrano::FigaroYml::Paths
2
+ include Capistrano::FigaroYml::Helpers
3
+
4
+ namespace :load do task :defaults do
5
+ set :figaro_yml_local_path, "config/application.yml"
6
+ set :figaro_yml_remote_path, "config/application.yml"
7
+ set :figaro_yml_env, -> { fetch(:rails_env) || fetch(:stage) }
8
+ end
9
+ end
10
+
11
+ namespace :figaro_yml do
12
+
13
+ task :check_figaro_file_exists do
14
+ next if File.exists?(figaro_yml_local_path)
15
+ check_figaro_file_exists_error
16
+ exit 1
17
+ end
18
+
19
+ task :check_git_tracking do
20
+ next unless system("git ls-files #{fetch(:figaro_yml_local_path)} --error-unmatch >/dev/null 2>&1")
21
+ check_git_tracking_error
22
+ exit 1
23
+ end
24
+
25
+ task :check_config_present do
26
+ next unless local_figaro_yml(figaro_yml_env).nil?
27
+ check_config_present_error
28
+ exit 1
29
+ end
30
+
31
+ desc "figaro `application.yml` file checks"
32
+ task :check do
33
+ invoke "figaro_yml:check_figaro_file_exists"
34
+ invoke "figaro_yml:check_git_tracking"
35
+ invoke "figaro_yml:check_config_present"
36
+ end
37
+
38
+ desc "Setup figaro `application.yml` file on the server(s)"
39
+ task setup: [:check] do
40
+ content = figaro_yml_content
41
+ on release_roles :all do
42
+ execute :mkdir, "-pv", File.dirname(figaro_yml_remote_path)
43
+ upload! StringIO.new(content), figaro_yml_remote_path
44
+ end
45
+ end
46
+
47
+ # Update `linked_files` after the deploy starts so that users'
48
+ # `figaro_yml_remote_path` override is respected.
49
+ task :figaro_yml_symlink do
50
+ set :linked_files, fetch(:linked_files, []).push(fetch(:figaro_yml_remote_path))
51
+ end
52
+ after "deploy:started", "figaro_yml:figaro_yml_symlink"
53
+
54
+ end
55
+
56
+ desc "Server setup tasks"
57
+ task :setup do
58
+ invoke "secrets_yml:setup"
59
+ end
60
+
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-figaro-yml
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chia-Hui Chou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sshkit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.2.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.2.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: |
62
+ Capistrano tasks for automating figaro `application.yml` file handling for Rails 4+ apps.
63
+ This plugins syncs contents of your local figaro file and copies that to
64
+ the remote server.
65
+ email:
66
+ - chouandy625@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - CHANGELOG.md
72
+ - Gemfile
73
+ - LICENSE.md
74
+ - README.md
75
+ - Rakefile
76
+ - capistrano-figaro-yml.gemspec
77
+ - lib/capistrano-figaro-yml.rb
78
+ - lib/capistrano/figaro_yml.rb
79
+ - lib/capistrano/figaro_yml/helpers.rb
80
+ - lib/capistrano/figaro_yml/paths.rb
81
+ - lib/capistrano/figaro_yml/version.rb
82
+ - lib/capistrano/tasks/figaro_yml.rake
83
+ homepage: https://github.com/ChouAndy/capistrano-figaro-yml
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.4.5
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Capistrano tasks for automating figaro `application.yml` file handling for
107
+ Rails 4+ apps.
108
+ test_files: []