capistrano-rbenv 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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-rbenv.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Yamashita Yuu
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.
@@ -0,0 +1,58 @@
1
+ # capistrano-rbenv
2
+
3
+ a capistrano recipe to manage rubies with [rbenv](https://github.com/sstephenson/rbenv).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-rbenv'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-rbenv
18
+
19
+ ## Usage
20
+
21
+ This recipe will install [rbenv](https://github.com/sstephenson/rbenv) and [ruby-build](https://github.com/sstephenson/ruby-build) during `deploy:setup` task.
22
+
23
+ To setup rbenv for your application, add following in you `config/deploy.rb`.
24
+
25
+ # in "config/deploy.rb"
26
+ require 'capistrano-rbenv'
27
+
28
+ Following options are available to manage your rbenv.
29
+
30
+ * `:rbenv_branch` - the git branch to install `rbenv` from. use `master` by default.
31
+ * `:rbenv_bundler_gem` - package name of `bundler`.
32
+ * `:rbenv_bundler_version` - version for `bundler` package.
33
+ * `:rbenv_cmd` - the `rbenv` command.
34
+ * `:rbenv_path` - the path where `rbenv` will be installed. use `$HOME/.rbenv` by default.
35
+ * `:rbenv_plugins_options` - install options for rbenv plugins.
36
+ * `:rbenv_plugins` - rbenv plugins to install. install `ruby-build` by default.
37
+ * `:rbenv_repository` 'git://github.com/sstephenson/rbenv.git')
38
+ * `:rbenv_ruby_dependencies` %w(build-essential libreadline6-dev zlib1g-dev libssl-dev bison))
39
+ * `:rbenv_ruby_version` - the ruby version to install. install `1.9.3-p194` by default.
40
+ * `:rbenv_use_bundler` - controls whether installing bundler or not. `true` by default.
41
+ * `:rbenv_use_plugins` - controls whether installing rbenv plugins or not. `true` by default.
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
50
+
51
+ ## Author
52
+
53
+ - YAMASHITA Yuu (https://github.com/yyuu)
54
+ - Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano-rbenv/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Yamashita Yuu"]
6
+ gem.email = ["yamashita@geishatokyo.com"]
7
+ gem.description = %q{a capistrano recipe to manage rubies with rbenv.}
8
+ gem.summary = %q{a capistrano recipe to manage rubies with rbenv.}
9
+ gem.homepage = "https://github.com/yyuu/capistrano-rbenv"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "capistrano-rbenv"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Capistrano::Rbenv::VERSION
17
+
18
+ gem.add_dependency("capistrano")
19
+ end
@@ -0,0 +1,8 @@
1
+ require "capistrano-rbenv/deploy"
2
+ require "capistrano-rbenv/version"
3
+
4
+ module Capistrano
5
+ module Rbenv
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,137 @@
1
+ module Capistrano
2
+ module Rbenv
3
+ def self.extended(configuration)
4
+ configuration.load {
5
+ namespace(:rbenv) {
6
+ _cset(:rbenv_path) {
7
+ capture("echo $HOME/.rbenv").chomp()
8
+ }
9
+ _cset(:rbenv_bin) {
10
+ File.join(rbenv_path, 'bin', 'rbenv')
11
+ }
12
+ _cset(:rbenv_cmd) { # to use custom rbenv_path, we use `env` instead of cap's default_environment.
13
+ path = "#{rbenv_path}/bin:#{rbenv_path}/shims:$PATH"
14
+ "env PATH=#{path.dump()} #{rbenv_bin}"
15
+ }
16
+ _cset(:rbenv_repository, 'git://github.com/sstephenson/rbenv.git')
17
+ _cset(:rbenv_branch, 'master')
18
+
19
+ _cset(:rbenv_use_plugins, true)
20
+ _cset(:rbenv_plugins, {
21
+ 'ruby-build' => 'git://github.com/sstephenson/ruby-build.git',
22
+ })
23
+ _cset(:rbenv_plugins_options, {
24
+ 'ruby-build' => {:branch => 'master'},
25
+ })
26
+ _cset(:rbenv_plugins_path) {
27
+ File.join(rbenv_path, 'plugins')
28
+ }
29
+
30
+ _cset(:rbenv_git) {
31
+ if scm == :git
32
+ if fetch(:scm_command, :default) == :default
33
+ fetch(:git, 'git')
34
+ else
35
+ scm_command
36
+ end
37
+ else
38
+ fetch(:git, 'git')
39
+ end
40
+ }
41
+
42
+ _cset(:rbenv_ruby_version, '1.9.3-p194')
43
+ _cset(:rbenv_ruby_dependencies, %w(build-essential libreadline6-dev zlib1g-dev libssl-dev bison))
44
+
45
+ _cset(:rbenv_use_bundler, true)
46
+ set(:bundle_cmd) { # override bundle_cmd in "bundler/capistrano"
47
+ rbenv_use_bundler ? "#{rbenv_cmd} exec bundle" : 'bundle'
48
+ }
49
+
50
+ desc("Setup rbenv.")
51
+ task(:setup, :except => { :no_release => true }) {
52
+ dependencies
53
+ update
54
+ configure
55
+ build
56
+ setup_bundler if rbenv_use_bundler
57
+ }
58
+ after 'deploy:setup', 'rbenv:setup'
59
+
60
+ def _rbenv_sync(repository, destination, revision)
61
+ git = rbenv_git
62
+ remote = 'origin'
63
+ verbose = "-q"
64
+ run((<<-E).gsub(/\s+/, ' '))
65
+ if test -d #{destination}; then
66
+ cd #{destination} && #{git} fetch #{verbose} #{remote} && #{git} fetch --tags #{verbose} #{remote} && #{git} merge #{verbose} #{remote}/#{revision};
67
+ else
68
+ #{git} clone #{verbose} #{repository} #{destination} && cd #{destination} && #{git} checkout #{verbose} #{revision};
69
+ fi;
70
+ E
71
+ end
72
+
73
+ desc("Update rbenv installation.")
74
+ task(:update, :except => { :no_release => true }) {
75
+ _rbenv_sync(rbenv_repository, rbenv_path, rbenv_branch)
76
+ plugins.update if rbenv_use_plugins
77
+ }
78
+
79
+ desc("Purge rbenv.")
80
+ task(:purge, :except => { :no_release => true }) {
81
+ run("rm -rf #{rbenv_path}")
82
+ }
83
+
84
+ namespace(:plugins) {
85
+ desc("Update rbenv plugins.")
86
+ task(:update, :except => { :no_release => true }) {
87
+ rbenv_plugins.each { |name, repository|
88
+ options = ( rbenv_plugins_options[name] || {})
89
+ branch = ( options[:branch] || 'master' )
90
+ _rbenv_sync(repository, File.join(rbenv_plugins_path, name), branch)
91
+ }
92
+ }
93
+ }
94
+
95
+ task(:configure, :except => { :no_release => true }) {
96
+ # nop
97
+ }
98
+
99
+ task(:dependencies, :except => { :no_release => true }) {
100
+ unless rbenv_ruby_dependencies.empty? # dpkg-query is faster than apt-get on querying if packages are installed
101
+ run("dpkg-query --show #{rbenv_ruby_dependencies.join(' ')} 2>/dev/null || #{sudo} apt-get -y install #{rbenv_ruby_dependencies.join(' ')}")
102
+ end
103
+ }
104
+
105
+ desc("Build ruby within rbenv.")
106
+ task(:build, :except => { :no_release => true }) {
107
+ ruby = fetch(:rbenv_ruby_cmd, 'ruby')
108
+ run("#{rbenv_cmd} whence #{ruby} | grep -q #{rbenv_ruby_version} || #{rbenv_cmd} install #{rbenv_ruby_version}")
109
+ run("#{rbenv_cmd} global #{rbenv_ruby_version} && #{rbenv_cmd} exec #{ruby} --version")
110
+ }
111
+
112
+ _cset(:rbenv_bundler_gem, 'bundler')
113
+ task(:setup_bundler, :except => { :no_release => true }) {
114
+ gem = "#{rbenv_cmd} exec gem"
115
+ if v = fetch(:rbenv_bundler_version, nil)
116
+ q = "-n #{rbenv_bundler_gem} -v #{v}"
117
+ f = "grep #{rbenv_bundler_gem} | grep #{v}"
118
+ i = "-v #{v} #{rbenv_bundler_gem}"
119
+ else
120
+ q = "-n #{rbenv_bundler_gem}"
121
+ f = "grep #{rbenv_bundler_gem}"
122
+ i = "#{rbenv_bundler_gem}"
123
+ end
124
+ run("unset -v GEM_HOME; #{gem} query #{q} 2>/dev/null | #{f} || #{gem} install #{i}")
125
+ run("#{rbenv_cmd} rehash && #{bundle_cmd} version")
126
+ }
127
+ }
128
+ }
129
+ end
130
+ end
131
+ end
132
+
133
+ if Capistrano::Configuration.instance
134
+ Capistrano::Configuration.instance.extend(Capistrano::Rbenv)
135
+ end
136
+
137
+ # vim:set ft=ruby ts=2 sw=2 :
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Rbenv
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-rbenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Yamashita Yuu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: a capistrano recipe to manage rubies with rbenv.
31
+ email:
32
+ - yamashita@geishatokyo.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - capistrano-rbenv.gemspec
43
+ - lib/capistrano-rbenv.rb
44
+ - lib/capistrano-rbenv/deploy.rb
45
+ - lib/capistrano-rbenv/version.rb
46
+ homepage: https://github.com/yyuu/capistrano-rbenv
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.23
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: a capistrano recipe to manage rubies with rbenv.
70
+ test_files: []
71
+ has_rdoc: