puppet-repl 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/lib/puppet-repl/cli.rb +2 -3
- data/lib/puppet-repl/repl_code.rb +12 -6
- data/lib/puppet-repl/support.rb +6 -2
- data/lib/puppet-repl/support/input_responders.rb +8 -1
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 408591cb70bc73f12741cabe810d1f58e07a22fd
|
4
|
+
data.tar.gz: a3ab223176561bb31ef3ad0ea22835d30d57e8cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbf76410d58fcf91583aae4e2106be760a1e8618094610e7bbc793231e66fe5814a8b062e38825366efb1ffd50eb0cf8d0af8d07e5192c1243585e81ad0417f0
|
7
|
+
data.tar.gz: fb82f8c440e493467740582e554378a4e2c8f3e7f334f631164a28c73aad6e66fa1c5f734b41c1894561e0fcf146a93715f16a8316e43239abc65bd6d870c527
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/puppet-repl/cli.rb
CHANGED
@@ -186,6 +186,7 @@ Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "clas
|
|
186
186
|
rescue Puppet::ParseErrorWithIssue => e
|
187
187
|
if multiline_input?(e)
|
188
188
|
out_buffer.print ' '
|
189
|
+
full_buffer += "\n"
|
189
190
|
next
|
190
191
|
end
|
191
192
|
end
|
@@ -203,11 +204,9 @@ Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "clas
|
|
203
204
|
repl_obj.remote_node_name = options[:node_name] if options[:node_name]
|
204
205
|
repl_obj.initialize_from_scope(options[:scope])
|
205
206
|
puts repl_obj.whereami if options[:source_file] and options[:source_line]
|
206
|
-
# helper code to make tests exit the loop
|
207
|
-
repl_obj.read_loop unless options[:run_once]
|
208
207
|
if options[:play]
|
209
208
|
repl_obj.play_back(options)
|
210
|
-
|
209
|
+
elsif ! options[:run_once]
|
211
210
|
repl_obj.read_loop
|
212
211
|
end
|
213
212
|
end
|
@@ -21,12 +21,18 @@ require_relative 'code/code_file'
|
|
21
21
|
# @param [Symbol] code_type The type of code the file contains.
|
22
22
|
# @return [Code]
|
23
23
|
def from_file(filename, code_type = nil)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
code_file = CodeFile.new(filename, code_type)
|
25
|
+
new(code_file.code, 1, code_file.code_type)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Instantiate a `Code` object containing code loaded from a file or
|
29
|
+
# Pry's line buffer.
|
30
|
+
#
|
31
|
+
# @param [String] source code".
|
32
|
+
# @param [Symbol] code_type The type of code the file contains.
|
33
|
+
# @return [Code]
|
34
|
+
def from_string(code, code_type = nil)
|
35
|
+
new(code, 1, code_type)
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
data/lib/puppet-repl/support.rb
CHANGED
@@ -139,10 +139,14 @@ module PuppetRepl
|
|
139
139
|
# in order to add functions to the scope the loaders must be created
|
140
140
|
# in order to call native functions we need to set the global_scope
|
141
141
|
ast = generate_ast(input)
|
142
|
-
|
142
|
+
# record the input for puppet to retrieve and reference later
|
143
|
+
File.open('.puppet_repl_input.pp', 'w') do |f|
|
144
|
+
f.write(input)
|
145
|
+
end
|
146
|
+
Puppet.override( {:code => input, :global_scope => scope, :loaders => scope.compiler.loaders } , 'For puppet-repl') do
|
143
147
|
# because the repl is not a module we leave the modname blank
|
144
148
|
scope.environment.known_resource_types.import_ast(ast, '')
|
145
|
-
parser.evaluate_string(scope, input)
|
149
|
+
parser.evaluate_string(scope, input, File.expand_path('.puppet_repl_input.pp'))
|
146
150
|
end
|
147
151
|
end
|
148
152
|
|
@@ -15,11 +15,18 @@ module PuppetRepl
|
|
15
15
|
file=@source_file
|
16
16
|
line_num=@source_line_num
|
17
17
|
if file and line_num
|
18
|
-
|
18
|
+
if file == :code
|
19
|
+
source_code = Puppet[:code]
|
20
|
+
code = ReplCode.from_string(source_code, :puppet)
|
21
|
+
else
|
22
|
+
code = ReplCode.from_file(file, :puppet)
|
23
|
+
end
|
19
24
|
return code.with_marker(line_num).around(line_num, 5).with_line_numbers.with_indentation(5).to_s
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
28
|
+
# displays the facterdb filter
|
29
|
+
# @param [Array] - args is not used
|
23
30
|
def facterdb_filter(args=[])
|
24
31
|
dynamic_facterdb_filter.ai
|
25
32
|
end
|
data/lib/version.rb
CHANGED