omglog 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/omglog +12 -45
- metadata +15 -4
data/bin/omglog
CHANGED
@@ -1,51 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
3
|
-
require 'rb-fsevent'
|
4
2
|
|
5
|
-
|
6
|
-
YELLOW, BLUE, GREY, HIGHLIGHT = '0;33', '0;34', '0;90', '1;30;47'
|
7
|
-
SHORTEST_MESSAGE = 12
|
8
|
-
LOG_CMD = %{git log --all --date-order --graph --color --pretty="format: \2%h\3\2%d\3\2 %an, %ar\3\2 %s\3"}
|
9
|
-
LOG_REGEX = /(.*)\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003/
|
3
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
10
4
|
|
11
|
-
|
12
|
-
rows, cols = `tput lines; tput cols`.scan(/\d+/).map(&:to_i)
|
13
|
-
`#{LOG_CMD} -#{rows}`.tap {|log|
|
14
|
-
print CLEAR + log.split("\n")[0...(rows - 1)].map {|l|
|
15
|
-
commit = l.scan(LOG_REGEX).flatten.map(&:to_s)
|
16
|
-
commit.any? ? render_commit(commit, cols) : l
|
17
|
-
}.join("\n") + "\n" + "\e[#{GREY}mupdated #{Time.now.strftime("%a %H:%M:%S")}\e[m ".rjust(cols + 8)
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def render_commit commit, cols
|
22
|
-
row_highlight = commit[2][/[^\/]HEAD\b/] ? HIGHLIGHT : YELLOW
|
23
|
-
[nil, row_highlight, BLUE, '', GREY].map {|c| "\e[#{c}m" if c }.zip(
|
24
|
-
arrange_commit(commit, cols)
|
25
|
-
).join + "\e[m"
|
26
|
-
end
|
27
|
-
|
28
|
-
def arrange_commit commit, cols
|
29
|
-
commit[0].chomp!(' ')
|
30
|
-
commit[-2].sub!(/(\d+)\s(\w)[^\s]+ ago/, '\1\2 ago')
|
31
|
-
room = [cols - [commit[0].gsub(/\e\[[\d;]*m/, ''), commit[1..-2]].flatten.map(&:length).inject(&:+), SHORTEST_MESSAGE].max
|
32
|
-
commit.tap {|commit|
|
33
|
-
commit[3, 0] = if commit[-1].length > room
|
34
|
-
commit.pop[0...(room - 1)] + '…'
|
35
|
-
else
|
36
|
-
commit.pop.ljust(room)
|
37
|
-
end
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_change &block
|
42
|
-
FSEvent.new.tap {|fsevent|
|
43
|
-
fsevent.watch('.git', &block)
|
44
|
-
fsevent.run
|
45
|
-
}
|
46
|
-
end
|
5
|
+
require 'omglog'
|
47
6
|
|
48
7
|
abort("Run omglog at the root of the git repo you'd like to watch.") if (ARGV & %w[-h --help help]).any?
|
49
8
|
abort("The current directory doesn't look like the root of a git repo.") unless File.directory?('.git')
|
50
|
-
|
51
|
-
|
9
|
+
|
10
|
+
if RUBY_PLATFORM[/darwin/i]
|
11
|
+
require 'osx'
|
12
|
+
Omglog.run_on Omglog::OSX
|
13
|
+
elsif RUBY_PLATFORM[/linux/i]
|
14
|
+
require 'linux'
|
15
|
+
Omglog.run_on Omglog::Linux
|
16
|
+
else
|
17
|
+
abort("Sorry, your system isn't supported yet. It just needs notification support -- i.e. fsevents on OS X, or inotify on Linux.")
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omglog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-fsevent
|
16
|
-
requirement: &
|
16
|
+
requirement: &70104722537000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: 0.4.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70104722537000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rb-inotify
|
27
|
+
requirement: &70104722536420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70104722536420
|
25
36
|
description: Realtime git logging using fseventsd. omg!
|
26
37
|
email: ben@hoskings.net
|
27
38
|
executables:
|