puppet-debugger 0.10.3 → 0.11.0

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +16 -74
  3. data/.rubocop_todo.yml +59 -59
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +7 -0
  6. data/Gemfile +3 -2
  7. data/lib/plugins/puppet-debugger/input_responders/functions.rb +100 -1
  8. data/lib/puppet-debugger/cli.rb +1 -2
  9. data/lib/puppet-debugger/input_responder_plugin.rb +8 -1
  10. data/lib/puppet-debugger/support.rb +14 -2
  11. data/lib/puppet-debugger/version.rb +1 -1
  12. data/puppet-debugger.gemspec +2 -0
  13. data/spec/fixtures/modules/extlib/.editorconfig +14 -0
  14. data/spec/fixtures/modules/extlib/.fixtures.yml +3 -0
  15. data/spec/fixtures/modules/extlib/.github/CONTRIBUTING.md +184 -0
  16. data/spec/fixtures/modules/extlib/.github/ISSUE_TEMPLATE.md +26 -0
  17. data/spec/fixtures/modules/extlib/.github/PULL_REQUEST_TEMPLATE.md +20 -0
  18. data/spec/fixtures/modules/extlib/.gitignore +21 -0
  19. data/spec/fixtures/modules/extlib/.msync.yml +1 -0
  20. data/spec/fixtures/modules/extlib/.overcommit.yml +64 -0
  21. data/spec/fixtures/modules/extlib/.pmtignore +21 -0
  22. data/spec/fixtures/modules/extlib/.rspec +2 -0
  23. data/spec/fixtures/modules/extlib/.rspec_parallel +1 -0
  24. data/spec/fixtures/modules/extlib/.rubocop.yml +545 -0
  25. data/spec/fixtures/modules/extlib/.sync.yml +12 -0
  26. data/spec/fixtures/modules/extlib/.travis.yml +47 -0
  27. data/spec/fixtures/modules/extlib/.yardopts +2 -0
  28. data/spec/fixtures/modules/extlib/Gemfile +82 -0
  29. data/spec/fixtures/modules/extlib/Rakefile +82 -0
  30. data/spec/fixtures/modules/extlib/functions/dir_split.pp +25 -0
  31. data/spec/fixtures/modules/extlib/functions/file_separator.pp +7 -0
  32. data/spec/fixtures/modules/extlib/functions/mkdir_p.pp +20 -0
  33. data/spec/fixtures/modules/extlib/functions/path_join.pp +29 -0
  34. data/spec/fixtures/modules/extlib/lib/puppet/functions/cache_data.rb +11 -0
  35. data/spec/fixtures/modules/extlib/lib/puppet/functions/default_content.rb +11 -0
  36. data/spec/fixtures/modules/extlib/lib/puppet/functions/dump_args.rb +11 -0
  37. data/spec/fixtures/modules/extlib/lib/puppet/functions/echo.rb +11 -0
  38. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/cache_data.rb +48 -0
  39. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/default_content.rb +37 -0
  40. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/dump_args.rb +20 -0
  41. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb +45 -0
  42. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/has_module.rb +33 -0
  43. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/ip_to_cron.rb +39 -0
  44. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/random_password.rb +63 -0
  45. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/resources_deep_merge.rb +87 -0
  46. data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/sort_by_version.rb +15 -0
  47. data/spec/fixtures/modules/extlib/lib/puppet/functions/ip_to_cron.rb +11 -0
  48. data/spec/fixtures/modules/extlib/lib/puppet/functions/random_password.rb +11 -0
  49. data/spec/fixtures/modules/extlib/lib/puppet/functions/resources_deep_merge.rb +11 -0
  50. data/spec/fixtures/modules/extlib/metadata.json +66 -0
  51. data/spec/input_responder_plugin_spec.rb +1 -1
  52. data/spec/input_responders/functions_spec.rb +46 -1
  53. data/spec/spec_helper.rb +5 -5
  54. data/spec/support_spec.rb +0 -8
  55. metadata +69 -4
  56. data/lib/puppet-debugger/support/functions.rb +0 -72
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "puppet-extlib",
3
+ "version": "3.1.1-rc0",
4
+ "source": "https://github.com/voxpupuli/puppet-extlib.git",
5
+ "project_page": "https://github.com/voxpupuli/puppet-extlib",
6
+ "issues_url": "https://github.com/voxpupuli/puppet-extlib/issues",
7
+ "author": "Vox Pupuli",
8
+ "license": "Apache-2.0",
9
+ "summary": "extlib provides functions out of scope puppetlabs/stdlib",
10
+ "description": "extlib provides functions out of scope puppetlabs/stdlib",
11
+ "tags": [
12
+ "voxpupuli",
13
+ "extlib",
14
+ "stdlib"
15
+ ],
16
+ "requirements": [
17
+ {
18
+ "name": "puppet",
19
+ "version_requirement": ">= 5.5.8 < 7.0.0"
20
+ }
21
+ ],
22
+ "dependencies": [
23
+ {
24
+ "name": "puppetlabs/stdlib",
25
+ "version_requirement": ">= 4.6.0 < 6.0.0"
26
+ }
27
+ ],
28
+ "operatingsystem_support": [
29
+ {
30
+ "operatingsystem": "RedHat",
31
+ "operatingsystemrelease": [
32
+ "6",
33
+ "7"
34
+ ]
35
+ },
36
+ {
37
+ "operatingsystem": "CentOS",
38
+ "operatingsystemrelease": [
39
+ "6",
40
+ "7"
41
+ ]
42
+ },
43
+ {
44
+ "operatingsystem": "Scientific",
45
+ "operatingsystemrelease": [
46
+ "6",
47
+ "7"
48
+ ]
49
+ },
50
+ {
51
+ "operatingsystem": "Debian",
52
+ "operatingsystemrelease": [
53
+ "8",
54
+ "9"
55
+ ]
56
+ },
57
+ {
58
+ "operatingsystem": "Ubuntu",
59
+ "operatingsystemrelease": [
60
+ "14.04",
61
+ "16.04",
62
+ "18.04"
63
+ ]
64
+ }
65
+ ]
66
+ }
@@ -29,7 +29,7 @@ describe :input_responder_plugin do
29
29
  end
30
30
 
31
31
  {scope: Puppet::Parser::Scope, node: Puppet::Node, facts: Puppet::Node::Facts,
32
- environment: Puppet::Node::Environment, function_map: Hash,
32
+ environment: Puppet::Node::Environment,
33
33
  compiler: Puppet::Parser::Compiler, catalog: Puppet::Resource::Catalog}.each do |name, klass|
34
34
  it "can access #{name}" do
35
35
  expect(plugin.send(name).class).to be klass
@@ -4,17 +4,62 @@ require 'puppet-debugger/plugin_test_helper'
4
4
 
5
5
  describe :functions do
6
6
  include_examples 'plugin_tests'
7
+
7
8
  let(:input) do
8
9
  "md5('hello')"
9
10
  end
11
+
12
+ let(:mod_dir) do
13
+ File.join(fixtures_dir, 'modules', 'extlib')
14
+ end
15
+
16
+ it 'runs' do
17
+ expect(plugin.run).to be_a String
18
+ end
19
+
20
+ it 'returns functions' do
21
+ expect(plugin.function_map).to be_a Hash
22
+ end
23
+
24
+ it 'sorted_list' do
25
+ expect(plugin.sorted_list).to be_a Array
26
+ expect(plugin.sorted_list.first).to be_a Hash
27
+ end
28
+
29
+ it 'returns function names' do
30
+ expect(plugin.func_list).to be_a Array
31
+ expect(plugin.func_list.find {|m| m =~ /md5/ }).to eq('md5()')
32
+ end
33
+
10
34
  it 'execute md5' do
11
35
  debugger_output = /5d41402abc4b2a76b9719d911017c592/
12
- debugger.handle_input(input)
36
+ debugger.handle_input("md5('hello')")
13
37
  expect(output.string).to match(debugger_output)
14
38
  end
39
+
15
40
  it 'execute swapcase' do
16
41
  debugger_output = /HELLO/
17
42
  debugger.handle_input("swapcase('hello')")
18
43
  expect(output.string).to match(debugger_output)
19
44
  end
45
+
46
+ it '#function_obj with native function' do
47
+ expect(plugin.function_obj(File.join(mod_dir, 'functions', 'dir_split.pp'))).to eq(
48
+ {:file=>File.join(mod_dir, 'functions', 'dir_split.pp'), :mod_name=>"extlib",
49
+ :full_name=>"extlib::dir_split", :name=>"extlib::dir_split", :namespace=>'extlib',
50
+ :summary => "Splits the given directory or directories into individual paths."}
51
+ )
52
+ end
53
+
54
+ it '#function_obj ruby v4 without namespace' do
55
+ expect(plugin.function_obj(File.join(mod_dir,'lib', 'puppet', 'functions', 'echo.rb')))
56
+ .to eq({:file=>File.join(mod_dir,'lib', 'puppet', 'functions', 'echo.rb'), :mod_name=>"extlib",
57
+ :full_name=>"echo", :name=>"echo", :namespace=>"", :summary => "DEPRECATED. Use the namespaced function [`extlib::echo`](#extlibecho) instead."})
58
+ end
59
+
60
+ it '#function_obj ruby v4 and namespace' do
61
+ expect(plugin.function_obj(File.join(mod_dir,'lib', 'puppet', 'functions', 'extlib', 'echo.rb')))
62
+ .to eq({:file=>File.join(mod_dir, 'lib', 'puppet', 'functions', 'extlib', 'echo.rb'), :mod_name=>"extlib",
63
+ :full_name=>"extlib::echo", :name=>"extlib::echo", :namespace=>'extlib', :summary => nil})
64
+ end
20
65
  end
data/spec/spec_helper.rb CHANGED
@@ -36,11 +36,11 @@ def stdlib_path
36
36
  File.join(Puppet[:basemodulepath].split(':').first, 'stdlib')
37
37
  end
38
38
 
39
- # def install_stdlib
40
- # `bundle exec puppet module install puppetlabs/stdlib` unless File.exists?(stdlib_path)
41
- # end
42
- #
43
- # install_stdlib
39
+ def install_stdlib
40
+ `bundle exec puppet module install puppetlabs/stdlib` unless File.exists?(stdlib_path)
41
+ end
42
+
43
+ #install_stdlib
44
44
 
45
45
  def fixtures_dir
46
46
  File.join(File.dirname(__FILE__), 'fixtures')
data/spec/support_spec.rb CHANGED
@@ -40,14 +40,6 @@ describe 'support' do
40
40
  # manifest_file.close
41
41
  end
42
42
 
43
- context '#function_map' do
44
- it 'should list functions' do
45
- func = debugger.function_map["#{puppet_version}::hiera"]
46
- expect(debugger.function_map).to be_instance_of(Hash)
47
- expect(func).to eq(name: 'hiera', parent: puppet_version)
48
- end
49
- end
50
-
51
43
  it 'should return a puppet version' do
52
44
  expect(puppet_version).to match(/puppet-\d\.\d+.\d/)
53
45
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-debugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: table_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: pluginator
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rb-readline
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.5
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: puppet
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -157,7 +185,6 @@ files:
157
185
  - lib/puppet-debugger/support/environment.rb
158
186
  - lib/puppet-debugger/support/errors.rb
159
187
  - lib/puppet-debugger/support/facts.rb
160
- - lib/puppet-debugger/support/functions.rb
161
188
  - lib/puppet-debugger/support/loader.rb
162
189
  - lib/puppet-debugger/support/node.rb
163
190
  - lib/puppet-debugger/support/scope.rb
@@ -170,6 +197,44 @@ files:
170
197
  - spec/facts_spec.rb
171
198
  - spec/fixtures/environments/production/manifests/site.pp
172
199
  - spec/fixtures/invalid_node_obj.yaml
200
+ - spec/fixtures/modules/extlib/.editorconfig
201
+ - spec/fixtures/modules/extlib/.fixtures.yml
202
+ - spec/fixtures/modules/extlib/.github/CONTRIBUTING.md
203
+ - spec/fixtures/modules/extlib/.github/ISSUE_TEMPLATE.md
204
+ - spec/fixtures/modules/extlib/.github/PULL_REQUEST_TEMPLATE.md
205
+ - spec/fixtures/modules/extlib/.gitignore
206
+ - spec/fixtures/modules/extlib/.msync.yml
207
+ - spec/fixtures/modules/extlib/.overcommit.yml
208
+ - spec/fixtures/modules/extlib/.pmtignore
209
+ - spec/fixtures/modules/extlib/.rspec
210
+ - spec/fixtures/modules/extlib/.rspec_parallel
211
+ - spec/fixtures/modules/extlib/.rubocop.yml
212
+ - spec/fixtures/modules/extlib/.sync.yml
213
+ - spec/fixtures/modules/extlib/.travis.yml
214
+ - spec/fixtures/modules/extlib/.yardopts
215
+ - spec/fixtures/modules/extlib/Gemfile
216
+ - spec/fixtures/modules/extlib/Rakefile
217
+ - spec/fixtures/modules/extlib/functions/dir_split.pp
218
+ - spec/fixtures/modules/extlib/functions/file_separator.pp
219
+ - spec/fixtures/modules/extlib/functions/mkdir_p.pp
220
+ - spec/fixtures/modules/extlib/functions/path_join.pp
221
+ - spec/fixtures/modules/extlib/lib/puppet/functions/cache_data.rb
222
+ - spec/fixtures/modules/extlib/lib/puppet/functions/default_content.rb
223
+ - spec/fixtures/modules/extlib/lib/puppet/functions/dump_args.rb
224
+ - spec/fixtures/modules/extlib/lib/puppet/functions/echo.rb
225
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/cache_data.rb
226
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/default_content.rb
227
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/dump_args.rb
228
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb
229
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/has_module.rb
230
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/ip_to_cron.rb
231
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/random_password.rb
232
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/resources_deep_merge.rb
233
+ - spec/fixtures/modules/extlib/lib/puppet/functions/extlib/sort_by_version.rb
234
+ - spec/fixtures/modules/extlib/lib/puppet/functions/ip_to_cron.rb
235
+ - spec/fixtures/modules/extlib/lib/puppet/functions/random_password.rb
236
+ - spec/fixtures/modules/extlib/lib/puppet/functions/resources_deep_merge.rb
237
+ - spec/fixtures/modules/extlib/metadata.json
173
238
  - spec/fixtures/node_obj.yaml
174
239
  - spec/fixtures/sample_manifest.pp
175
240
  - spec/fixtures/sample_start_debugger.pp
@@ -221,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
286
  - !ruby/object:Gem::Version
222
287
  version: '0'
223
288
  requirements: []
224
- rubygems_version: 3.0.2
289
+ rubygems_version: 3.0.3
225
290
  signing_key:
226
291
  specification_version: 4
227
292
  summary: A repl based debugger for the puppet language
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PuppetDebugger
4
- module Support
5
- module Functions
6
- # returns a array of function files which is only required
7
- # when displaying the function map, puppet will load each function on demand
8
- # in the future we may want to utilize the puppet loaders to find these things
9
- def function_files
10
- search_dirs = lib_dirs.map do |lib_dir|
11
- [File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'),
12
- File.join(lib_dir, 'functions', '**', '*.rb'),
13
- File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
14
- end
15
- # add puppet lib directories
16
- search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'),
17
- File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
18
- Dir.glob(search_dirs.flatten)
19
- end
20
-
21
- def data_type_files
22
- search_dirs = lib_dirs.map do |lib_dir|
23
- [File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'),
24
- File.join(lib_dir, 'functions', '**', '*.rb'),
25
- File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
26
- end
27
- # add puppet lib directories
28
- search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'),
29
- File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
30
- Dir.glob(search_dirs.flatten)
31
- end
32
-
33
- # returns either the module name or puppet version
34
- def mod_finder
35
- @mod_finder ||= Regexp.new('\/([\w\-\.]+)\/lib')
36
- end
37
-
38
- # returns a map of functions
39
- def function_map
40
- unless @functions
41
- do_initialize
42
- @functions = {}
43
- function_files.each do |file|
44
- obj = {}
45
- name = File.basename(file, '.rb')
46
- obj[:name] = name
47
- # return the last matched in cases where rbenv might be involved
48
- obj[:parent] = file.scan(mod_finder).flatten.last
49
- @functions["#{obj[:parent]}::#{name}"] = obj
50
- end
51
- end
52
- @functions
53
- end
54
-
55
- # gather all the lib dirs
56
- def lib_dirs(module_dirs = modules_paths)
57
- dirs = module_dirs.map do |mod_dir|
58
- Dir["#{mod_dir}/*/lib"].entries
59
- end.flatten
60
- dirs + [puppet_repl_lib_dir]
61
- end
62
-
63
- # load all the lib dirs so puppet can find the functions
64
- # at this time, this function is not being used
65
- def load_lib_dirs(module_dirs = modules_paths)
66
- lib_dirs(module_dirs).each do |lib|
67
- $LOAD_PATH << lib
68
- end
69
- end
70
- end
71
- end
72
- end