puppet-repl 0.0.6 → 0.0.7

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: 157dfb5c0e9d81188f376d8baa9c8e365e76dbb8
4
- data.tar.gz: 58ccca9e95a7033ea5bd621c93c299a69cf6fc74
3
+ metadata.gz: efa15e795af4973b078852664154fe9e60d9b908
4
+ data.tar.gz: a59f074150a899b9e67c59ca9b6874651541b7c4
5
5
  SHA512:
6
- metadata.gz: 2c32ed3f424316cca76ed22f856162e7b942b2528fb38f8b9690067e5cf78b21b91da5bebb7e00b5c12b285002ff74ea559307413cc4d666c8c2b66de591de66
7
- data.tar.gz: 93d04ab8eb1cab1706098a9fcb2782409a413f61782099e7efbfdf3e24922fb40d52158069ea3f69d77bb8e4e145acd37de7e202cd986b875f9a03fc9dd30b9c
6
+ metadata.gz: 174bc1f05d44735c39e55417eb05cd54bb19a6a666572afc46bc025868c3a26f3624ba4d5d691d15e7b4360ac743e0cfb24e53bcf8f77548ea9dd16e0ce4234f
7
+ data.tar.gz: d3b20b61ea361187b5cf646b5336a3f58207f54ed40c39b3dde5582dddeefca7e87a925f0e04f99b2046e6c5aea50e056dedb23ed5545f43968092e40e52befc
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.7
2
+ * Added ability to list scope variables
3
+ ## 0.0.6
4
+ * Bug fix for puppet 3.8
5
+ ## 0.0.5
6
+ * Added ability to set puppet log level
data/Gemfile CHANGED
@@ -1,8 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
  gem 'puppet', ENV['PUPPET_GEM_VERSION'] || ">= 3.8"
3
3
  gem 'facterdb'
4
- # Add dependencies to develop your gem here.
5
- # Include everything needed to run rake, tests, features, etc.
4
+ gem 'awesome_print'
6
5
 
7
6
  group :test do
8
7
  gem "rspec"
data/Gemfile.lock CHANGED
@@ -3,6 +3,7 @@ GEM
3
3
  specs:
4
4
  CFPropertyList (2.2.8)
5
5
  addressable (2.4.0)
6
+ awesome_print (1.6.1)
6
7
  builder (3.2.2)
7
8
  coderay (1.1.0)
8
9
  descendants_tracker (0.0.4)
@@ -93,6 +94,7 @@ PLATFORMS
93
94
  ruby
94
95
 
95
96
  DEPENDENCIES
97
+ awesome_print
96
98
  bundler
97
99
  facterdb
98
100
  jeweler (~> 2.0.1)
@@ -102,3 +104,6 @@ DEPENDENCIES
102
104
  rdoc (~> 3.12)
103
105
  rspec
104
106
  simplecov
107
+
108
+ BUNDLED WITH
109
+ 1.11.2
data/README.md CHANGED
@@ -75,7 +75,36 @@ Type "exit", "functions", "types", "reset", "help" for more information.
75
75
  => File['/etc/httpd/httpd.conf']
76
76
  >>
77
77
  ```
78
+ ### Listing variables
79
+ To see the current variables in the scope use the `vars` keyword.
78
80
 
81
+ ```
82
+ >> $var1 = 'value'
83
+ => value
84
+ >> $var2 = {'key1' => 'value1'}
85
+ => {"key1"=>"value1"}
86
+ >> vars
87
+ "Facts were removed for easier viewing"
88
+ {
89
+ "datacenter" => "datacenter1",
90
+ "facts" => "removed by the puppet-repl",
91
+ "module_name" => "",
92
+ "name" => "main",
93
+ "title" => "main",
94
+ "trusted" => {
95
+ "authenticated" => "local",
96
+ "certname" => nil,
97
+ "domain" => nil,
98
+ "extensions" => {},
99
+ "hostname" => nil
100
+ },
101
+ "var1" => "value",
102
+ "var2" => {
103
+ "key1" => "value1"
104
+ }
105
+ }
106
+
107
+ ```
79
108
  ## Using functions
80
109
  Functions will run and produce the desired output. If you type the word `functions`
81
110
  a list of available functions will be displayed on the screen.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -0,0 +1,29 @@
1
+ module AwesomePrint
2
+ module Puppet
3
+ def self.included(base)
4
+ base.send :alias_method, :cast_without_puppet_resource, :cast
5
+ base.send :alias_method, :cast, :cast_with_puppet_resource
6
+ end
7
+
8
+ # this tells ap how to cast our object so we can be specific
9
+ # about printing different puppet objects
10
+ def cast_with_puppet_resource(object, type)
11
+ cast = cast_without_puppet_resource(object, type)
12
+ if (defined?(::Puppet::Type)) && (object.is_a?(::Puppet::Type))
13
+ cast = :puppet_resource_instance
14
+ end
15
+ cast
16
+ end
17
+
18
+ def awesome_puppet_resource_instance(object)
19
+ '' if object.nil?
20
+ title = object.title
21
+ name = object.name
22
+ h = object.to_hash.merge(:name => object.name, :title => object.title)
23
+ res_str = awesome_hash(h)
24
+ "#{object.class} #{res_str.gsub(':', '')}"
25
+ end
26
+ end
27
+ end
28
+
29
+ AwesomePrint::Formatter.send(:include, AwesomePrint::Puppet)
data/lib/puppet-repl.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  require_relative 'puppet-repl/cli'
2
2
  require_relative 'version'
3
+ require 'awesome_print'
4
+ require_relative 'awesome_print/ext/awesome_puppet'
@@ -49,9 +49,15 @@ module PuppetRepl
49
49
  when /^:set/
50
50
  handle_set(input)
51
51
  when 'facts'
52
- puts JSON.pretty_generate(node.facts)
52
+ vars = Hash[ node.facts.map { |k, v| [k.to_s, v] } ]
53
+ ap(vars, {:sort_keys => true, :indent => -1})
53
54
  when '_'
54
55
  puts(" => #{@last_item}")
56
+ when 'vars'
57
+ vars = scope.to_hash.delete_if {| key, value | node.facts.key?(key.to_sym) }
58
+ vars['facts'] = 'removed by the puppet-repl'
59
+ ap 'Facts were removed for easier viewing'
60
+ ap(vars, {:sort_keys => true, :indent => -1})
55
61
  when 'environment'
56
62
  puts "Puppet Environment: #{puppet_env_name}"
57
63
  when 'exit'
@@ -73,7 +79,7 @@ Ruby Version: #{RUBY_VERSION}
73
79
  Puppet Version: #{Puppet.version}
74
80
  Puppet Repl Version: #{PuppetRepl::VERSION}
75
81
  Created by: NWOps <corey@nwops.io>
76
- Type "exit", "functions", "facts", "reset", "help" for more information.
82
+ Type "exit", "functions", "vars", "facts", "reset", "help" for more information.
77
83
 
78
84
  EOT
79
85
  end
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PuppetRepl
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/puppet-repl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "puppet-repl"
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
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"]
12
- s.date = "2016-03-30"
12
+ s.date = "2016-04-02"
13
13
  s.description = "A interactive command line tool for evaluating the puppet language"
14
14
  s.email = "corey@nwops.io"
15
15
  s.executables = ["prepl"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ".document",
22
22
  ".rspec",
23
23
  ".travis.yml",
24
+ "CHANGELOG.md",
24
25
  "Gemfile",
25
26
  "Gemfile.lock",
26
27
  "LICENSE.txt",
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
28
29
  "Rakefile",
29
30
  "VERSION",
30
31
  "bin/prepl",
32
+ "lib/awesome_print/ext/awesome_puppet.rb",
31
33
  "lib/puppet-repl.rb",
32
34
  "lib/puppet-repl/cli.rb",
33
35
  "lib/puppet-repl/support.rb",
@@ -49,17 +51,20 @@ Gem::Specification.new do |s|
49
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
52
  s.add_runtime_dependency(%q<puppet>, [">= 3.8"])
51
53
  s.add_runtime_dependency(%q<facterdb>, [">= 0"])
54
+ s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
52
55
  s.add_development_dependency(%q<pry>, [">= 0"])
53
56
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
54
57
  else
55
58
  s.add_dependency(%q<puppet>, [">= 3.8"])
56
59
  s.add_dependency(%q<facterdb>, [">= 0"])
60
+ s.add_dependency(%q<awesome_print>, [">= 0"])
57
61
  s.add_dependency(%q<pry>, [">= 0"])
58
62
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
63
  end
60
64
  else
61
65
  s.add_dependency(%q<puppet>, [">= 3.8"])
62
66
  s.add_dependency(%q<facterdb>, [">= 0"])
67
+ s.add_dependency(%q<awesome_print>, [">= 0"])
63
68
  s.add_dependency(%q<pry>, [">= 0"])
64
69
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
70
  end
@@ -15,7 +15,7 @@ describe "PuppetRepl" do
15
15
  'help'
16
16
  end
17
17
  it 'can show the help screen' do
18
- repl_output = /Ruby Version: #{RUBY_VERSION}\nPuppet Version: \d.\d.\d\nPuppet Repl Version: \d.\d.\d\nCreated by: NWOps <corey@nwops.io>\nType \"exit\", \"functions\", \"facts\", \"reset\", \"help\" for more information.\n\n/
18
+ repl_output = /Ruby Version: #{RUBY_VERSION}\nPuppet Version: \d.\d.\d\nPuppet Repl Version: \d.\d.\d\nCreated by: NWOps <corey@nwops.io>\nType \"exit\", \"functions\", \"vars\", \"facts\", \"reset\", \"help\" for more information.\n\n/
19
19
  expect{repl.handle_input(input)}.to output(repl_output).to_stdout
20
20
  end
21
21
  end
@@ -90,7 +90,7 @@ describe "PuppetRepl" do
90
90
  "facts"
91
91
  end
92
92
  it 'should be able to print facts' do
93
- expect{repl.handle_input(input)}.to output(/"kernel": "Linux"/).to_stdout
93
+ expect{repl.handle_input(input)}.to output(/kernel/).to_stdout
94
94
  end
95
95
  end
96
96
 
@@ -106,6 +106,20 @@ describe "PuppetRepl" do
106
106
  end
107
107
  end
108
108
 
109
+ describe 'vars' do
110
+ let(:input) do
111
+ "vars"
112
+ end
113
+ it 'display facts variable' do
114
+ output = /facts/
115
+ expect{repl.handle_input(input)}.to output(output).to_stdout
116
+ end
117
+ it 'dispaly local variable' do
118
+ repl.handle_input("$var1 = 'value1'")
119
+ expect{repl.handle_input(input)}.to output(/var1/).to_stdout
120
+ end
121
+ end
122
+
109
123
  describe 'execute functions' do
110
124
  let(:input) do
111
125
  "md5('hello')"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-repl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -78,6 +92,7 @@ files:
78
92
  - .document
79
93
  - .rspec
80
94
  - .travis.yml
95
+ - CHANGELOG.md
81
96
  - Gemfile
82
97
  - Gemfile.lock
83
98
  - LICENSE.txt
@@ -85,6 +100,7 @@ files:
85
100
  - Rakefile
86
101
  - VERSION
87
102
  - bin/prepl
103
+ - lib/awesome_print/ext/awesome_puppet.rb
88
104
  - lib/puppet-repl.rb
89
105
  - lib/puppet-repl/cli.rb
90
106
  - lib/puppet-repl/support.rb