puppet-strings 2.1.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -4
  3. data/CONTRIBUTING.md +32 -2
  4. data/README.md +81 -17
  5. data/lib/puppet-strings.rb +13 -4
  6. data/lib/puppet-strings/describe.rb +68 -0
  7. data/lib/puppet-strings/json.rb +2 -38
  8. data/lib/puppet-strings/markdown.rb +3 -1
  9. data/lib/puppet-strings/markdown/base.rb +37 -16
  10. data/lib/puppet-strings/markdown/data_type.rb +34 -0
  11. data/lib/puppet-strings/markdown/data_types.rb +41 -0
  12. data/lib/puppet-strings/markdown/function.rb +2 -2
  13. data/lib/puppet-strings/markdown/resource_type.rb +19 -2
  14. data/lib/puppet-strings/markdown/table_of_contents.rb +1 -0
  15. data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +12 -4
  16. data/lib/puppet-strings/markdown/templates/data_type.erb +93 -0
  17. data/lib/puppet-strings/markdown/templates/data_type_function.erb +67 -0
  18. data/lib/puppet-strings/markdown/templates/function.erb +36 -1
  19. data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
  20. data/lib/puppet-strings/markdown/templates/resource_type.erb +32 -12
  21. data/lib/puppet-strings/markdown/templates/table_of_contents.erb +6 -6
  22. data/lib/puppet-strings/tasks/generate.rb +10 -3
  23. data/lib/puppet-strings/version.rb +1 -1
  24. data/lib/puppet-strings/yard.rb +16 -0
  25. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  26. data/lib/puppet-strings/yard/code_objects/class.rb +2 -2
  27. data/lib/puppet-strings/yard/code_objects/data_type.rb +100 -0
  28. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +58 -0
  29. data/lib/puppet-strings/yard/code_objects/defined_type.rb +2 -2
  30. data/lib/puppet-strings/yard/code_objects/function.rb +4 -4
  31. data/lib/puppet-strings/yard/code_objects/plan.rb +2 -2
  32. data/lib/puppet-strings/yard/code_objects/provider.rb +1 -1
  33. data/lib/puppet-strings/yard/code_objects/task.rb +1 -1
  34. data/lib/puppet-strings/yard/code_objects/type.rb +48 -6
  35. data/lib/puppet-strings/yard/handlers.rb +3 -0
  36. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +24 -0
  37. data/lib/puppet-strings/yard/handlers/ruby/base.rb +12 -1
  38. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +393 -0
  39. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +2 -12
  40. data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +1 -9
  41. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +3 -3
  42. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +135 -0
  43. data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +56 -0
  44. data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +9 -115
  45. data/lib/puppet-strings/yard/parsers/json/parser.rb +4 -2
  46. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +14 -7
  47. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +25 -0
  48. data/lib/puppet-strings/yard/tags.rb +2 -0
  49. data/lib/puppet-strings/yard/tags/enum_tag.rb +12 -0
  50. data/lib/puppet-strings/yard/tags/factory.rb +16 -0
  51. data/lib/puppet-strings/yard/tags/overload_tag.rb +2 -2
  52. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_data_type.erb +10 -0
  53. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +9 -0
  54. data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +2 -0
  55. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +18 -1
  56. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/box_info.erb +10 -0
  57. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/header.erb +1 -0
  58. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/method_details_list.erb +6 -0
  59. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/note.erb +6 -0
  60. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/overview.erb +6 -0
  61. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +13 -0
  62. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/source.erb +12 -0
  63. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/summary.erb +4 -0
  64. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/todo.erb +6 -0
  65. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/alias_of.erb +10 -0
  66. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/box_info.erb +10 -0
  67. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/header.erb +1 -0
  68. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/note.erb +6 -0
  69. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/overview.erb +6 -0
  70. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +17 -0
  71. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/source.erb +12 -0
  72. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/summary.erb +4 -0
  73. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/todo.erb +6 -0
  74. data/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +3 -1
  75. data/lib/puppet-strings/yard/templates/default/tags/html/enum.erb +17 -0
  76. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +7 -0
  77. data/lib/puppet-strings/yard/util.rb +48 -0
  78. data/lib/puppet/face/strings.rb +68 -3
  79. metadata +36 -45
  80. data/Gemfile +0 -37
  81. data/HISTORY.md +0 -218
  82. data/JSON.md +0 -802
  83. data/Rakefile +0 -93
  84. data/codecov.yml +0 -3
  85. data/misc/ANNOUNCEMENT_TEMPLATE.md +0 -40
  86. data/spec/acceptance/emit_json_options.rb +0 -71
  87. data/spec/acceptance/generate_markdown_spec.rb +0 -49
  88. data/spec/acceptance/lib/util.rb +0 -163
  89. data/spec/acceptance/running_strings_generate.rb +0 -54
  90. data/spec/fixtures/acceptance/modules/test/functions/add.pp +0 -9
  91. data/spec/fixtures/acceptance/modules/test/lib/puppet/functions/4x_function.rb +0 -5
  92. data/spec/fixtures/acceptance/modules/test/lib/puppet/parser/functions/function3x.rb +0 -2
  93. data/spec/fixtures/acceptance/modules/test/lib/puppet/provider/server/linux.rb +0 -9
  94. data/spec/fixtures/acceptance/modules/test/lib/puppet/type/database.rb +0 -15
  95. data/spec/fixtures/acceptance/modules/test/manifests/init.pp +0 -27
  96. data/spec/fixtures/acceptance/modules/test/manifests/triple_nested_classes.pp +0 -27
  97. data/spec/fixtures/acceptance/modules/test/metadata.json +0 -6
  98. data/spec/fixtures/unit/json/output.json +0 -660
  99. data/spec/fixtures/unit/json/output_with_plan.json +0 -697
  100. data/spec/fixtures/unit/json/output_without_puppet_function.json +0 -480
  101. data/spec/fixtures/unit/markdown/output.md +0 -444
  102. data/spec/fixtures/unit/markdown/output_with_plan.md +0 -478
  103. data/spec/spec_helper.rb +0 -45
  104. data/spec/spec_helper_acceptance.rb +0 -28
  105. data/spec/unit/puppet-strings/json_spec.rb +0 -229
  106. data/spec/unit/puppet-strings/markdown/base_spec.rb +0 -146
  107. data/spec/unit/puppet-strings/markdown_spec.rb +0 -283
  108. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +0 -92
  109. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +0 -124
  110. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +0 -217
  111. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +0 -231
  112. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +0 -315
  113. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +0 -729
  114. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +0 -139
  115. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +0 -214
  116. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +0 -269
  117. data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +0 -70
  118. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +0 -56
  119. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +0 -209
  120. data/spec/unit/puppet-strings/yard/util_spec.rb +0 -48
@@ -1,283 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet-strings/markdown'
3
- require 'puppet-strings/markdown/table_of_contents'
4
- require 'tempfile'
5
-
6
- describe PuppetStrings::Markdown do
7
- before :each do
8
- # Populate the YARD registry with both Puppet and Ruby source
9
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
10
- # An overview for a simple class.
11
- # @summary A simple class.
12
- # @todo Do a thing
13
- # @note some note
14
- # @since 1.0.0
15
- # @see www.puppet.com
16
- # @example This is an example
17
- # class { 'klass':
18
- # param1 => 1,
19
- # param3 => 'foo',
20
- # }
21
- # @example This is another example
22
- # class { 'klass':
23
- # param1 => 1,
24
- # param3 => 'foo',
25
- # }
26
- # @raise SomeError
27
- # @param param1 First param.
28
- # @param param2 Second param.
29
- # @option param2 [String] :opt1 something about opt1
30
- # @option param2 [Hash] :opt2 a hash of stuff
31
- # @param param3 Third param.
32
- #
33
- class klass (
34
- Integer $param1 = 1,
35
- $param2 = undef,
36
- String $param3 = 'hi'
37
- ) inherits foo::bar {
38
- }
39
-
40
- # Overview for class noparams
41
- # @api private
42
- class noparams () {}
43
-
44
- # An overview for a simple defined type.
45
- # @summary A simple defined type.
46
- # @since 1.1.0
47
- # @see www.puppet.com
48
- # @example Here's an example of this type:
49
- # klass::dt { 'foo':
50
- # param1 => 33,
51
- # param4 => false,
52
- # }
53
- # @return shouldn't return squat
54
- # @raise SomeError
55
- # @param param1 First param.
56
- # @param param2 Second param.
57
- # @option param2 [String] :opt1 something about opt1
58
- # @option param2 [Hash] :opt2 a hash of stuff
59
- # @param param3 Third param.
60
- # @param param4 Fourth param.
61
- define klass::dt (
62
- Integer $param1 = 44,
63
- $param2,
64
- String $param3 = 'hi',
65
- Boolean $param4 = true
66
- ) {
67
- }
68
- SOURCE
69
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) if TEST_PUPPET_PLANS
70
- # A simple plan.
71
- # @param param1 First param.
72
- # @param param2 Second param.
73
- # @param param3 Third param.
74
- plan plann(String $param1, $param2, Integer $param3 = 1) {
75
- }
76
- SOURCE
77
-
78
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :json)
79
- {
80
- "description": "Allows you to backup your database to local file.",
81
- "input_method": "stdin",
82
- "parameters": {
83
- "database": {
84
- "description": "Database to connect to",
85
- "type": "Optional[String[1]]"
86
- },
87
- "user": {
88
- "description": "The user",
89
- "type": "Optional[String[1]]"
90
- },
91
- "password": {
92
- "description": "The password",
93
- "type": "Optional[String[1]]"
94
- },
95
- "sql": {
96
- "description": "Path to file you want backup to",
97
- "type": "String[1]"
98
- }
99
- }
100
- }
101
- SOURCE
102
-
103
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
104
- # A simple Puppet function.
105
- # @param param1 First param.
106
- # @param param2 Second param.
107
- # @param param3 Third param.
108
- # @option param3 [Array] :param3opt Something about this option
109
- # @raise SomeError this is some error
110
- # @return [Undef] Returns nothing.
111
- function func(Integer $param1, $param2, String $param3 = hi) {
112
- }
113
- SOURCE
114
-
115
- YARD::Parser::SourceParser.parse_string(<<-SOURCE, :ruby)
116
- # An example 4.x function.
117
- Puppet::Functions.create_function(:func4x) do
118
- # An overview for the first overload.
119
- # @raise SomeError this is some error
120
- # @param param1 The first parameter.
121
- # @param param2 The second parameter.
122
- # @option param2 [String] :option an option
123
- # @option param2 [String] :option2 another option
124
- # @param param3 The third parameter.
125
- # @return Returns nothing.
126
- dispatch :foo do
127
- param 'Integer', :param1
128
- param 'Any', :param2
129
- optional_param 'Array[String]', :param3
130
- return_type 'Undef'
131
- end
132
-
133
- # An overview for the second overload.
134
- # @param param The first parameter.
135
- # @param block The block parameter.
136
- # @return Returns a string.
137
- dispatch :other do
138
- param 'Boolean', :param
139
- block_param
140
- return_type 'String'
141
- end
142
- end
143
-
144
- # An example 4.x function with only one signature.
145
- Puppet::Functions.create_function(:func4x_1) do
146
- # @param param1 The first parameter.
147
- # @return [Undef] Returns nothing.
148
- dispatch :foobarbaz do
149
- param 'Integer', :param1
150
- end
151
- end
152
-
153
- # An example 3.x function
154
- Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC
155
- Documentation for an example 3.x function.
156
- @param param1 [String] The first parameter.
157
- @param param2 [Integer] The second parameter.
158
- @return [Undef]
159
- @example Calling the function.
160
- func3x('hi', 10)
161
- DOC
162
- ) do |*args|
163
- #...
164
- end
165
-
166
- Puppet::Type.type(:database).provide :linux do
167
- desc 'An example provider on Linux.'
168
- confine kernel: 'Linux'
169
- confine osfamily: 'RedHat'
170
- defaultfor :kernel => 'Linux'
171
- defaultfor :osfamily => 'RedHat', :operatingsystemmajrelease => '7'
172
- has_feature :implements_some_feature
173
- has_feature :some_other_feature
174
- commands foo: '/usr/bin/foo'
175
- end
176
-
177
- Puppet::Type.newtype(:database) do
178
- desc <<-DESC
179
- An example database server type.
180
- @option opts :foo bar
181
- @raise SomeError
182
- @example here's an example
183
- database { 'foo':
184
- address => 'qux.baz.bar',
185
- }
186
- DESC
187
- feature :encryption, 'The provider supports encryption.', methods: [:encrypt]
188
- ensurable do
189
- desc 'What state the database should be in.'
190
- defaultvalues
191
- aliasvalue(:up, :present)
192
- aliasvalue(:down, :absent)
193
- defaultto :up
194
- end
195
-
196
- newparam(:address) do
197
- isnamevar
198
- desc 'The database server name.'
199
- end
200
-
201
- newparam(:encryption_key, required_features: :encryption) do
202
- desc 'The encryption key to use.'
203
- end
204
-
205
- newparam(:encrypt, :parent => Puppet::Parameter::Boolean) do
206
- desc 'Whether or not to encrypt the database.'
207
- defaultto false
208
- end
209
-
210
- newproperty(:file) do
211
- desc 'The database file to use.'
212
- end
213
-
214
- newproperty(:log_level) do
215
- desc 'The log level to use.'
216
- newvalue(:debug)
217
- newvalue(:warn)
218
- newvalue(:error)
219
- defaultto 'warn'
220
- end
221
- end
222
-
223
- Puppet::ResourceApi.register_type(
224
- name: 'apt_key',
225
- docs: <<-EOS,
226
- @summary Example resource type using the new API.
227
- @raise SomeError
228
- This type provides Puppet with the capabilities to manage GPG keys needed
229
- by apt to perform package validation. Apt has it's own GPG keyring that can
230
- be manipulated through the `apt-key` command.
231
- @example here's an example
232
- apt_key { '6F6B15509CF8E59E6E469F327F438280EF8D349F':
233
- source => 'http://apt.puppetlabs.com/pubkey.gpg'
234
- }
235
-
236
- **Autorequires**:
237
- If Puppet is given the location of a key file which looks like an absolute
238
- path this type will autorequire that file.
239
- EOS
240
- attributes: {
241
- ensure: {
242
- type: 'Enum[present, absent]',
243
- desc: 'Whether this apt key should be present or absent on the target system.'
244
- },
245
- id: {
246
- type: 'Variant[Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/], Pattern[/\A(0x)?[0-9a-fA-F]{16}\Z/], Pattern[/\A(0x)?[0-9a-fA-F]{40}\Z/]]',
247
- behaviour: :namevar,
248
- desc: 'The ID of the key you want to manage.',
249
- },
250
- # ...
251
- created: {
252
- type: 'String',
253
- behaviour: :read_only,
254
- desc: 'Date the key was created, in ISO format.',
255
- },
256
- },
257
- autorequires: {
258
- file: '$source', # will evaluate to the value of the `source` attribute
259
- package: 'apt',
260
- },
261
- )
262
- SOURCE
263
- end
264
-
265
- let(:filename) do
266
- if TEST_PUPPET_PLANS
267
- 'output_with_plan.md'
268
- else
269
- 'output.md'
270
- end
271
- end
272
- let(:baseline_path) { File.join(File.dirname(__FILE__), "../../fixtures/unit/markdown/#{filename}") }
273
- let(:baseline) { File.read(baseline_path) }
274
-
275
- describe 'rendering markdown to a file' do
276
- it 'should output the expected markdown content' do
277
- Tempfile.open('md') do |file|
278
- PuppetStrings::Markdown.render(file.path)
279
- expect(File.read(file.path)).to eq(baseline)
280
- end
281
- end
282
- end
283
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet-strings/yard/code_objects/task'
3
- require 'puppet-strings/yard/parsers/json/task_statement'
4
-
5
- describe PuppetStrings::Yard::CodeObjects::Task do
6
- let(:source) { <<-SOURCE
7
- {
8
- "description": "Allows you to backup your database to local file.",
9
- "input_method": "stdin",
10
- "parameters": {
11
- "database": {
12
- "description": "Database to connect to",
13
- "type": "Optional[String[1]]"
14
- },
15
- "user": {
16
- "description": "The user",
17
- "type": "Optional[String[1]]"
18
- },
19
- "password": {
20
- "description": "The password",
21
- "type": "Optional[String[1]]"
22
- },
23
- "sql": {
24
- "description": "Path to file you want backup to",
25
- "type": "String[1]"
26
- }
27
- }
28
- }
29
- SOURCE
30
- }
31
- let(:json) { JSON.parse(source) }
32
- let(:statement) { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") }
33
- subject { PuppetStrings::Yard::CodeObjects::Task.new(statement) }
34
-
35
- describe '#type' do
36
- it 'returns the correct type' do
37
- expect(subject.type).to eq(:puppet_task)
38
- end
39
- end
40
-
41
- describe '#source' do
42
- it 'returns the source' do
43
- expect(subject.source).to eq(source)
44
- end
45
- end
46
-
47
- describe '#to_hash' do
48
- let(:expected) do
49
- {
50
- :name => "test",
51
- :supports_noop => false,
52
- :docstring => {
53
- :text=>"Allows you to backup your database to local file.",
54
- :tags=> [
55
- {
56
- :name=>"database",
57
- :tag_name=>"param",
58
- :text=>"Database to connect to",
59
- :types=> ["Optional[String[1]]"]
60
- },
61
- {
62
- :name=>"user",
63
- :tag_name=>"param",
64
- :text=>"The user",
65
- :types=> ["Optional[String[1]]"]
66
- },
67
- {
68
- :name=>"password",
69
- :tag_name=>"param",
70
- :text=>"The password",
71
- :types=> ["Optional[String[1]]"]
72
- },
73
- {
74
- :name=>"sql",
75
- :tag_name=>"param",
76
- :text=>"Path to file you want backup to",
77
- :types=>["String[1]"]
78
- }
79
- ]
80
- },
81
- :file => "test.json",
82
- :input_method => "stdin",
83
- :line => 0,
84
- :source => "{\n \"description\": \"Allows you to backup your database to local file.\",\n \"input_method\": \"stdin\",\n \"parameters\": {\n \"database\": {\n \"description\": \"Database to connect to\",\n \"type\": \"Optional[String[1]]\"\n },\n \"user\": {\n \"description\": \"The user\",\n \"type\": \"Optional[String[1]]\"\n },\n \"password\": {\n \"description\": \"The password\",\n \"type\": \"Optional[String[1]]\"\n },\n \"sql\": {\n \"description\": \"Path to file you want backup to\",\n \"type\": \"String[1]\"\n }\n }\n}\n"
85
- }
86
- end
87
-
88
- it 'returns the correct hash' do
89
- expect(subject.to_hash).to eq(expected)
90
- end
91
- end
92
- end
@@ -1,124 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet-strings/yard'
3
-
4
- describe PuppetStrings::Yard::Handlers::JSON::TaskHandler do
5
- subject {
6
- YARD::Parser::SourceParser.parse_string(source, :json)
7
- YARD::Registry.all(:puppet_task)
8
- }
9
-
10
- describe 'parsing source without a task definition' do
11
- let(:source) { 'notice hi' }
12
-
13
- it 'no defined types should be in the registry' do
14
- expect(subject.empty?).to eq(true)
15
- end
16
- end
17
-
18
- describe 'parsing source with a syntax error' do
19
- let(:source) { <<-SOURCE
20
- {
21
- "input_method": "stdin",
22
- "parameters":
23
- "database": {
24
- "description": "Database to connect to",
25
- "type": "Optional[String[1]]"
26
- }
27
- }
28
- }
29
- SOURCE
30
- }
31
-
32
- it 'should log an error' do
33
- expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\):/).to_stdout_from_any_process
34
- expect(subject.empty?).to eq(true)
35
- end
36
- end
37
-
38
- describe 'parsing a defined type with a missing docstring' do
39
- let(:source) { <<-SOURCE
40
- {
41
- "input_method": "stdin",
42
- "parameters": {
43
- "database": {
44
- "description": "Database to connect to",
45
- "type": "Optional[String[1]]"
46
- },
47
- "user": {
48
- "description": "The user",
49
- "type": "Optional[String[1]]"
50
- },
51
- "password": {
52
- "description": "The password",
53
- "type": "Optional[String[1]]"
54
- },
55
- "sql": {
56
- "description": "Path to file you want backup to",
57
- "type": "String[1]"
58
- }
59
- }
60
- }
61
- SOURCE
62
- }
63
-
64
- it 'should log a warning' do
65
- expect{ subject }.to output(/\[warn\]: Missing a description for Puppet Task \(stdin\)/).to_stdout_from_any_process
66
- end
67
- end
68
-
69
- describe 'parsing a defined type with a docstring' do
70
- let(:source) { <<-SOURCE
71
- {
72
- "description": "Allows you to backup your database to local file.",
73
- "input_method": "stdin",
74
- "parameters": {
75
- "database": {
76
- "description": "Database to connect to",
77
- "type": "Optional[String[1]]"
78
- },
79
- "user": {
80
- "description": "The user",
81
- "type": "Optional[String[1]]"
82
- },
83
- "password": {
84
- "description": "The password",
85
- "type": "Optional[String[1]]"
86
- },
87
- "sql": {
88
- "description": "Path to file you want backup to",
89
- "type": "String[1]"
90
- }
91
- }
92
- }
93
-
94
- SOURCE
95
- }
96
-
97
- it 'should register a task object' do
98
- expect(subject.size).to eq(1)
99
- object = subject.first
100
- expect(object).to be_a(PuppetStrings::Yard::CodeObjects::Task)
101
- expect(object.namespace).to eq(PuppetStrings::Yard::CodeObjects::Tasks.instance)
102
- end
103
- end
104
-
105
- describe 'parsing a Task with a missing parameter description' do
106
- let(:source) { <<-SOURCE
107
- {
108
- "description": "Allows you to backup your database to local file.",
109
- "input_method": "stdin",
110
- "parameters": {
111
- "database": {
112
- "type": "Optional[String[1]]"
113
- }
114
- }
115
- }
116
- SOURCE
117
- }
118
-
119
- it 'should output a warning' do
120
- expect{ subject }.to output(/\[warn\]: Missing description for param 'database' in Puppet Task \(stdin\)/).to_stdout_from_any_process
121
- end
122
- end
123
-
124
- end