Sha256: 4004f7489036a3627433abce950b69fac72b3ecad1f980ae0e2593ceeb87a76f

Contents?: true

Size: 1003 Bytes

Versions: 5

Compression:

Stored size: 1003 Bytes

Contents

require 'socket'
require 'runit-man/service_info'
require 'runit-man/partials'
require 'sinatra/content_for'

module Helpers
  include Rack::Utils
  include Sinatra::Partials
  include Sinatra::ContentFor
  alias_method :h, :escape_html

  attr_accessor :even_or_odd_state

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

  def service_infos
    ServiceInfo.all
  end

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

  def even_or_odd
    self.even_or_odd_state = !even_or_odd_state
    even_or_odd_state
  end

  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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
runit-man-1.4.3 lib/runit-man/helpers.rb
runit-man-1.4.1 lib/runit-man/helpers.rb
runit-man-1.4 lib/runit-man/helpers.rb
runit-man-1.3 lib/runit-man/helpers.rb
runit-man-1.2 lib/runit-man/helpers.rb