Module: Space::View::Helpers

Included in:
Space::View, Template
Defined in:
lib/space/view/helpers.rb

Instance Method Summary collapse

Instance Method Details

#bundle_depsObject



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

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

#bundle_infoObject



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

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

#bundle_statusObject



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

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

#format_boolean(value) ⇒ Object



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

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

#git_aheadObject



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

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

#git_statusObject



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

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

#i(string, width = 2) ⇒ Object



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

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



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

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

#repo_localObject



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

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

#repo_local?Boolean

Returns:

  • (Boolean)


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

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

#repo_nameObject



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

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

#repo_selected?Boolean

Returns:

  • (Boolean)


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

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

#repo_statusObject



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

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

#tableize(string) ⇒ Object



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

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