Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Addition of Ruby 2.2 and 2.3 #69

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 48 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,39 @@
}
default:{
case $version {
/^1\.8.*$/:{
/^1\.8(\..*)*$/:{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we don't use those match groups somewhere else we could simply leave them out

suggested: /^1\.8\..*$/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That implies that there will always be a '.' after the minor version. That's not always been the case afaik?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know ruby devs are following semantic versioning which I think will always result in a version of the format $major.$minor.$patch.

But I just realized debian package names either contain two or three digits (e.g. ruby1.9.1, ruby2.1). Therefore your solution might be more logical for most users.

$real_ruby_package = "${ruby::params::ruby_package}1.8"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '14.04') >= 0 {
warning('Packages for Ruby 1.8 are not available from default repositories.')
}
}
/^1\.9.*$/:{
/^1\.9(\..*)*$/:{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/^1\.9\..*$/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'd be more inclined to change the other files to match what's currently in my PR - dev.pp is the only other place this happens.

$real_ruby_package = "${ruby::params::ruby_package}1.9.1"
}
/^2\.0.*$/:{
/^2\.0(\..*)*$/:{
$real_ruby_package = "${ruby::params::ruby_package}2.0"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '13.10') < 0 {
warning('Packages for Ruby 2.0 are not available from default repositories.')
}
}
/^2\.1.*$/:{
/^2\.1(\..*)*$/:{
$real_ruby_package = "${ruby::params::ruby_package}2.1"
if ! $suppress_warnings {
warning('Packages for Ruby 2.1 are not available from default repositories.')
}
}
/^2\.2(\..*)*$/:{
$real_ruby_package = "${ruby::params::ruby_package}2.2"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '14.10') < 0 {
warning('Packages for Ruby 2.2 are not available from default repositories.')
}
}
/^2\.3(\..*)*$/:{
$real_ruby_package = "${ruby::params::ruby_package}2.3"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '16.04') < 0 {
warning('Packages for Ruby 2.3 are not available from default repositories.')
}
}
default: {
$real_ruby_package = $ruby_package
}
Expand Down Expand Up @@ -201,27 +213,39 @@
$real_default_bin = $system_default_bin
} else {
case $version {
/^1\.8.*$/:{
/^1\.8(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}1.8"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '14.04') >= 0 {
warning('No binary for Ruby 1.8.x available from default repositories')
}
}
/^1\.9.*$/:{
/^1\.9(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}1.9.1"
}
/^2\.0.*$/:{
/^2\.0(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}2.0"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '13.10') < 0 {
warning('No binary for Ruby 2.0.x available from default repositories')
}
}
/^2\.1.*$/:{
/^2\.1(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}2.1"
if ! $suppress_warnings {
warning('No binary for Ruby 2.1.x available from default repositories')
}
}
/^2\.2(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}2.2"
if ! $suppress_warnings {
warning('No binary for Ruby 2.2.x available from default repositories')
}
}
/^2\.3(\..*)*$/:{
$real_default_bin = "${ruby::params::ruby_bin_base}2.3"
if ! $suppress_warnings {
warning('No binary for Ruby 2.3.x available from default repositories')
}
}
default: {
fail('Unable to resolve default ruby binary')
}
Expand All @@ -231,27 +255,39 @@
$real_default_gem = $system_default_gem
} else {
case $version {
/^1\.8.*$/:{
/^1\.8(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}1.8"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '14.04') >= 0 {
warning('No binary package for Ruby 1.8.x available from default repositories')
}
}
/^1\.9.*$/:{
/^1\.9(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}1.9.1"
}
/^2\.0.*$/:{
/^2\.0(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}2.0"
if ! $suppress_warnings and versioncmp($::operatingsystemrelease, '13.10') < 0 {
warning('No binary package for Ruby 2.0.x available from default repositories')
}
}
/^2\.1.*$/:{
/^2\.1(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}2.1"
if ! $suppress_warnings {
warning('No binary package for Ruby 2.1.x available from default repositories')
}
}
/^2\.2(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}2.2"
if ! $suppress_warnings {
warning('No binary package for Ruby 2.2.x available from default repositories')
}
}
/^2\.3(\..*)*$/:{
$real_default_gem = "${ruby::params::ruby_gem_base}2.3"
if ! $suppress_warnings {
warning('No binary package for Ruby 2.3.x available from default repositories')
}
}
default: {
fail('Unable to resolve default gem binary')
}
Expand Down
197 changes: 196 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,68 @@
}
end

describe 'with ruby 2.2 with switch' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec tests are missing Ubuntu testing which is referenced in the manifest.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems Travis fails quite catastrophically on Puppet 4.x and Rubies 2.2 and 2.3. Not sure where to go from here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically you won't need to spec test against ruby 2.2 or 2.3 on Puppet 4 yet because it still uses 2.1 internally I believe.

let :params do
{
:version => '2.2',
:switch => true
}
end
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'ruby2.2'
})
}
it {
should contain_file('ruby_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/ruby',
'target' => '/usr/bin/ruby2.2',
'require' => 'Package[ruby]'
} )
}
it {
should contain_file('gem_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/gem',
'target' => '/usr/bin/gem2.2',
'require' => 'Package[rubygems]'
} )
}
end

describe 'with ruby 2.3 with switch' do
let :params do
{
:version => '2.3',
:switch => true
}
end
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'ruby2.3'
})
}
it {
should contain_file('ruby_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/ruby',
'target' => '/usr/bin/ruby2.3',
'require' => 'Package[ruby]'
} )
}
it {
should contain_file('gem_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/gem',
'target' => '/usr/bin/gem2.3',
'require' => 'Package[rubygems]'
} )
}
end

describe 'with ruby 1.8 with set_system_default' do
let :params do
{
Expand Down Expand Up @@ -1418,7 +1480,7 @@

end

context 'On Ubuntu 14.04LTS (Trusty Tahr' do
context 'On Ubuntu 14.04LTS (Trusty Tahr)' do
let :facts do
{
:osfamily => 'Debian',
Expand Down Expand Up @@ -1737,6 +1799,139 @@

end

context 'On Ubuntu 16.04LTS (Xenial Xerus)' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '16.04'
}
end
it { should contain_class('ruby::params') }
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'ruby',
})
}
it {
should contain_package('rubygems').with({
'ensure' => 'installed',
'name' => 'rubygems',
'require' => 'Package[ruby]',
})
}
it { should_not contain_package('rubygems-update') }
it { should_not contain_exec('ruby::update_rubygems') }
it { should_not contain_package('ruby-switch') }
it { should_not contain_exec('switch_ruby') }
it { should_not contain_file('ruby_bin') }
it { should_not contain_file('gem_bin') }

describe 'with a custom ruby package' do
let :params do
{
:ruby_package => 'sparkly-ruby'
}
end
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'sparkly-ruby'
})
}
end

describe 'with a custom rubygems package' do
let :params do
{
:rubygems_package => 'sparkly-rubygems'
}
end
it {
should contain_package('rubygems').with({
'name' => 'sparkly-rubygems',
})
}
end

describe 'when using the latest release' do
let :params do
{
:latest_release => true
}
end
it {
should contain_package('ruby').with({
'ensure' => 'latest'
})
}
end

describe 'with ruby 2.3 with switch' do
let :params do
{
:version => '2.3',
:switch => true
}
end
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'ruby2.3'
})
}
it {
should contain_file('ruby_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/ruby',
'target' => '/usr/bin/ruby2.3',
'require' => 'Package[ruby]'
} )
}
it {
should contain_file('gem_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/gem',
'target' => '/usr/bin/gem2.3',
'require' => 'Package[rubygems]'
} )
}
end

describe 'with ruby 2.3 with set_system_default' do
let :params do
{
:version => '2.3',
:set_system_default => true
}
end
it {
should contain_package('ruby').with({
'ensure' => 'installed',
'name' => 'ruby2.3'
})
}
it {
should contain_file('ruby_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/ruby',
'target' => '/usr/bin/ruby2.3',
'require' => 'Package[ruby]'
} )
}
it {
should contain_file('gem_bin').with({
'ensure' => 'link',
'path' => '/usr/bin/gem',
'target' => '/usr/bin/gem2.3',
'require' => 'Package[rubygems]'
} )
}
end

end

context 'With an Unkown operating system' do
let :facts do
{
Expand Down
4 changes: 4 additions & 0 deletions tests/ruby2.2.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class { '::ruby':
version => '2.2',
set_system_default => true,
}
4 changes: 4 additions & 0 deletions tests/ruby2.3.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class { '::ruby':
version => '2.3',
set_system_default => true,
}