puppet-repl 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d5637d4132c4a51886e9ed737581c7a8f99b261
4
- data.tar.gz: 00af9d2c0e0ad195268e6d35545ad8ab67627d1d
3
+ metadata.gz: fca43c00cf702ad994bc3395a543372b20b7478e
4
+ data.tar.gz: a12d76da5da680e202faff71c4e6dba21c760943
5
5
  SHA512:
6
- metadata.gz: 46953cae49824a46ef5d0b86c5766790f8e5395bfda8805f4467146599d8e7750a275c97bd2edfca23972302a59ef46a2d00d5ea273559c7890c8cac1117d737
7
- data.tar.gz: fceeea3fff2318bce930f6d722313a293c558c6b8f4cc2ac72410f0cb2f315fa670db5573be592a14d737dc832a00a806f5c993425e3ee842381facf8971a164
6
+ metadata.gz: e285235f53e3aa78b1617ba646b3967169858bc5d4046dddb8d0e94fe42d550ffd8cd2517362249ba6325d76236f47efb02bb302914da1c2b7d78a2b4148f879
7
+ data.tar.gz: 17fd10ecc0a1b30d9f64e855d6e21455408377d7c4bc7b50d7bab79427e692e9daeee1933e02654e79027737fc275fb45a1c123b5457acea6f1505c5b9985da5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -58,7 +58,7 @@ Ruby Version: #{RUBY_VERSION}
58
58
  Puppet Version: #{Puppet.version}
59
59
  Puppet Repl Version: #{PuppetRepl::VERSION}
60
60
  Created by: NWOps <corey@nwops.io>
61
- Type "exit", "functions", "types", "reset", "help" for more information.
61
+ Type "exit", "functions", "facts", "reset", "help" for more information.
62
62
 
63
63
  EOT
64
64
  end
@@ -26,24 +26,6 @@ module PuppetRepl
26
26
  @puppet_lib_dir ||= File.dirname(Puppet.method(:[]).source_location.first)
27
27
  end
28
28
 
29
- def new_parser
30
- @new_parser ||= Puppet::Parser::ParserFactory.parser
31
- # setting the file and string results in evaulting the string
32
- # setting the file and not the string results in evaulting the file
33
- @new_parser.file = 'repl'
34
- #this defines what to parse, and where it came from (can use ‘repl’ as the filename)
35
- @new_parser
36
- end
37
-
38
- def puppet_evaluate(input)
39
- new_parser.string = input
40
- result = new_parser.parse
41
- #- this creates the top level definitions
42
- # repl is just a fake name for the module
43
- #result = result.instantiate('repl')
44
- result.safeevaluate(scope) #- this evaluates and returns the result
45
- end
46
-
47
29
  # returns a array of function files
48
30
  def function_files
49
31
  search_dirs = lib_dirs.map do |lib_dir|
@@ -135,10 +117,11 @@ module PuppetRepl
135
117
  end
136
118
 
137
119
  def create_scope
138
- @compiler = create_compiler(node)
120
+ @compiler = create_compiler(node) # creates a new compiler for each scope
139
121
  scope = Puppet::Parser::Scope.new(compiler)
140
122
  scope.source = Puppet::Resource::Type.new(:node, node.name)
141
- scope.parent = @compiler.topscope
123
+ scope.parent = compiler.topscope
124
+ load_lib_dirs
142
125
  compiler.compile # this will load everything into the scope
143
126
  scope
144
127
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PuppetRepl
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/puppet-repl.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "puppet-repl"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Corey Osman"]
@@ -14,7 +14,7 @@ describe "PuppetRepl" do
14
14
  'help'
15
15
  end
16
16
  it 'can show the help screen' do
17
- repl_output = "Ruby Version: #{RUBY_VERSION}\nPuppet Version: 4.3.2\nPuppet Repl Version: 0.0.3\nCreated by: NWOps <corey@nwops.io>\nType \"exit\", \"functions\", \"types\", \"reset\", \"help\" for more information.\n\n"
17
+ repl_output = "Ruby Version: #{RUBY_VERSION}\nPuppet Version: 4.3.2\nPuppet Repl Version: 0.0.4\nCreated by: NWOps <corey@nwops.io>\nType \"exit\", \"functions\", \"facts\", \"reset\", \"help\" for more information.\n\n"
18
18
  expect{repl.handle_input(input)}.to output(repl_output).to_stdout
19
19
  end
20
20
  end
@@ -92,4 +92,20 @@ describe "PuppetRepl" do
92
92
  expect{repl.handle_input(input)}.to output(/"kernel": "Linux"/).to_stdout
93
93
  end
94
94
  end
95
+
96
+ describe 'execute functions' do
97
+ let(:input) do
98
+ "md5('hello')"
99
+ end
100
+ it 'should be able to print facts' do
101
+ sum = " => 5d41402abc4b2a76b9719d911017c592\n"
102
+ expect{repl.handle_input(input)}.to output(sum).to_stdout
103
+ end
104
+ it 'should be able to print facts' do
105
+ output = " => HELLO\n"
106
+ expect{repl.handle_input("swapcase(hello)")}.to output(output).to_stdout
107
+ end
108
+
109
+ end
110
+
95
111
  end
data/spec/support_spec.rb CHANGED
@@ -42,5 +42,6 @@ describe 'support' do
42
42
  expect(repl.facts[:fqdn]).to eq('foo.example.com')
43
43
  end
44
44
 
45
-
45
+
46
+
46
47
  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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman