puppet-debugger 0.15.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +21 -45
- data/.rubocop.yml +64 -233
- data/.rubocop_todo.yml +89 -147
- data/.ruby-version +1 -1
- data/.vscode/launch.json +15 -0
- data/CHANGELOG.md +34 -2
- data/Gemfile +7 -5
- data/README.md +29 -261
- data/Rakefile +11 -12
- data/bin/pdb +1 -1
- data/lib/awesome_print/ext/awesome_puppet.rb +22 -8
- data/lib/plugins/puppet-debugger/input_responders/benchmark.rb +5 -4
- data/lib/plugins/puppet-debugger/input_responders/classes.rb +14 -2
- data/lib/plugins/puppet-debugger/input_responders/classification.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/commands.rb +18 -18
- data/lib/plugins/puppet-debugger/input_responders/datatypes.rb +22 -6
- data/lib/plugins/puppet-debugger/input_responders/environment.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/exit.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/facterdb_filter.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/facts.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/functions.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/help.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/krt.rb +4 -2
- data/lib/plugins/puppet-debugger/input_responders/play.rb +22 -24
- data/lib/plugins/puppet-debugger/input_responders/reset.rb +5 -3
- data/lib/plugins/puppet-debugger/input_responders/resources.rb +16 -7
- data/lib/plugins/puppet-debugger/input_responders/set.rb +34 -32
- data/lib/plugins/puppet-debugger/input_responders/stacktrace.rb +23 -0
- data/lib/plugins/puppet-debugger/input_responders/types.rb +6 -2
- data/lib/plugins/puppet-debugger/input_responders/vars.rb +8 -7
- data/lib/plugins/puppet-debugger/input_responders/whereami.rb +5 -3
- data/lib/puppet-debugger.rb +1 -45
- data/lib/puppet-debugger/cli.rb +120 -92
- data/lib/puppet-debugger/code/code_file.rb +13 -14
- data/lib/puppet-debugger/code/code_range.rb +5 -3
- data/lib/puppet-debugger/code/loc.rb +1 -1
- data/lib/puppet-debugger/debugger_code.rb +2 -0
- data/lib/puppet-debugger/hooks.rb +15 -16
- data/lib/puppet-debugger/input_responder_plugin.rb +54 -52
- data/lib/puppet-debugger/monkey_patches.rb +57 -0
- data/lib/puppet-debugger/plugin_test_helper.rb +9 -8
- data/lib/puppet-debugger/support.rb +27 -17
- data/lib/puppet-debugger/support/environment.rb +10 -3
- data/lib/puppet-debugger/support/errors.rb +25 -27
- data/lib/puppet-debugger/support/facts.rb +5 -5
- data/lib/puppet-debugger/support/node.rb +4 -7
- data/lib/puppet-debugger/support/scope.rb +29 -0
- data/lib/puppet-debugger/trollop.rb +38 -31
- data/lib/puppet-debugger/version.rb +1 -1
- data/lib/puppet/application/debugger.rb +151 -126
- data/output.json +1 -0
- data/puppet-debugger.gemspec +17 -15
- data/spec/awesome_print/ext/awesome_puppet_spec.rb +30 -30
- data/spec/fixtures/pe-xl-core-0.puppet.vm.json +1 -0
- data/spec/fixtures/sample_start_debugger.pp +3 -2
- data/spec/hooks_spec.rb +33 -35
- data/spec/input_responder_plugin_spec.rb +7 -6
- data/spec/input_responders/benchmark_spec.rb +3 -1
- data/spec/input_responders/classes_spec.rb +12 -13
- data/spec/input_responders/classification_spec.rb +4 -2
- data/spec/input_responders/commands_spec.rb +2 -0
- data/spec/input_responders/datatypes_spec.rb +8 -2
- data/spec/input_responders/environment_spec.rb +2 -0
- data/spec/input_responders/exit_spec.rb +9 -11
- data/spec/input_responders/facterdb_filter_spec.rb +2 -0
- data/spec/input_responders/facts_spec.rb +2 -0
- data/spec/input_responders/functions_spec.rb +30 -28
- data/spec/input_responders/help_spec.rb +5 -3
- data/spec/input_responders/krt_spec.rb +3 -1
- data/spec/input_responders/play_spec.rb +10 -20
- data/spec/input_responders/reset_spec.rb +2 -0
- data/spec/input_responders/resources_spec.rb +7 -1
- data/spec/input_responders/set_spec.rb +3 -1
- data/spec/input_responders/stacktrace_spec.rb +15 -0
- data/spec/input_responders/types_spec.rb +2 -0
- data/spec/input_responders/vars_spec.rb +4 -4
- data/spec/input_responders/whereami_spec.rb +2 -0
- data/spec/pdb_spec.rb +0 -9
- data/spec/puppet/application/debugger_spec.rb +35 -17
- data/spec/puppet_debugger_spec.rb +81 -83
- data/spec/remote_node_spec.rb +1 -5
- data/spec/spec_helper.rb +22 -18
- data/spec/support_spec.rb +3 -5
- data/test_matrix.rb +1 -1
- metadata +53 -19
data/bin/pdb
CHANGED
@@ -3,5 +3,5 @@
|
|
3
3
|
|
4
4
|
require 'puppet-debugger'
|
5
5
|
|
6
|
-
puts
|
6
|
+
puts 'The debugger pdb command will be removed in a future release please use puppet-debugger or puppet debugger instead'.warning
|
7
7
|
PuppetDebugger::Cli.start
|
@@ -34,12 +34,25 @@ module AwesomePrint
|
|
34
34
|
cast = :puppet_resource
|
35
35
|
elsif /Puppet::Pops::Types/.match(object.class.to_s)
|
36
36
|
cast = :puppet_type
|
37
|
+
elsif /Bolt::/.match(object.class.to_s)
|
38
|
+
cast = :bolt_type
|
37
39
|
end
|
38
40
|
cast
|
39
41
|
end
|
40
42
|
|
43
|
+
def awesome_bolt_type(object)
|
44
|
+
if object.class.to_s.include?('Result')
|
45
|
+
object.to_data.ai
|
46
|
+
elsif object.is_a?(::Bolt::Target)
|
47
|
+
object.to_h.merge(object.detail).ai
|
48
|
+
else
|
49
|
+
object.ai
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
41
53
|
def awesome_puppet_resource(object)
|
42
54
|
return '' if object.nil?
|
55
|
+
|
43
56
|
resource_object = object.to_ral
|
44
57
|
awesome_puppet_type(resource_object)
|
45
58
|
end
|
@@ -47,16 +60,17 @@ module AwesomePrint
|
|
47
60
|
def awesome_puppet_type(object)
|
48
61
|
return '' if object.nil?
|
49
62
|
return object.to_s unless object.respond_to?(:name) && object.respond_to?(:title) && object.respond_to?(:to_hash)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
63
|
+
|
64
|
+
h = if [].respond_to?(:to_h)
|
65
|
+
# to_h is only supported in ruby 2.1+
|
66
|
+
object.to_hash.merge(name: object.name, title: object.title).sort.to_h
|
67
|
+
else
|
68
|
+
object.to_hash.merge(name: object.name, title: object.title)
|
69
|
+
end
|
70
|
+
res_str = awesome_hash(JSON.parse(h.to_json)) # converting to json removes symbols
|
57
71
|
"#{object.class} #{res_str}"
|
58
72
|
end
|
59
73
|
end
|
60
74
|
end
|
61
75
|
|
62
|
-
AwesomePrint::Formatter.
|
76
|
+
AwesomePrint::Formatter.include AwesomePrint::Puppet
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'benchmark'
|
2
4
|
require 'puppet-debugger/input_responder_plugin'
|
3
5
|
module PuppetDebugger
|
4
6
|
module InputResponders
|
5
7
|
class Benchmark < InputResponderPlugin
|
6
|
-
COMMAND_WORDS = %w
|
8
|
+
COMMAND_WORDS = %w[benchmark bm].freeze
|
7
9
|
SUMMARY = 'Benchmark your Puppet code.'
|
8
10
|
COMMAND_GROUP = :tools
|
9
11
|
|
10
12
|
def run(args = [])
|
11
|
-
if args.count
|
13
|
+
if args.count.positive?
|
12
14
|
enable(false)
|
13
15
|
out = debugger.handle_input(args.first)
|
14
16
|
disable
|
@@ -34,7 +36,6 @@ module PuppetDebugger
|
|
34
36
|
'On'
|
35
37
|
end
|
36
38
|
end
|
37
|
-
|
38
39
|
end
|
39
40
|
end
|
40
|
-
end
|
41
|
+
end
|
@@ -1,15 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Classes < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[classes].freeze
|
6
8
|
SUMMARY = 'List all the classes current in the catalog.'
|
7
9
|
COMMAND_GROUP = :scope
|
8
10
|
|
9
11
|
def run(args = [])
|
10
|
-
|
12
|
+
filter = args
|
13
|
+
classes = find_classes(debugger.catalog.classes, filter)
|
14
|
+
classes.ai
|
11
15
|
end
|
12
16
|
|
17
|
+
def find_classes(classes, filter = [])
|
18
|
+
return classes if filter.nil? || filter.empty?
|
19
|
+
|
20
|
+
filter_string = filter.join(' ').downcase
|
21
|
+
classes.find_all do |klass|
|
22
|
+
klass.downcase.include?(filter_string)
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Classification < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[classification].freeze
|
6
8
|
SUMMARY = 'Show the classification details of the node.'
|
7
9
|
COMMAND_GROUP = :node
|
8
10
|
|
9
|
-
def run(
|
11
|
+
def run(_args = [])
|
10
12
|
debugger.node.classes.ai
|
11
13
|
end
|
12
14
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Commands < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[commands].freeze
|
6
8
|
SUMMARY = 'List all available commands, aka. this screen'
|
7
9
|
COMMAND_GROUP = :help
|
8
10
|
|
9
|
-
def run(
|
11
|
+
def run(_args = [])
|
10
12
|
commands_list
|
11
13
|
end
|
12
14
|
|
@@ -31,9 +33,9 @@ module PuppetDebugger
|
|
31
33
|
def command_groups
|
32
34
|
unless @command_groups
|
33
35
|
@command_groups = {}
|
34
|
-
self.class.command_output.each do |
|
36
|
+
self.class.command_output.each do |item|
|
35
37
|
if @command_groups[item[:group]]
|
36
|
-
@command_groups[item[:group]].merge!(
|
38
|
+
@command_groups[item[:group]].merge!(item[:words].first => item[:summary])
|
37
39
|
else
|
38
40
|
@command_groups[item[:group]] = { item[:words].first => item[:summary] }
|
39
41
|
end
|
@@ -43,12 +45,12 @@ module PuppetDebugger
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def self.command_list_regex
|
46
|
-
out = command_list.map {|n| "^#{n}"}.join('|')
|
47
|
-
|
48
|
+
out = command_list.map { |n| "^#{n}" }.join('|')
|
49
|
+
/#{out}/
|
48
50
|
end
|
49
51
|
|
50
52
|
def self.command_list
|
51
|
-
command_output.map{|f| f[:words] }.flatten
|
53
|
+
command_output.map { |f| f[:words] }.flatten
|
52
54
|
end
|
53
55
|
|
54
56
|
def self.command_output
|
@@ -56,22 +58,20 @@ module PuppetDebugger
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def self.plugins
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
raise PuppetDebugger::Exception::InvalidCommand.new(message: "Unsupported gem version. Please update with: gem update --system")
|
64
|
-
end
|
61
|
+
debug_plugins = Pluginator.find('puppet-debugger')
|
62
|
+
debug_plugins['input_responders']
|
63
|
+
rescue NoMethodError
|
64
|
+
raise PuppetDebugger::Exception::InvalidCommand.new(message: 'Unsupported gem version. Please update with: gem update --system')
|
65
65
|
end
|
66
66
|
|
67
67
|
# @param name [String] - the name of the command that is associated with a plugin
|
68
68
|
# @return [PuppetDebugger::InputResponders::InputResponderPlugin]
|
69
69
|
def self.plugin_from_command(name)
|
70
|
-
|
71
|
-
raise PuppetDebugger::Exception::InvalidCommand.new(message: "invalid command #{name}") unless
|
72
|
-
p
|
73
|
-
end
|
70
|
+
plug = plugins.find { |p| p::COMMAND_WORDS.include?(name) }
|
71
|
+
raise PuppetDebugger::Exception::InvalidCommand.new(message: "invalid command #{name}") unless plug
|
74
72
|
|
73
|
+
plug
|
74
|
+
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
@@ -1,13 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Datatypes < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[datatypes].freeze
|
6
8
|
SUMMARY = 'List all the datatypes available in the environment.'
|
7
9
|
COMMAND_GROUP = :environment
|
8
10
|
|
9
11
|
def run(args = [])
|
10
|
-
|
12
|
+
filter = args
|
13
|
+
datatypes = find_datatypes(all_data_types.sort, filter)
|
14
|
+
datatypes.ai
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_datatypes(datatypes, filter = [])
|
18
|
+
return datatypes if filter.nil? || filter.empty?
|
19
|
+
|
20
|
+
filter_string = filter.join(' ').downcase
|
21
|
+
datatypes.find_all do |datatype|
|
22
|
+
datatype.downcase.include?(filter_string)
|
23
|
+
end
|
11
24
|
end
|
12
25
|
|
13
26
|
# @return [Array[String]] - returns a list of all the custom data types found in all the modules in the environment
|
@@ -17,15 +30,19 @@ module PuppetDebugger
|
|
17
30
|
files.map do |f|
|
18
31
|
m = File.read(f).match(/type\s([a-z\d\:_]+)/i)
|
19
32
|
next if m =~ /type|alias/ # can't figure out the best way to filter type and alias out
|
33
|
+
|
20
34
|
m[1] if m && m[1] =~ /::/
|
21
35
|
end.uniq.compact
|
22
36
|
end
|
23
37
|
|
38
|
+
# loaders.instance_variable_get(:@loaders_by_name)['boltlib']
|
39
|
+
# [:func_4x, :func_4xpp, :func_3x, :datatype, :type_pp,
|
40
|
+
# :resource_type_pp, :plan, :task]
|
24
41
|
# @return [Array[String]] - a list of core data types
|
25
42
|
def core_datatypes
|
26
|
-
loaders.implementation_registry
|
27
|
-
|
28
|
-
|
43
|
+
loaders.implementation_registry.instance_variable_get(:@parent)
|
44
|
+
.instance_variable_get(:@implementations_per_type_name)
|
45
|
+
.keys.find_all { |t| t !~ /::/ }
|
29
46
|
end
|
30
47
|
|
31
48
|
# @return [Array[String]] - combined list of core data types and environment data types
|
@@ -36,7 +53,6 @@ module PuppetDebugger
|
|
36
53
|
end
|
37
54
|
core_datatypes + environment_data_types
|
38
55
|
end
|
39
|
-
|
40
56
|
end
|
41
57
|
end
|
42
58
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Environment < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[environment].freeze
|
6
8
|
SUMMARY = 'Show the current environment name'
|
7
9
|
COMMAND_GROUP = :context
|
8
10
|
|
9
|
-
def run(
|
11
|
+
def run(_args = [])
|
10
12
|
"Puppet Environment: #{debugger.puppet_env_name}"
|
11
13
|
end
|
12
14
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Exit < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[exit].freeze
|
6
8
|
SUMMARY = 'Quit Puppet Debugger.'
|
7
9
|
COMMAND_GROUP = :help
|
8
10
|
|
9
|
-
def run(
|
11
|
+
def run(_args = [])
|
10
12
|
exit 0
|
11
13
|
end
|
12
14
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class FacterdbFilter < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[facterdb_filter ff].freeze
|
6
8
|
SUMMARY = 'Set the facterdb filter'
|
7
9
|
COMMAND_GROUP = :node
|
8
10
|
|
9
11
|
# displays the facterdb filter
|
10
12
|
# @param [Array] - args is not used
|
11
|
-
def run(
|
13
|
+
def run(_args = [])
|
12
14
|
debugger.dynamic_facterdb_filter.ai
|
13
15
|
end
|
14
16
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'puppet-debugger/input_responder_plugin'
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Facts < InputResponderPlugin
|
5
|
-
COMMAND_WORDS = %w
|
7
|
+
COMMAND_WORDS = %w[facts].freeze
|
6
8
|
SUMMARY = 'List all the facts associated with the node.'
|
7
9
|
COMMAND_GROUP = :node
|
8
10
|
|
9
|
-
def run(
|
11
|
+
def run(_args = [])
|
10
12
|
variables = debugger.node.facts.values
|
11
13
|
variables.ai(sort_keys: true, indent: -1)
|
12
14
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'puppet-debugger/input_responder_plugin'
|
4
|
+
require 'table_print'
|
3
5
|
require 'fileutils'
|
4
6
|
require 'bundler'
|
5
7
|
|
6
8
|
module PuppetDebugger
|
7
9
|
module InputResponders
|
8
10
|
class Functions < InputResponderPlugin
|
9
|
-
COMMAND_WORDS = %w
|
10
|
-
SUMMARY =
|
11
|
+
COMMAND_WORDS = %w[functions].freeze
|
12
|
+
SUMMARY = 'List all the functions available in the environment.'
|
11
13
|
COMMAND_GROUP = :environment
|
12
|
-
FUNC_NATIVE_NAME_REGEX =
|
13
|
-
FUNC_V4_NAME_REGEX =
|
14
|
+
FUNC_NATIVE_NAME_REGEX = /\Afunction\s([\w\:]+)/.freeze
|
15
|
+
FUNC_V4_NAME_REGEX = /Puppet\:\:Functions.create_function\s?\(?\:?\'?([\w\:]+)/.freeze
|
14
16
|
|
15
17
|
def run(args = [])
|
16
|
-
filter = args.first ||
|
17
|
-
TablePrint::Printer.table_print(sorted_list(filter), [
|
18
|
+
filter = args.first || ''
|
19
|
+
TablePrint::Printer.table_print(sorted_list(filter), %i[full_name mod_name])
|
18
20
|
end
|
19
21
|
|
20
|
-
def sorted_list(filter =
|
22
|
+
def sorted_list(filter = '')
|
21
23
|
search = /#{Regexp.escape(filter)}/
|
22
24
|
function_map.values.find_all do |v|
|
23
25
|
"#{v[:mod_name]}_#{v[:full_name]}" =~ search
|
@@ -27,7 +29,7 @@ module PuppetDebugger
|
|
27
29
|
# append a () to functions so we know they are functions
|
28
30
|
def func_list
|
29
31
|
# ideally we should get a list of function names via the puppet loader
|
30
|
-
function_map.map { |
|
32
|
+
function_map.map { |_name, metadata| "#{metadata[:full_name]}()" }
|
31
33
|
end
|
32
34
|
|
33
35
|
# @return [Hash] - a map of all the functions
|
@@ -45,8 +47,8 @@ module PuppetDebugger
|
|
45
47
|
def current_module_dir
|
46
48
|
@current_module_dir ||= begin
|
47
49
|
File.dirname(::Bundler.default_gemfile)
|
48
|
-
|
49
|
-
|
50
|
+
rescue ::Bundler::GemfileNotFound
|
51
|
+
Dir.pwd
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -62,26 +64,26 @@ module PuppetDebugger
|
|
62
64
|
namespace = nil
|
63
65
|
name = nil
|
64
66
|
if file =~ /\.pp/
|
65
|
-
File.readlines(file, :
|
67
|
+
File.readlines(file, encoding: 'UTF-8').find do |line|
|
66
68
|
# TODO: not getting namespace for functio
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
next unless line.match(FUNC_NATIVE_NAME_REGEX)
|
70
|
+
|
71
|
+
namespace, name = Regexp.last_match(1).split('::', 2)
|
72
|
+
name = namespace if name.nil?
|
73
|
+
namespace = '' if namespace == name
|
72
74
|
end
|
73
|
-
elsif file.include?(
|
74
|
-
File.readlines(file, :
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
elsif file.include?('lib/puppet/functions')
|
76
|
+
File.readlines(file, encoding: 'UTF-8').find do |line|
|
77
|
+
next unless line.match(FUNC_V4_NAME_REGEX)
|
78
|
+
|
79
|
+
namespace, name = Regexp.last_match(1).split('::', 2)
|
80
|
+
name = namespace if name.nil?
|
81
|
+
namespace = '' if namespace == name
|
80
82
|
end
|
81
83
|
end
|
82
84
|
name ||= File.basename(file, File.extname(file))
|
83
85
|
match = file.match('\/(?<mod>[\w\-\.]+)\/(lib|functions|manifests)')
|
84
|
-
summary_match = File.read(file, :
|
86
|
+
summary_match = File.read(file, encoding: 'UTF-8').match(/@summary\s(.*)/)
|
85
87
|
summary = summary_match[1] if summary_match
|
86
88
|
# fetch the puppet version if this is a function from puppet gem
|
87
89
|
captures = file.match(/(puppet-[\d\.]+)/)
|
@@ -106,15 +108,15 @@ module PuppetDebugger
|
|
106
108
|
# in the future we may want to utilize the puppet loaders to find these things
|
107
109
|
def function_files
|
108
110
|
search_dirs = lib_dirs.map do |lib_dir|
|
109
|
-
[File.join(lib_dir,
|
110
|
-
File.join(lib_dir,
|
111
|
-
File.join(File.dirname(lib_dir),
|
112
|
-
File.join(lib_dir,
|
111
|
+
[File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'),
|
112
|
+
File.join(lib_dir, 'functions', '**', '*.rb'),
|
113
|
+
File.join(File.dirname(lib_dir), 'functions', '**', '*.pp'),
|
114
|
+
File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
|
113
115
|
end
|
114
116
|
|
115
117
|
# add puppet lib directories
|
116
|
-
search_dirs << [File.join(puppet_lib_dir,
|
117
|
-
File.join(puppet_lib_dir,
|
118
|
+
search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'),
|
119
|
+
File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
|
118
120
|
Dir.glob(search_dirs.flatten)
|
119
121
|
end
|
120
122
|
end
|