puppet-strings 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +14 -5
  4. data/JSON.md +41 -11
  5. data/README.md +66 -7
  6. data/Rakefile +99 -29
  7. data/lib/puppet-strings/json.rb +2 -0
  8. data/lib/puppet-strings/markdown.rb +2 -0
  9. data/lib/puppet-strings/markdown/data_type.rb +18 -0
  10. data/lib/puppet-strings/markdown/data_types.rb +41 -0
  11. data/lib/puppet-strings/markdown/function.rb +2 -2
  12. data/lib/puppet-strings/markdown/table_of_contents.rb +1 -0
  13. data/lib/puppet-strings/markdown/templates/data_type.erb +78 -0
  14. data/lib/puppet-strings/tasks/generate.rb +3 -2
  15. data/lib/puppet-strings/version.rb +1 -1
  16. data/lib/puppet-strings/yard.rb +10 -0
  17. data/lib/puppet-strings/yard/code_objects.rb +2 -0
  18. data/lib/puppet-strings/yard/code_objects/class.rb +1 -1
  19. data/lib/puppet-strings/yard/code_objects/data_type.rb +80 -0
  20. data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +58 -0
  21. data/lib/puppet-strings/yard/code_objects/defined_type.rb +1 -1
  22. data/lib/puppet-strings/yard/code_objects/function.rb +3 -3
  23. data/lib/puppet-strings/yard/code_objects/plan.rb +1 -1
  24. data/lib/puppet-strings/yard/handlers.rb +2 -0
  25. data/lib/puppet-strings/yard/handlers/puppet/data_type_alias_handler.rb +24 -0
  26. data/lib/puppet-strings/yard/handlers/ruby/base.rb +2 -2
  27. data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +236 -0
  28. data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +1 -3
  29. data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +2 -2
  30. data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +5 -6
  31. data/lib/puppet-strings/yard/parsers/json/parser.rb +1 -1
  32. data/lib/puppet-strings/yard/parsers/puppet/parser.rb +14 -7
  33. data/lib/puppet-strings/yard/parsers/puppet/statement.rb +25 -0
  34. data/lib/puppet-strings/yard/tags/overload_tag.rb +1 -1
  35. data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_data_type.erb +10 -0
  36. data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +9 -0
  37. data/lib/puppet-strings/yard/templates/default/layout/html/objects.erb +2 -0
  38. data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +18 -1
  39. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/box_info.erb +10 -0
  40. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/header.erb +1 -0
  41. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/note.erb +6 -0
  42. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/overview.erb +6 -0
  43. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb +5 -0
  44. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/source.erb +12 -0
  45. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/summary.erb +4 -0
  46. data/lib/puppet-strings/yard/templates/default/puppet_data_type/html/todo.erb +6 -0
  47. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/alias_of.erb +10 -0
  48. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/box_info.erb +10 -0
  49. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/header.erb +1 -0
  50. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/note.erb +6 -0
  51. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/overview.erb +6 -0
  52. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb +17 -0
  53. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/source.erb +12 -0
  54. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/summary.erb +4 -0
  55. data/lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/todo.erb +6 -0
  56. data/lib/puppet-strings/yard/templates/default/tags/setup.rb +1 -0
  57. data/lib/puppet/face/strings.rb +3 -3
  58. data/spec/acceptance/emit_json_options_spec.rb +69 -0
  59. data/spec/acceptance/generate_markdown_spec.rb +13 -15
  60. data/spec/acceptance/running_strings_generate_spec.rb +78 -0
  61. data/spec/fixtures/acceptance/modules/test/metadata.json +5 -1
  62. data/spec/fixtures/acceptance/modules/test/types/elephant.pp +2 -0
  63. data/spec/fixtures/unit/markdown/output_with_data_types.md +553 -0
  64. data/spec/spec_helper.rb +3 -0
  65. data/spec/spec_helper_acceptance.rb +52 -22
  66. data/spec/spec_helper_acceptance_local.rb +10 -0
  67. data/spec/unit/puppet-strings/describe_spec.rb +7 -7
  68. data/spec/unit/puppet-strings/json_spec.rb +23 -4
  69. data/spec/unit/puppet-strings/markdown/base_spec.rb +3 -3
  70. data/spec/unit/puppet-strings/markdown_spec.rb +84 -23
  71. data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +1 -1
  72. data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +4 -4
  73. data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +8 -8
  74. data/spec/unit/puppet-strings/yard/handlers/puppet/data_type_alias_handler_spec.rb +65 -0
  75. data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +8 -8
  76. data/spec/unit/puppet-strings/yard/handlers/puppet/function_handler_spec.rb +13 -13
  77. data/spec/unit/puppet-strings/yard/handlers/ruby/data_type_handler_spec.rb +232 -0
  78. data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +36 -19
  79. data/spec/unit/puppet-strings/yard/handlers/ruby/provider_handler_spec.rb +26 -7
  80. data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +7 -7
  81. data/spec/unit/puppet-strings/yard/handlers/ruby/type_handler_spec.rb +26 -10
  82. data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +2 -2
  83. data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +42 -0
  84. data/spec/unit/puppet-strings/yard/util_spec.rb +1 -1
  85. metadata +35 -7
  86. data/spec/acceptance/emit_json_options.rb +0 -71
  87. data/spec/acceptance/lib/util.rb +0 -163
  88. data/spec/acceptance/running_strings_generate.rb +0 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9556dd124a1f5f4dfcaf4457232efbea310988d8
4
- data.tar.gz: 3ef01d946f16d66c1d3af2c32345a90364ef57c6
2
+ SHA256:
3
+ metadata.gz: 8a70d1194ec3d0f50cc7924ce43b3d996b08db414a31639d38135c90863b3163
4
+ data.tar.gz: 821fef3a3e096caa7a3a51024db23e18658baba2b25bf4f503a750952e8e3657
5
5
  SHA512:
6
- metadata.gz: 516ae9d909f068fc6c25cbb0f8839b06a16509201bfb7081f0f9ee985088a740780495ce00d50ac5d1c12560ac6d35fad7d2234dc31fc206ad79aa3ce8d5ddbb
7
- data.tar.gz: eb5ec2204cac028fa9a27d7c5536694e3f07669d854e7323dba6d03d7cfeff369b92358ee19d4db9cb43fcc44df0f57540b1b41080eca6f1e21fc759e1c8d011
6
+ metadata.gz: 457119ac6a325f6c4f62923a6180b05d346b0e2d2b7e560b4cddfeda51f345284e98421abb46a68a2a3c0bd62933300394866d91247d69ef2b154667ffd91df3
7
+ data.tar.gz: db555eb951d97aa8ac62396693c9c9d317f4e361b4b9dd405d9b7d21d6ccda9f89beb70f292053e6f0440e02b6cf9fb2b8e5f9defb209a6920a7597337128834
@@ -3,6 +3,18 @@
3
3
  All significant changes to this repo will be summarized in this file.
4
4
 
5
5
 
6
+ ## [v2.3.0](https://github.com/puppetlabs/puppet-strings/tree/v2.3.0) (2019-07-17)
7
+
8
+ [Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v2.2.0...v2.3.0)
9
+
10
+ Added
11
+
12
+ - Add Puppet Data Type documentation [\#199](https://github.com/puppetlabs/puppet-strings/pull/199) ([glennsarti](https://github.com/glennsarti))
13
+
14
+ Fixed
15
+
16
+ - \(PDOC-283\) Fix namespaced symbols [\#205](https://github.com/puppetlabs/puppet-strings/pull/205) ([glennsarti](https://github.com/glennsarti))
17
+
6
18
  ## [v2.2.0](https://github.com/puppetlabs/puppet-strings/tree/v2.2.0) (2019-04-05)
7
19
 
8
20
  [Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v2.1.0...v2.2.0)
data/Gemfile CHANGED
@@ -23,10 +23,8 @@ group :test do
23
23
  end
24
24
 
25
25
  group :acceptance do
26
- gem 'beaker', '< 3.0'
27
- gem 'beaker-rspec'
28
- gem 'beaker-hostgenerator'
29
- gem 'beaker-abs'
26
+ # Litmus has dependencies which require Ruby 2.5 (Puppet 6) or above.
27
+ gem 'puppet_litmus' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.5.0')
30
28
  end
31
29
 
32
30
  group :development do
@@ -35,4 +33,15 @@ group :development do
35
33
  gem 'pry-byebug'
36
34
  end
37
35
 
38
- gem 'rubocop', '~> 0.49'
36
+ gem 'rubocop-rspec'
37
+ gem 'rubocop', '~> 0.57.2'
38
+
39
+ # Evaluate Gemfile.local if it exists
40
+ if File.exists? "#{__FILE__}.local"
41
+ eval(File.read("#{__FILE__}.local"), binding)
42
+ end
43
+
44
+ # Evaluate ~/.gemfile if it exists
45
+ if File.exists?(File.join(Dir.home, '.gemfile'))
46
+ eval(File.read(File.join(Dir.home, '.gemfile')), binding)
47
+ end
data/JSON.md CHANGED
@@ -9,17 +9,19 @@ puppet strings generate --format json
9
9
  Document Schema
10
10
  ===============
11
11
 
12
- At the top level, there are seven arrays in the JSON document:
13
-
14
- | Document Key | Description |
15
- | ---------------- | ----------------------------------------------------------------------------- |
16
- | puppet_classes | The list of Puppet classes that were parsed. |
17
- | defined_types | The list of defined types that were parsed. |
18
- | resource_types | The list of resource types that were parsed. |
19
- | providers | The list of resource providers that were parsed. |
20
- | puppet_functions | The list of Puppet functions (4.x, 4.x and Puppet language) that were parsed. |
21
- | puppet_tasks | The list of Puppet tasks that were parsed. |
22
- | puppet_plans | The list of Puppet plans that were parsed. |
12
+ At the top level, there are nine arrays in the JSON document:
13
+
14
+ | Document Key | Description |
15
+ | ----------------- | ----------------------------------------------------------------------------- |
16
+ | puppet_classes | The list of Puppet classes that were parsed. |
17
+ | data_types | The list of data types that were parsed. |
18
+ | data_type_aliases | | The list of data types that were parsed. |
19
+ | defined_types | The list of defined types that were parsed. |
20
+ | resource_types | The list of resource types that were parsed. |
21
+ | providers | The list of resource providers that were parsed. |
22
+ | puppet_functions | The list of Puppet functions (4.x, 4.x and Puppet language) that were parsed. |
23
+ | puppet_tasks | The list of Puppet tasks that were parsed. |
24
+ | puppet_plans | The list of Puppet plans that were parsed. |
23
25
 
24
26
  Puppet Classes
25
27
  --------------
@@ -36,6 +38,34 @@ Each entry in the `puppet_classes` list is an object with the following attribut
36
38
  | defaults | The map of parameter names to default values. |
37
39
  | source | The Puppet source code for the class. |
38
40
 
41
+ Data Types
42
+ ----------
43
+
44
+ Each entry in the `data_types` list is an object with the following attributes:
45
+
46
+ | Attribute Key | Description |
47
+ | ------------- | ----------------------------------------------------------- |
48
+ | name | The name of the data type. |
49
+ | file | The file defining the data type. |
50
+ | line | The line where the data type is data. |
51
+ | docstring | The *DocString* object for the data type (see below). |
52
+ | defaults | The map of parameter names to default values. |
53
+ | source | The ruby source code for the data type. (Not Implemented) |
54
+
55
+ Data Type Aliases
56
+ -----------------
57
+
58
+ Each entry in the `data_type_aliases` list is an object with the following attributes:
59
+
60
+ | Attribute Key | Description |
61
+ | ------------- | ----------------------------------------------------------------- |
62
+ | name | The name of the data type. |
63
+ | file | The file defining the data type. |
64
+ | line | The line where the data type is defined. |
65
+ | docstring | The *DocString* object for the data type (see below). |
66
+ | alias_of | The actual type this is an alias of. |
67
+ | source | The Puppet source code for the data type alias. (Not Implemented) |
68
+
39
69
  Defined Types
40
70
  -------------
41
71
 
data/README.md CHANGED
@@ -25,19 +25,33 @@ Puppet Strings generates documentation for Puppet code and extensions written in
25
25
  ### Requirements
26
26
 
27
27
  * Ruby 2.1.9 or newer
28
- * Puppet 4.0 or newer
29
- * The `yard` Ruby gem
28
+ * Puppet 4.0.0 or newer
30
29
 
31
30
  ### Install Puppet Strings
32
31
 
33
- 1. Install the YARD gem by running `gem install yard`
34
- 1. Install the `puppet-strings` gem by running `gem install puppet-strings`
35
- 1. **Optional**: Set YARD options for Strings
32
+ Installation instructions vary slightly depending on how you have installed Puppet:
36
33
 
37
- To use YARD options with Puppet Strings, specify a `yardopts` file in the same directory in which you run `puppet strings`. Puppet Strings supports the Markdown format and automatically sets the YARD `markup` option to `markdown`.
34
+ #### Installing Puppet Strings with [`puppet-agent`](https://puppet.com/docs/puppet/6.4/about_agent.html#what-puppet-agent-and-puppetserver-are) package
38
35
 
39
- To see a list of available YARD options, run `yard help doc`. For details about YARD options configuration, see the [YARD docs](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md#config).
36
+ Install the `puppet-strings` gem into the `puppet-agent` environment:
40
37
 
38
+ ```
39
+ sudo /opt/puppetlabs/puppet/bin/gem install puppet-strings
40
+ ```
41
+
42
+ #### Installing Puppet Strings with standalone `puppet` gem
43
+
44
+ Install the `puppet-strings` gem into the same Ruby installation where you have installed the `puppet` gem:
45
+
46
+ ```
47
+ gem install puppet-strings
48
+ ```
49
+
50
+ ### Configure Puppet Strings (Optional)
51
+
52
+ To use YARD options with Puppet Strings, specify a `.yardopts` file in the same directory in which you run `puppet strings`. Puppet Strings supports the Markdown format and automatically sets the YARD `markup` option to `markdown`.
53
+
54
+ To see a list of available YARD options, run `yard help doc`. For details about YARD options configuration, see the [YARD docs](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md#config).
41
55
 
42
56
  ## Generating documentation with Puppet Strings
43
57
 
@@ -74,6 +88,51 @@ To run specs, run the `spec` rake task:
74
88
  $ bundle install --path .bundle/gems
75
89
  $ bundle exec rake spec
76
90
 
91
+ ### Running Acceptance Tests
92
+
93
+ We are experimenting with a new tool for running acceptance tests. It's name is [puppet_litmus](https://github.com/puppetlabs/puppet_litmus) and replaces beaker as the test runner.
94
+
95
+ An example of running the acceptance tests locally with Docker:
96
+
97
+ 1. Ensure [Docker](https://www.docker.com/products/docker-desktop) is installed and running.
98
+
99
+ 2. Install Ruby gems. This step can be skipped if you have already followed the [Running Specs](#running-specs) instructions
100
+
101
+ ``` text
102
+ $ bundle install --path .bundle/gems
103
+ ```
104
+
105
+ 3. Provision a docker container, in this case CentOS 7
106
+
107
+ ``` text
108
+ $ bundle exec rake litmus:provision[docker, centos:7]
109
+ ```
110
+
111
+ 4. Install test items; Puppet Agent, our test module, and the puppet-strings gem built from this source code
112
+
113
+ ``` text
114
+ $ bundle exec rake litmus:install_agent[puppet6]
115
+ $ bundle exec rake litmus:install_module_fixtures
116
+ $ bundle exec rake litmus:install_gems
117
+ ```
118
+
119
+ 5. Run the acceptance tests. These tests can be run more than once without the need to run the provisioning steps again
120
+
121
+ ``` text
122
+ $ bundle exec rake litmus:acceptance:parallel
123
+ ```
124
+
125
+ 6. Remove any test containers
126
+
127
+ ``` text
128
+ $ bundle exec rake litmus:tear_down
129
+ ```
130
+
131
+ The [Litmus Wiki](https://github.com/puppetlabs/puppet_litmus/wiki) contains more indepth information about Litmus. There is also a tutorial on using Litmus with an example [Puppet Module](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module)
132
+
133
+
134
+ An example of run the acceptance tests follow the instructions [here].
135
+
77
136
  ## Support
78
137
 
79
138
  Please log tickets and issues in our [JIRA tracker][JIRA]. A [mailing list](https://groups.google.com/forum/?fromgroups#!forum/puppet-users) is available for asking questions and getting help from others.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
+ require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
2
+ require 'puppetlabs_spec_helper/tasks/fixtures'
1
3
  require 'bundler/gem_tasks'
2
- #require 'puppetlabs_spec_helper/rake_tasks'
3
4
  require 'puppet-lint/tasks/puppet-lint'
4
5
 
5
6
  require 'rspec/core/rake_task'
@@ -23,45 +24,114 @@ task :validate do
23
24
  end
24
25
  end
25
26
 
26
- task :acceptance do
27
- require 'beaker-hostgenerator'
27
+ namespace :litmus do
28
+ # Install the puppet module fixture on a collection of nodes
29
+ #
30
+ # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
31
+ desc 'install_module_fixtures - build and install module fixtures'
32
+ task :install_module_fixtures, [:target_node_name] do |_task, args|
33
+ inventory_hash = inventory_hash_from_inventory_file
34
+ target_nodes = find_targets(inventory_hash, args[:target_node_name])
35
+ if target_nodes.empty?
36
+ puts 'No targets found'
37
+ exit 0
38
+ end
39
+ include BoltSpec::Run
40
+ require 'pdk/module/build'
28
41
 
29
- install_type = 'aio'
30
- target = ENV['platform']
31
- abs = if ENV['BEAKER_ABS'] then 'abs' else 'vmpooler' end
32
- if ! target
33
- STDERR.puts 'TEST_TARGET environment variable is not set'
34
- STDERR.puts 'setting to default value of "centos7-64ma".'
35
- target = "centos7-64ma{type=#{install_type}}"
36
- end
42
+ module_fixture_dir = File.expand_path(File.join(File.dirname(__FILE__), 'spec', 'fixtures', 'acceptance', 'modules', 'test'))
43
+ module_tar = nil
44
+ Dir.chdir(module_fixture_dir) do
45
+ opts = {}
46
+ opts[:force] = true
47
+ builder = PDK::Module::Build.new(opts)
48
+ module_tar = builder.build
49
+ puts 'Built'
50
+ module_tar = Dir.glob('pkg/*.tar.gz').max_by { |f| File.mtime(f) }
51
+ raise "Unable to find package in 'pkg/*.tar.gz'" if module_tar.nil?
52
+ module_tar = File.expand_path(module_tar)
53
+ end
37
54
 
38
- unless target =~ /type=/
39
- puts "INFO: adding 'type=#{install_type}' to host config"
40
- target += "{type=#{install_type}}"
55
+ target_string = if args[:target_node_name].nil?
56
+ 'all'
57
+ else
58
+ args[:target_node_name]
59
+ end
60
+ # TODO: Currently this is Linux only
61
+ tmp_path = '/tmp/'
62
+ run_local_command("bundle exec bolt file upload #{module_tar} #{tmp_path}#{File.basename(module_tar)} --nodes #{target_string} --inventoryfile inventory.yaml")
63
+ install_module_command = "puppet module install #{tmp_path}#{File.basename(module_tar)}"
64
+ result = run_command(install_module_command, target_nodes, config: nil, inventory: inventory_hash)
65
+ if result.is_a?(Array)
66
+ result.each do |node|
67
+ puts "#{node['node']} failed #{node['result']}" if node['status'] != 'success'
68
+ end
69
+ else
70
+ raise "Failed trying to run '#{install_module_command}' against inventory."
71
+ end
72
+ puts 'Installed'
41
73
  end
42
74
 
43
- cli = BeakerHostGenerator::CLI.new([target, '--hypervisor', abs])
44
- nodeset_dir = 'spec/acceptance/nodesets'
45
- nodeset = "#{nodeset_dir}/#{target}.yml"
46
- FileUtils.mkdir_p(nodeset_dir)
47
- File.open(nodeset, 'w') do |fh|
48
- fh.print(cli.execute)
75
+ def install_remote_gem(gem_name, target_nodes, inventory_hash)
76
+ # TODO: Currently this is Linux only
77
+ install_command = "/opt/puppetlabs/puppet/bin/gem install #{gem_name}"
78
+ result = run_command(install_command, target_nodes, config: nil, inventory: inventory_hash)
79
+ if result.is_a?(Array)
80
+ result.each do |node|
81
+ puts "#{node['node']} failed #{node['result']}" if node['status'] != 'success'
82
+ end
83
+ else
84
+ raise "Failed trying to run '#{install_command}' against inventory."
85
+ end
49
86
  end
50
- puts "nodeset file:"
51
- puts nodeset
52
- sh 'gem build puppet-strings.gemspec'
53
- sh 'puppet module build spec/fixtures/acceptance/modules/test'
54
- if ENV['BEAKER_keyfile']
55
- sh "BEAKER_set=#{target} rspec spec/acceptance/*.rb"
56
- else
57
- sh "BEAKER_keyfile=$HOME/.ssh/id_rsa-acceptance BEAKER_set=#{target} rspec spec/acceptance/*.rb"
87
+
88
+ # Install the gem under test and required fixture on a collection of nodes
89
+ #
90
+ # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
91
+ desc 'install_gems - build and install module fixtures'
92
+ task :install_gems, [:target_node_name] do |_task, args|
93
+ inventory_hash = inventory_hash_from_inventory_file
94
+ target_nodes = find_targets(inventory_hash, args[:target_node_name])
95
+ if target_nodes.empty?
96
+ puts 'No targets found'
97
+ exit 0
98
+ end
99
+ include BoltSpec::Run
100
+
101
+ # Build the gem
102
+ `gem build puppet-strings.gemspec --quiet`
103
+ result = $CHILD_STATUS
104
+ raise "Unable to build the puppet-strings gem. Returned exit code #{result.exitstatus}" unless result.exitstatus.zero?
105
+ puts 'Built'
106
+ # Find the gem build artifact
107
+ gem_tar = Dir.glob('puppet-strings-*.gem').max_by { |f| File.mtime(f) }
108
+ raise "Unable to find package in 'puppet-strings-*.gem'" if gem_tar.nil?
109
+ gem_tar = File.expand_path(gem_tar)
110
+
111
+ target_string = if args[:target_node_name].nil?
112
+ 'all'
113
+ else
114
+ args[:target_node_name]
115
+ end
116
+ # TODO: Currently this is Linux only
117
+ tmp_path = '/tmp/'
118
+ run_local_command("bundle exec bolt file upload #{gem_tar} #{tmp_path}#{File.basename(gem_tar)} --nodes #{target_string} --inventoryfile inventory.yaml")
119
+
120
+
121
+ # Install dependent gems
122
+ install_remote_gem('yard', target_nodes, inventory_hash)
123
+ install_remote_gem('rgen', target_nodes, inventory_hash)
124
+ # Install puppet-strings
125
+ install_remote_gem(tmp_path + File.basename(gem_tar), target_nodes, inventory_hash)
126
+ puts 'Installed'
58
127
  end
59
128
  end
60
129
 
61
130
  task(:rubocop) do
62
131
  require 'rubocop'
63
132
  cli = RuboCop::CLI.new
64
- cli.run(%w(-D -f s))
133
+ result = cli.run(%w(-D -f s))
134
+ abort unless result == RuboCop::CLI::STATUS_SUCCESS
65
135
  end
66
136
 
67
137
  #### CHANGELOG ####
@@ -8,6 +8,8 @@ module PuppetStrings::Json
8
8
  def self.render(file = nil)
9
9
  document = {
10
10
  puppet_classes: YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash),
11
+ data_types: YARD::Registry.all(:puppet_data_type).sort_by!(&:name).map!(&:to_hash),
12
+ data_type_aliases: YARD::Registry.all(:puppet_data_type_alias).sort_by!(&:name).map!(&:to_hash),
11
13
  defined_types: YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash),
12
14
  resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash),
13
15
  providers: YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash),
@@ -5,6 +5,7 @@ module PuppetStrings::Markdown
5
5
  require_relative 'markdown/puppet_classes'
6
6
  require_relative 'markdown/functions'
7
7
  require_relative 'markdown/defined_types'
8
+ require_relative 'markdown/data_types'
8
9
  require_relative 'markdown/resource_types'
9
10
  require_relative 'markdown/puppet_tasks'
10
11
  require_relative 'markdown/puppet_plans'
@@ -20,6 +21,7 @@ module PuppetStrings::Markdown
20
21
  final << PuppetStrings::Markdown::DefinedTypes.render
21
22
  final << PuppetStrings::Markdown::ResourceTypes.render
22
23
  final << PuppetStrings::Markdown::Functions.render
24
+ final << PuppetStrings::Markdown::DataTypes.render
23
25
  final << PuppetStrings::Markdown::PuppetTasks.render
24
26
  final << PuppetStrings::Markdown::PuppetPlans.render
25
27
 
@@ -0,0 +1,18 @@
1
+ require 'puppet-strings/markdown/base'
2
+
3
+ module PuppetStrings::Markdown
4
+ # This class encapsualtes ruby data types and puppet type aliases
5
+ class DataType < Base
6
+ attr_reader :alias_of
7
+
8
+ def initialize(registry)
9
+ @template = 'data_type.erb'
10
+ super(registry, 'data type')
11
+ @alias_of = registry[:alias_of] unless registry[:alias_of].nil?
12
+ end
13
+
14
+ def render
15
+ super(@template)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'data_type'
2
+
3
+ module PuppetStrings::Markdown
4
+ module DataTypes
5
+
6
+ # @return [Array] list of data types
7
+ def self.in_dtypes
8
+ arr = YARD::Registry.all(:puppet_data_type).map!(&:to_hash)
9
+ arr.concat(YARD::Registry.all(:puppet_data_type_alias).map!(&:to_hash))
10
+
11
+ arr.sort! { |a,b| a[:name] <=> b[:name] }
12
+ arr.map! { |a| PuppetStrings::Markdown::DataType.new(a) }
13
+ end
14
+
15
+ def self.contains_private?
16
+ result = false
17
+ unless in_dtypes.nil?
18
+ in_dtypes.find { |type| type.private? }.nil? ? false : true
19
+ end
20
+ end
21
+
22
+ def self.render
23
+ final = in_dtypes.length > 0 ? "## Data types\n\n" : ""
24
+ in_dtypes.each do |type|
25
+ final << type.render unless type.private?
26
+ end
27
+ final
28
+ end
29
+
30
+
31
+ def self.toc_info
32
+ final = ["Data types"]
33
+
34
+ in_dtypes.each do |type|
35
+ final.push(type.toc_info)
36
+ end
37
+
38
+ final
39
+ end
40
+ end
41
+ end