Module: Ops::Helpers

Defined in:
lib/ops/server/helpers.rb

Constant Summary collapse

'https://github.com/rentpath'.freeze

Instance Method Summary collapse

Instance Method Details

#app_nameObject



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


24
25
26
# File 'lib/ops/server/helpers.rb', line 24

def commit_link(commit)
  github_link 'commit', commit
end


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

#hostnameObject



5
6
7
# File 'lib/ops/server/helpers.rb', line 5

def hostname
  @hostname ||= `/bin/hostname` || 'Unknown'
end

#repo_nameObject



28
29
30
# File 'lib/ops/server/helpers.rb', line 28

def repo_name
  Ops.config[:repo_name] || app_name
end


20
21
22
# File 'lib/ops/server/helpers.rb', line 20

def version_link(version)
  github_link 'tree', version
end