Class: Insync::RepoWatch
Instance Method Summary collapse
-
#initialize(path) ⇒ RepoWatch
constructor
A new instance of RepoWatch.
- #inspect_path(path) ⇒ Object
- #watch ⇒ Object
Constructor Details
#initialize(path) ⇒ RepoWatch
Returns a new instance of RepoWatch.
38 39 40 |
# File 'lib/insync.rb', line 38 def initialize(path) @path = path end |
Instance Method Details
#inspect_path(path) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/insync.rb', line 54 def inspect_path(path) begin repo = Repository.new path if repo.remote_origin_exists? local = repo.log remote = repo.remote_log if local.first.id != remote.first.id && local.count == remote.count puts colorize("\n#{path}\n => Out of sync\n", { :foreground => :red, :config => :bright }) elsif local.count < remote.count puts colorize("\n#{path}\n => Behind by #{remote.count-local.count} commits\n", { :foreground => :blue, :config => :bright }) elsif local.count > remote.count puts colorize("\n#{path}\n => Ahead by #{local.count-remote.count} commits\n", { :foreground => :magenta, :config => :bright }) end end rescue nil end end |
#watch ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/insync.rb', line 42 def watch directory_entries = Dir.entries(@path) dirs = directory_entries.find_all {|e| File.directory?(full_path_of e) && e =~ /^[^.]+/} inspect_path(@path) dirs.each do |dir_name| dir = full_path_of dir_name inspect_path(dir) end end |