Class: Banalize::Describe

Inherits:
Object
  • Object
show all
Defined in:
lib/helpers/description.rb

Overview

Helper methods for printing out policies descriptions.

Constant Summary collapse

FORMAT =

Format for markdown documentation for policies

<<-FORM

## %s

*%s*

* Policy name: %s
* Severity:    %s
* Style:       %s
* Defaults:    %s

**Description**

````
%s

````

------------------------------------------------------------------

FORM

Class Method Summary collapse

Class Method Details

.markdown(policies) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/helpers/description.rb', line 36

def self.markdown policies

  puts <<-PUT
# @title List of available policies

# Banalizer

![banalize](images/banalize_small.png)

PUT

  policies.each do |pol|

    defl = ""

    if pol[:default]
      pol[:default].each { |k,v| defl << "\n  * #{k}: #{v}\n" }
    end

    defl = "N/A" if defl.empty?

    printf FORMAT,
    pol[:policy].to_s.titleize,
    pol[:synopsis],
    pol[:policy],
    pol[:severity],
    pol[:style],
    defl,
    pol[:description]
  end
end

.screen(policies) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/helpers/description.rb', line 68

def self.screen policies
  policies.each do |pol|
    yellow
    printf "%s :  %s\n", pol[:policy].to_s.color(:bold), pol[:synopsis].color(:green)
    yellow

    puts pol[:description]
    puts
  end
end

.yellowObject



32
33
34
# File 'lib/helpers/description.rb', line 32

def self.yellow
  printf "%s\n", ('~' * 80).color(:yellow)
end