puppet-repl 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/puppet-repl/cli.rb +1 -1
- data/lib/puppet-repl/support.rb +3 -20
- data/lib/version.rb +1 -1
- data/puppet-repl.gemspec +1 -1
- data/spec/puppet-repl_spec.rb +17 -1
- data/spec/support_spec.rb +2 -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: fca43c00cf702ad994bc3395a543372b20b7478e
|
4
|
+
data.tar.gz: a12d76da5da680e202faff71c4e6dba21c760943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e285235f53e3aa78b1617ba646b3967169858bc5d4046dddb8d0e94fe42d550ffd8cd2517362249ba6325d76236f47efb02bb302914da1c2b7d78a2b4148f879
|
7
|
+
data.tar.gz: 17fd10ecc0a1b30d9f64e855d6e21455408377d7c4bc7b50d7bab79427e692e9daeee1933e02654e79027737fc275fb45a1c123b5457acea6f1505c5b9985da5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/puppet-repl/cli.rb
CHANGED
@@ -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", "
|
61
|
+
Type "exit", "functions", "facts", "reset", "help" for more information.
|
62
62
|
|
63
63
|
EOT
|
64
64
|
end
|
data/lib/puppet-repl/support.rb
CHANGED
@@ -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 =
|
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
data/puppet-repl.gemspec
CHANGED
data/spec/puppet-repl_spec.rb
CHANGED
@@ -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.
|
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