Skip to content

Commit a9ace87

Browse files
committed
rubocop and old ruby
1 parent 67fb84a commit a9ace87

15 files changed

Lines changed: 53 additions & 59 deletions

lib/puppet-strings.rb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
2929
args << '--backtrace' if options[:backtrace]
3030
args << "-m#{options[:markup] || 'markdown'}"
3131

32-
if options[:json]
33-
json_file = options[:path]
32+
if options[:json] || options[:markdown]
33+
file = options[:path]
3434
# Disable output and prevent stats/progress when writing to STDOUT
3535
args << '-n'
36-
args << '-q' unless json_file
37-
args << '--no-stats' unless json_file
38-
args << '--no-progress' unless json_file
36+
args << '-q' unless file
37+
args << '--no-stats' unless file
38+
args << '--no-progress' unless file
3939
end
4040

4141
yard_args = options[:yard_args]
@@ -47,20 +47,25 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
4747

4848
# If outputting JSON, render the output
4949
if options[:json]
50-
require 'puppet-strings/json'
51-
PuppetStrings::Json.render(options[:path])
50+
render_json(options[:path])
5251
end
5352

53+
# If outputting Markdown, render the output
5454
if options[:markdown]
55-
require 'puppet-strings/markdown'
56-
if options[:stdout]
57-
PuppetStrings::Markdown.generate('stdout')
58-
else
59-
PuppetStrings::Markdown.generate(options[:path])
60-
end
55+
render_markdown(options[:path])
6156
end
6257
end
6358

59+
def self.render_json(path)
60+
require 'puppet-strings/json'
61+
PuppetStrings::Json.render(path)
62+
end
63+
64+
def self.render_markdown(path)
65+
require 'puppet-strings/markdown'
66+
PuppetStrings::Markdown.render(path)
67+
end
68+
6469
# Runs the YARD documentation server.
6570
# @param [Array<String>] args The arguments to YARD.
6671
def self.run_server(*args)

lib/puppet-strings/markdown.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def self.generate
2121
final
2222
end
2323

24-
def self.render(path)
25-
if path == 'stdout'
24+
def self.render(path = nil)
25+
if path.nil?
2626
puts generate
2727
exit
2828
else

lib/puppet-strings/markdown/puppet_class.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
module PuppetStrings::Markdown
44
class PuppetClass < Base
5-
def initialize(registry:,
6-
template: 'puppet_resource.erb')
7-
@template = template
5+
def initialize(registry)
6+
@template = 'puppet_resource.erb'
87
super(registry, 'class')
98
end
109

lib/puppet-strings/markdown/puppet_classes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.in_classes
99
def self.render
1010
final = "## Classes\n\n"
1111
in_classes.each do |klass|
12-
final << PuppetStrings::Markdown::PuppetClass.new(registry: klass).render
12+
final << PuppetStrings::Markdown::PuppetClass.new(klass).render
1313
end
1414
final
1515
end
@@ -18,7 +18,7 @@ def self.toc_info
1818
final = []
1919

2020
in_classes.each do |klass|
21-
final.push(PuppetStrings::Markdown::PuppetClass.new(registry: klass).toc_info)
21+
final.push(PuppetStrings::Markdown::PuppetClass.new(klass).toc_info)
2222
end
2323

2424
final

lib/puppet-strings/markdown/puppet_defined_type.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
module PuppetStrings::Markdown
44
class PuppetDefinedType < Base
5-
def initialize(registry:,
6-
template: 'puppet_resource.erb')
7-
@template = template
5+
def initialize(registry)
6+
@template = 'puppet_resource.erb'
87
super(registry, 'defined type')
98
end
109

lib/puppet-strings/markdown/puppet_defined_types.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.in_dtypes
99
def self.render
1010
final = "## Defined types\n\n"
1111
in_dtypes.each do |type|
12-
final << PuppetStrings::Markdown::PuppetDefinedType.new(registry: type).render
12+
final << PuppetStrings::Markdown::PuppetDefinedType.new(type).render
1313
end
1414
final
1515
end
@@ -18,7 +18,7 @@ def self.toc_info
1818
final = []
1919

2020
in_dtypes.each do |type|
21-
final.push(PuppetStrings::Markdown::PuppetDefinedType.new(registry: type).toc_info)
21+
final.push(PuppetStrings::Markdown::PuppetDefinedType.new(type).toc_info)
2222
end
2323

2424
final

lib/puppet-strings/markdown/puppet_function.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ module PuppetStrings::Markdown
44
class PuppetFunction < Base
55
attr_reader :signatures
66

7-
def initialize(registry:,
8-
template: 'puppet_function.erb')
9-
@template = template
7+
def initialize(registry)
8+
@template = 'puppet_function.erb'
109
super(registry, 'function')
1110
@signatures = []
1211
registry[:signatures].each do |sig|
13-
@signatures.push(Signature.new(registry: sig))
12+
@signatures.push(Signature.new(sig))
1413
end
1514
end
1615

@@ -20,8 +19,9 @@ def render
2019
end
2120

2221
class PuppetFunction::Signature < Base
23-
def initialize(registry:)
24-
super(registry, 'function signature')
22+
def initialize(registry)
23+
@registry = registry
24+
super(@registry, 'function signature')
2525
end
2626

2727
def signature

lib/puppet-strings/markdown/puppet_functions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.in_functions
99
def self.render
1010
final = "## Functions\n\n"
1111
in_functions.each do |func|
12-
final << PuppetStrings::Markdown::PuppetFunction.new(registry: func).render
12+
final << PuppetStrings::Markdown::PuppetFunction.new(func).render
1313
end
1414
final
1515
end
@@ -18,7 +18,7 @@ def self.toc_info
1818
final = []
1919

2020
in_functions.each do |func|
21-
final.push(PuppetStrings::Markdown::PuppetFunction.new(registry: func).toc_info)
21+
final.push(PuppetStrings::Markdown::PuppetFunction.new(func).toc_info)
2222
end
2323

2424
final

lib/puppet-strings/markdown/puppet_resource_type.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
module PuppetStrings::Markdown
44
class PuppetResourceType < Base
5-
def initialize(registry:,
6-
template: 'puppet_resource_type.erb')
7-
@template = template
5+
def initialize(registry)
6+
@template = 'puppet_resource_type.erb'
87
super(registry, 'resource type')
98
end
109

lib/puppet-strings/markdown/puppet_resource_types.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.in_rtypes
99
def self.render
1010
final = "## Resource types\n\n"
1111
in_rtypes.each do |type|
12-
final << PuppetStrings::Markdown::PuppetResourceType.new(registry: type).render
12+
final << PuppetStrings::Markdown::PuppetResourceType.new(type).render
1313
end
1414
final
1515
end
@@ -18,7 +18,7 @@ def self.toc_info
1818
final = []
1919

2020
in_rtypes.each do |type|
21-
final.push(PuppetStrings::Markdown::PuppetResourceType.new(registry: type).toc_info)
21+
final.push(PuppetStrings::Markdown::PuppetResourceType.new(type).toc_info)
2222
end
2323

2424
final

0 commit comments

Comments
 (0)