puppet-strings 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/CODEOWNERS +1 -0
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/task.rb +1 -1
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +12 -2
- data/spec/spec_helper_acceptance.rb +1 -1
- data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +77 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e021936451f50bd6d90032ebb46117245b1be028c0e717a02bb54ceb682194
|
4
|
+
data.tar.gz: 2ae779863af3e9882d2d5c6a0609cfb4fd994a2683429a9f62a271762e58828d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4795376753de54d5157d4b040781e9b2c322a777efa62b0400968ec895cb6a5aba32c20d19c374f9a5ab4c06b6fdcf6256f9c722684b356f1b64907194487f22
|
7
|
+
data.tar.gz: 564f9d8ec0b7db59f46c882358c3126ad7d98f9629c4760f96b496f94563af69f69dcc0560fcb6465c88c0104aca6dd8d1df2342740b626a3c3e9fc80f3b90a3
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
All significant changes to this repo will be summarized in this file.
|
4
4
|
|
5
5
|
|
6
|
+
## [v2.3.1](https://github.com/puppetlabs/puppet-strings/tree/v2.3.1) (2019-09-23)
|
7
|
+
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v2.3.0...v2.3.1)
|
9
|
+
|
10
|
+
Fixed
|
11
|
+
|
12
|
+
- \(maint\) Use parameters method instead of json\['parameters'\] [\#211](https://github.com/puppetlabs/puppet-strings/pull/211) ([lucywyman](https://github.com/lucywyman))
|
13
|
+
- \(PDOC-285\) Fix data\_type\_handler for errors and numbers [\#209](https://github.com/puppetlabs/puppet-strings/pull/209) ([glennsarti](https://github.com/glennsarti))
|
14
|
+
|
6
15
|
## [v2.3.0](https://github.com/puppetlabs/puppet-strings/tree/v2.3.0) (2019-07-17)
|
7
16
|
|
8
17
|
[Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v2.2.0...v2.3.0)
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @puppet-strings-maintainers
|
@@ -43,7 +43,7 @@ class PuppetStrings::Yard::CodeObjects::Task < PuppetStrings::Yard::CodeObjects:
|
|
43
43
|
|
44
44
|
def parameters
|
45
45
|
parameters = []
|
46
|
-
statement.
|
46
|
+
statement.parameters.each do |name,props|
|
47
47
|
parameters.push({ name: name.to_s,
|
48
48
|
tag_name: 'param',
|
49
49
|
text: props['description'] || "",
|
@@ -14,7 +14,7 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
14
14
|
return unless ruby_module_name == 'Puppet::DataTypes' || ruby_module_name == 'DataTypes' # rubocop:disable Style/MultipleComparison This reads better
|
15
15
|
object = get_datatype_yard_object(get_name(statement, 'Puppet::DataTypes.create_type'))
|
16
16
|
|
17
|
-
actual_params = extract_params_for_data_type
|
17
|
+
actual_params = extract_params_for_data_type
|
18
18
|
|
19
19
|
# Mark the data type as public if it doesn't already have an api tag
|
20
20
|
object.add_tag YARD::Tags::Tag.new(:api, 'public') unless object.has_tag? :api
|
@@ -65,7 +65,13 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
65
65
|
interface_string = node_as_string(parameters[0])
|
66
66
|
next unless interface_string
|
67
67
|
# Ref - https://github.com/puppetlabs/puppet/blob/ba4d1a1aba0095d3c70b98fea5c67434a4876a61/lib/puppet/datatypes.rb#L159
|
68
|
-
parsed_interface =
|
68
|
+
parsed_interface = nil
|
69
|
+
begin
|
70
|
+
parsed_interface = Puppet::Pops::Parser::EvaluatingParser.new.parse_string("{ #{interface_string} }").body
|
71
|
+
rescue Puppet::Error => e
|
72
|
+
log.warn "Invalid datatype definition at #{statement.file}:#{statement.line}: #{e.basic_message}"
|
73
|
+
next
|
74
|
+
end
|
69
75
|
next unless parsed_interface
|
70
76
|
|
71
77
|
# Now that we parsed the Puppet code (as a string) into a LiteralHash PCore type (Puppet AST),
|
@@ -146,6 +152,10 @@ class PuppetStrings::Yard::Handlers::Ruby::DataTypeHandler < PuppetStrings::Yard
|
|
146
152
|
o.value
|
147
153
|
end
|
148
154
|
|
155
|
+
def literal_UnaryMinusExpression(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
156
|
+
-1 * literal(o.expr)
|
157
|
+
end
|
158
|
+
|
149
159
|
def literal_LiteralBoolean(o) # rubocop:disable Naming/UncommunicativeMethodParamName
|
150
160
|
o.value
|
151
161
|
end
|
@@ -25,7 +25,7 @@ else
|
|
25
25
|
options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
|
26
26
|
options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
|
27
27
|
options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
|
28
|
-
options[:verify_host_key] = Net::SSH::Verifiers::
|
28
|
+
options[:verify_host_key] = Net::SSH::Verifiers::Never.new unless node_config.dig('ssh', 'host-key-check').nil?
|
29
29
|
host = if ENV['TARGET_HOST'].include?(':')
|
30
30
|
ENV['TARGET_HOST'].split(':').first
|
31
31
|
else
|
@@ -189,6 +189,83 @@ SOURCE
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
testcases = [
|
193
|
+
{ :value => '-1', :expected => -1 },
|
194
|
+
{ :value => '0', :expected => 0 },
|
195
|
+
{ :value => '10', :expected => 10 },
|
196
|
+
{ :value => '0777', :expected => 511 },
|
197
|
+
{ :value => '0xFF', :expected => 255 },
|
198
|
+
{ :value => '0.1', :expected => 0.1 },
|
199
|
+
{ :value => '31.415e-1', :expected => 3.1415 },
|
200
|
+
{ :value => '0.31415e1', :expected => 3.1415 }
|
201
|
+
].each do |testcase|
|
202
|
+
describe "parsing a valid data type definition with numeric default #{testcase[:value]}" do
|
203
|
+
let(:source) { <<-SOURCE
|
204
|
+
# An example Puppet Data Type in Ruby.
|
205
|
+
# @param num1 A numeric parameter
|
206
|
+
Puppet::DataTypes.create_type('RubyDataType') do
|
207
|
+
interface <<-PUPPET
|
208
|
+
attributes => {
|
209
|
+
num1 => { type => Numeric, value => #{testcase[:value]} },
|
210
|
+
}
|
211
|
+
PUPPET
|
212
|
+
end
|
213
|
+
SOURCE
|
214
|
+
}
|
215
|
+
|
216
|
+
it 'should register a data type object' do
|
217
|
+
expect(subject.size).to eq(1)
|
218
|
+
object = subject.first
|
219
|
+
expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
|
220
|
+
expect(object.parameters.size).to eq(1)
|
221
|
+
expect(object.parameters[0]).to eq(['num1', testcase[:expected]])
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe 'parsing a invalid data type definition' do
|
227
|
+
let(:source) { <<-SOURCE
|
228
|
+
# The msg attribute is missing a comma.
|
229
|
+
#
|
230
|
+
# @param msg A message parameter5.
|
231
|
+
# @param arg1 Optional String parameter5. Defaults to 'param'.
|
232
|
+
Puppet::DataTypes.create_type('RubyDataType') do
|
233
|
+
interface <<-PUPPET
|
234
|
+
attributes => {
|
235
|
+
msg => Variant[Numeric, String[1,2]]
|
236
|
+
arg1 => { type => Optional[String[1]], value => "param" }
|
237
|
+
}
|
238
|
+
PUPPET
|
239
|
+
end
|
240
|
+
SOURCE
|
241
|
+
}
|
242
|
+
|
243
|
+
it 'should register a partial data type object' do
|
244
|
+
expect(subject.size).to eq(1)
|
245
|
+
object = subject.first
|
246
|
+
expect(object).to be_a(PuppetStrings::Yard::CodeObjects::DataType)
|
247
|
+
expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::DataTypes.instance)
|
248
|
+
expect(object.name).to eq(:RubyDataType)
|
249
|
+
expect(object.docstring).to eq('The msg attribute is missing a comma.')
|
250
|
+
# The attributes will be missing therefore only one tag
|
251
|
+
expect(object.docstring.tags.size).to eq(1)
|
252
|
+
tags = object.docstring.tags(:api)
|
253
|
+
expect(tags.size).to eq(1)
|
254
|
+
expect(tags[0].text).to eq('public')
|
255
|
+
|
256
|
+
# Check that the param tags are removed
|
257
|
+
tags = object.docstring.tags(:param)
|
258
|
+
expect(tags.size).to eq(0)
|
259
|
+
|
260
|
+
# Check for default values
|
261
|
+
expect(object.parameters.size).to eq(0)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should log a warning' do
|
265
|
+
expect{ subject }.to output(/\[warn\]: Invalid datatype definition at (.+):[0-9]+: Syntax error at 'arg1'/).to_stdout_from_any_process
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
192
269
|
describe 'parsing a data type with a summary' do
|
193
270
|
context 'when the summary has fewer than 140 characters' do
|
194
271
|
let(:source) { <<-SOURCE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-strings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -50,6 +50,7 @@ extra_rdoc_files:
|
|
50
50
|
- README.md
|
51
51
|
files:
|
52
52
|
- CHANGELOG.md
|
53
|
+
- CODEOWNERS
|
53
54
|
- COMMITTERS.md
|
54
55
|
- CONTRIBUTING.md
|
55
56
|
- Gemfile
|
@@ -281,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
282
|
version: '0'
|
282
283
|
requirements:
|
283
284
|
- puppet, >= 4.0.0
|
284
|
-
rubygems_version: 3.0.
|
285
|
+
rubygems_version: 3.0.3
|
285
286
|
signing_key:
|
286
287
|
specification_version: 4
|
287
288
|
summary: Puppet documentation via YARD
|