capistrano-opscomplete 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9557996df286d6b2ad029eb5915b019a1c158f6e
4
- data.tar.gz: f53793ef28924bf828c7b9c3a7daa4a9eb4d4c4c
2
+ SHA256:
3
+ metadata.gz: fbb4c106ea61f218ac2ed13cab91256b12d76e6d064343d36a9b78c941bba2af
4
+ data.tar.gz: 4c849d23d37b0abfab117914d29edfd9425bf6ddbb12baed15586474fd33bcb1
5
5
  SHA512:
6
- metadata.gz: 47efafd91d9cca904694c487043c6b7475a581fe6a625a8f437da6c9ea64251af51f688677e4706c39e5da9441416d141dfac2775c7bf19d75a81cc90d9d47dd
7
- data.tar.gz: c2ae884f910cbc6fd398d7c3df31c8670cc80e6cb213fbdbf92422629fb25690692016be0b6d71b6df5aeb65984f0f5091fb157780017cb65c3ce5936938442d
6
+ metadata.gz: 529b9dd12ad04f4cfd707704505c57f69276b01c53a9ed944e5bfa13eb8537dca8cc21c3a25eed03b8049810df11f78b23ca87a9050a66bb868901d7531ea2f0
7
+ data.tar.gz: 37d3ceb10b4d99ab89ee12730dfda034cb26d482e8b11545e49a3fd71e88a4e26ae74ae0168d7bda6d608e53843d2d33e666464a16d82bd74ec95c76d0382771
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.3.0] - 2019-04-05
2
+ ### Added
3
+ - You can now specify the rubygems and bundler version to be installed. (#4)
4
+
5
+ ### Changed
6
+ - Support more rubygems versions by using --no-document rather than --no-ri/--no-rdoc (#6)
7
+ - Use makandra-rubocop to improve code style, moved some rbenv calls to DSL (#3)
8
+ - Fixed a deprecation warning where opscomplete:ruby:update_ruby_build was called multiple times. (#7)
9
+
10
+ ### Removed
11
+ - `appserver:restart` task has been obsoleted. Please use https://github.com/capistrano/passenger (#1)
12
+
1
13
  ## [0.2.0] - 2018-08-28
2
14
  ### Added
3
15
  - Look up .ruby-version from your local branch (cwd) if other options fail
@@ -14,4 +26,5 @@
14
26
  ### Added
15
27
  - Initial release.
16
28
 
29
+ [0.3.0]: https://github.com/makandra/capistrano-opscomplete/compare/v0.2.0...v0.3.0
17
30
  [0.2.0]: https://github.com/makandra/capistrano-opscomplete/compare/v0.1.0...v0.2.0
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- #git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
1
+ source 'https://rubygems.org'
4
2
 
5
3
  # Specify your gem's dependencies in capistrano-opscomplete.gemspec
6
4
  gemspec
data/README.md CHANGED
@@ -33,8 +33,6 @@ Now, add some [hooks](#using-capistrano-hooks) in your capistrano configuration.
33
33
  ```ruby
34
34
  # After unpacking your release, before bundling, compiling assets, ...
35
35
  after 'deploy:updating', 'opscomplete:ruby:ensure'
36
- # After your application has been successfully deployed and the current symlink has been set
37
- after 'deploy:published', 'opscomplete:appserver:restart'
38
36
  ```
39
37
 
40
38
  ## Usage
@@ -80,14 +78,12 @@ More specifically this task will:
80
78
  - Install the `bundler` and `geordi` gem if required.
81
79
  - Run `rbenv rehash` if required.
82
80
 
83
- **Note:** If, for any reason, no `.ruby-version` file can be found in your release or current working directory, you may set the following option in deploy.rb:
81
+ **Note:** If, for any reason, no `.ruby-version` file can be found in your release or current working directory, you may set the following option in `deploy.rb`:
84
82
 
85
83
  ```ruby
86
84
  set :opscomplete_ruby_version, '<VERSION>'
87
85
  ```
88
86
 
89
- Where `<VERSION>` is the desired ruby version.
90
-
91
87
  **Optional:** By default, the ruby version is checked/installed for all server roles. If you want to limit the rbenv operations to certain roles, set `rbenv_roles` in your `deploy.rb`:
92
88
 
93
89
  ```ruby
@@ -96,15 +92,17 @@ set :rbenv_roles, :web
96
92
  set :rbenv_roles, [:web, :worker]
97
93
  ```
98
94
 
99
- ### opscomplete:appserver:restart
100
-
101
- To restart your application server execute:
95
+ **Optional:** By default, the most recent version of bundler will be installed. If you want a specific bundler version available for your release, set it in your `deploy.rb`:
102
96
 
103
- $ bundle exec cap <ENVIRONMENT> opscomplete:appserver:restart
97
+ ```ruby
98
+ set :bundler_version, '<VERSION>'
99
+ ```
104
100
 
105
- Where `<ENVIRONMENT>` could be `production`, `staging**, ...
101
+ **Optional:** By default, the rubygems version defined by the ruby-build manifest will be installed. If you want a specific rubygems version available for your release, set it in your `deploy.rb`:
106
102
 
107
- **Note**: The current version of this gem only support the passenger app server. The current version of this gem does not support restarting your application, if multiple instances of passenger are running on the same host. This would be the case if you have Apache _and_ Nginx servers running on the same host.
103
+ ```ruby
104
+ set :rubygems_version, '<VERSION>'
105
+ ```
108
106
 
109
107
  ### Using capistrano hooks
110
108
 
@@ -112,7 +110,6 @@ There are many hooks available in the [default deploy flow](https://capistranorb
112
110
 
113
111
  ```ruby
114
112
  after 'deploy:updating', 'opscomplete:ruby:ensure'
115
- after 'deploy:published', 'opscomplete:appserver:restart'
116
113
  ```
117
114
 
118
115
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -1,36 +1,39 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "capistrano/opscomplete/version"
3
+ require 'capistrano/opscomplete/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "capistrano-opscomplete"
7
- spec.version = Capistrano::Opscomplete::VERSION
8
- spec.authors = ["Makandra Operations"]
9
- spec.email = ["ops@makandra.de"]
6
+ spec.name = 'capistrano-opscomplete'
7
+ spec.version = Capistrano::Opscomplete::VERSION
8
+ spec.authors = ['Makandra Operations']
9
+ spec.email = ['ops@makandra.de']
10
10
 
11
- spec.summary = %q{Capistrano tasks for easy deployment to a makandra opscomplete environment.}
12
- spec.homepage = "https://opscomplete.com/ruby"
11
+ spec.summary = %q(Capistrano tasks for easy deployment to a makandra opscomplete environment.)
12
+ spec.homepage = 'https://opscomplete.com/ruby'
13
13
 
14
- spec.license = 'MIT'
14
+ spec.license = 'MIT'
15
15
 
16
16
  if spec.respond_to?(:metadata)
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
  else
19
- raise "RubyGems 2.0 or newer is required to protect against " \
20
- "public gem pushes."
19
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
20
+ 'public gem pushes.'
21
21
  end
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^((test|spec|features)/|.gitignore|.rubocop.yml)}) }
27
27
  end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r(^exe/)) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
31
 
32
- spec.add_development_dependency "bundler", "~> 1.16"
33
- spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.required_rubygems_version = '>=2.0.1'
33
+
34
+ spec.add_development_dependency 'makandra-rubocop', '~> 0'
35
+ spec.add_development_dependency 'bundler', '~> 1.16'
36
+ spec.add_development_dependency 'rake', '~> 10.0'
34
37
 
35
38
  spec.add_dependency 'capistrano', '>=3.0', '<4.0.0'
36
39
  end
@@ -2,7 +2,7 @@ module Capistrano
2
2
  module DSL
3
3
  # A whole capistrano/rake namespace, for grouping our helpers and tasks
4
4
  module Opscomplete
5
- def managed_ruby
5
+ def managed_ruby?
6
6
  test("[ -f #{rbenv_root_path}/.ruby_managed_by_makandra ]")
7
7
  end
8
8
 
@@ -56,12 +56,36 @@ module Capistrano
56
56
  def rbenv_installed_rubies
57
57
  if test("[ -d #{rbenv_root_path}/versions ]")
58
58
  rbenv_installed_rubies = capture(:ls, '-1', "#{rbenv_root_path}/versions").split("\n")
59
- return rbenv_installed_rubies.map!(&:strip)
59
+ rbenv_installed_rubies.map!(&:strip)
60
60
  else
61
61
  warn("Could not look up installed versions from missing '.rbenv/versions' directory. This is probably the first ruby install for this rbenv.")
62
- return []
62
+ []
63
63
  end
64
64
  end
65
+
66
+ def rbenv_exec(*args)
67
+ execute(:rbenv, :exec, *args)
68
+ end
69
+
70
+ def gem_installed?(name, version = nil)
71
+ if version
72
+ test(:rbenv, :exec, "gem query --quiet --installed --version #{version} --name-matches ^#{name}$")
73
+ else
74
+ test(:rbenv, :exec, :gem, :query, "--quiet --installed --name-matches ^#{name}$")
75
+ end
76
+ end
77
+
78
+ def gem_install(name, version = nil)
79
+ if version
80
+ rbenv_exec('gem install', name, '--no-document', '--version', version)
81
+ else
82
+ rbenv_exec('gem install', name, '--no-document')
83
+ end
84
+ end
85
+
86
+ def rubygems_install(version)
87
+ rbenv_exec('gem update --no-document --system', version)
88
+ end
65
89
  end
66
90
  end
67
91
  end
@@ -1,4 +1,4 @@
1
- require "capistrano/opscomplete/version"
1
+ require 'capistrano/opscomplete/version'
2
2
 
3
- load File.expand_path('../opscomplete/tasks.rake', __FILE__)
4
- load File.expand_path('../opscomplete/deploy.rake', __FILE__)
3
+ load File.expand_path('opscomplete/tasks.rake', __dir__)
4
+ load File.expand_path('opscomplete/deploy.rake', __dir__)
@@ -19,7 +19,7 @@ namespace :opscomplete do
19
19
  desc 'Check if rbenv global ruby is set according to application\'s .ruby-version.'
20
20
  task :check do
21
21
  on roles fetch(:rbenv_roles, :all) do |host|
22
- warn("#{host}: Managed ruby environment! Won't do any changes to ruby version.") if managed_ruby
22
+ warn("#{host}: Managed ruby environment! Won't do any changes to ruby version.") if managed_ruby?
23
23
  unless capture(:rbenv, :global) == app_ruby_version
24
24
  raise Capistrano::ValidationError,
25
25
  "#{host}: Ruby version is not set according to application\'s .ruby-version file. Use cap opscomplete:ruby:ensure."
@@ -52,8 +52,11 @@ namespace :opscomplete do
52
52
  # desc 'Install bundler gem'
53
53
  task :install_bundler do
54
54
  on roles fetch(:rbenv_roles, :all) do
55
- next if test(:rbenv, :exec, :gem, :query, '--quiet --installed --name-matches ^bundler$')
56
- execute(:rbenv, :exec, :gem, :install, :bundler, '--quiet --no-rdoc --no-ri')
55
+ if fetch(:bundler_version, false)
56
+ gem_install('bundler', fetch(:bundler_version)) unless gem_installed?('bundler', fetch(:bundler_version))
57
+ else
58
+ gem_install('bundler') unless gem_installed?('bundler')
59
+ end
57
60
  set :rbenv_needs_rehash, true
58
61
  end
59
62
  end
@@ -61,45 +64,48 @@ namespace :opscomplete do
61
64
  # desc 'Install geordi gem'
62
65
  task :install_geordi do
63
66
  on roles fetch(:rbenv_roles, :all) do
64
- next if test(:rbenv, :exec, :gem, :query, '--quiet --installed --name-matches ^geordi$')
65
- execute(:rbenv, :exec, :gem, :install, :geordi, '--quiet --no-rdoc --no-ri')
67
+ gem_install('geordi') unless gem_installed?('geordi')
66
68
  set :rbenv_needs_rehash, true
67
69
  end
68
70
  end
69
71
 
72
+ task :install_rubygems do
73
+ on roles fetch(:rbenv_roles, :all) do
74
+ # if no rubygems_version was set, we use and don't check the rubygems version installed by rbenv
75
+ if fetch(:rubygems_version, false)
76
+ current_rubygems_version = capture(:rbenv, :exec, :gem, '--version').chomp
77
+ info("Ensuring requested RubyGems version #{fetch(:rubygems_version)}")
78
+ next if current_rubygems_version == fetch(:rubygems_version)
79
+ info("Previously installed RubyGems version was #{current_rubygems_version}")
80
+ rbenv_exec(:gem, :update, '--no-document', '--system', fetch(:rubygems_version))
81
+ set :rbenv_needs_rehash, true
82
+ end
83
+ end
84
+ end
85
+
70
86
  desc 'Install and configure ruby according to applications .ruby-version.'
71
87
  task :ensure do
88
+ invoke('opscomplete:ruby:update_ruby_build')
72
89
  on roles fetch(:rbenv_roles, :all) do |host|
73
- if managed_ruby
90
+ if managed_ruby?
74
91
  raise Capistrano::ValidationError, "#{host}: Managed ruby environment! Won't do any changes to ruby version."
75
92
  end
76
93
  if rbenv_installed_rubies.include?(app_ruby_version)
77
94
  info("#{host}: Required ruby version '#{app_ruby_version}' is installed.")
95
+ elsif rbenv_installable_rubies.include?(app_ruby_version)
96
+ info("#{host}: Required ruby version is not installed, but available for installation.")
97
+ execute(:rbenv, :install, app_ruby_version)
98
+ set :rbenv_needs_rehash, true
78
99
  else
79
- invoke('opscomplete:ruby:update_ruby_build')
80
- if rbenv_installable_rubies.include?(app_ruby_version)
81
- info("#{host}: Required ruby version is not installed, but available for installation.")
82
- execute(:rbenv, :install, app_ruby_version)
83
- set :rbenv_needs_rehash, true
84
- else
85
- raise Capistrano::ValidationError,
86
- "#{host}: Ruby version required by application is neither installed nor installable using ruby-install."
87
- end
100
+ raise Capistrano::ValidationError,
101
+ "#{host}: Ruby version required by application is neither installed nor installable using ruby-install."
88
102
  end
89
103
  execute(:rbenv, :global, app_ruby_version) unless capture(:rbenv, :global) == app_ruby_version
90
104
  end
105
+ invoke('opscomplete:ruby:install_rubygems')
91
106
  invoke('opscomplete:ruby:install_bundler')
92
107
  invoke('opscomplete:ruby:install_geordi')
93
108
  invoke('opscomplete:ruby:rehash') if fetch(:rbenv_needs_rehash, false)
94
109
  end
95
110
  end
96
-
97
- namespace :appserver do
98
- desc 'Restart Application'
99
- task :restart do
100
- on roles :app do
101
- execute "sudo passenger-config restart-app --ignore-app-not-running #{fetch(:deploy_to)}"
102
- end
103
- end
104
- end
105
111
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Opscomplete
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-opscomplete
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makandra Operations
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-28 00:00:00.000000000 Z
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: makandra-rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +87,6 @@ files:
73
87
  - bin/console
74
88
  - bin/setup
75
89
  - capistrano-opscomplete.gemspec
76
- - lib/capistrano-opscomplete.rb
77
90
  - lib/capistrano/dsl/opscomplete.rb
78
91
  - lib/capistrano/opscomplete.rb
79
92
  - lib/capistrano/opscomplete/deploy.rake
@@ -97,10 +110,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
110
  requirements:
98
111
  - - ">="
99
112
  - !ruby/object:Gem::Version
100
- version: '0'
113
+ version: 2.0.1
101
114
  requirements: []
102
115
  rubyforge_project:
103
- rubygems_version: 2.6.13
116
+ rubygems_version: 2.7.6
104
117
  signing_key:
105
118
  specification_version: 4
106
119
  summary: Capistrano tasks for easy deployment to a makandra opscomplete environment.
File without changes