Module: Helpers
- Includes:
- Rack::Utils, Sinatra::ContentFor, Sinatra::Partials
- Defined in:
- lib/runit-man/helpers.rb
Instance Attribute Summary collapse
-
#even_or_odd_state ⇒ Object
Returns the value of attribute even_or_odd_state.
Instance Method Summary collapse
- #even_or_odd ⇒ Object
- #host_name ⇒ Object
- #log_link(name, options = {}) ⇒ Object
- #service_action(name, action, label) ⇒ Object
- #service_infos ⇒ Object
- #stat_subst(s) ⇒ Object
Instance Attribute Details
#even_or_odd_state ⇒ Object
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_odd ⇒ Object
48 49 50 51 |
# File 'lib/runit-man/helpers.rb', line 48 def even_or_odd self.even_or_odd_state = !even_or_odd_state even_or_odd_state end |
#host_name ⇒ Object
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 |
#log_link(name, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/runit-man/helpers.rb', line 37 def log_link(name, = {}) count = ([:count] || 100).to_i title = [:title].to_s || count blank = [:blank] || false hint = [:hint].to_s || '' raw = [:raw] || false hint = " title=\"#{h(hint)}\"" unless hint.empty? blank = blank ? ' target="_blank"' : '' "<a#{hint}#{blank} href=\"/#{h(name)}/log#{ (count != 100) ? "/#{count}" : '' }#{ raw ? '.txt' : '' }#footer\">#{h(title)}</a>" 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_infos ⇒ Object
25 26 27 |
# File 'lib/runit-man/helpers.rb', line 25 def service_infos ServiceInfo.all end |
#stat_subst(s) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/runit-man/helpers.rb', line 53 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 |