5
5
# Implements the strings:generate task.
6
6
namespace :strings do
7
7
desc 'Generate Puppet documentation with YARD.'
8
- task :generate , [ :patterns , :debug , :backtrace , :markup , :json , :markdown , :yard_args ] do |t , args |
8
+ task :generate , [ :patterns , :debug , :backtrace , :markup , :json , :markdown , :yard_args ] do |_t , args |
9
9
patterns = args [ :patterns ]
10
10
patterns = patterns . split if patterns
11
11
patterns ||= PuppetStrings ::DEFAULT_SEARCH_PATTERNS
16
16
markup : args [ :markup ] || 'markdown' ,
17
17
}
18
18
19
- raise ( " Error: Both JSON and Markdown output have been selected. Please select one." ) if args [ :json ] == 'true' && args [ :markdown ] == 'true'
19
+ raise ( ' Error: Both JSON and Markdown output have been selected. Please select one.' ) if args [ :json ] == 'true' && args [ :markdown ] == 'true'
20
20
21
21
# rubocop:disable Style/PreferredHashMethods
22
22
# Because of Ruby, true and false from the args are both strings and both true. Here,
28
28
# @param [Symbol] possible format option
29
29
# @return nil
30
30
def parse_format_option ( args , options , format )
31
- if args . has_key? format
32
- options [ format ] = args [ format ] == 'false' || args [ format ] . empty? ? false : true
33
- if options [ format ]
34
- options [ :path ] = args [ format ] == 'true' ? nil : args [ format ]
35
- end
36
- end
31
+ return unless args . has_key? format
32
+ options [ format ] = args [ format ] == 'false' || args [ format ] . empty? ? false : true
33
+ return unless options [ format ]
34
+ options [ :path ] = args [ format ] == 'true' ? nil : args [ format ]
37
35
end
38
36
# rubocop:enable Style/PreferredHashMethods
39
37
40
- %i[ json markdown ] . each { |format | parse_format_option ( args , options , format ) }
38
+ [ : json, : markdown] . each { |format | parse_format_option ( args , options , format ) }
41
39
42
40
warn ( 'yard_args behavior is a little dodgy, use at your own risk' ) if args [ :yard_args ]
43
41
options [ :yard_args ] = args [ :yard_args ] . split if args . key? :yard_args
@@ -47,7 +45,7 @@ def parse_format_option(args, options, format)
47
45
48
46
namespace :generate do
49
47
desc 'Generate Puppet Reference documentation.'
50
- task :reference , [ :patterns , :debug , :backtrace ] do |t , args |
48
+ task :reference , [ :patterns , :debug , :backtrace ] do |_t , args |
51
49
Rake ::Task [ 'strings:generate' ] . invoke ( args [ :patterns ] , args [ :debug ] , args [ :backtrace ] , nil , 'false' , 'true' )
52
50
end
53
51
end
0 commit comments