mina-dotenv 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e18ee3724b237a536e1fe9fa92b6f40952c506b1
4
+ data.tar.gz: 65b804aa66f49ed44e674ee71c4153ff2fa4b292
5
+ SHA512:
6
+ metadata.gz: ca31fff7f8560543661db3aa600329aa9be40d34c51ae1c3957dd6a248ec285b5173651301f02642944903b5ccd8ccc617c8c2ac0422768311c681736b1c9d84
7
+ data.tar.gz: 13fb43aba437da092d07c877bd23d47c481ea06e00f00e8e396ad2008ca23f317a4acce908531dd477196d95ebdb4acfba8635ea94e2b73fe713c1ed1ddb9e49
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .DS_Store
3
+ coverage
data/Gemfile ADDED
File without changes
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Stanko Krtalić Rusendić
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Mina-dotenv
2
+
3
+ :black_circle: [Dotenv](https://github.com/bkeepers/dotenv) plugin for mina.
4
+
5
+ Alleviate the need to SSH to your server and setup an `.env` file manually there. This plugin simply copies your local `.env` to your server :yum:
6
+
7
+ ## Installation
8
+
9
+ To use it in your project's deployment process install this gem with the following command:
10
+
11
+ ```bash
12
+ gem install mina-dotenv
13
+ ```
14
+
15
+ Add the following line to your `deploy.rb` script:
16
+
17
+ ```Ruby
18
+ require 'mina/dotenv'
19
+ ```
20
+
21
+ This enables you to use the `dotenv:push` task in your deploy script.
22
+
23
+ To automatically push your `.env` file to the server add this line to your `deploy` task:
24
+
25
+ ```Ruby
26
+ invoke :'dotenv:push'
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ Your development machine and your server will often need different keys to run your app. Therefore a `:dotenv_location` variable exist to define which `.env` file to push to the server.
32
+
33
+ __Important:__ The `:dotenv_location` defaults to `.env`
34
+
35
+ To change which `.env` file to push add this line your `deploy.rb` file:
36
+
37
+ ```Ruby
38
+ set :dotenv_location, '.server_env'
39
+ ```
40
+
41
+ ## Example deploy script
42
+
43
+ ```Ruby
44
+ require 'mina/bundler'
45
+ require 'mina/rails'
46
+ require 'mina/git'
47
+ require 'mina/rbenv'
48
+ require 'mina/dotenv' # <---- Added this line
49
+
50
+ set :domain, 'my-page.com'
51
+ set :deploy_to, '/home/deploy/www/...'
52
+ set :repository, 'https://github.com/...'
53
+ set :branch, 'master'
54
+ set :dotenv_location, '.server_env' # <--- Added this line
55
+
56
+ ...
57
+
58
+ desc "Deploys the current version to the server."
59
+ task :deploy => :environment do
60
+ to :before_hook do
61
+ end
62
+
63
+ deploy do
64
+ invoke :'git:clone'
65
+ invoke :'deploy:link_shared_paths'
66
+ invoke :'dotenv:push' # <----- Added this line
67
+ invoke :'bundle:install'
68
+ invoke :'rails:assets_precompile'
69
+ invoke :'deploy:cleanup'
70
+
71
+ to :launch do
72
+ queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
73
+ queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
74
+ end
75
+ end
76
+ end
77
+ ```
78
+
79
+ ## What it does
80
+
81
+ ### Tasks
82
+
83
+ #### Push
84
+
85
+ The push task will look for the '.env' file specified in the `:dotenv_location` variable. If found it will copy it's content and echo it to an `.env` file located in the `shared` folder location you your app's deploy location. And symlink it to the root of the newest release.
86
+
87
+ If no local `.env` file is found a blank one will be created on the server.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,8 @@
1
+ require 'mina/dotenv/version'
2
+ require 'mina/dotenv/defaults'
3
+ require 'mina/dotenv/tasks'
4
+
5
+ module Mina
6
+ module Dotenv
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ set_default :dotenv_location, '.env'
@@ -0,0 +1,20 @@
1
+ require 'mina/dotenv/utils'
2
+
3
+ namespace :dotenv do
4
+ desc 'Copies the local .env file to the server'
5
+ task :push do
6
+ remote_dotenv_path = "#{deploy_to}/#{shared_path}/.env"
7
+
8
+ dotenv = Mina::Dotenv::Utils.read_file(dotenv_location)
9
+ queue! %(
10
+ echo #{dotenv.shellescape} | sed -e 's/^[ \t]*//' > #{remote_dotenv_path}
11
+ )
12
+ queue! %(rm -f .env)
13
+ queue! %(ln -nFs #{remote_dotenv_path} .env)
14
+ end
15
+
16
+ # TODO: Implement this
17
+ # desc 'Copies the remote .env file to the current directory'
18
+ # task :pull do
19
+ # end
20
+ end
@@ -0,0 +1,10 @@
1
+ module Mina
2
+ module Dotenv
3
+ module Utils
4
+ def self.read_file(file_path)
5
+ return '' unless File.exist?(file_path)
6
+ File.open(file_path, 'r').read
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module Mina
2
+ module Dotenv
3
+ module VERSION
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ TINY = 0
7
+ PRE = nil
8
+
9
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina/dotenv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'mina-dotenv'
8
+ spec.version = Mina::Dotenv::VERSION::STRING
9
+ spec.authors = ['Stanko Krtalić Rusendić']
10
+ spec.email = ['stanko.krtalic@gmail.com']
11
+
12
+ spec.summary = 'Dotenv tasks for mina'
13
+ spec.description = 'Dotenv tasks for mina'
14
+
15
+ spec.homepage = 'https://github.com/Stankec/mina-dotenv'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`
19
+ .split("\x0")
20
+ .reject { |f| f.match(/^(test|spec|features)\//) }
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'mina'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.8'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-dotenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stanko Krtalić Rusendić
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-22 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.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Dotenv tasks for mina
56
+ email:
57
+ - stanko.krtalic@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/mina/dotenv.rb
68
+ - lib/mina/dotenv/defaults.rb
69
+ - lib/mina/dotenv/tasks.rb
70
+ - lib/mina/dotenv/utils.rb
71
+ - lib/mina/dotenv/version.rb
72
+ - mina-dotenv.gemspec
73
+ homepage: https://github.com/Stankec/mina-dotenv
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.4.5
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Dotenv tasks for mina
97
+ test_files: []
98
+ has_rdoc: