puppet-repl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +97 -0
- data/LICENSE.txt +20 -0
- data/README.md +84 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/bin/prepl +5 -0
- data/lib/puppet-repl/cli.rb +106 -0
- data/lib/puppet-repl.rb +2 -0
- data/lib/version.rb +3 -0
- data/puppet-repl.gemspec +76 -0
- data/spec/puppet-repl_spec.rb +61 -0
- data/spec/spec_helper.rb +31 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f50d114eed718108fb705d0a03a06afcc2e44a94
|
4
|
+
data.tar.gz: 37e67568fffa41aeec376da36f2d7b50453965d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c1d732e9ddc6878fbb875b818b67fe3eeaf04cc17492dd2a7eb78f611c619f80c9559434815d03691f44463e6d63c6b53f692a13e21c3b32314d11f9429d143f
|
7
|
+
data.tar.gz: b7673de9a0f6fc739230f8e4f2881495a93fc56eb346205d347a9354b32dfdcdc766eb5d5200534a80efebd03d332ae65af4f561100cf5f0308a6a5a80d3db2a
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem 'puppet', ">= 3.8"
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec"
|
10
|
+
gem 'pry'
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler"
|
13
|
+
gem "jeweler", "~> 2.0.1"
|
14
|
+
gem "simplecov", ">= 0"
|
15
|
+
gem 'rake'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
CFPropertyList (2.2.8)
|
5
|
+
addressable (2.4.0)
|
6
|
+
builder (3.2.2)
|
7
|
+
coderay (1.1.0)
|
8
|
+
descendants_tracker (0.0.4)
|
9
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
docile (1.1.5)
|
12
|
+
facter (2.4.6)
|
13
|
+
CFPropertyList (~> 2.2.6)
|
14
|
+
faraday (0.9.2)
|
15
|
+
multipart-post (>= 1.2, < 3)
|
16
|
+
git (1.2.9.1)
|
17
|
+
github_api (0.13.1)
|
18
|
+
addressable (~> 2.4.0)
|
19
|
+
descendants_tracker (~> 0.0.4)
|
20
|
+
faraday (~> 0.8, < 0.10)
|
21
|
+
hashie (>= 3.4)
|
22
|
+
multi_json (>= 1.7.5, < 2.0)
|
23
|
+
oauth2
|
24
|
+
hashie (3.4.3)
|
25
|
+
hiera (3.0.6)
|
26
|
+
json_pure
|
27
|
+
highline (1.7.8)
|
28
|
+
jeweler (2.0.1)
|
29
|
+
builder
|
30
|
+
bundler (>= 1.0)
|
31
|
+
git (>= 1.2.5)
|
32
|
+
github_api
|
33
|
+
highline (>= 1.6.15)
|
34
|
+
nokogiri (>= 1.5.10)
|
35
|
+
rake
|
36
|
+
rdoc
|
37
|
+
json (1.8.3)
|
38
|
+
json_pure (1.8.3)
|
39
|
+
jwt (1.5.1)
|
40
|
+
method_source (0.8.2)
|
41
|
+
mini_portile2 (2.0.0)
|
42
|
+
multi_json (1.11.2)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.6.7.2)
|
46
|
+
mini_portile2 (~> 2.0.0.rc2)
|
47
|
+
oauth2 (1.1.0)
|
48
|
+
faraday (>= 0.8, < 0.10)
|
49
|
+
jwt (~> 1.0, < 1.5.2)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (>= 1.2, < 3)
|
53
|
+
pry (0.10.3)
|
54
|
+
coderay (~> 1.1.0)
|
55
|
+
method_source (~> 0.8.1)
|
56
|
+
slop (~> 3.4)
|
57
|
+
puppet (4.3.2)
|
58
|
+
facter (> 2.0, < 4)
|
59
|
+
hiera (>= 2.0, < 4)
|
60
|
+
json_pure
|
61
|
+
rack (1.6.4)
|
62
|
+
rake (10.5.0)
|
63
|
+
rdoc (3.12.2)
|
64
|
+
json (~> 1.4)
|
65
|
+
rspec (3.4.0)
|
66
|
+
rspec-core (~> 3.4.0)
|
67
|
+
rspec-expectations (~> 3.4.0)
|
68
|
+
rspec-mocks (~> 3.4.0)
|
69
|
+
rspec-core (3.4.3)
|
70
|
+
rspec-support (~> 3.4.0)
|
71
|
+
rspec-expectations (3.4.0)
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
+
rspec-support (~> 3.4.0)
|
74
|
+
rspec-mocks (3.4.1)
|
75
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
76
|
+
rspec-support (~> 3.4.0)
|
77
|
+
rspec-support (3.4.1)
|
78
|
+
simplecov (0.11.2)
|
79
|
+
docile (~> 1.1.0)
|
80
|
+
json (~> 1.8)
|
81
|
+
simplecov-html (~> 0.10.0)
|
82
|
+
simplecov-html (0.10.0)
|
83
|
+
slop (3.6.0)
|
84
|
+
thread_safe (0.3.5)
|
85
|
+
|
86
|
+
PLATFORMS
|
87
|
+
ruby
|
88
|
+
|
89
|
+
DEPENDENCIES
|
90
|
+
bundler
|
91
|
+
jeweler (~> 2.0.1)
|
92
|
+
pry
|
93
|
+
puppet (>= 3.8)
|
94
|
+
rake
|
95
|
+
rdoc (~> 3.12)
|
96
|
+
rspec
|
97
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2016 Corey Osman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# puppet-repl
|
2
|
+
|
3
|
+
A interactive command line tool for evaluating the puppet language.
|
4
|
+
|
5
|
+
## Compatibility
|
6
|
+
Requires Puppet 3.8+ and only uses the future parser.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
`gem install puppet-repl`
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
Puppet-repl will only parse and evaulate your code. It will not build a catalog
|
13
|
+
and try to enforce the catalog. This has a few side affects.
|
14
|
+
|
15
|
+
1. Type and provider code will not get run.
|
16
|
+
2. Nothing is created or destroyed on your system.
|
17
|
+
|
18
|
+
`prepl`
|
19
|
+
|
20
|
+
Example Usage
|
21
|
+
```
|
22
|
+
MacBook-Pro-2/tmp % prepl
|
23
|
+
Puppet Version: 4.2.2
|
24
|
+
Puppet Repl Version: 0.0.1
|
25
|
+
Created by: NWOps <corey@nwops.io>
|
26
|
+
Type "exit", "functions", "types", "reset", "help" for more information.
|
27
|
+
|
28
|
+
>> file{'/tmp/test2': ensure => present}
|
29
|
+
=> File['/tmp/test2']
|
30
|
+
>> ['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }
|
31
|
+
=>
|
32
|
+
/tmp/test3
|
33
|
+
/tmp/test4
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
Using Variables
|
38
|
+
```
|
39
|
+
MacBook-Pro-2/tmp % prepl
|
40
|
+
Puppet Version: 4.2.2
|
41
|
+
Puppet Repl Version: 0.0.1
|
42
|
+
Created by: NWOps <corey@nwops.io>
|
43
|
+
Type "exit", "functions", "types", "reset", "help" for more information.
|
44
|
+
|
45
|
+
>> $config_file = '/etc/httpd/httpd.conf'
|
46
|
+
=> /etc/httpd/httpd.conf
|
47
|
+
>> file{$config_file: ensure => present, content => 'hello'}
|
48
|
+
=> File['/etc/httpd/httpd.conf']
|
49
|
+
>>
|
50
|
+
```
|
51
|
+
|
52
|
+
Using functions: functions will run and produce the desired output.
|
53
|
+
|
54
|
+
```
|
55
|
+
>> split('hello/there/one/two/three','/')
|
56
|
+
=>
|
57
|
+
hello
|
58
|
+
there
|
59
|
+
one
|
60
|
+
two
|
61
|
+
three
|
62
|
+
|
63
|
+
```
|
64
|
+
## Duplicate resource error
|
65
|
+
Just like normal puppet code you cannot create duplicate resources.
|
66
|
+
|
67
|
+
```
|
68
|
+
>> file{'/tmp/failure2.txt': ensure => present}
|
69
|
+
=> Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: File[/tmp/failure2.txt] is already declared in file :1; cannot redeclare at line 1 at line 1:1
|
70
|
+
|
71
|
+
```
|
72
|
+
You can reset the parser by running `reset` within the repl without having to exit.
|
73
|
+
|
74
|
+
## Troubleshooting
|
75
|
+
## Forward
|
76
|
+
I was just playing around and created this simple tool. Its alpha quality,
|
77
|
+
and a ton of features need to be added. Please create a issue if you see a bug or feature that should be added.
|
78
|
+
|
79
|
+
Pull requests welcomed.
|
80
|
+
|
81
|
+
## Copyright
|
82
|
+
|
83
|
+
Copyright (c) 2016 Corey Osman. See LICENSE.txt for
|
84
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
require_relative 'lib/version'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
18
|
+
gem.name = "puppet-repl"
|
19
|
+
gem.version = "#{PuppetRepl::VERSION}"
|
20
|
+
gem.homepage = "http://github.com/nwops/puppet-repl"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{A repl for the puppet language}
|
23
|
+
gem.description = %Q{A interactive command line tool for evaluating the puppet language}
|
24
|
+
gem.email = "corey@nwops.io"
|
25
|
+
gem.authors = ["Corey Osman"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Code coverage detail"
|
37
|
+
task :simplecov do
|
38
|
+
ENV['COVERAGE'] = "true"
|
39
|
+
Rake::Task['spec'].execute
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'rdoc/task'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "puppet-repl #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/prepl
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'puppet/pops'
|
3
|
+
require "readline"
|
4
|
+
|
5
|
+
module PuppetRepl
|
6
|
+
class Cli
|
7
|
+
|
8
|
+
# returns a future parser for evaluating code
|
9
|
+
def parser
|
10
|
+
@parser || ::Puppet::Pops::Parser::EvaluatingParser.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def module_dirs
|
14
|
+
Puppet.settings[:basemodulepath].split(':')
|
15
|
+
end
|
16
|
+
|
17
|
+
# creates a puppet environment given a module path and environment name
|
18
|
+
def puppet_environment
|
19
|
+
@puppet_environment ||= Puppet::Node::Environment.create('production', module_dirs)
|
20
|
+
end
|
21
|
+
|
22
|
+
def scope
|
23
|
+
unless @scope
|
24
|
+
begin
|
25
|
+
Puppet.initialize_settings
|
26
|
+
rescue
|
27
|
+
# do nothing otherwise calling init twice raises an error
|
28
|
+
end
|
29
|
+
#options['parameters']
|
30
|
+
#options['facts']
|
31
|
+
#options[:classes]
|
32
|
+
node_name = 'node_name'
|
33
|
+
node = Puppet::Node.new(node_name, :environment => puppet_environment)
|
34
|
+
compiler = Puppet::Parser::Compiler.new(node)
|
35
|
+
@scope = Puppet::Parser::Scope.new(compiler)
|
36
|
+
@scope.source = Puppet::Resource::Type.new(:node, node_name)
|
37
|
+
@scope.parent = compiler.topscope
|
38
|
+
end
|
39
|
+
@scope
|
40
|
+
end
|
41
|
+
|
42
|
+
def puppet_eval(input)
|
43
|
+
begin
|
44
|
+
parser.evaluate_string(scope, input)
|
45
|
+
rescue ArgumentError => e
|
46
|
+
e.message
|
47
|
+
rescue Puppet::ParseErrorWithIssue => e
|
48
|
+
e.message
|
49
|
+
rescue Exception => e
|
50
|
+
e.message
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def normalize_output(result)
|
55
|
+
if result.instance_of?(Array)
|
56
|
+
if result.count == 1
|
57
|
+
return result.first
|
58
|
+
end
|
59
|
+
end
|
60
|
+
result
|
61
|
+
end
|
62
|
+
#scope.environment.known_resource_types
|
63
|
+
def handle_input(input)
|
64
|
+
case input
|
65
|
+
when 'help'
|
66
|
+
PuppetRepl::Cli.print_repl_desc
|
67
|
+
when 'functions'
|
68
|
+
puts "list of functions coming soon"
|
69
|
+
when 'types'
|
70
|
+
puts "list of types coming soon"
|
71
|
+
when '_'
|
72
|
+
puts(" => #{@last_item}")
|
73
|
+
when 'exit'
|
74
|
+
exit 0
|
75
|
+
when 'reset'
|
76
|
+
@scope = nil
|
77
|
+
else
|
78
|
+
result = puppet_eval(input)
|
79
|
+
@last_item = result
|
80
|
+
puts(" => #{normalize_output(result)}")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.ripl_start
|
85
|
+
Ripl.start
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.print_repl_desc
|
89
|
+
puts(<<-EOT)
|
90
|
+
Puppet Version: #{Puppet.version}
|
91
|
+
Puppet Repl Version: #{PuppetRepl::VERSION}
|
92
|
+
Created by: NWOps <corey@nwops.io>
|
93
|
+
Type "exit", "functions", "types", "reset", "help" for more information.
|
94
|
+
|
95
|
+
EOT
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.start
|
99
|
+
print_repl_desc
|
100
|
+
repl_obj = new
|
101
|
+
while buf = Readline.readline(">> ", true)
|
102
|
+
repl_obj.handle_input(buf)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/lib/puppet-repl.rb
ADDED
data/lib/version.rb
ADDED
data/puppet-repl.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "puppet-repl"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Corey Osman"]
|
12
|
+
s.date = "2016-02-19"
|
13
|
+
s.description = "A interactive command line tool for evaluating the puppet language"
|
14
|
+
s.email = "corey@nwops.io"
|
15
|
+
s.executables = ["prepl"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/prepl",
|
30
|
+
"lib/puppet-repl.rb",
|
31
|
+
"lib/puppet-repl/cli.rb",
|
32
|
+
"lib/version.rb",
|
33
|
+
"puppet-repl.gemspec",
|
34
|
+
"spec/puppet-repl_spec.rb",
|
35
|
+
"spec/spec_helper.rb"
|
36
|
+
]
|
37
|
+
s.homepage = "http://github.com/nwops/puppet-repl"
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = "2.0.14"
|
41
|
+
s.summary = "A repl for the puppet language"
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 4
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
|
48
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
51
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
53
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<puppet>, [">= 3.8"])
|
57
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
60
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
62
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<puppet>, [">= 3.8"])
|
67
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
68
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
72
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "PuppetRepl" do
|
4
|
+
let(:resource) do
|
5
|
+
"service{'httpd': ensure => running}"
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:repl) do
|
9
|
+
PuppetRepl::Cli.new
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'help' do
|
13
|
+
let(:input) do
|
14
|
+
'help'
|
15
|
+
end
|
16
|
+
it 'can show the help screen' do
|
17
|
+
repl_output = "Puppet Version: 4.3.2\nPuppet Repl Version: 0.0.1\nCreated by: NWOps <corey@nwops.io>\nType \"exit\", \"functions\", \"types\", \"reset\", \"help\" for more information.\n\n"
|
18
|
+
expect{repl.handle_input(input)}.to output(repl_output).to_stdout
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'variables' do
|
23
|
+
let(:input) do
|
24
|
+
"$file_path = '/tmp/test2.txt'"
|
25
|
+
end
|
26
|
+
it 'can process a variable' do
|
27
|
+
repl_output = " => /tmp/test2.txt\n"
|
28
|
+
expect{repl.handle_input(input)}.to output(repl_output).to_stdout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'resource' do
|
33
|
+
let(:input) do
|
34
|
+
"file{'/tmp/test2.txt': ensure => present, mode => '0755'}"
|
35
|
+
end
|
36
|
+
it 'can process a resource' do
|
37
|
+
repl_output = " => File['/tmp/test2.txt']\n"
|
38
|
+
expect{repl.handle_input(input)}.to output(repl_output).to_stdout
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'bad input' do
|
43
|
+
let(:input) do
|
44
|
+
"Service{"
|
45
|
+
end
|
46
|
+
it 'can process' do
|
47
|
+
repl_output = " => Syntax error at end of file\n"
|
48
|
+
expect{repl.handle_input(input)}.to output(repl_output).to_stdout
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'each block' do
|
53
|
+
let(:input) do
|
54
|
+
"['/tmp/test3', '/tmp/test4'].each |String $path| { file{$path: ensure => present} }"
|
55
|
+
end
|
56
|
+
it 'can process a each block' do
|
57
|
+
repl_output = " => [\"/tmp/test3\", \"/tmp/test4\"]\n"
|
58
|
+
expect{repl.handle_input(input)}.to output(repl_output).to_stdout
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require_relative '../lib/puppet-repl'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
module SimpleCov::Configuration
|
6
|
+
def clean_filters
|
7
|
+
@filters = []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
SimpleCov.configure do
|
12
|
+
clean_filters
|
13
|
+
load_adapter 'test_frameworks'
|
14
|
+
end
|
15
|
+
|
16
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
17
|
+
add_filter "/.rvm/"
|
18
|
+
end
|
19
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
20
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
21
|
+
|
22
|
+
require 'rspec'
|
23
|
+
require 'puppet-repl'
|
24
|
+
|
25
|
+
# Requires supporting files with custom matchers and macros, etc,
|
26
|
+
# in ./support/ and its subdirectories.
|
27
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
28
|
+
|
29
|
+
RSpec.configure do |config|
|
30
|
+
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-repl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Corey Osman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: puppet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A interactive command line tool for evaluating the puppet language
|
126
|
+
email: corey@nwops.io
|
127
|
+
executables:
|
128
|
+
- prepl
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files:
|
131
|
+
- LICENSE.txt
|
132
|
+
- README.md
|
133
|
+
files:
|
134
|
+
- .document
|
135
|
+
- .rspec
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- VERSION
|
142
|
+
- bin/prepl
|
143
|
+
- lib/puppet-repl.rb
|
144
|
+
- lib/puppet-repl/cli.rb
|
145
|
+
- lib/version.rb
|
146
|
+
- puppet-repl.gemspec
|
147
|
+
- spec/puppet-repl_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
homepage: http://github.com/nwops/puppet-repl
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.0.14
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: A repl for the puppet language
|
173
|
+
test_files: []
|