Skip to content

Commit d6d3c9e

Browse files
authored
Merge pull request #7 from deanmax/rx_2283
RX-2283: export all rubies env settings
2 parents 2005bd6 + d8e6f02 commit d6d3c9e

File tree

4 files changed

+47
-9
lines changed

4 files changed

+47
-9
lines changed

.fixtures.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ fixtures:
22
symlinks:
33
ruby: "#{source_dir}"
44
repositories:
5-
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
6-
"rvm": "git://github.com/maestrodev/puppet-rvm.git"
5+
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
6+
rvm: "git://github.com/maestrodev/puppet-rvm.git"
7+
concat: "git://github.com/puppetlabs/puppetlabs-concat.git"

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The full functionality of this module requires Hiera.
77
To simply ensure that one or more Ruby versions are installed, use the base `ruby` class with an array of Ruby Software Collections names:
88

99
```
10-
class { ruby:
10+
class { ruby:
1111
$rubies => [ 'ruby200', 'rh-ruby22', ],
1212
}
1313
```
@@ -31,7 +31,7 @@ Gems can be installed system-wide on a per-Ruby basis.
3131
}
3232
```
3333

34-
Any Gem executable (binary or script) will be installed into `/opt/rh/<ruby>/root/usr/local/bin`, and that directory will be added to the `PATH` environment variable inside the relevant Software Collection enable script. This ensures that Gem executables will be available when the Software Collection is enabled.
34+
Any Gem executable (binary or script) will be installed into `/opt/rh/<ruby>/root/usr/local/bin`, and that directory will be added to the `PATH` environment variable inside the relevant Software Collection enable script. This ensures that Gem executables will be available when the Software Collection is enabled.
3535

3636
The default Gem installation options include `--no-ridoc` and `--no-rdoc`. If you wish to install documentation, you may do so:
3737
```
@@ -86,6 +86,13 @@ The default for SCL gems is to pass `--no-ridoc` and `--no-rdoc` to the installa
8686
ridoc: true
8787
rdoc: true
8888

89+
## Running Tests
90+
91+
To run the Puppet spec tests, you will need to run the setup rake task first:
92+
93+
1. `rake spec_clean && rake spec_prep` to set up your environment, *especially* if you updated .fixtures.yml
94+
2. `rake spec` from current directory to start the test
95+
8996
# Contributing
9097
Pull requests are warmly welcomed!
9198

manifests/init.pp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,23 @@
6565
# in one shot
6666
ruby::usr_local { $rubies: }
6767

68-
# enable the default Ruby in all users' bash environments
69-
file { '/etc/profile.d/scl-ruby.sh':
70-
ensure => link,
71-
target => "/opt/rh/${default_ruby}/enable",
72-
require => Package["${default_ruby}-ruby"],
68+
# enable Rubies in all users' bash environments
69+
$_target_env = '/etc/profile.d/scl-ruby.sh'
70+
71+
concat { $_target_env:
72+
owner => 'root',
73+
group => 'root',
74+
mode => '0644',
75+
}
76+
77+
# reverse rubies order to make sure the first in the list is the default ruby
78+
# refer to repo README for default ruby definition
79+
reverse($rubies).each |Integer $id, String $version| {
80+
concat::fragment { $version:
81+
target => $_target_env,
82+
source => "/opt/rh/${version}/enable",
83+
order => $id,
84+
}
7385
}
7486

7587
# get the default set of system gems

spec/classes/ruby_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,22 @@
2727
end
2828
end
2929

30+
context 'multiple ruby envs enablement with reverse order of the array' do
31+
let :params do
32+
{ :rubies => [ 'rh-zzoriginalfirstelement', 'rh-ruby22', 'rh-ruby24', 'rh-aaoriginallastelement' ] }
33+
end
34+
it { is_expected.to contain_concat("/etc/profile.d/scl-ruby.sh") }
35+
it { is_expected.to contain_concat__fragment("rh-aaoriginallastelement").with(
36+
'order' => 0,
37+
)}
38+
it { is_expected.to contain_concat__fragment("rh-ruby24").with(
39+
'order' => 1,
40+
)}
41+
it { is_expected.to contain_concat__fragment("rh-ruby22").with(
42+
'order' => 2,
43+
)}
44+
it { is_expected.to contain_concat__fragment("rh-zzoriginalfirstelement").with(
45+
'order' => 3,
46+
)}
47+
end
3048
end

0 commit comments

Comments
 (0)