Top Level Namespace

Includes:
Toss::Meta, Toss::Ssh

Defined Under Namespace

Modules: Toss Classes: Server

Instance Method Summary collapse

Methods included from Toss::Ssh

included

Methods included from Toss::Meta

included

Instance Method Details

#bblue(str) ⇒ Object

34 Bright Blue



54
55
56
# File 'lib/toss/color.rb', line 54

def bblue(str)
  colorize(str, "1;34")
end

#bcyan(str) ⇒ Object

36 Bright Cyan



74
75
76
# File 'lib/toss/color.rb', line 74

def bcyan(str)
  colorize(str, "1;36")
end

#bgreen(str) ⇒ Object

32 Bright Green



34
35
36
# File 'lib/toss/color.rb', line 34

def bgreen(str)
  colorize(str, "1;32")
end

#black(str) ⇒ Object

30 Black



14
15
16
# File 'lib/toss/color.rb', line 14

def black(str)
  colorize(str, "30")
end

#blue(str) ⇒ Object

34 Blue



49
50
51
# File 'lib/toss/color.rb', line 49

def blue(str)
  colorize(str, "34")
end

#bmagenta(str) ⇒ Object

35 Bright Magenta



64
65
66
# File 'lib/toss/color.rb', line 64

def bmagenta(str)
  colorize(str, "1;35")
end

#bred(str) ⇒ Object

31 Bright Red



24
25
26
# File 'lib/toss/color.rb', line 24

def bred(str)
  colorize(str, "1;31")
end

#bwhite(str) ⇒ Object

37 Bright White



84
85
86
# File 'lib/toss/color.rb', line 84

def bwhite(str)
  colorize(str, "1;37")
end

#byellow(str) ⇒ Object

33 Bright Yellow



44
45
46
# File 'lib/toss/color.rb', line 44

def byellow(str)
  colorize(str, "1;33")
end

#cap_words(str) ⇒ Object



35
36
37
# File 'lib/toss.rb', line 35

def cap_words(str) 
  str.split(" ").each{|word| word.capitalize!}.join(" ") 
end

#colorize(str, beginColor, endColor = 0) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
# File 'lib/toss/color.rb', line 1

def colorize(str, beginColor, endColor = 0)
  return str unless STDOUT.isatty

  begin
    require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
  rescue LoadError
    raise 'You must gem install win32console to use colorize on Windows'
  end
    
  "\e[#{beginColor}m#{str}\e[#{endColor}m"
end

#cyan(str) ⇒ Object

36 Cyan



69
70
71
# File 'lib/toss/color.rb', line 69

def cyan(str)
  colorize(str, "36")
end

#green(str) ⇒ Object

32 Green



29
30
31
# File 'lib/toss/color.rb', line 29

def green(str)
  colorize(str, "32")
end

#magenta(str) ⇒ Object

35 Magenta



59
60
61
# File 'lib/toss/color.rb', line 59

def magenta(str)
  colorize(str, "35")
end

#red(str) ⇒ Object

31 Red



19
20
21
# File 'lib/toss/color.rb', line 19

def red(str)
  colorize(str, "31")
end

#rollback_stepsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/toss.rb', line 21

def rollback_steps
  @step_index.downto(0) do |index|
    m = method(steps[index][0])
    if m.arity == -1
      puts "== " + red("Rolling Back") + " " + bwhite(cap_words(steps[index][0].to_s.gsub("_", " "))) + " =="

      if m.call(true) == false
        puts "here"
        exit(1)
      end
    end
  end
end

#server(properties) ⇒ Object



1
2
3
# File 'lib/toss/server.rb', line 1

def server(properties)
  return Server.new(properties)
end

#step(step_name, options = {}) ⇒ Object



17
18
19
# File 'lib/toss.rb', line 17

def step(step_name, options={})
  steps << [step_name, options]
end

#stepsObject



13
14
15
# File 'lib/toss.rb', line 13

def steps
  @steps ||= []
end

#white(str) ⇒ Object

37 White



79
80
81
# File 'lib/toss/color.rb', line 79

def white(str)
  colorize(str, "37")
end

#with(obj, &block) ⇒ Object



5
6
7
# File 'lib/toss/server.rb', line 5

def with(obj, &block)
  obj.instance_eval &block
end

#yellow(str) ⇒ Object

33 Yellow



39
40
41
# File 'lib/toss/color.rb', line 39

def yellow(str)
  colorize(str, "33")
end