mina-config 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 152340b5d39b85176be19edd9b87e779d7b9c8a2
4
+ data.tar.gz: fdec71830cb42986844ffd3b1870057208de4fb9
5
+ SHA512:
6
+ metadata.gz: b3d8b9a7789b0414dadec24329dc6a08f1afb3ce23a57040ed5b2dd61119e4d2ac699a3a969a7c9e7b1ac9f0708dcbed50b84519cbec52e9a84a1f1ecc268621
7
+ data.tar.gz: aa75fb46c580bca25a2d50fc5f55f6ca24820149a7bc729e033a9712051745d5d4c19d4edad6e04e87dbf59d00353493f0e9388367f21ce750573579a36405b1
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina-config.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Zachary Mckenzie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Zachary Mckenzie
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,81 @@
1
+ # Mina::Config
2
+
3
+ Adds a multi-environment yml configuration file to mina. Environment configuration is dynamically created by the definitions in the deploy.yml file.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mina-config'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mina-config
18
+
19
+ ## Usage
20
+
21
+ Require `mina/config` in `config/deploy.rb`:
22
+
23
+ ```rb
24
+ require 'mina/config'
25
+ require 'mina/bundler'
26
+ require 'mina/rails'
27
+ require 'mina/git'
28
+
29
+ ...
30
+
31
+ task setup: :environment do
32
+ ...
33
+ end
34
+
35
+ desc 'Deploys the current version to the server.'
36
+ task deploy: :environment do
37
+ ...
38
+ end
39
+ ```
40
+
41
+ Then run the config initializer:
42
+
43
+ ```shell
44
+ $ mina config:init
45
+ ```
46
+
47
+ It will create `config/deploy.yml`.
48
+ Use this file to define stage-specific configuration.
49
+
50
+ ```yml
51
+ common: &common
52
+ app: Mina_config
53
+ repository: git@github.com:zmckenzie/mina-config.git
54
+ shared_paths: ['config/database.yml', 'log']
55
+ staging:
56
+ <<: *common
57
+ domain: staging.example.com
58
+ user: example
59
+ branch: staging
60
+ ```
61
+
62
+ Now deploy `staging` with:
63
+
64
+ ```shell
65
+ $ mina deploy
66
+ ```
67
+
68
+ Or specify a stage explicitly:
69
+
70
+ ```shell
71
+ $ mina staging deploy
72
+ $ mina production deploy
73
+ ```
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it ( http://github.com/zmckenzie/mina-config/fork )
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,12 @@
1
+ class String
2
+ def dedent
3
+ lines = split "\n"
4
+ return self if lines.empty?
5
+ indents = lines.map do |line|
6
+ line =~ /\S/ ? (line.start_with?(" ") ? line.match(/^ +/).offset(0)[1] : 0) : nil
7
+ end
8
+ min_indent = indents.compact.min
9
+ return self if min_indent.zero?
10
+ lines.map { |line| line =~ /\S/ ? line.gsub(/^ {#{min_indent}}/, "") : line }.join "\n"
11
+ end
12
+ end
@@ -0,0 +1,89 @@
1
+ require 'mina/config/version'
2
+ require 'fileutils'
3
+ require 'yaml'
4
+ require 'mina/rvm'
5
+ require 'active_support/core_ext/hash'
6
+ require 'mina/String'
7
+
8
+
9
+ default_env = fetch(:default_env, 'staging')
10
+ config_file = 'config/deploy.yml'
11
+ set :config, YAML.load(File.open(config_file)).with_indifferent_access if File.exists? config_file
12
+ set :rails_env, ENV['to'] || :staging
13
+
14
+ unless config.nil?
15
+ envs = []
16
+ config.each {|k,v| envs << k}
17
+
18
+ set :environments, envs
19
+ end
20
+
21
+ unless environments.nil?
22
+ environments.each do |environment|
23
+ desc "Set the environment to #{environment}."
24
+ task(environment) do
25
+ set :rails_env, environment
26
+ set :branch, config[rails_env]['branch']
27
+ set :user, config[rails_env]['user']
28
+ set :domain, config[rails_env]['domain']
29
+ set :app, config[rails_env]['app']
30
+ set :repository, config[rails_env]['repository']
31
+ set :shared_paths, config[rails_env]['shared_paths']
32
+
33
+ set :deploy_to, "/srv/app/#{app}"
34
+
35
+ set :ruby_version, File.read('.ruby-version')
36
+
37
+ invoke :"rvm:use[ruby-#{ruby_version}]"
38
+ end
39
+ end
40
+
41
+ unless environments.include?(ARGV.first)
42
+ invoke default_env
43
+ end
44
+ end
45
+
46
+ namespace :config do
47
+ desc 'Create deploy config file'
48
+ task :init do
49
+ if File.exists?(config_file).blank?
50
+ app_params = {}
51
+ puts "What is your app name?"
52
+ app_params.store(:common, {})
53
+ app_params[:common][:app_name] = STDIN.gets.chomp
54
+ puts "What is the ssh url for the repository?"
55
+ app_params[:common][:repo] = STDIN.gets.chomp
56
+ %w{staging production}.each do |stage|
57
+ app_params.store("#{stage}".to_sym, {})
58
+ puts "----------#{stage} Configuration----------"
59
+ puts "What is the domain for #{stage}?"
60
+ app_params["#{stage}".to_sym][:domain] = STDIN.gets.chomp
61
+ puts "What is the user for #{stage}?"
62
+ app_params["#{stage}".to_sym][:user] = STDIN.gets.chomp
63
+ puts "What is the branch for #{stage}?"
64
+ app_params["#{stage}".to_sym][:branch] = STDIN.gets.chomp
65
+ end
66
+
67
+ deploy_yml = "
68
+ common: &common
69
+ app: #{app_params[:common][:app_name]}
70
+ repository: #{app_params[:common][:repo]}
71
+ shared_paths: ['config/database.yml', 'log']"
72
+
73
+ app_params.each do |k,v|
74
+ if(k != :common)
75
+ deploy_yml += "
76
+ #{k}:
77
+ <<: *common
78
+ domain: #{app_params[k][:domain]}
79
+ user: #{app_params[k][:user]}
80
+ branch: #{app_params[k][:branch]}"
81
+ end
82
+ end
83
+
84
+ File.open(config_file, 'w') do |f|
85
+ f.puts deploy_yml.dedent
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,5 @@
1
+ module Mina
2
+ module Config
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina/config/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina-config"
8
+ spec.version = Mina::Config::VERSION
9
+ spec.authors = ["Zachary Mckenzie"]
10
+ spec.email = ["Zachary.Mckenzie@agapered.com"]
11
+ spec.summary = %q{Adds a multi-environment yml configuration file to mina}
12
+ spec.description = %q{Adds a multi-environment yml configuration file to mina. Environment configuration is dynamically created by the definitions in the deploy.yml file.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_dependency "mina"
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Zachary Mckenzie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mina
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Adds a multi-environment yml configuration file to mina. Environment
56
+ configuration is dynamically created by the definitions in the deploy.yml file.
57
+ email:
58
+ - Zachary.Mckenzie@agapered.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/mina/String.rb
70
+ - lib/mina/config.rb
71
+ - lib/mina/config/version.rb
72
+ - mina-config.gemspec
73
+ homepage: ''
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.1
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Adds a multi-environment yml configuration file to mina
97
+ test_files: []