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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca90b4e2bd2667abaceead15b141c87b712aea32
4
- data.tar.gz: 20aedb19e5dd5e93b62faf0438f47d7619a20e5a
3
+ metadata.gz: 408591cb70bc73f12741cabe810d1f58e07a22fd
4
+ data.tar.gz: a3ab223176561bb31ef3ad0ea22835d30d57e8cb
5
5
  SHA512:
6
- metadata.gz: 9dc96e79ff9bd8a348b0cf64d81cb857a38656e4d19a91e6d8a7d325eff7e5c6fa11f0ac3e01fcc178348986d5701f0677b0a1f84d3d502b66ddf2b07cc9da24
7
- data.tar.gz: 3a5f8b6056dcf2d63101c25ea30765bf74a63a158211f72d8f3be45289683cdb5a8d653a768cad6b991ada7a5c353acaabdb8a19463295baef1155fc35455646
6
+ metadata.gz: dbf76410d58fcf91583aae4e2106be760a1e8618094610e7bbc793231e66fe5814a8b062e38825366efb1ffd50eb0cf8d0af8d07e5192c1243585e81ad0417f0
7
+ data.tar.gz: fb82f8c440e493467740582e554378a4e2c8f3e7f334f631164a28c73aad6e66fa1c5f734b41c1894561e0fcf146a93715f16a8316e43239abc65bd6d870c527
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  # rcov generated
2
+ .puppet_repl_input*
2
3
  local_test_results
3
4
  bundle
4
5
  bundler
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.3
2
+ * Adds ability to call breakpoints from within repl
3
+ * Adds newline for each multiline input
1
4
  ## 0.3.2
2
5
  * Fixes #31 - adds ability to show surrounding code
3
6
  ## 0.3.1
@@ -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
- else
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
- if filename == :code
25
- new(Puppet[:code], 1, code_type)
26
- else
27
- code_file = CodeFile.new(filename, code_type)
28
- new(code_file.code, 1, code_file.code_type)
29
- end
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
 
@@ -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
- Puppet.override( {:global_scope => scope, :loaders => scope.compiler.loaders } , 'For puppet-repl') do
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
- code = ReplCode.from_file(file, :puppet)
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
@@ -1,3 +1,3 @@
1
1
  module PuppetRepl
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman