Skip to content

Commit 869f401

Browse files
committed
Fix lint and spec tests after PDK update
1 parent 7062c7a commit 869f401

File tree

13 files changed

+146
-110
lines changed

13 files changed

+146
-110
lines changed

.fixtures.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ fixtures:
22
repositories:
33
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
44
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
5+
chocolatey: "https://github.com/puppetlabs/puppetlabs-chocolatey.git"
6+
powershell: "https://github.com/puppetlabs/puppetlabs-powershell.git"
7+
registry: "https://github.com/puppetlabs/puppetlabs-registry.git"
58
vcsrepo: "https://github.com/puppetlabs/puppetlabs-vcsrepo.git"
69
symlinks:
710
software: "#{source_dir}"

.sync.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ Gemfile:
4747
- gem: puppet-lint-unquoted_string-check
4848
- gem: puppet-lint-variable_contains_upcase
4949
- gem: puppet-lint-version_comparison-check
50+
51+
Rakefile:
52+
extra_disabled_lint_checks:
53+
- disable_security_package_pinned_version

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ require 'puppet-syntax/tasks/puppet-syntax'
33
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
44

55
PuppetLint.configuration.send('relative')
6+
PuppetLint.configuration.send('disable_security_package_pinned_version')

lib/puppet/provider/package/apm.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22

33
require 'puppet/provider/package'
44

5-
Puppet::Type.type(:package).provide(:apm, :parent => Puppet::Provider::Package) do
5+
Puppet::Type.type(:package).provide(:apm, parent: Puppet::Provider::Package) do
66
desc 'Atom packages via `apm`.'
77

88
has_feature :installable, :uninstallable, :upgradeable, :versionable
99

10-
commands :apm => 'apm'
10+
commands apm: 'apm'
1111

1212
def self.parse(line, user)
13-
return unless line.chomp =~ / (\S+)@(\d+\.\d+\.\d+)/
14-
{ :name => Regexp.last_match(1), :provider => :apm,
15-
:ensure => Regexp.last_match(2), :source => user }
13+
return unless line.chomp =~ %r{ (\S+)@(\d+\.\d+\.\d+)}
14+
{ name: Regexp.last_match(1), provider: :apm,
15+
ensure: Regexp.last_match(2), source: user }
1616
end
1717

1818
def self.instances_by_user(user)
1919
command = [command(:apm), :list, '--no-color']
2020

2121
begin
2222
output = execute(command, command_opts(user))
23-
[].tap do |a|
23+
[].tap { |a|
2424
output.lines.each do |line|
2525
next unless (package = parse(line, user))
2626
a << new(package)
2727
end
28-
end.compact
28+
}.compact
2929
rescue Puppet::ExecutionFailure => e
3030
raise Puppet::Error, "Could not list atom packages: #{e}"
3131
end
3232
end
3333

3434
def self.instances
35-
Dir.entries(home_prefix).reject { |u| u.start_with?('.') || u.eql?('Shared') }.collect do |user|
35+
Dir.entries(home_prefix).reject { |u| u.start_with?('.') || u.eql?('Shared') }.map { |user|
3636
instances_by_user(user)
37-
end.flatten
37+
}.flatten
3838
end
3939

4040
def query
@@ -50,7 +50,7 @@ def latest
5050
command = [command(:apm), :upgrade, '--list', '--no-color']
5151
output = execute(command, self.class.command_opts(@resource[:source]))
5252

53-
if output =~ / #{Regexp.escape @resource[:name]} (\d+\.\d+\.\d+) -> (\d+\.\d+\.\d+)/
53+
if output =~ %r{ #{Regexp.escape @resource[:name]} (\d+\.\d+\.\d+) -> (\d+\.\d+\.\d+)}
5454
Regexp.last_match(2)
5555
else
5656
@property_hash[:ensure]
@@ -61,7 +61,7 @@ def install
6161
command = [command(:apm), :install]
6262

6363
should = @resource.should(:ensure)
64-
command << if %i[latest installed present].include?(should)
64+
command << if [:latest, :installed, :present].include?(should)
6565
@resource[:name]
6666
else
6767
"#{@resource[:name]}@#{should}"
@@ -101,13 +101,13 @@ def self.home_prefix
101101
def self.command_opts(user)
102102
Dir.chdir(home(user).to_s)
103103
@command_opts ||= {
104-
:combine => true,
105-
:custom_environment => {
106-
'HOME' => home(user).to_s,
107-
'PATH' => '/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin'
104+
combine: true,
105+
custom_environment: {
106+
'HOME' => home(user).to_s,
107+
'PATH' => '/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin',
108108
},
109-
:failonfail => true,
110-
:uid => default_user(user)
109+
failonfail: true,
110+
uid: default_user(user),
111111
}
112112
end
113113
end

lib/puppet/provider/package/appcompressed.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
# lib/puppet/provider/package/appcompressed.rb
22

33
require 'puppet/provider/package'
4-
Puppet::Type.type(:package).provide(:appcompressed, :parent => Puppet::Provider::Package) do
4+
Puppet::Type.type(:package).provide(:appcompressed, parent: Puppet::Provider::Package) do
55
desc 'Installs a compressed .app. Supports zip, tar.gz, tar.bz2'
66

77
FLAVORS = %w[zip tgz tar.gz tbz tbz2 tar.bz2].freeze
88

9-
confine :operatingsystem => :darwin
9+
confine operatingsystem: :darwin
1010

11-
commands :curl => '/usr/bin/curl'
12-
commands :ditto => '/usr/bin/ditto'
13-
commands :tar => '/usr/bin/tar'
11+
commands curl: '/usr/bin/curl'
12+
commands ditto: '/usr/bin/ditto'
13+
commands tar: '/usr/bin/tar'
1414
# commands :rm => '/bin/rm'
1515

1616
# JJM We store a cookie for each installed .app.compressed in /var/db
1717
def self.instances_by_name
1818
# Allow this gross code....
19-
# rubocop:disable Style/BlockDelimiters, Style/MultilineBlockChain
20-
Dir.entries('/var/db').find_all { |f|
21-
f =~ /^\.puppet_appcompressed_installed_/
22-
}.collect do |f|
23-
name = f.sub(/^\.puppet_appcompressed_installed_/, '')
19+
# rubocop:disable Style/MultilineBlockChain
20+
Dir.entries('/var/db').select { |f|
21+
f =~ %r{^\.puppet_appcompressed_installed_}
22+
}.map do |f|
23+
name = f.sub(%r{^\.puppet_appcompressed_installed_}, '')
2424
yield name if block_given?
2525
name
2626
end
27-
# rubocop:enable Style/BlockDelimiters, Style/MultilineBlockChain
27+
# rubocop:enable Style/MultilineBlockChain
2828
end
2929

3030
def self.instances
31-
instances_by_name.collect do |name|
32-
new(:name => name, :provider => :appcompressed, :ensure => :installed)
31+
instances_by_name.map do |name|
32+
new(name: name, provider: :appcompressed, ensure: :installed)
3333
end
3434
end
3535

3636
def query
3737
return unless File.exist?(receipt_path)
3838
{
39-
:name => @resource[:name],
40-
:ensure => :installed
39+
name: @resource[:name],
40+
ensure: :installed,
4141
}
4242
end
4343

@@ -86,7 +86,7 @@ def install
8686
private
8787

8888
def flavor
89-
@resource[:flavor] || @resource[:source].match(/\.(#{FLAVORS.join('|')})$/i) { |m| m[1] }
89+
@resource[:flavor] || @resource[:source].match(%r{\.(#{FLAVORS.join('|')})$}i) { |m| m[1] }
9090
end
9191

9292
# This is not always correct...

lib/puppet/provider/package/prefpanecompressed.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
# lib/puppet/provider/package/prefpanecompressed.rb
22

33
require 'puppet/provider/package'
4-
Puppet::Type.type(:package).provide(:prefpanecompressed, :parent => Puppet::Provider::Package) do
4+
Puppet::Type.type(:package).provide(:prefpanecompressed, parent: Puppet::Provider::Package) do
55
desc 'Installs a compressed .prefPane. Supports zip, tar.gz, tar.bz2'
66

77
FLAVORZ = %w[zip tgz tar.gz tbz tbz2 tar.bz2].freeze
88

9-
confine :operatingsystem => :darwin
9+
confine operatingsystem: :darwin
1010

11-
commands :curl => '/usr/bin/curl'
12-
commands :ditto => '/usr/bin/ditto'
13-
commands :tar => '/usr/bin/tar'
11+
commands curl: '/usr/bin/curl'
12+
commands ditto: '/usr/bin/ditto'
13+
commands tar: '/usr/bin/tar'
1414
# commands :rm => '/bin/rm'
1515

1616
# JJM We store a cookie for each installed .app.compressed in /var/db
1717
def self.instances_by_name
1818
# Allow this gross code....
19-
# rubocop:disable Style/BlockDelimiters, Style/MultilineBlockChain
20-
Dir.entries('/var/db').find_all { |f|
21-
f =~ /^\.puppet_prefpanecompressed_installed_/
22-
}.collect do |f|
23-
name = f.sub(/^\.puppet_prefpanecompressed_installed_/, '')
19+
# rubocop:disable Style/MultilineBlockChain
20+
Dir.entries('/var/db').select { |f|
21+
f =~ %r{^\.puppet_prefpanecompressed_installed_}
22+
}.map do |f|
23+
name = f.sub(%r{^\.puppet_prefpanecompressed_installed_}, '')
2424
yield name if block_given?
2525
name
2626
end
27-
# rubocop:enable Style/BlockDelimiters, Style/MultilineBlockChain
27+
# rubocop:enable Style/MultilineBlockChain
2828
end
2929

3030
def self.instances
31-
instances_by_name.collect do |name|
32-
new(:name => name, :provider => :prefpanecompressed, :ensure => :installed)
31+
instances_by_name.map do |name|
32+
new(name: name, provider: :prefpanecompressed, ensure: :installed)
3333
end
3434
end
3535

3636
def query
3737
return unless File.exist?(receipt_path)
3838
{
39-
:name => @resource[:name],
40-
:ensure => :installed
39+
name: @resource[:name],
40+
ensure: :installed,
4141
}
4242
end
4343

@@ -86,7 +86,7 @@ def install
8686
private
8787

8888
def flavor
89-
@resource[:flavor] || @resource[:source].match(/\.(#{FLAVORZ.join('|')})$/i) { |m| m[1] }
89+
@resource[:flavor] || @resource[:source].match(%r{\.(#{FLAVORZ.join('|')})$}i) { |m| m[1] }
9090
end
9191

9292
# This is not always correct...

manifests/editors/atom.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
}
8686
}
8787
'windows': {
88+
$apm_require = undef
89+
8890
package { 'atom':
8991
ensure => $ensure,
9092
provider => chocolatey,

manifests/init.pp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@
1616
) inherits software::params {
1717

1818
# Not Used
19-
fail("The ${module_name} module does not use the ${name} class.
20-
Just include the software or group classes you want like this:
21-
include software::browsers::chrome (just chrome) include software::browsers (all browsers in group)")
22-
19+
fail("The ${module_name} module does not use the ${name} class. Just include the software or group classes you want.")
2320
}

0 commit comments

Comments
 (0)