puppet-strings 2.2.0 → 2.6.0

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