Module: Helpers

Includes:
Rack::Utils, Sinatra::ContentFor, Sinatra::Partials
Defined in:
lib/runit-man/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#even_or_odd_stateObject

Returns the value of attribute even_or_odd_state.



12
13
14
# File 'lib/runit-man/helpers.rb', line 12

def even_or_odd_state
  @even_or_odd_state
end

Instance Method Details

#even_or_oddObject



37
38
39
40
# File 'lib/runit-man/helpers.rb', line 37

def even_or_odd
  self.even_or_odd_state = !even_or_odd_state
  even_or_odd_state
end

#host_nameObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/runit-man/helpers.rb', line 14

def host_name
  unless @host_name
    begin
      @host_name = Socket.gethostbyname(Socket.gethostname).first
    rescue
      @host_name = Socket.gethostname
    end
  end
  @host_name
end

#service_action(name, action, label) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/runit-man/helpers.rb', line 29

def service_action(name, action, label)
  partial :service_action, :locals => {
    :name   => name,
    :action => action,
    :label  => label
  }
end

#service_infosObject



25
26
27
# File 'lib/runit-man/helpers.rb', line 25

def service_infos
  ServiceInfo.all
end

#stat_subst(s) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/runit-man/helpers.rb', line 42

def stat_subst(s)
  s.split(/\s/).map do |s|
    if s =~ /(\w+)/ && t.runit.services.table.subst[$1].translated?
      s.sub(/\w+/, t.runit.services.table.subst[$1].to_s)
    else
      s
    end
  end.join(' ')
end