Skip to content

Commit 9e4f908

Browse files
authored
Merge pull request #3 from voxpupuli/ruby27
Add Ruby 2.7/3.0 support
2 parents f88755e + fb3e086 commit 9e4f908

File tree

9 files changed

+30
-40
lines changed

9 files changed

+30
-40
lines changed

.rubocop_todo.yml

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ RSpec/ExpectInHook:
9494
Exclude:
9595
- 'spec/unit/openvox-strings/json_spec.rb'
9696

97-
# Offense count: 5
98-
# This cop supports safe autocorrection (--autocorrect).
99-
RSpec/IncludeExamples:
100-
Exclude:
101-
- 'spec/unit/openvox-strings/json_spec.rb'
102-
- 'spec/unit/openvox-strings/markdown_spec.rb'
103-
10497
# Offense count: 91
10598
RSpec/MultipleExpectations:
10699
Max: 64
@@ -127,17 +120,6 @@ Rake/Desc:
127120
Exclude:
128121
- 'Rakefile'
129122

130-
# Offense count: 1
131-
# This cop supports safe autocorrection (--autocorrect).
132-
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
133-
# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
134-
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
135-
# FunctionalMethods: let, let!, subject, watch
136-
# AllowedMethods: lambda, proc, it
137-
Style/BlockDelimiters:
138-
Exclude:
139-
- 'lib/openvox-strings/markdown/base.rb'
140-
141123
# Offense count: 1
142124
Style/ClassVars:
143125
Exclude:
@@ -150,6 +132,15 @@ Style/CombinableLoops:
150132
- 'lib/openvox-strings/markdown.rb'
151133
- 'lib/openvox-strings/yard/handlers/ruby/data_type_handler.rb'
152134

135+
# Offense count: 2
136+
# This cop supports unsafe autocorrection (--autocorrect-all).
137+
# Configuration parameters: EnforcedStyle.
138+
# SupportedStyles: literals, strict
139+
Style/MutableConstant:
140+
Exclude:
141+
- 'lib/openvox-strings/yard/handlers/ruby/base.rb'
142+
- 'lib/openvox-strings/yard/parsers/puppet/statement.rb'
143+
153144
# Offense count: 20
154145
# Configuration parameters: AllowedMethods.
155146
# AllowedMethods: respond_to_missing?
@@ -169,11 +160,10 @@ Style/OptionalBooleanParameter:
169160
- 'lib/openvox-strings/yard/handlers/ruby/data_type_handler.rb'
170161
- 'lib/openvox-strings/yard/handlers/ruby/function_handler.rb'
171162

172-
# Offense count: 3
163+
# Offense count: 2
173164
# This cop supports safe autocorrection (--autocorrect).
174165
Style/RedundantParentheses:
175166
Exclude:
176-
- 'lib/openvox-strings/yard/code_objects/function.rb'
177167
- 'lib/openvox-strings/yard/handlers/puppet/function_handler.rb'
178168
- 'lib/openvox-strings/yard/tags/overload_tag.rb'
179169

@@ -209,13 +199,12 @@ Style/StringLiterals:
209199
- 'Gemfile'
210200
- 'Rakefile'
211201

212-
# Offense count: 7
202+
# Offense count: 6
213203
# This cop supports safe autocorrection (--autocorrect).
214204
# Configuration parameters: EnforcedStyle, AllowSafeAssignment.
215205
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex
216206
Style/TernaryParentheses:
217207
Exclude:
218-
- 'lib/openvox-strings/markdown/base.rb'
219208
- 'lib/openvox-strings/tasks/generate.rb'
220209
- 'lib/openvox-strings/yard/templates/default/layout/html/setup.rb'
221210
- 'lib/openvox-strings/yard/templates/default/tags/setup.rb'
@@ -250,15 +239,14 @@ Style/TrailingCommaInArrayLiteral:
250239
- 'spec/unit/openvox-strings/yard/handlers/ruby/data_type_handler_spec.rb'
251240
- 'spec/unit/openvox-strings/yard/parsers/puppet/parser_spec.rb'
252241

253-
# Offense count: 32
242+
# Offense count: 30
254243
# This cop supports safe autocorrection (--autocorrect).
255244
# Configuration parameters: EnforcedStyleForMultiline.
256245
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
257246
Style/TrailingCommaInHashLiteral:
258247
Exclude:
259248
- 'lib/openvox-strings/describe.rb'
260249
- 'lib/openvox-strings/json.rb'
261-
- 'lib/openvox-strings/markdown/base.rb'
262250
- 'lib/openvox-strings/tasks/generate.rb'
263251
- 'lib/openvox-strings/tasks/validate.rb'
264252
- 'lib/openvox-strings/yard/code_objects/data_type.rb'

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ group :development do
3232
end
3333

3434
group :rubocop do
35-
gem 'voxpupuli-rubocop', '~> 4.1.0'
35+
gem 'voxpupuli-rubocop', '~> 3.1.0'
3636
end
3737

3838
# https://github.com/OpenVoxProject/puppet/issues/90

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ Strings processes code and YARD-style code comments to create documentation in H
1010

1111
### Requirements
1212

13-
* Ruby 3.1.0 or newer
14-
* Puppet 8.0.0 or newer
13+
* Ruby 2.7 or newer
14+
* OpenVox 7 or newer
15+
16+
For detailed dependencies, please checkout the gemspec file.
1517

1618
### Install Puppet Strings
1719

lib/openvox-strings/markdown/base.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def initialize(registry, component_type)
9595
summary: 'summary',
9696
note: 'note',
9797
todo: 'todo',
98-
deprecated: 'deprecated' }.each do |method_name, tag_name|
98+
deprecated: 'deprecated', }.each do |method_name, tag_name|
9999
# @return [String] unless the tag is nil or the string.empty?
100100
define_method method_name do
101101
@tags.find { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }[:text] if @tags.any? { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }
@@ -181,9 +181,9 @@ def defaults
181181
def toc_info
182182
{
183183
name: name.to_s,
184-
link:,
184+
link: link,
185185
desc: summary || @registry[:docstring][:text][0..140].tr("\n", ' '),
186-
private: private?
186+
private: private?,
187187
}
188188
end
189189

@@ -199,9 +199,9 @@ def private?
199199
def word_wrap(text, line_width: 120, break_sequence: "\n")
200200
return unless text
201201

202-
text.split("\n").map! { |line|
203-
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
204-
} * break_sequence
202+
text.split("\n").map! do |line|
203+
(line.length > line_width) ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
204+
end * break_sequence
205205
end
206206

207207
# @return [String] full markdown rendering of a component

lib/openvox-strings/yard/code_objects/function.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def signature
6969
name, default = parameter
7070
tag = tags.find { |t| t.name == name } if tags
7171
type = tag&.types ? "#{tag.type} " : 'Any '
72-
prefix = (name[0]).to_s if name.start_with?('*', '&')
72+
prefix = name[0].to_s if name.start_with?('*', '&')
7373
name = name[1..] if prefix
7474
default = " = #{default}" if default
7575
"#{type}#{prefix}$#{name}#{default}"
@@ -94,7 +94,7 @@ def to_hash
9494
hash[:signatures] << { signature: o.signature, docstring: OpenvoxStrings::Yard::Util.docstring_to_hash(o.docstring, %i[param option enum return example]) }
9595
end
9696
else
97-
hash[:signatures] << { signature:, docstring: OpenvoxStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) }
97+
hash[:signatures] << { signature: signature, docstring: OpenvoxStrings::Yard::Util.docstring_to_hash(docstring, %i[param option enum return example]) }
9898
end
9999

100100
hash[:docstring] = OpenvoxStrings::Yard::Util.docstring_to_hash(docstring)

lib/openvox-strings/yard/handlers/ruby/data_type_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def extract_params(hash)
237237
default = value['value'] unless value['value'].nil?
238238
end
239239
data_type = [data_type] unless data_type.nil? || data_type.is_a?(Array)
240-
params_hash[key] = { types: data_type, default: }
240+
params_hash[key] = { types: data_type, default: default }
241241
end
242242

243243
params_hash

lib/openvox-strings/yard/parsers/puppet/statement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def initialize(object, file)
170170
case type_expr
171171
when Puppet::Pops::Model::AccessExpression
172172
# TODO: I don't like rebuilding the source from the AST, but AccessExpressions don't expose the original source
173-
@alias_of = "#{OpenvoxStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
173+
@alias_of = +"#{OpenvoxStrings::Yard::Util.ast_to_text(type_expr.left_expr)}[" # alias_of should be mutable so we add a + to the string.
174174
@alias_of << type_expr.keys.map { |key| OpenvoxStrings::Yard::Util.ast_to_text(key) }.join(', ')
175175
@alias_of << ']'
176176
else

openvox-strings.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
1212
s.summary = 'Puppet documentation via YARD'
1313
s.email = '[email protected]'
1414
s.homepage = 'https://github.com/voxpupuli/openvox-strings'
15-
s.required_ruby_version = '>= 3.1.0'
15+
s.required_ruby_version = '>= 2.7.0'
1616

1717
s.extra_rdoc_files = [
1818
'CHANGELOG.md',
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
]
2323
s.files = Dir['CHANGELOG.md', 'README.md', 'LICENSE', 'lib/**/*', 'exe/**/*']
2424

25-
s.add_dependency 'openvox', '~> 8.19'
25+
s.add_dependency 'openvox', '>= 7', '< 9'
2626
s.add_dependency 'rgen', '~> 0.9'
2727
s.add_dependency 'yard', '~> 0.9'
2828
end

spec/unit/openvox-strings/json_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
310310
#
311311
# @param [Proc] block The block to capture output from
312312
# @return [Hash] A hash containing the captured output
313-
def capture_output(&)
313+
def capture_output(&_block)
314314
begin
315315
$stdout = StringIO.new
316316
$stderr = StringIO.new

0 commit comments

Comments
 (0)