Module: Ops::Helpers
- Defined in:
- lib/ops/server/helpers.rb
Constant Summary collapse
- GITHUB_ORG_LINK =
'https://github.com/rentpath'
Instance Method Summary collapse
- #app_name ⇒ Object
- #commit_link(commit) ⇒ Object
- #github_link(resource, subresource) ⇒ Object
- #hostname ⇒ Object
- #print_detail(object, indent = 0) ⇒ Object
- #version_link(version) ⇒ Object
Instance Method Details
#app_name ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ops/server/helpers.rb', line 9 def app_name @app_name ||= begin dirs = Dir.pwd.split('/') if dirs.last =~ /^\d+$/ dirs[-3] else dirs.last end.sub(/\.com$/, '') end end |
#commit_link(commit) ⇒ Object
24 25 26 |
# File 'lib/ops/server/helpers.rb', line 24 def commit_link(commit) github_link 'commit', commit end |
#github_link(resource, subresource) ⇒ Object
28 29 30 |
# File 'lib/ops/server/helpers.rb', line 28 def github_link(resource, subresource) "<a href='#{GITHUB_ORG_LINK}/#{app_name}/#{resource}/#{subresource}'>#{subresource}</a>" unless subresource =~ /^Unknown/ end |
#hostname ⇒ Object
5 6 7 |
# File 'lib/ops/server/helpers.rb', line 5 def hostname @hostname ||= `/bin/hostname` || 'Unknown' end |
#print_detail(object, indent = 0) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ops/server/helpers.rb', line 32 def print_detail(object, indent = 0) output = "" if object.kind_of? Hash output << "{\n" output << object.collect { |key, value| " " * indent + " #{print_detail key} => #{print_detail value, indent+1}" }.join(",\n") << "\n" output << " " * indent + "}" else output << object.inspect end output end |
#version_link(version) ⇒ Object
20 21 22 |
# File 'lib/ops/server/helpers.rb', line 20 def version_link(version) github_link 'tree', version end |