Class: MuSL::Maker::Scenario

Inherits:
Object
  • Object
show all
Includes:
Mu::Helper
Defined in:
lib/mu/maker.rb

Constant Summary

Constants included from Mu::Helper

Mu::Helper::ESCAPES

Instance Method Summary collapse

Methods included from Mu::Helper

#ask, #bin2hex, #error, #escape, #format_float, #get_file_as_string_array, #make_xml, #msg, #shift, #to_boolean

Instance Method Details

#attrs(kvs = {}) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/mu/maker.rb', line 90

def attrs kvs = {}
    return '' if kvs.empty?
    
    ary = []
    kvs.each_pair do |key, val|
        if ( (val.is_a? String) &&  (val.length === 0)  )
            #val = escape(val.to_s)
            val = '"' + escape(val.to_s) + '"'
        elsif val.is_a? Symbol
            val = escape(val.to_s)
        else
            val = escape(val.to_s)
        end
        ary << (key.to_s + ':' + val.to_s)
    end
    return '(' + ary.join(', ') + ')'
end

#block(start, finish, opts = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



52
53
54
55
56
57
58
# File 'lib/mu/maker.rb', line 52

def block start, finish, opts={}
    musl << indent(depth) + start + "\r\n"
    @depth += 1
    yield self
    @depth -= 1
    musl << indent(depth) + finish + "\r\n"
end

#comment(text) ⇒ Object



40
41
42
# File 'lib/mu/maker.rb', line 40

def comment text
    line '# ' + text
end

#create(name) ⇒ Object

yield |scenario|



60
61
62
63
64
# File 'lib/mu/maker.rb', line 60

def create name # yield |scenario|
    block 'scenario(name: "' + name + '") {', '}' do
        yield self
    end
end

#depthObject



24
25
26
# File 'lib/mu/maker.rb', line 24

def depth
    @depth ||= 0
end

#globalsObject

yield |globals|



78
79
80
81
82
# File 'lib/mu/maker.rb', line 78

def globals # yield |globals|
    block 'variables {', '}' do
        yield Globals.new(self)
    end
end

#hostsObject

yield |hosts|



66
67
68
69
70
# File 'lib/mu/maker.rb', line 66

def hosts # yield |hosts|
    block 'hosts {', '}' do
        yield Hosts.new(self)
    end
end

#indent(amount) ⇒ Object



32
33
34
# File 'lib/mu/maker.rb', line 32

def indent amount
    " " * (4 * amount)
end

#line(text = '') ⇒ Object



36
37
38
# File 'lib/mu/maker.rb', line 36

def line text=''
    musl << indent(depth) + text + "\r\n"
end

#literal(text) ⇒ Object



44
45
46
# File 'lib/mu/maker.rb', line 44

def literal text
    musl << indent(depth) + text + "\r\n"
end

#literal_no_format(text) ⇒ Object



48
49
50
# File 'lib/mu/maker.rb', line 48

def literal_no_format text
    musl << text
end

#muslObject



28
29
30
# File 'lib/mu/maker.rb', line 28

def musl
    @musl ||= []
end

#optionsObject

yield |options|



72
73
74
75
76
# File 'lib/mu/maker.rb', line 72

def options # yield |options|
    block 'options {', '}' do
        yield Options.new(self)
    end
end

#stepsObject

yield |steps|



84
85
86
87
88
# File 'lib/mu/maker.rb', line 84

def steps # yield |steps|
    block 'steps { ', '}' do
        yield Steps.new(self)
    end
end