Module: Ops::Helpers
- Defined in:
- lib/ops/server/helpers.rb
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
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ops/server/helpers.rb', line 7 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
22 23 24 |
# File 'lib/ops/server/helpers.rb', line 22 def commit_link(commit) github_link 'commit', commit end |
#github_link(resource, subresource) ⇒ Object
26 27 28 |
# File 'lib/ops/server/helpers.rb', line 26 def github_link(resource, subresource) "https://github.com/primedia/#{app_name}/#{resource}/#{subresource}" unless subresource =~ /^Unknown/ end |
#hostname ⇒ Object
3 4 5 |
# File 'lib/ops/server/helpers.rb', line 3 def hostname @hostname ||= `/bin/hostname` || 'Unknown' end |
#print_detail(object, indent = 0) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ops/server/helpers.rb', line 30 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
18 19 20 |
# File 'lib/ops/server/helpers.rb', line 18 def version_link(version) github_link 'tree', version end |