capify-rbenv 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capify-rbenv.gemspec +31 -0
- data/lib/capistrano/rbenv.rb +1 -0
- data/lib/capistrano/rbenv/version.rb +5 -0
- data/lib/capistrano/rbenv/with_hooks.rb +3 -0
- data/lib/capistrano/rbenv/without_hooks.rb +2 -0
- data/lib/capistrano/tasks/defaults.rake +56 -0
- data/lib/capistrano/tasks/deploy.rake +3 -0
- data/lib/capistrano/tasks/rbenv.rake +59 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fa81866e990f52998c1095061b3d6213a39f891e108540dab79c4345ce16596d
|
4
|
+
data.tar.gz: 65dfc7661e797bd5da57846bfcabc77dbda4579f504227f51902b0cbae04badc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5346d8028276476d0a8fd51c076720efb8197f3dcb66644e8c472328e90b846f050598a321429e9be2137d27edfb42ec7b1c75b583ae3811a3ba19a3c3081524
|
7
|
+
data.tar.gz: 87e16f87e3b4125bee086de6bc64346369681a3e21a7f043c44150b1fb645ace1756ff15ccd1edfaff6b5cfe4eb7e7df7bf8b0084fde2035c842ff8445599006
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Muhammad Usman
|
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,97 @@
|
|
1
|
+
# Capify::Rbenv
|
2
|
+
|
3
|
+
Capistrano recipes to setup rbenv, ruby and bundler. It provides all the goodies of [capistrano-rbenv](https://github.com/capistrano/rbenv) and adds more features, like:
|
4
|
+
|
5
|
+
* Install [rbenv](https://github.com/rbenv/rbenv) if not installed already.
|
6
|
+
* Install [ruby-build](https://github.com/rbenv/ruby-build) if not installed already.
|
7
|
+
* Install specified ruby version if not installed already.
|
8
|
+
* Install specified bundler version if not installed already.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'capistrano', '~> 3.13'
|
16
|
+
gem 'capify-rbenv', '~> 1.0'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
$ bundle install
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Capfile
|
29
|
+
require 'capistrano/rbenv'
|
30
|
+
|
31
|
+
|
32
|
+
# config/deploy.rb
|
33
|
+
set :rbenv_ruby, '2.7.1' # Set ruby version to install (Required)
|
34
|
+
set :rbenv_bundler, '2.1.4' # Set bundler version to install (Required)
|
35
|
+
|
36
|
+
# In case you want to set ruby version from .ruby-version file:
|
37
|
+
# set :rbenv_ruby, File.read('.ruby-version').strip
|
38
|
+
```
|
39
|
+
|
40
|
+
Following is the list of all optional configurable options along with their default values and examples.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# Set rbenv installation type (user/system)
|
44
|
+
set :rbenv_type, :user
|
45
|
+
|
46
|
+
# Set rbenv installation path
|
47
|
+
set :rbenv_path, fetch(:rbenv_type) == :system ? '/usr/local/rbenv' : '$HOME/.rbenv'
|
48
|
+
|
49
|
+
# Set rbenv directory for installed ruby versions
|
50
|
+
set :rbenv_ruby_dir, "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}"
|
51
|
+
|
52
|
+
# Set or append the list of dependencies to install
|
53
|
+
# See lib/capistrano/tasks/defaults.rake for default dependencies
|
54
|
+
append :rbenv_deps, 'libsqlite3-dev', 'sqlite3'
|
55
|
+
|
56
|
+
# Set dependencies installer
|
57
|
+
set :rbenv_deps_installler, 'apt-get install -y'
|
58
|
+
|
59
|
+
# Set or append customs bins to create under rbenv
|
60
|
+
# See lib/capistrano/tasks/defaults.rake for default bins
|
61
|
+
append :rbenv_map_bins, 'puma', 'pumactl'
|
62
|
+
```
|
63
|
+
|
64
|
+
When you `require 'capistrano/rbenv'` in your Capfile, it will add default hooks to capistrano deploy that will automatically setup everything (rbenv, ruby, bundler) you need. If you want to skip the default hooks and setup everything on your own, use the following instructions,
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# Capfile
|
68
|
+
require 'capistrano/rbenv/without_hooks'
|
69
|
+
|
70
|
+
|
71
|
+
# Then add it as a hook
|
72
|
+
after :some_task, 'rbenv:setup'
|
73
|
+
|
74
|
+
# Or invoke manually
|
75
|
+
task :custom_setup do
|
76
|
+
invoke 'rbenv:setup'
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
## Available tasks
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
rbenv:install # Install rbenv
|
84
|
+
rbenv:install_ruby # Install ruby
|
85
|
+
rbenv:install_bundler # Install bundler gem
|
86
|
+
rbenv:install_ruby_build # Install/Update ruby_build - rbenv plugin
|
87
|
+
rbenv:setup # Setup rbenv, ruby-build, ruby and bundler
|
88
|
+
```
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/uxxman/capify-rbenv.
|
93
|
+
|
94
|
+
|
95
|
+
## License
|
96
|
+
|
97
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "capify/rbenv"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'lib/capistrano/rbenv/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'capify-rbenv'
|
5
|
+
spec.version = Capistrano::Rbenv::VERSION
|
6
|
+
spec.authors = ['Muhammad Usman']
|
7
|
+
spec.email = ['uxman.sherwani@gmail.com']
|
8
|
+
|
9
|
+
spec.summary = 'Capistrano recipe to setup rbenv, ruby and bundler'
|
10
|
+
spec.description = 'Setup ruby environemnt on remote server(s) using rbenv'
|
11
|
+
spec.homepage = 'https://github.com/uxxman/capify-rbenv'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
|
+
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
17
|
+
spec.metadata['changelog_uri'] = spec.homepage
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_dependency 'capistrano', '~> 3.1'
|
30
|
+
spec.add_dependency 'sshkit', '~> 1.3'
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'capistrano/rbenv/with_hooks'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
namespace :load do
|
2
|
+
task :defaults do
|
3
|
+
default_deps = %w[
|
4
|
+
libpq-dev
|
5
|
+
libssl-dev
|
6
|
+
zlib1g-dev
|
7
|
+
libreadline-dev
|
8
|
+
build-essential
|
9
|
+
]
|
10
|
+
|
11
|
+
default_bins = %w[
|
12
|
+
gem
|
13
|
+
rake
|
14
|
+
ruby
|
15
|
+
rails
|
16
|
+
bundle
|
17
|
+
]
|
18
|
+
|
19
|
+
# Set ruby version to install using rbenv (Required)
|
20
|
+
# set :rbenv_ruby, '2.7.1'
|
21
|
+
|
22
|
+
# Set bundler version to install using rbenv (Required)
|
23
|
+
# set :rbenv_bundler, '2.1.4'
|
24
|
+
|
25
|
+
# Set rbenv installation type (user/system)
|
26
|
+
set_if_empty :rbenv_type, :user
|
27
|
+
|
28
|
+
# Set rbenv installation path
|
29
|
+
set_if_empty :rbenv_path, fetch(:rbenv_type) == :system ? '/usr/local/rbenv' : '$HOME/.rbenv'
|
30
|
+
|
31
|
+
# Set rbenv directory for installed ruby versions
|
32
|
+
set_if_empty :rbenv_ruby_dir, "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}"
|
33
|
+
|
34
|
+
# Set list of custom dependencies to install
|
35
|
+
set_if_empty :rbenv_deps, default_deps.join(' ')
|
36
|
+
|
37
|
+
# Set dependencies installer
|
38
|
+
set_if_empty :rbenv_deps_installler, 'apt-get install -y'
|
39
|
+
|
40
|
+
# Set customs bins to create under rbenv
|
41
|
+
set_if_empty :rbenv_map_bins, default_bins
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
Capistrano::DSL.stages.each do |stage|
|
47
|
+
after stage, :rbenv_map_bins do
|
48
|
+
SSHKit.config.default_env.merge!({ rbenv_root: fetch(:rbenv_path), rbenv_version: fetch(:rbenv_ruby) })
|
49
|
+
SSHKit.config.command_map[:rbenv] = "#{fetch(:rbenv_path)}/bin/rbenv"
|
50
|
+
rbenv_prefix = fetch(:rbenv_prefix, "#{fetch(:rbenv_path)}/bin/rbenv exec")
|
51
|
+
|
52
|
+
fetch(:rbenv_map_bins).uniq.each do |command|
|
53
|
+
SSHKit.config.command_map.prefix[command.to_sym].unshift(rbenv_prefix)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
namespace :rbenv do
|
2
|
+
RBENV_REPO_URL = 'https://github.com/rbenv/rbenv.git'.freeze
|
3
|
+
RUBY_BUILD_REPO_URL = 'https://github.com/rbenv/ruby-build.git'.freeze
|
4
|
+
|
5
|
+
|
6
|
+
desc 'Install rbenv'
|
7
|
+
task :install do
|
8
|
+
on roles(:app) do
|
9
|
+
next if test "[ -d #{fetch(:rbenv_path)} ]"
|
10
|
+
|
11
|
+
execute :sudo, "#{fetch(:rbenv_deps_installler)} #{fetch(:rbenv_default_deps)} #{fetch(:rbenv_deps)}"
|
12
|
+
execute :git, "clone #{RBENV_REPO_URL} #{fetch(:rbenv_path)}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
desc 'Install/Update ruby-build - rbenv plugin'
|
18
|
+
task :install_ruby_build do
|
19
|
+
on roles(:app) do
|
20
|
+
ruby_build_path = "#{fetch(:rbenv_path)}/plugins/ruby-build"
|
21
|
+
|
22
|
+
if test "[ -d #{ruby_build_path} ]"
|
23
|
+
execute :git, "-C #{ruby_build_path} pull"
|
24
|
+
else
|
25
|
+
invoke 'rbenv:install'
|
26
|
+
execute :git, "clone #{RUBY_BUILD_REPO_URL} #{ruby_build_path}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
desc 'Install ruby'
|
33
|
+
task :install_ruby do
|
34
|
+
on roles(:app) do
|
35
|
+
next if test "[ -d #{fetch(:rbenv_ruby_dir)} ]"
|
36
|
+
|
37
|
+
invoke 'rbenv:install_ruby_build'
|
38
|
+
execute :rbenv, "install #{fetch(:rbenv_ruby)}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
desc 'Install bundler'
|
44
|
+
task :install_bundler do
|
45
|
+
on roles(:app) do
|
46
|
+
next if test :gem, :query, "-q -i -n ^bundler$ -v #{fetch(:rbenv_bundler)}"
|
47
|
+
|
48
|
+
invoke 'rbenv:install_ruby'
|
49
|
+
execute "echo 'gem: --no-document' >> ~/.gemrc"
|
50
|
+
execute :gem, :install, :bundler, "-v #{fetch(:rbenv_bundler)}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
desc 'Setup rbenv, ruby-build, ruby and bundler'
|
56
|
+
task :setup do
|
57
|
+
invoke 'rbenv:install_bundler'
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capify-rbenv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Muhammad Usman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-27 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.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
description: Setup ruby environemnt on remote server(s) using rbenv
|
42
|
+
email:
|
43
|
+
- uxman.sherwani@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- capify-rbenv.gemspec
|
56
|
+
- lib/capistrano/rbenv.rb
|
57
|
+
- lib/capistrano/rbenv/version.rb
|
58
|
+
- lib/capistrano/rbenv/with_hooks.rb
|
59
|
+
- lib/capistrano/rbenv/without_hooks.rb
|
60
|
+
- lib/capistrano/tasks/defaults.rake
|
61
|
+
- lib/capistrano/tasks/deploy.rake
|
62
|
+
- lib/capistrano/tasks/rbenv.rake
|
63
|
+
homepage: https://github.com/uxxman/capify-rbenv
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata:
|
67
|
+
homepage_uri: https://github.com/uxxman/capify-rbenv
|
68
|
+
source_code_uri: https://github.com/uxxman/capify-rbenv
|
69
|
+
changelog_uri: https://github.com/uxxman/capify-rbenv
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.3.0
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.1.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Capistrano recipe to setup rbenv, ruby and bundler
|
89
|
+
test_files: []
|