puppet-debugger 0.10.3 → 0.11.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 +16 -74
- data/.rubocop_todo.yml +59 -59
- data/.ruby-version +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile +3 -2
- data/lib/plugins/puppet-debugger/input_responders/functions.rb +100 -1
- data/lib/puppet-debugger/cli.rb +1 -2
- data/lib/puppet-debugger/input_responder_plugin.rb +8 -1
- data/lib/puppet-debugger/support.rb +14 -2
- data/lib/puppet-debugger/version.rb +1 -1
- data/puppet-debugger.gemspec +2 -0
- data/spec/fixtures/modules/extlib/.editorconfig +14 -0
- data/spec/fixtures/modules/extlib/.fixtures.yml +3 -0
- data/spec/fixtures/modules/extlib/.github/CONTRIBUTING.md +184 -0
- data/spec/fixtures/modules/extlib/.github/ISSUE_TEMPLATE.md +26 -0
- data/spec/fixtures/modules/extlib/.github/PULL_REQUEST_TEMPLATE.md +20 -0
- data/spec/fixtures/modules/extlib/.gitignore +21 -0
- data/spec/fixtures/modules/extlib/.msync.yml +1 -0
- data/spec/fixtures/modules/extlib/.overcommit.yml +64 -0
- data/spec/fixtures/modules/extlib/.pmtignore +21 -0
- data/spec/fixtures/modules/extlib/.rspec +2 -0
- data/spec/fixtures/modules/extlib/.rspec_parallel +1 -0
- data/spec/fixtures/modules/extlib/.rubocop.yml +545 -0
- data/spec/fixtures/modules/extlib/.sync.yml +12 -0
- data/spec/fixtures/modules/extlib/.travis.yml +47 -0
- data/spec/fixtures/modules/extlib/.yardopts +2 -0
- data/spec/fixtures/modules/extlib/Gemfile +82 -0
- data/spec/fixtures/modules/extlib/Rakefile +82 -0
- data/spec/fixtures/modules/extlib/functions/dir_split.pp +25 -0
- data/spec/fixtures/modules/extlib/functions/file_separator.pp +7 -0
- data/spec/fixtures/modules/extlib/functions/mkdir_p.pp +20 -0
- data/spec/fixtures/modules/extlib/functions/path_join.pp +29 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/cache_data.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/default_content.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/dump_args.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/echo.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/cache_data.rb +48 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/default_content.rb +37 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/dump_args.rb +20 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/echo.rb +45 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/has_module.rb +33 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/ip_to_cron.rb +39 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/random_password.rb +63 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/resources_deep_merge.rb +87 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/extlib/sort_by_version.rb +15 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/ip_to_cron.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/random_password.rb +11 -0
- data/spec/fixtures/modules/extlib/lib/puppet/functions/resources_deep_merge.rb +11 -0
- data/spec/fixtures/modules/extlib/metadata.json +66 -0
- data/spec/input_responder_plugin_spec.rb +1 -1
- data/spec/input_responders/functions_spec.rb +46 -1
- data/spec/spec_helper.rb +5 -5
- data/spec/support_spec.rb +0 -8
- metadata +69 -4
- data/lib/puppet-debugger/support/functions.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e98e90f35a13e50b2b3f02e7c8b5aa590daa90b31df68a868403fba0399ef35e
|
4
|
+
data.tar.gz: 10bee3e410b82be3c5ff0f8134b6ac1fb8c38cfc2a1d21a10bbd214059ba6434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4ab1e0c51864faf1f53ac54b7a54f158e74e446888b6671a1d51ec48a8fb316b15419330d98d8e350b0e7df2875e47c3d88c840bd6b72e1679fc2ae5eb89a00
|
7
|
+
data.tar.gz: 6185292e9b63138cee9727c78d305e8ed00e463ba43b27a44d0ff7b0e42c0d76d098263a8a6987b771f89d561950fc5cc0eac8c637e332c53d69692c2dce11cf
|
data/.gitlab-ci.yml
CHANGED
@@ -58,14 +58,13 @@ bump_and_tag:
|
|
58
58
|
# script:
|
59
59
|
# - "curl -X POST -F token=$PREPL_BUILD_TRIGGER_TOKEN -F ref=$REF https://gitlab.com/api/v3/projects/1146764/trigger/builds"
|
60
60
|
|
61
|
-
.ruby_20: &ruby20
|
62
|
-
image: ruby:2.0
|
63
|
-
|
64
|
-
.ruby_21: &ruby21
|
65
|
-
image: ruby:2.1
|
66
|
-
|
67
61
|
.ruby_22: &ruby22
|
68
62
|
image: ruby:2.2
|
63
|
+
script:
|
64
|
+
- gem install bundler -v 1.17.3 > /dev/null
|
65
|
+
- bundle install --without development validate
|
66
|
+
- bundle exec puppet module install puppetlabs-stdlib
|
67
|
+
- bundle exec rake spec
|
69
68
|
|
70
69
|
.ruby_23: &ruby23
|
71
70
|
image: ruby:2.3
|
@@ -76,8 +75,12 @@ bump_and_tag:
|
|
76
75
|
.ruby_25: &ruby25
|
77
76
|
image: ruby:2.5
|
78
77
|
|
78
|
+
|
79
|
+
.ruby_25: &ruby26
|
80
|
+
image: ruby:2.6
|
81
|
+
|
79
82
|
gem_production:
|
80
|
-
image: ruby:2.
|
83
|
+
image: ruby:2.5
|
81
84
|
tags:
|
82
85
|
- ruby
|
83
86
|
before_script:
|
@@ -88,54 +91,18 @@ gem_production:
|
|
88
91
|
only:
|
89
92
|
- tags
|
90
93
|
|
91
|
-
puppet_38_ruby20:
|
92
|
-
variables:
|
93
|
-
PUPPET_GEM_VERSION: "~> 3.8.0"
|
94
|
-
<<: *puppet_job_def
|
95
|
-
<<: *ruby20
|
96
|
-
|
97
|
-
puppet_38_ruby21:
|
98
|
-
variables:
|
99
|
-
PUPPET_GEM_VERSION: "~> 3.8.0"
|
100
|
-
<<: *puppet_job_def
|
101
|
-
<<: *ruby21
|
102
|
-
|
103
|
-
puppet_43_ruby20:
|
104
|
-
variables:
|
105
|
-
PUPPET_GEM_VERSION: "~> 4.3.0"
|
106
|
-
<<: *puppet_job_def
|
107
|
-
<<: *ruby20
|
108
|
-
|
109
|
-
puppet_43_ruby21:
|
110
|
-
variables:
|
111
|
-
PUPPET_GEM_VERSION: "~> 4.3.0"
|
112
|
-
<<: *puppet_job_def
|
113
|
-
<<: *ruby21
|
114
|
-
|
115
94
|
puppet_43_ruby22:
|
116
95
|
variables:
|
117
96
|
PUPPET_GEM_VERSION: "~> 4.3.0"
|
118
97
|
<<: *puppet_job_def
|
119
98
|
<<: *ruby22
|
120
99
|
|
121
|
-
puppet_44_ruby21:
|
122
|
-
variables:
|
123
|
-
PUPPET_GEM_VERSION: "~> 4.4.0"
|
124
|
-
<<: *puppet_job_def
|
125
|
-
<<: *ruby21
|
126
|
-
|
127
100
|
puppet_44_ruby22:
|
128
101
|
variables:
|
129
102
|
PUPPET_GEM_VERSION: "~> 4.4.0"
|
130
103
|
<<: *puppet_job_def
|
131
104
|
<<: *ruby22
|
132
105
|
|
133
|
-
puppet_45_ruby21:
|
134
|
-
variables:
|
135
|
-
PUPPET_GEM_VERSION: "~> 4.5.0"
|
136
|
-
<<: *puppet_job_def
|
137
|
-
<<: *ruby21
|
138
|
-
|
139
106
|
puppet_46_ruby22:
|
140
107
|
variables:
|
141
108
|
PUPPET_GEM_VERSION: "~> 4.6.0"
|
@@ -154,37 +121,6 @@ puppet_410_ruby24:
|
|
154
121
|
<<: *puppet_job_def
|
155
122
|
<<: *ruby24
|
156
123
|
|
157
|
-
puppet_50_ruby24:
|
158
|
-
variables:
|
159
|
-
PUPPET_GEM_VERSION: "~> 5.0"
|
160
|
-
<<: *puppet_job_def
|
161
|
-
<<: *ruby24
|
162
|
-
|
163
|
-
puppet_51_ruby24:
|
164
|
-
variables:
|
165
|
-
PUPPET_GEM_VERSION: "~> 5.1"
|
166
|
-
<<: *puppet_job_def
|
167
|
-
<<: *ruby24
|
168
|
-
|
169
|
-
puppet_52_ruby24:
|
170
|
-
variables:
|
171
|
-
PUPPET_GEM_VERSION: "~> 5.2"
|
172
|
-
<<: *puppet_job_def
|
173
|
-
<<: *ruby24
|
174
|
-
|
175
|
-
puppet_53_ruby24:
|
176
|
-
variables:
|
177
|
-
PUPPET_GEM_VERSION: "~> 5.3"
|
178
|
-
<<: *puppet_job_def
|
179
|
-
<<: *ruby24
|
180
|
-
|
181
|
-
|
182
|
-
puppet_54_ruby24:
|
183
|
-
variables:
|
184
|
-
PUPPET_GEM_VERSION: "~> 5.4"
|
185
|
-
<<: *puppet_job_def
|
186
|
-
<<: *ruby24
|
187
|
-
|
188
124
|
puppet_55_ruby24:
|
189
125
|
variables:
|
190
126
|
PUPPET_GEM_VERSION: "~> 5.5"
|
@@ -196,3 +132,9 @@ puppet_60_ruby25:
|
|
196
132
|
PUPPET_GEM_VERSION: "~> 6.0"
|
197
133
|
<<: *puppet_job_def
|
198
134
|
<<: *ruby25
|
135
|
+
|
136
|
+
puppet_60_ruby25:
|
137
|
+
variables:
|
138
|
+
PUPPET_GEM_VERSION: "~> 6.4"
|
139
|
+
<<: *puppet_job_def
|
140
|
+
<<: *ruby25
|
data/.rubocop_todo.yml
CHANGED
@@ -12,12 +12,12 @@
|
|
12
12
|
# SupportedStyles: start_of_line, def
|
13
13
|
Lint/DefEndAlignment:
|
14
14
|
Exclude:
|
15
|
-
-
|
15
|
+
- "lib/puppet-debugger/support/errors.rb"
|
16
16
|
|
17
17
|
# Offense count: 1
|
18
18
|
Lint/ElseLayout:
|
19
19
|
Exclude:
|
20
|
-
-
|
20
|
+
- "lib/puppet-debugger/support/play.rb"
|
21
21
|
|
22
22
|
# Offense count: 10
|
23
23
|
# Cop supports --auto-correct.
|
@@ -25,39 +25,39 @@ Lint/ElseLayout:
|
|
25
25
|
# SupportedStyles: keyword, variable, start_of_line
|
26
26
|
Lint/EndAlignment:
|
27
27
|
Exclude:
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
28
|
+
- "lib/puppet-debugger/code/code_file.rb"
|
29
|
+
- "lib/puppet-debugger/code/code_range.rb"
|
30
|
+
- "lib/puppet-debugger/code/loc.rb"
|
31
|
+
- "lib/trollop.rb"
|
32
32
|
|
33
33
|
# Offense count: 3
|
34
34
|
Lint/HandleExceptions:
|
35
35
|
Exclude:
|
36
|
-
-
|
37
|
-
-
|
36
|
+
- "lib/puppet-debugger/support.rb"
|
37
|
+
- "lib/trollop.rb"
|
38
38
|
|
39
39
|
# Offense count: 1
|
40
40
|
Lint/NestedMethodDefinition:
|
41
41
|
Exclude:
|
42
|
-
-
|
42
|
+
- "lib/trollop.rb"
|
43
43
|
|
44
44
|
# Offense count: 1
|
45
45
|
Lint/ShadowingOuterLocalVariable:
|
46
46
|
Exclude:
|
47
|
-
-
|
47
|
+
- "lib/puppet-debugger/support/input_responders.rb"
|
48
48
|
|
49
49
|
# Offense count: 18
|
50
50
|
Lint/UselessAssignment:
|
51
51
|
Exclude:
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
52
|
+
- "lib/puppet-debugger/support.rb"
|
53
|
+
- "lib/puppet-debugger/support/environment.rb"
|
54
|
+
- "lib/puppet-debugger/support/errors.rb"
|
55
|
+
- "lib/puppet-debugger/support/functions.rb"
|
56
|
+
- "lib/puppet-debugger/support/input_responders.rb"
|
57
|
+
- "lib/puppet-debugger/support/node.rb"
|
58
|
+
- "lib/puppet-debugger/support/play.rb"
|
59
|
+
- "lib/puppet/application/debugger.rb"
|
60
|
+
- "spec/support_spec.rb"
|
61
61
|
|
62
62
|
# Offense count: 22
|
63
63
|
Metrics/AbcSize:
|
@@ -107,78 +107,78 @@ Metrics/PerceivedComplexity:
|
|
107
107
|
# Cop supports --auto-correct.
|
108
108
|
Performance/RedundantMatch:
|
109
109
|
Exclude:
|
110
|
-
-
|
110
|
+
- "lib/awesome_print/ext/awesome_puppet.rb"
|
111
111
|
|
112
112
|
# Offense count: 8
|
113
113
|
Style/AccessorMethodName:
|
114
114
|
Exclude:
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
115
|
+
- "lib/puppet-debugger/support/compiler.rb"
|
116
|
+
- "lib/puppet-debugger/support/environment.rb"
|
117
|
+
- "lib/puppet-debugger/support/facts.rb"
|
118
|
+
- "lib/puppet-debugger/support/input_responders.rb"
|
119
|
+
- "lib/puppet-debugger/support/node.rb"
|
120
|
+
- "lib/puppet-debugger/support/scope.rb"
|
121
121
|
|
122
122
|
# Offense count: 2
|
123
123
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
124
124
|
# SupportedStyles: nested, compact
|
125
125
|
Style/ClassAndModuleChildren:
|
126
126
|
Exclude:
|
127
|
-
-
|
128
|
-
-
|
127
|
+
- "lib/puppet/application/debugger.rb"
|
128
|
+
- "spec/spec_helper.rb"
|
129
129
|
|
130
130
|
# Offense count: 21
|
131
131
|
Style/Documentation:
|
132
132
|
Exclude:
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
-
|
138
|
-
-
|
139
|
-
-
|
140
|
-
-
|
141
|
-
-
|
142
|
-
-
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
133
|
+
- "spec/**/*"
|
134
|
+
- "test/**/*"
|
135
|
+
- "lib/awesome_print/ext/awesome_puppet.rb"
|
136
|
+
- "lib/puppet-debugger/cli.rb"
|
137
|
+
- "lib/puppet-debugger/code/code_file.rb"
|
138
|
+
- "lib/puppet-debugger/support.rb"
|
139
|
+
- "lib/puppet-debugger/support/compiler.rb"
|
140
|
+
- "lib/puppet-debugger/support/environment.rb"
|
141
|
+
- "lib/puppet-debugger/support/errors.rb"
|
142
|
+
- "lib/puppet-debugger/support/facts.rb"
|
143
|
+
- "lib/puppet-debugger/support/functions.rb"
|
144
|
+
- "lib/puppet-debugger/support/input_responders.rb"
|
145
|
+
- "lib/puppet-debugger/support/node.rb"
|
146
|
+
- "lib/puppet-debugger/support/play.rb"
|
147
|
+
- "lib/puppet-debugger/support/scope.rb"
|
148
|
+
- "lib/puppet/application/debugger.rb"
|
149
|
+
- "lib/trollop.rb"
|
150
150
|
|
151
151
|
# Offense count: 2
|
152
152
|
Style/DoubleNegation:
|
153
153
|
Exclude:
|
154
|
-
-
|
154
|
+
- "lib/puppet-debugger/debugger_code.rb"
|
155
155
|
|
156
156
|
# Offense count: 10
|
157
157
|
# Configuration parameters: MinBodyLength.
|
158
158
|
Style/GuardClause:
|
159
159
|
Exclude:
|
160
|
-
-
|
161
|
-
-
|
162
|
-
-
|
163
|
-
-
|
164
|
-
-
|
160
|
+
- "lib/puppet-debugger/cli.rb"
|
161
|
+
- "lib/puppet-debugger/support.rb"
|
162
|
+
- "lib/puppet-debugger/support/input_responders.rb"
|
163
|
+
- "lib/puppet-debugger/support/play.rb"
|
164
|
+
- "lib/trollop.rb"
|
165
165
|
- puppet-debugger.gemspec
|
166
166
|
|
167
167
|
# Offense count: 2
|
168
168
|
Style/IdenticalConditionalBranches:
|
169
169
|
Exclude:
|
170
|
-
-
|
170
|
+
- "lib/puppet-debugger/support/play.rb"
|
171
171
|
|
172
172
|
# Offense count: 2
|
173
173
|
Style/MethodMissing:
|
174
174
|
Exclude:
|
175
|
-
-
|
176
|
-
-
|
175
|
+
- "lib/puppet-debugger/debugger_code.rb"
|
176
|
+
- "lib/trollop.rb"
|
177
177
|
|
178
178
|
# Offense count: 1
|
179
179
|
Style/MultilineTernaryOperator:
|
180
180
|
Exclude:
|
181
|
-
-
|
181
|
+
- "lib/puppet/application/debugger.rb"
|
182
182
|
|
183
183
|
# Offense count: 2
|
184
184
|
# Cop supports --auto-correct.
|
@@ -186,8 +186,8 @@ Style/MultilineTernaryOperator:
|
|
186
186
|
# SupportedStyles: predicate, comparison
|
187
187
|
Style/NumericPredicate:
|
188
188
|
Exclude:
|
189
|
-
-
|
190
|
-
-
|
189
|
+
- "spec/**/*"
|
190
|
+
- "lib/puppet-debugger/code/code_range.rb"
|
191
191
|
|
192
192
|
# Offense count: 3
|
193
193
|
# Cop supports --auto-correct.
|
@@ -195,11 +195,11 @@ Style/NumericPredicate:
|
|
195
195
|
# SupportedStyles: slashes, percent_r, mixed
|
196
196
|
Style/RegexpLiteral:
|
197
197
|
Exclude:
|
198
|
-
-
|
198
|
+
- "spec/puppet_debugger_spec.rb"
|
199
199
|
|
200
200
|
# Offense count: 1
|
201
201
|
# Cop supports --auto-correct.
|
202
202
|
# Configuration parameters: AllowAsExpressionSeparator.
|
203
203
|
Style/Semicolon:
|
204
204
|
Exclude:
|
205
|
-
-
|
205
|
+
- "lib/puppet/application/debugger.rb"
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.11.0
|
4
|
+
|
5
|
+
- Fixes native functions not shown in functions command
|
6
|
+
- Prints functions into a table with proper namespace shown
|
7
|
+
- Adds table print gem
|
8
|
+
- Adds rb-readline for universal readline support on all platforms
|
9
|
+
|
3
10
|
## 0.10.3
|
4
11
|
|
5
12
|
- Remove warning message about incorrect version
|
data/Gemfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
source 'http://rubygems.org'
|
3
3
|
gem 'awesome_print', '~> 1.7'
|
4
|
-
gem 'facterdb', '>= 0.
|
4
|
+
gem 'facterdb', '>= 0.5.0'
|
5
5
|
gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 4.10.1'
|
6
6
|
gem 'pluginator', '~> 1.5.0'
|
7
|
-
|
7
|
+
gem 'rb-readline'
|
8
|
+
gem 'table_print'
|
8
9
|
group :test, :development do
|
9
10
|
# ruby versions prior to 2.0 cannot install json_pure 2.0.2+
|
10
11
|
gem 'bundler'
|
@@ -1,15 +1,114 @@
|
|
1
1
|
require 'puppet-debugger/input_responder_plugin'
|
2
|
+
require 'table_print'
|
3
|
+
|
2
4
|
module PuppetDebugger
|
3
5
|
module InputResponders
|
4
6
|
class Functions < InputResponderPlugin
|
5
7
|
COMMAND_WORDS = %w(functions)
|
6
8
|
SUMMARY = 'List all the functions available in the environment.'
|
7
9
|
COMMAND_GROUP = :environment
|
10
|
+
FUNC_NATIVE_NAME_REGEX = %r{\Afunction\s([\w\:]+)}
|
11
|
+
FUNC_V4_NAME_REGEX = %r{Puppet\:\:Functions.create_function\s?\(?\:?\'?([\w\:]+)}
|
8
12
|
|
9
13
|
def run(args = [])
|
10
14
|
filter = args.first || ''
|
11
|
-
|
15
|
+
TablePrint::Printer.table_print(sorted_list(filter), [:full_name, :mod_name])
|
16
|
+
end
|
17
|
+
|
18
|
+
def sorted_list(filter = '')
|
19
|
+
search = /#{Regexp.escape(filter)}/
|
20
|
+
function_map.values.find_all do | v|
|
21
|
+
"#{v[:mod_name]}_#{v[:full_name]}" =~ search
|
22
|
+
end.sort {|a,b| a[:full_name] <=> b[:full_name]}
|
23
|
+
end
|
24
|
+
|
25
|
+
# append a () to functions so we know they are functions
|
26
|
+
def func_list
|
27
|
+
# ideally we should get a list of function names via the puppet loader
|
28
|
+
function_map.map { |name, metadata| "#{metadata[:full_name]}()" }
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash] - a map of all the functions
|
32
|
+
def function_map
|
33
|
+
functions = {}
|
34
|
+
function_files.each do |file|
|
35
|
+
obj = function_obj(file)
|
36
|
+
# return the last matched in cases where rbenv might be involved
|
37
|
+
functions[obj[:full_name]] = obj
|
38
|
+
end
|
39
|
+
functions
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def lib_dirs(module_dirs = modules_paths)
|
44
|
+
dirs = module_dirs.map do |mod_dir|
|
45
|
+
Dir["#{mod_dir}/*/lib"].entries
|
46
|
+
end.flatten
|
47
|
+
dirs + [puppet_debugger_lib_dir]
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# @return [Array] - returns a array of the parentname and function name
|
52
|
+
def function_obj(file)
|
53
|
+
namespace = nil
|
54
|
+
name = nil
|
55
|
+
if file =~ /\.pp/
|
56
|
+
File.readlines(file, :encoding => 'UTF-8').find do |line|
|
57
|
+
# TODO: not getting namespace for functio
|
58
|
+
if line.match(FUNC_NATIVE_NAME_REGEX)
|
59
|
+
namespace, name = $1.split('::', 2)
|
60
|
+
name = namespace if name.nil?
|
61
|
+
namespace = '' if namespace == name
|
62
|
+
end
|
63
|
+
end
|
64
|
+
elsif file.include?('lib/puppet/functions')
|
65
|
+
File.readlines(file, :encoding => 'UTF-8').find do |line|
|
66
|
+
if line.match(FUNC_V4_NAME_REGEX)
|
67
|
+
namespace, name = $1.split('::', 2)
|
68
|
+
name = namespace if name.nil?
|
69
|
+
namespace = '' if namespace == name
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
name ||= File.basename(file, File.extname(file))
|
74
|
+
match = file.match('\/(?<mod>[\w\-\.]+)\/(lib|functions|manifests)')
|
75
|
+
summary_match = File.read(file, :encoding => 'UTF-8').match(/@summary\s(.*)/)
|
76
|
+
summary = summary_match[1] if summary_match
|
77
|
+
|
78
|
+
# match = file.match('(?<mod>\w+)\/functions|manifests|lib')
|
79
|
+
mod_name = match[:mod] unless match.nil?
|
80
|
+
full_name = namespace.nil? || namespace.empty? ? name : name.prepend("#{namespace}::")
|
81
|
+
{namespace: namespace, summary: summary, mod_name: mod_name, name: name, full_name: full_name, file: file}
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# load all the lib dirs so puppet can find the functions
|
87
|
+
# at this time, this function is not being used
|
88
|
+
def load_lib_dirs(module_dirs = modules_paths)
|
89
|
+
lib_dirs(module_dirs).each do |lib|
|
90
|
+
$LOAD_PATH << lib
|
91
|
+
end
|
12
92
|
end
|
93
|
+
|
94
|
+
# returns a array of function files which is only required
|
95
|
+
# when displaying the function map, puppet will load each function on demand
|
96
|
+
# in the future we may want to utilize the puppet loaders to find these things
|
97
|
+
def function_files
|
98
|
+
search_dirs = lib_dirs.map do |lib_dir|
|
99
|
+
[File.join(lib_dir, 'puppet', 'functions', '**', '*.rb'),
|
100
|
+
File.join(lib_dir, 'functions', '**', '*.rb'),
|
101
|
+
File.join(File.dirname(lib_dir), 'functions', '**', '*.pp'),
|
102
|
+
File.join(lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
|
103
|
+
end
|
104
|
+
|
105
|
+
# add puppet lib directories
|
106
|
+
search_dirs << [File.join(puppet_lib_dir, 'puppet', 'functions', '**', '*.rb'),
|
107
|
+
File.join(puppet_lib_dir, 'puppet', 'parser', 'functions', '*.rb')]
|
108
|
+
Dir.glob(search_dirs.flatten)
|
109
|
+
end
|
110
|
+
|
111
|
+
|
13
112
|
end
|
14
113
|
end
|
15
114
|
end
|
data/lib/puppet-debugger/cli.rb
CHANGED
@@ -69,8 +69,7 @@ module PuppetDebugger
|
|
69
69
|
variables = scope.to_hash.keys
|
70
70
|
# prepend a :: to topscope variables
|
71
71
|
scoped_vars = variables.map { |k, _v| scope.compiler.topscope.exist?(k) ? "$::#{k}" : "$#{k}" }
|
72
|
-
|
73
|
-
funcs = function_map.keys.map { |k| "#{k.split('::').last}()" }
|
72
|
+
funcs = PuppetDebugger::InputResponders::Functions.instance.func_list
|
74
73
|
PuppetDebugger::InputResponders::Datatypes.instance.debugger = self
|
75
74
|
(scoped_vars + funcs + static_responder_list + PuppetDebugger::InputResponders::Datatypes.instance.all_data_types).uniq.sort
|
76
75
|
end
|
@@ -8,7 +8,7 @@ module PuppetDebugger
|
|
8
8
|
extend Forwardable
|
9
9
|
attr_accessor :debugger
|
10
10
|
def_delegators :debugger, :scope, :node, :environment, :loaders, :puppet_environment,
|
11
|
-
:add_hook, :handle_input, :delete_hook, :
|
11
|
+
:add_hook, :handle_input, :delete_hook, :puppet_lib_dir, :modules_paths
|
12
12
|
def_delegators :scope, :compiler, :catalog
|
13
13
|
def_delegators :node, :facts
|
14
14
|
|
@@ -53,5 +53,12 @@ module PuppetDebugger
|
|
53
53
|
def run(args = [])
|
54
54
|
raise NotImplementedError
|
55
55
|
end
|
56
|
+
|
57
|
+
# this is the lib directory of this gem
|
58
|
+
# in order to load any puppet functions from this gem we need to add the lib path
|
59
|
+
# of this gem
|
60
|
+
def puppet_debugger_lib_dir
|
61
|
+
File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib'))
|
62
|
+
end
|
56
63
|
end
|
57
64
|
end
|
@@ -15,7 +15,6 @@ module PuppetDebugger
|
|
15
15
|
include PuppetDebugger::Support::Environment
|
16
16
|
include PuppetDebugger::Support::Facts
|
17
17
|
include PuppetDebugger::Support::Scope
|
18
|
-
include PuppetDebugger::Support::Functions
|
19
18
|
include PuppetDebugger::Support::Node
|
20
19
|
include PuppetDebugger::Support::Loader
|
21
20
|
|
@@ -44,14 +43,27 @@ module PuppetDebugger
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
46
|
+
def lib_dirs(module_dirs = modules_paths)
|
47
|
+
dirs = module_dirs.map do |mod_dir|
|
48
|
+
Dir["#{mod_dir}/*/lib"].entries
|
49
|
+
end.flatten
|
50
|
+
dirs + [puppet_debugger_lib_dir]
|
51
|
+
end
|
52
|
+
|
47
53
|
def static_responder_list
|
48
54
|
PuppetDebugger::InputResponders::Commands.command_list
|
49
55
|
end
|
50
56
|
|
57
|
+
# returns either the module name or puppet version
|
58
|
+
def mod_finder
|
59
|
+
@mod_finder ||= Regexp.new('\/([\w\-\.]+)\/lib')
|
60
|
+
end
|
61
|
+
|
51
62
|
# this is the lib directory of this gem
|
52
63
|
# in order to load any puppet functions from this gem we need to add the lib path
|
53
64
|
# of this gem
|
54
|
-
|
65
|
+
# @deprecated
|
66
|
+
def puppet_debugger_lib_dir
|
55
67
|
File.expand_path(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib'))
|
56
68
|
end
|
57
69
|
|
data/puppet-debugger.gemspec
CHANGED
@@ -30,7 +30,9 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.licenses = ["MIT"]
|
31
31
|
s.rubygems_version = "2.4.5.1"
|
32
32
|
s.summary = "A repl based debugger for the puppet language"
|
33
|
+
s.add_runtime_dependency(%q<table_print>, [">= 1.0.0"])
|
33
34
|
s.add_runtime_dependency(%q<pluginator>, ["~> 1.5.0"])
|
35
|
+
s.add_runtime_dependency(%q<rb-readline>, ['>= 0.5.5'])
|
34
36
|
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
35
37
|
s.add_runtime_dependency(%q<facterdb>, [">= 0.4.0"])
|
36
38
|
s.add_runtime_dependency(%q<awesome_print>, ["~> 1.7"])
|