Module: Space::Helpers

Included in:
Screen::View
Defined in:
lib/space/helpers.rb

Instance Method Summary collapse

Instance Method Details

#bundle_depsObject



52
53
54
# File 'lib/space/helpers.rb', line 52

def bundle_deps
  bundle.deps.map { |dep| "#{dep.ref} #{format_boolean(dep.fresh?)} #{dep.name}" }.join("\n")
end

#bundle_infoObject



48
49
50
# File 'lib/space/helpers.rb', line 48

def bundle_info
  bundle.info.ansi(:red) unless bundle.clean?
end

#bundle_statusObject



44
45
46
# File 'lib/space/helpers.rb', line 44

def bundle_status
  "Bundle: #{format_boolean(bundle.clean?)}"
end

#format_boolean(value) ⇒ Object



56
57
58
# File 'lib/space/helpers.rb', line 56

def format_boolean(value)
  value ? ''.ansi(:green, :bold) : ''.ansi(:red, :bold)
end

#git_aheadObject



40
41
42
# File 'lib/space/helpers.rb', line 40

def git_ahead
  " #{git.ahead} commit#{'s' if git.ahead > 1} ahead".ansi(:yellow)
end

#git_statusObject



36
37
38
# File 'lib/space/helpers.rb', line 36

def git_status
  "Git: #{format_boolean(git.clean?)}#{git_ahead if git.ahead?}"
end

#i(string, width = 2) ⇒ Object



60
61
62
63
64
65
# File 'lib/space/helpers.rb', line 60

def i(string, width = 2)
  lines = string.split("\n")
  lines = lines.map { |line| line.wrap(80).split("\n") }.flatten
  lines = lines.map { |line| [' ' * width, line].join }
  lines.join("\n")
end

#project_titleObject



7
8
9
# File 'lib/space/helpers.rb', line 7

def project_title
  "Project: #{name}".ansi(:bold)
end

#repo_localObject



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

def repo_local
  'L'.ansi(:bold, :red) if repo_local?
end

#repo_local?Boolean

Returns:

  • (Boolean)


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

def repo_local?
  project.local_repos.include?(repo.name)
end

#repo_nameObject



16
17
18
# File 'lib/space/helpers.rb', line 16

def repo_name
  repo.name.ansi(:bold)
end

#repo_selected?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/space/helpers.rb', line 32

def repo_selected?
  repos.scoped? && repos.scope.include?(repo)
end

#repo_statusObject



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

def repo_status
  [git.branch, git.commit, repo_local].compact.join(', ')
end

#tableize(string) ⇒ Object



11
12
13
14
# File 'lib/space/helpers.rb', line 11

def tableize(string)
  string.split(' ')
  project.local_repos.join(', ')
end