Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
feat(ruby): introduced new ruby-version JSON parameter.
Browse files Browse the repository at this point in the history
This removes a misleading `ruby-ng.ruby_version` paramater in favor of
new universal `ruby-version`. The problem was, that the old one was used
for both distributions (Ubuntu and Amazon Linux) while in fact,
`ruby-ng` was referring to Ubuntu-only cookbook.

The new parameter is distro-agnostic and cookbook-agnostic, clearly
speaking it's intention.

Resolves #156

BREAKING CHANGE: If you were using `ruby-ng.ruby_version` JSON
configuration parameter in your stack/layer configuration, please change
it to `ruby-version`. Since `ruby-version` is set by default to the
freshest version of ruby available, you may end up with unexpected
upgrade of ruby on your system.
  • Loading branch information
ajgon committed Jun 8, 2018
1 parent 2ed059d commit 99798ce
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,4 @@ suites:
webserver:
adapter: 'apache2'
port: 8081
'ruby-ng':
ruby_version: '2.3'
'ruby-version': '2.3'
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# ruby
default['build-essential']['compile_time'] = true
default['ruby-ng']['ruby_version'] = node['ruby'].try(:[], 'version') || '2.5'
default['ruby-version'] = node['ruby'].try(:[], 'version') || '2.5'
default['nginx']['source']['modules'] = %w[
nginx::http_ssl_module nginx::http_realip_module nginx::http_gzip_static_module nginx::headers_more_module
nginx::http_stub_status_module
Expand Down
11 changes: 8 additions & 3 deletions docs/source/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ convention).
of an application, not included in this list - it will be skipped, as this list
takes precedence over anything else.

- ``node['ruby-ng']['ruby_version']``
- ``node['ruby-version']``

- **Type:** string
- **Default:** ``2.5``
- Sets the Ruby version used through the system. See `ruby-ng cookbook documentation`_
for more details
- Sets the Ruby version used through the system. For debian-based distributions,
a ``ruby-ng`` cookbook is used (check `ruby-ng cookbook documentation`_).
For Amazon Linux, packages provided by distribution (i.e. ``ruby23``,
``ruby23-devel`` etc.).
**Important** please note, that some versions may be available on one system,
and not on the other (for example ``ruby-ng`` gets freshest versions of ruby
way earlier than Amazon Linux).

Cross-application attributes
----------------------------
Expand Down
3 changes: 2 additions & 1 deletion recipes/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@

# Ruby and bundler
if node['platform_family'] == 'debian'
node.default['ruby-ng']['ruby_version'] = node['ruby-version']
include_recipe 'ruby-ng::dev'
else
ruby_pkg_version = node['ruby-ng']['ruby_version'].split('.')[0..1]
ruby_pkg_version = node['ruby-version'].split('.')[0..1]
package "ruby#{ruby_pkg_version.join('')}"
package "ruby#{ruby_pkg_version.join('')}-devel"
execute "/usr/sbin/alternatives --set ruby /usr/bin/ruby#{ruby_pkg_version.join('.')}"
Expand Down

0 comments on commit 99798ce

Please sign in to comment.