Skip to content

Commit 5bec15b

Browse files
committed
(MAINT) Rubocop - (lib) fixes for face
1 parent 5b932b6 commit 5bec15b

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

lib/puppet/face/strings.rb

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
check_required_features
3333
require 'puppet-strings'
3434

35-
PuppetStrings::generate(
35+
PuppetStrings.generate(
3636
args.count > 1 ? args[0..-2] : PuppetStrings::DEFAULT_SEARCH_PATTERNS,
37-
build_generate_options(args.last)
37+
build_generate_options(args.last),
3838
)
3939
nil
4040
end
@@ -79,35 +79,34 @@
7979
return
8080
end
8181
puts 'Starting YARD documentation server.'
82-
PuppetStrings::run_server('-m', *module_docs)
82+
PuppetStrings.run_server('-m', *module_docs)
8383
nil
8484
end
8585
end
8686

87-
action(:describe) do #This is Kris' experiment with string based describe
88-
option "--list" do
89-
summary "list types"
87+
action(:describe) do # This is Kris' experiment with string based describe
88+
option '--list' do
89+
summary 'list types'
9090
end
91-
option "--providers" do
92-
summary "provide details on providers"
91+
option '--providers' do
92+
summary 'provide details on providers'
9393
end
9494

95-
#TODO: Implement the rest of describe behavior
96-
# * --help:
97-
# Print this help text
95+
# TODO: Implement the rest of describe behavior
96+
# * --help:
97+
# Print this help text
9898

99-
# * --providers:
100-
# Describe providers in detail for each type
99+
# * --providers:
100+
# Describe providers in detail for each type
101101

102-
# * --list:
103-
# List all types
102+
# * --list:
103+
# List all types
104104

105-
# * --meta:
106-
# List all metaparameters
107-
108-
# * --short:
109-
# List only parameters without detail
105+
# * --meta:
106+
# List all metaparameters
110107

108+
# * --short:
109+
# List only parameters without detail
111110

112111
when_invoked do |*args|
113112
check_required_features
@@ -117,27 +116,24 @@
117116
options[:describe] = true
118117
options[:stdout] = true
119118
options[:format] = 'json'
120-
119+
121120
if args.length > 1
122121
if options[:list]
123-
warn "WARNING: ignoring types when listing all types."
122+
warn 'WARNING: ignoring types when listing all types.'
124123
else
125124
options[:describe_types] = args[0..-2]
126125
end
127126
end
128127

129-
#TODO: Set up search_patterns and whatever else needed to collect data for describe - currently missing some
128+
# TODO: Set up search_patterns and whatever else needed to collect data for describe - currently missing some
130129
# manifests/**/*.pp
131130
# functions/**/*.pp
132131
# tasks/*.json
133132
# plans/*.pp
134-
search_patterns = %w(
135-
types/**/*.pp
136-
lib/**/*.rb
137-
)
138-
PuppetStrings::generate(
133+
search_patterns = ['types/**/*.pp', 'lib/**/*.rb']
134+
PuppetStrings.generate(
139135
search_patterns,
140-
build_generate_options(options)
136+
build_generate_options(options),
141137
)
142138
nil
143139
end
@@ -146,9 +142,9 @@
146142
# Checks that the required features are installed.
147143
# @return [void]
148144
def check_required_features
149-
raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
150-
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
151-
raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION.match?(/^1\.8/)
145+
raise "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard?
146+
raise "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen?
147+
raise 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION.match?(%r{^1\.8})
152148
end
153149

154150
# Builds the options to PuppetStrings.generate.
@@ -186,7 +182,7 @@ def build_generate_options(options = nil, *yard_args)
186182
generate_options[:json] = true
187183
generate_options[:path] ||= options[:emit_json] if options[:emit_json]
188184
else
189-
raise RuntimeError, "Invalid format #{options[:format]}. Please select 'json' or 'markdown'."
185+
raise "Invalid format #{options[:format]}. Please select 'json' or 'markdown'."
190186
end
191187
elsif options[:emit_json] || options[:emit_json_stdout]
192188
generate_options[:json] = true

0 commit comments

Comments
 (0)