Skip to content

Commit ece3679

Browse files
committed
feat(gems): allow to specify gems' versions
1 parent 233e225 commit ece3679

31 files changed

+92
-2
lines changed

packages/gems.sls

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,25 @@ gem_req_pkgs:
2727
### GEMS to install
2828
# (requires the ruby/rubygem deb/rpm installed, either by the system or listed in
2929
# the required packages
30+
# Standarize gems to format { gem: version }
31+
{% set gem = namespace(name = '', version = '') %}
32+
3033
{%- for gm in wanted_gems %}
31-
{{ gm }}:
34+
{%- if gm is mapping %}
35+
{%- for k,v in gm.items() %}
36+
{%- set gem.name = k %}
37+
{%- set gem.version = v %}
38+
{%- endfor %}
39+
{%- else %}
40+
{%- set gem.name = gm %}
41+
{%- set gem.version = 'version_undefined' %}
42+
{%- endif %}
43+
{{ gem.name }}-{{ gem.version }}:
3244
gem.installed:
45+
- name: {{ gem.name }}
46+
{%- if gem.version != 'version_undefined' %}
47+
- version: {{ gem.version }}
48+
{%- endif %}
3349
- require:
3450
- pkg: gem_req_pkgs
3551
{%- if req_states %}

pillar.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ packages:
5757
wanted:
5858
- progressbar
5959
- minitest
60+
# You can also specify a desired gem version
61+
- some_gem: 1.2.3
62+
- other: 2.3.4
6063
unwanted:
6164
- diff-lcs
6265
- kitchen-vagrant

test/integration/default/controls/gems_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
end
2121
end
2222

23+
### SPECIFIC GEMS VERSIONS
24+
control "Specific gems' versions" do
25+
title 'should be installed'
26+
27+
specific_gems = {
28+
'regexp_parser' => '1.7.0',
29+
'strings' => '0.1.8'
30+
}
31+
specific_gems.each do |p, v|
32+
describe gem(p) do
33+
it { should be_installed }
34+
its('versions') { should include(v) }
35+
end
36+
end
37+
end
38+
2339
### UNWANTED
2440
control 'Unwanted gems' do
2541
title 'should be uninstalled'

test/integration/default/files/_mapdata/almalinux-8.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ values:
3333
- kwalify
3434
wanted:
3535
- progressbar
36+
- strings: 0.1.8
37+
- regexp_parser: 1.7.0
3638
golang:
3739
clean: []
3840
goget: []

test/integration/default/files/_mapdata/amazonlinux-2.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ values:
3333
- kwalify
3434
wanted:
3535
- progressbar
36+
- strings: 0.1.8
37+
- regexp_parser: 1.7.0
3638
golang:
3739
clean: []
3840
goget: []

test/integration/default/files/_mapdata/arch-base-latest.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ values:
3333
wanted:
3434
- progressbar
3535
- minitest
36+
- strings: 0.1.8
37+
- regexp_parser: 1.7.0
3638
golang:
3739
clean: []
3840
goget: []

test/integration/default/files/_mapdata/centos-7.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ values:
3333
- kwalify
3434
wanted:
3535
- progressbar
36+
- strings: 0.1.8
37+
- regexp_parser: 1.7.0
3638
golang:
3739
clean: []
3840
goget: []

test/integration/default/files/_mapdata/centos-8.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ values:
3333
- kwalify
3434
wanted:
3535
- progressbar
36+
- strings: 0.1.8
37+
- regexp_parser: 1.7.0
3638
golang:
3739
clean: []
3840
goget: []

test/integration/default/files/_mapdata/debian-10.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ values:
6161
wanted:
6262
- progressbar
6363
- minitest
64+
- strings: 0.1.8
65+
- regexp_parser: 1.7.0
6466
golang:
6567
clean: []
6668
goget: []

test/integration/default/files/_mapdata/debian-11.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ values:
6161
wanted:
6262
- progressbar
6363
- minitest
64+
- strings: 0.1.8
65+
- regexp_parser: 1.7.0
6466
golang:
6567
clean: []
6668
goget: []

0 commit comments

Comments
 (0)