Module: Git::Multi::Settings
- Defined in:
- lib/git/multi/settings.rb
Constant Summary collapse
- TICK =
["2714".hex].pack("U*").green.freeze
- CROSS =
["2718".hex].pack("U*").red.freeze
- ARROW =
["2794".hex].pack("U*").blue.freeze
Class Method Summary collapse
- .directory_status(messages, directory) ⇒ Object
- .file_status(file, message = 'File') ⇒ Object
- .home_status(home) ⇒ Object
- .main_workarea_status(workarea) ⇒ Object
- .organization_status(orgs) ⇒ Object
- .organization_workarea_status(orgs) ⇒ Object
- .setting_status(messages, valid, optional = false) ⇒ Object
- .token_status(token) ⇒ Object
- .user_status(user) ⇒ Object
- .user_workarea_status(user) ⇒ Object
- .workarea_status(message, workarea, owner) ⇒ Object
Class Method Details
.directory_status(messages, directory) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/git/multi/settings.rb', line 33 def directory_status , directory setting_status( , directory && !directory.empty? && File.directory?(directory), false ) end |
.file_status(file, message = 'File') ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/git/multi/settings.rb', line 21 def file_status file, = 'File' setting_status( [ , abbreviate(file), File.file?(file) ? "#{File.size(file).commify} bytes" : nil, ], file && !file.empty? && File.file?(file), false ) end |
.home_status(home) ⇒ Object
69 70 71 |
# File 'lib/git/multi/settings.rb', line 69 def home_status home directory_status(["Home", home], home) end |
.main_workarea_status(workarea) ⇒ Object
73 74 75 |
# File 'lib/git/multi/settings.rb', line 73 def main_workarea_status workarea directory_status(["Workarea (main)", abbreviate(workarea, :home)], workarea) end |
.organization_status(orgs) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/git/multi/settings.rb', line 56 def organization_status orgs for org in orgs setting_status(["Organization", org], org && !org.empty?, true) setting_status(["Organization", "member?"], Git::Hub.orgs.include?(org), !Git::Hub.connected?) end end |
.organization_workarea_status(orgs) ⇒ Object
81 82 83 84 85 |
# File 'lib/git/multi/settings.rb', line 81 def organization_workarea_status orgs for org in orgs workarea_status("Workarea (org: #{org})", Git::Multi::WORKAREA, org) end end |
.setting_status(messages, valid, optional = false) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/git/multi/settings.rb', line 11 def setting_status , valid, optional = false fields = .compact.join(' - ') icon = valid ? TICK : optional ? ARROW : CROSS if $INTERACTIVE print " #{fields}" ; sleep 0.75 ; puts "\x0d#{icon}" else puts "#{icon} #{fields}" end end |
.token_status(token) ⇒ Object
63 64 65 66 67 |
# File 'lib/git/multi/settings.rb', line 63 def token_status token setting_status(["Token", symbolize(token), describe(token)], !token.nil? && !token.empty?) setting_status(["Token", "valid?"], !token.nil? && !token.empty? && Git::Hub.login, !Git::Hub.connected?) setting_status(["Token", "owned by #{Git::Multi::USER}?"], Git::Hub.login == Git::Multi::USER, !Git::Hub.connected?) end |
.user_status(user) ⇒ Object
52 53 54 |
# File 'lib/git/multi/settings.rb', line 52 def user_status user setting_status(["User", user], user && !user.empty?) end |
.user_workarea_status(user) ⇒ Object
77 78 79 |
# File 'lib/git/multi/settings.rb', line 77 def user_workarea_status user workarea_status("Workarea (user: #{user})", Git::Multi::WORKAREA, user) end |
.workarea_status(message, workarea, owner) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/git/multi/settings.rb', line 41 def workarea_status , workarea, owner directory_status( [ , File.join(abbreviate(workarea, :workarea), owner), File.directory?(workarea) ? "#{Dir.new(workarea).git_repos(owner).count.commify} repos" : nil ], workarea ) end |