Skip to content

Commit b7d4a00

Browse files
rspec
1 parent 64bec7c commit b7d4a00

File tree

7 files changed

+98
-11
lines changed

7 files changed

+98
-11
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/.bundle/
22
/.yardoc
3-
/Gemfile.lock
43
/_yardoc/
54
/coverage/
65
/doc/
76
/pkg/
87
/spec/reports/
98
/tmp/
9+
/vendor/

Gemfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
gemspec
22
source 'https://rubygems.org' do
3-
gem 'rake'
3+
gem 'sensu-plugin'
44
group :development do
55
gem 'rubocop'
66
gem 'rspec'
77
gem 'coveralls'
8+
gem 'bundler', '~> 1.11'
9+
gem 'rake', '~> 10.0'
810
end
911
group :docs do
1012
gem 'yard'

Gemfile.lock

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
PATH
2+
remote: .
3+
specs:
4+
puppetfiles (0.1.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
ast (2.3.0)
10+
coveralls (0.8.13)
11+
json (~> 1.8)
12+
simplecov (~> 0.11.0)
13+
term-ansicolor (~> 1.3)
14+
thor (~> 0.19.1)
15+
tins (~> 1.6.0)
16+
diff-lcs (1.2.5)
17+
docile (1.1.5)
18+
json (1.8.3)
19+
mixlib-cli (1.6.0)
20+
parser (2.3.1.2)
21+
ast (~> 2.2)
22+
powerpack (0.1.1)
23+
rainbow (2.1.0)
24+
rake (10.5.0)
25+
rspec (3.4.0)
26+
rspec-core (~> 3.4.0)
27+
rspec-expectations (~> 3.4.0)
28+
rspec-mocks (~> 3.4.0)
29+
rspec-core (3.4.4)
30+
rspec-support (~> 3.4.0)
31+
rspec-expectations (3.4.0)
32+
diff-lcs (>= 1.2.0, < 2.0)
33+
rspec-support (~> 3.4.0)
34+
rspec-mocks (3.4.1)
35+
diff-lcs (>= 1.2.0, < 2.0)
36+
rspec-support (~> 3.4.0)
37+
rspec-support (3.4.1)
38+
rubocop (0.40.0)
39+
parser (>= 2.3.1.0, < 3.0)
40+
powerpack (~> 0.1)
41+
rainbow (>= 1.99.1, < 3.0)
42+
ruby-progressbar (~> 1.7)
43+
unicode-display_width (~> 1.0, >= 1.0.1)
44+
ruby-progressbar (1.8.1)
45+
sensu-plugin (1.3.0)
46+
json
47+
mixlib-cli (>= 1.5.0)
48+
simplecov (0.11.2)
49+
docile (~> 1.1.0)
50+
json (~> 1.8)
51+
simplecov-html (~> 0.10.0)
52+
simplecov-html (0.10.0)
53+
term-ansicolor (1.3.2)
54+
tins (~> 1.0)
55+
thor (0.19.1)
56+
tins (1.6.0)
57+
unicode-display_width (1.1.0)
58+
yard (0.8.7.6)
59+
60+
PLATFORMS
61+
ruby
62+
63+
DEPENDENCIES
64+
bundler (~> 1.11)!
65+
coveralls!
66+
puppetfiles!
67+
rake (~> 10.0)!
68+
rspec!
69+
rubocop!
70+
sensu-plugin!
71+
yard!
72+
73+
BUNDLED WITH
74+
1.12.5

bin/puppetfiles-update-module.rb

100644100755
+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rubocop:disable Style/FileName
1+
#!ruby
22
# @author Luca De Vitis <luca.devitis at moneysupermarket.com>
33
require 'sensu-plugin/check/cli'
44
require 'puppetfiles/bin/update_module'
@@ -23,4 +23,18 @@ class PuppetfilesUpdateModule < Sensu::Plugin::CLI
2323
long: '--set-option-ref REF',
2424
description: 'Set module git ref string',
2525
required: false
26+
27+
option :help,
28+
long: '--help',
29+
description: 'Show this message',
30+
on: :tail,
31+
boolean: true,
32+
show_options: true,
33+
exit: 0
34+
def output(*args)
35+
puts "#{self.class.name}: " + args.join(' ')
36+
end
37+
def run
38+
main
39+
end
2640
end

lib/puppetfiles/bin/update_module.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ module Bin
99
# Update 1 module details in all provided puppetfiles that contain it
1010
module UpdateModule
1111
# Run the module update
12-
def run
12+
def main
1313
mod = argv.first
1414
files = argv.drop(1)
1515
version = config[:version]
1616
keys = [:git, :ref]
1717
options = keys.map { |k| [k, config[k]] if config[k] }.compact.to_h
1818
::Puppetfiles.load files
1919
::Puppetfiles.update mod, version, options
20-
loaded = ::Puppetfiles.loaded.count
20+
count = ::Puppetfiles.loaded.count
2121
updated = ::Puppetfiles.loaded.count
2222
::Puppetfiles.save
23-
ok "#{loaded} Puppetfiles, `#{mod}' updated on #{updated}"
23+
ok "#{count} Puppetfiles loaded, `#{mod}' updated on #{updated}"
2424
end
2525
end
2626
end

puppetfiles.gemspec

-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,4 @@ Gem::Specification.new do |spec|
2424
spec.bindir = 'bin'
2525
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
2626
spec.require_paths = ['lib']
27-
28-
spec.add_development_dependency 'bundler', '~> 1.11'
29-
spec.add_development_dependency 'rake', '~> 10.0'
3027
end

spec/bin/update_module_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def output(msg = nil)
4545
UpdateModule.new([mod1[:name], puppetfile.path], version: value)
4646
end
4747
it 'should update module version' do
48-
expect { script.run }.to raise_error(SystemExit)
48+
expect { script.main }.to raise_error(SystemExit)
4949
expect(script.status).to eq(0)
5050
loaded = ::Puppetfiles.load [puppetfile.path]
5151
found = loaded.first[:modules].find { |m| m[:name] == mod1[:name] }
@@ -59,7 +59,7 @@ def output(msg = nil)
5959
UpdateModule.new([mod2[:name], puppetfile.path], name => value)
6060
end
6161
it "should update module option `:#{name}`" do
62-
expect { script.run }.to raise_error(SystemExit)
62+
expect { script.main }.to raise_error(SystemExit)
6363
expect(script.status).to eq(0)
6464
loaded = ::Puppetfiles.load [puppetfile.path]
6565
found = loaded.first[:modules].find { |m| m[:name] == mod2[:name] }

0 commit comments

Comments
 (0)