Skip to content

Commit 200ce83

Browse files
committed
proper privatize class methods
1 parent 123464b commit 200ce83

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

lib/puppet-check/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def self.run(args)
1616

1717
# parse the user arguments
1818
def self.parse(args)
19-
private_class_method :method
19+
private_class_method :parse
2020
require 'optparse'
2121

2222
# show help message if no args specified

lib/puppet-check/data_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def self.json(files)
206206

207207
# checks hieradata
208208
def self.hiera(data, file)
209-
private_class_method :method
209+
private_class_method :hiera
210210
warnings = []
211211

212212
# disregard nil/undef value data check if default values (common)

lib/puppet-check/output_results.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def self.run(files, format)
3333

3434
# output the results as text
3535
def self.text(files)
36-
private_class_method :method
36+
private_class_method :text
3737

3838
# output text for each of four file categories
3939
%i[errors warnings clean ignored].each do |category|

lib/puppet-check/regression_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def self.smoke(interface_nodes, octoconfig)
2424

2525
# config file loading
2626
def self.config(octoconfig)
27-
private_class_method :method
27+
private_class_method :config
2828
OctocatalogDiff::API::V1.config(filename: octoconfig)
2929
end
3030
end

lib/puppet-check/rspec_puppet_support.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def self.run
3030

3131
# setup the files, directories, and symlinks for rspec-puppet testing
3232
def self.file_setup(module_name)
33-
private_class_method :method
33+
private_class_method :file_setup
3434
# create all the necessary fixture dirs that are missing
3535
['spec/fixtures', 'spec/fixtures/manifests', 'spec/fixtures/modules'].each do |dir|
3636
Dir.mkdir(dir) unless File.directory?(dir)
@@ -59,7 +59,7 @@ def self.file_setup(module_name)
5959

6060
# setup the module dependencies for rspec-puppet testing
6161
def self.dependency_setup
62-
private_class_method :method
62+
private_class_method :dependency_setup
6363
require 'json'
6464

6565
# parse the metadata.json (assumes DataParser.json has already given it a pass)
@@ -86,7 +86,7 @@ def self.dependency_setup
8686

8787
# download external module dependency with git
8888
def self.git(git_url, args = '')
89-
private_class_method :method
89+
private_class_method :git
9090
# establish path to clone module to
9191
path = "spec/fixtures/modules/#{File.basename(git_url, '.git')}"
9292
# is the module present and already cloned with git? do a pull; otherwise, do a clone
@@ -99,15 +99,15 @@ def self.git(git_url, args = '')
9999

100100
# download external module dependency with forge
101101
def self.forge(forge_name, args = '')
102-
private_class_method :method
102+
private_class_method :forge
103103
# is the module present? do an upgrade; otherwise, do an install
104104
subcommand = File.directory?("spec/fixtures/modules/#{forge_name}") ? 'upgrade' : 'install'
105105
spawn("puppet module #{subcommand} --modulepath spec/fixtures/modules/ #{args} #{forge_name}")
106106
end
107107

108108
# download external module dependency with svn
109109
def self.svn(svn_url, args = '')
110-
private_class_method :method
110+
private_class_method :svn
111111
# establish path to checkout module to
112112
path = "spec/fixtures/modules/#{File.basename(svn_url)}"
113113
# is the module present and already checked out with svn? do an update; otherwise, do a checkout
@@ -120,7 +120,7 @@ def self.svn(svn_url, args = '')
120120

121121
# download external module dependency with hg
122122
def self.hg(hg_url, args = '')
123-
private_class_method :method
123+
private_class_method :hg
124124
# establish path to clone module to
125125
path = "spec/fixtures/modules/#{File.basename(hg_url)}"
126126
# is the module present and already cloned with hg? do a pull and update; otherwise do a clone

lib/puppet_check.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run(settings = {}, paths = [])
7070

7171
# establish default settings
7272
def self.defaults(settings = {})
73-
private_class_method :method
73+
private_class_method :defaults
7474

7575
# return settings with defaults where unspecified
7676
{
@@ -95,7 +95,7 @@ def self.defaults(settings = {})
9595

9696
# parse the paths and return the array of files
9797
def self.parse_paths(paths = [])
98-
private_class_method :method
98+
private_class_method :parse_paths
9999
files = []
100100

101101
# traverse the unique paths and return all files not explicitly in fixtures

spec/puppet-check/cli_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@
1212

1313
context '.parse' do
1414
it 'raises an error if an invalid option was specified' do
15-
expect { PuppetCheck::CLI.parse(%w[-s -asdf foo]) }.to raise_error(OptionParser::InvalidOption)
15+
expect { PuppetCheck::CLI.send(:parse, %w[-s -asdf foo]) }.to raise_error(OptionParser::InvalidOption)
1616
end
1717

1818
it 'allows fail on warnings, style, smoke, and regression checks to be enabled' do
19-
expect(PuppetCheck::CLI.parse(%w[--fail-on-warnings -s -r --smoke foo])).to include(fail_on_warnings: true, style: true, smoke: true, regression: true)
19+
expect(PuppetCheck::CLI.send(:parse, %w[--fail-on-warnings -s -r --smoke foo])).to include(fail_on_warnings: true, style: true, smoke: true, regression: true)
2020
end
2121

2222
it 'correctly parser EYAML options' do
23-
expect(PuppetCheck::CLI.parse(%w[--public pub.pem --private priv.pem])).to include(public: 'pub.pem', private: 'priv.pem')
23+
expect(PuppetCheck::CLI.send(:parse, %w[--public pub.pem --private priv.pem])).to include(public: 'pub.pem', private: 'priv.pem')
2424
end
2525

2626
it 'correctly parses a formatting option' do
27-
expect(PuppetCheck::CLI.parse(%w[-o text])).to include(output_format: 'text')
27+
expect(PuppetCheck::CLI.send(:parse, %w[-o text])).to include(output_format: 'text')
2828
end
2929

3030
it 'correctly parses octocatalog-diff options' do
31-
expect(PuppetCheck::CLI.parse(%w[--octoconfig config.cfg.rb --octonodes server1,server2])).to include(octoconfig: 'config.cfg.rb', octonodes: %w[server1 server2])
31+
expect(PuppetCheck::CLI.send(:parse, %w[--octoconfig config.cfg.rb --octonodes server1,server2])).to include(octoconfig: 'config.cfg.rb', octonodes: %w[server1 server2])
3232
end
3333

3434
it 'correctly parses PuppetLint arguments' do
35-
expect(PuppetCheck::CLI.parse(%w[--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo])).to include(puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'])
35+
expect(PuppetCheck::CLI.send(:parse, %w[--puppet-lint puppetlint-arg-one,puppetlint-arg-two foo])).to include(puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'])
3636
end
3737

3838
it 'correctly loads a .puppet-lint.rc' do
39-
expect(PuppetCheck::CLI.parse(%W[-c #{fixtures_dir}/manifests/.puppet-lint.rc])).to include(puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'])
39+
expect(PuppetCheck::CLI.send(:parse, %W[-c #{fixtures_dir}/manifests/.puppet-lint.rc])).to include(puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'])
4040
end
4141

4242
it 'correctly parses Rubocop arguments' do
43-
expect(PuppetCheck::CLI.parse(%w[--rubocop rubocop-arg-one,rubocop-arg-two foo])).to include(rubocop_args: ['--except', 'rubocop-arg-one,rubocop-arg-two'])
43+
expect(PuppetCheck::CLI.send(:parse, %w[--rubocop rubocop-arg-one,rubocop-arg-two foo])).to include(rubocop_args: ['--except', 'rubocop-arg-one,rubocop-arg-two'])
4444
end
4545

4646
it 'correctly parses multiple sets of arguments' do
47-
expect(PuppetCheck::CLI.parse(%w[-s --puppet-lint puppetlint-arg-one,puppetlint-arg-two --rubocop rubocop-arg-one,rubocop-arg-two foo])).to include(style: true, puppetlint_args: ['--puppetlint-arg-one', '--puppetlint-arg-two'], rubocop_args: ['--except', 'rubocop-arg-one,rubocop-arg-two'])
47+
expect(PuppetCheck::CLI.send(:parse, %w[-s --puppet-lint puppet-lint-arg-one,puppet-lint-arg-two --rubocop rubocop-arg-one,rubocop-arg-two foo])).to include(style: true, puppetlint_args: ['--puppet-lint-arg-one', '--puppet-lint-arg-two'], rubocop_args: ['--except', 'rubocop-arg-one,rubocop-arg-two'])
4848
end
4949
end
5050
end

spec/puppet-check/output_results_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
context '.text' do
66
it 'outputs files with errors' do
77
files = { errors: { 'foo' => ['i had an error'] } }
8-
expect { OutputResults.text(files) }.to output("\033[31mThe following files have errors:\033[0m\n-- foo:\ni had an error\n\n").to_stdout
8+
expect { OutputResults.send(:text, files) }.to output("\033[31mThe following files have errors:\033[0m\n-- foo:\ni had an error\n\n").to_stdout
99
end
1010
it 'outputs files with warnings' do
1111
files = { warnings: { 'foo' => ['i had a warning'] } }
12-
expect { OutputResults.text(files) }.to output("\033[33mThe following files have warnings:\033[0m\n-- foo:\ni had a warning\n\n").to_stdout
12+
expect { OutputResults.send(:text, files) }.to output("\033[33mThe following files have warnings:\033[0m\n-- foo:\ni had a warning\n\n").to_stdout
1313
end
1414
it 'outputs files with no errors or warnings' do
1515
files = { clean: ['foo'] }
16-
expect { OutputResults.text(files) }.to output("\033[32mThe following files have no errors or warnings:\033[0m\n-- foo\n\n").to_stdout
16+
expect { OutputResults.send(:text, files) }.to output("\033[32mThe following files have no errors or warnings:\033[0m\n-- foo\n\n").to_stdout
1717
end
1818
it 'outputs files that were not processed' do
1919
files = { ignored: ['foo'] }
20-
expect { OutputResults.text(files) }.to output("\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- foo\n\n").to_stdout
20+
expect { OutputResults.send(:text, files) }.to output("\033[36mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- foo\n\n").to_stdout
2121
end
2222
end
2323

spec/puppet-check/regression_check_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
context '.config' do
88
# json gem is messed up for the EOL Ruby versions
99
it 'raise an appropriate error if the file is malformed' do
10-
expect { RegressionCheck.config("#{fixtures_dir}metadata.json") }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
10+
expect { RegressionCheck.send(:config, "#{fixtures_dir}metadata.json") }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
1111
end
1212
it 'loads in a good octocatalog-diff config file' do
13-
expect { RegressionCheck.config("#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
13+
expect { RegressionCheck.send(:config, "#{octocatalog_diff_dir}octocatalog_diff.cfg.rb") }.not_to raise_exception
1414
end
1515
it 'loads in the settings from the file correctly' do
1616
# TODO

spec/puppet_check_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
context 'defaults' do
3535
it 'returns defaults correctly' do
36-
expect(PuppetCheck.defaults).to eql(
36+
expect(PuppetCheck.send(:defaults)).to eql(
3737
{
3838
fail_on_warning: false,
3939
style: false,
@@ -64,18 +64,18 @@
6464
puppetlint_args: %w[--puppetlint-arg-one --puppetlint-arg-two],
6565
rubocop_args: %w[--rubocop-arg-one --rubocop-arg-two]
6666
}
67-
expect(PuppetCheck.defaults(settings)).to eql(settings)
67+
expect(PuppetCheck.send(:defaults, settings)).to eql(settings)
6868
end
6969
end
7070

7171
context '.parse_paths' do
7272
before(:each) { Dir.chdir(fixtures_dir) }
7373

74-
let(:no_files) { PuppetCheck.parse_paths(%w[foo bar baz]) }
75-
let(:file) { PuppetCheck.parse_paths(['lib/good.rb']) }
76-
let(:dir) { PuppetCheck.parse_paths(['.']) }
77-
let(:multi_dir) { PuppetCheck.parse_paths(%w[hieradata lib manifests]) }
78-
let(:repeats) { PuppetCheck.parse_paths(['hieradata', 'hieradata', 'lib', 'hieradata/good.json', 'manifests/good.pp', 'manifests/good.pp']) }
74+
let(:no_files) { PuppetCheck.send(:parse_paths, %w[foo bar baz]) }
75+
let(:file) { PuppetCheck.send(:parse_paths, ['lib/good.rb']) }
76+
let(:dir) { PuppetCheck.send(:parse_paths, ['.']) }
77+
let(:multi_dir) { PuppetCheck.send(:parse_paths, %w[hieradata lib manifests]) }
78+
let(:repeats) { PuppetCheck.send(:parse_paths, ['hieradata', 'hieradata', 'lib', 'hieradata/good.json', 'manifests/good.pp', 'manifests/good.pp']) }
7979

8080
it 'raises an error if no files were found' do
8181
expect { no_files }.to raise_error(RuntimeError, 'puppet-check: no files found in supplied paths \'foo, bar, baz\'.')

0 commit comments

Comments
 (0)