oldskool-puppet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/oldskool/puppet_handler.rb +20 -0
- data/lib/oldskool/puppetdoc.rb +56 -0
- data/lib/oldskool-puppet.rb +2 -0
- data/views/password.erb +8 -0
- data/views/type.erb +37 -0
- metadata +71 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Oldskool
|
2
|
+
class PuppetHandler
|
3
|
+
def initialize(params, keyword, config)
|
4
|
+
@params = params
|
5
|
+
@keyword = keyword
|
6
|
+
@config = config
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def plugin_template(template)
|
11
|
+
File.read(File.expand_path("../../../views/#{template}.erb", __FILE__))
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle_request(keyword, query)
|
15
|
+
type = Puppetdoc.new(query)
|
16
|
+
|
17
|
+
{:template => plugin_template(:type), :type => type.doc}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
|
3
|
+
module Oldskool
|
4
|
+
class Puppetdoc
|
5
|
+
attr_reader :type
|
6
|
+
|
7
|
+
def initialize(type)
|
8
|
+
loadall
|
9
|
+
|
10
|
+
settype(type)
|
11
|
+
end
|
12
|
+
|
13
|
+
def loadall
|
14
|
+
Puppet::Type.loadall unless Puppet::Type.constants.include?("File")
|
15
|
+
end
|
16
|
+
|
17
|
+
def settype(type)
|
18
|
+
raise "Cannot find Puppet Type #{type}" unless Puppet::Type.const_defined?(type.capitalize)
|
19
|
+
@type = Puppet::Type.const_get(type.capitalize)
|
20
|
+
end
|
21
|
+
|
22
|
+
def cleantext(text)
|
23
|
+
(text =~ /^(\s+)/) ? text.gsub(/^#{$1}/,'') : text
|
24
|
+
end
|
25
|
+
|
26
|
+
def paramdoc(param)
|
27
|
+
doc = {}
|
28
|
+
|
29
|
+
if type.parameters.include?(param)
|
30
|
+
doc[:markdown] = cleantext(type.attrclass(param).doc)
|
31
|
+
doc[:type] = :param
|
32
|
+
elsif type.metaparams.include?(param)
|
33
|
+
doc[:markdown] = cleantext(type.attrclass(param).doc)
|
34
|
+
doc[:type] = :meta
|
35
|
+
end
|
36
|
+
|
37
|
+
if type.key_attributes.include?(param) and param != :name
|
38
|
+
doc[:type] = :namevar
|
39
|
+
end
|
40
|
+
|
41
|
+
doc
|
42
|
+
end
|
43
|
+
|
44
|
+
def doc
|
45
|
+
param_docs = {:name => type.name,
|
46
|
+
:description => cleantext(type.doc),
|
47
|
+
:version => Puppet.version,
|
48
|
+
:params => {}, :metaparams => {}}
|
49
|
+
|
50
|
+
type.parameters.each {|param| param_docs[:params][param] = paramdoc(param)}
|
51
|
+
type.metaparams.each {|param| param_docs[:metaparams][param] = paramdoc(param)}
|
52
|
+
|
53
|
+
param_docs
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/views/password.erb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<% unless @error %>
|
2
|
+
<table>
|
3
|
+
<tr><td><strong>Password:</strong></td><td><%= @result[:pw].password[:string] %></td></tr>
|
4
|
+
<tr><td><strong>Crypt:</strong></td><td><%= @result[:pw].password[:crypt] %></td></tr>
|
5
|
+
<tr><td><strong>MD5:</strong></td><td><%= @result[:pw].password[:md5] %></td></tr>
|
6
|
+
<tr><td><strong>Nato:</strong></td><td><%= @result[:pw].password[:nato] %></td></tr>
|
7
|
+
</table>
|
8
|
+
<% end %>
|
data/views/type.erb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
<% unless @error %>
|
2
|
+
<style>
|
3
|
+
code {
|
4
|
+
background-color: whiteSmoke;
|
5
|
+
padding: 0 0 0 0;
|
6
|
+
}
|
7
|
+
</style>
|
8
|
+
<h2><%= @result[:type][:name].to_s.capitalize %> version <%= @result[:type][:version] %></h2>
|
9
|
+
<p>
|
10
|
+
<a href="#params">Paramaters</a>, <a href="#metaparams">Meta Parameters</a>
|
11
|
+
</p>
|
12
|
+
<div>
|
13
|
+
<%= markdown @result[:type][:description] %>
|
14
|
+
</div>
|
15
|
+
<a name="params"></a>
|
16
|
+
<% @result[:type][:params].keys.sort.each do |param| %>
|
17
|
+
<% doc = @result[:type][:params][param] %>
|
18
|
+
<h3>
|
19
|
+
<%= param %>
|
20
|
+
<%= (doc[:type] == :namevar) ? '<span class="label success">Namevar</span>' : '' %>
|
21
|
+
</h3>
|
22
|
+
<div>
|
23
|
+
<%= markdown(doc[:markdown]) %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<a name="metaparams"></a>
|
27
|
+
<hr>
|
28
|
+
<% @result[:type][:metaparams].keys.sort.each do |param| %>
|
29
|
+
<% doc = @result[:type][:metaparams][param] %>
|
30
|
+
<h3>
|
31
|
+
<%= param %> <span class="label notice">Meta</span>
|
32
|
+
</h3>
|
33
|
+
<div>
|
34
|
+
<%= markdown(doc[:markdown]) %>
|
35
|
+
</div>
|
36
|
+
<% end %>
|
37
|
+
<% end %>
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oldskool-puppet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- R.I.Pienaar
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-01-28 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: "description: Generate documentation for Puppet types"
|
23
|
+
email: rip@devco.net
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/oldskool/puppetdoc.rb
|
32
|
+
- lib/oldskool/puppet_handler.rb
|
33
|
+
- lib/oldskool-puppet.rb
|
34
|
+
- views/type.erb
|
35
|
+
- views/password.erb
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://devco.net/
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: oldskool-1assword
|
70
|
+
test_files: []
|
71
|
+
|