Module: Space::Helpers
- Included in:
- Screen::View
- Defined in:
- lib/space/helpers.rb
Instance Method Summary collapse
- #bundle_deps ⇒ Object
- #bundle_info ⇒ Object
- #bundle_status ⇒ Object
- #format_boolean(value) ⇒ Object
- #git_ahead ⇒ Object
- #git_status ⇒ Object
- #i(string, width = 2) ⇒ Object
- #project_title ⇒ Object
- #repo_local ⇒ Object
- #repo_local? ⇒ Boolean
- #repo_name ⇒ Object
- #repo_selected? ⇒ Boolean
- #repo_status ⇒ Object
- #tableize(string) ⇒ Object
Instance Method Details
#bundle_deps ⇒ Object
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_info ⇒ Object
48 49 50 |
# File 'lib/space/helpers.rb', line 48 def bundle_info bundle.info.ansi(:red) unless bundle.clean? end |
#bundle_status ⇒ Object
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_ahead ⇒ Object
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_status ⇒ Object
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_title ⇒ Object
7 8 9 |
# File 'lib/space/helpers.rb', line 7 def project_title "Project: #{name}".ansi(:bold) end |
#repo_local ⇒ Object
24 25 26 |
# File 'lib/space/helpers.rb', line 24 def repo_local 'L'.ansi(:bold, :red) if repo_local? end |
#repo_local? ⇒ Boolean
28 29 30 |
# File 'lib/space/helpers.rb', line 28 def repo_local? project.local_repos.include?(repo.name) end |
#repo_name ⇒ Object
16 17 18 |
# File 'lib/space/helpers.rb', line 16 def repo_name repo.name.ansi(:bold) end |
#repo_selected? ⇒ Boolean
32 33 34 |
# File 'lib/space/helpers.rb', line 32 def repo_selected? repos.scoped? && repos.scope.include?(repo) end |
#repo_status ⇒ Object
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 |