Module: Ops::Helpers
- Defined in:
- lib/ops/server/helpers.rb
Constant Summary collapse
- GITHUB_ORG_LINK =
'https://github.com/rentpath'.freeze
Instance Method Summary collapse
- #app_name ⇒ Object
- #commit_link(commit) ⇒ Object
- #github_link(resource, subresource) ⇒ Object
- #hostname ⇒ Object
- #repo_name ⇒ 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
32 33 34 35 36 |
# File 'lib/ops/server/helpers.rb', line 32 def github_link(resource, subresource) unless subresource =~ /^Unknown/ "<a href='#{GITHUB_ORG_LINK}/#{repo_name}/#{resource}/#{subresource}'>#{subresource}</a>" end end |
#hostname ⇒ Object
5 6 7 |
# File 'lib/ops/server/helpers.rb', line 5 def hostname @hostname ||= `/bin/hostname` || 'Unknown' end |
#repo_name ⇒ Object
28 29 30 |
# File 'lib/ops/server/helpers.rb', line 28 def repo_name Ops.config[:repo_name] || app_name 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 |