omglog 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. data/lib/omglog.rb +22 -2
  2. metadata +2 -2
@@ -1,14 +1,30 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Omglog
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.7'
5
5
 
6
6
  def run_on system
7
7
  Omglog::Base.run
8
+ on_terminal_resize { Omglog::Base.run }
8
9
  system.on_change { Omglog::Base.run }
9
10
  end
10
11
  module_function :run_on
11
12
 
13
+ def on_terminal_resize &block
14
+ rendering = true
15
+ trap("WINCH") {
16
+ # A dragging resize fires lots of WINCH events; this throttles the redraw
17
+ # and should cause it to (usually) line up with the final dimensions.
18
+ if rendering
19
+ rendering = false
20
+ sleep 0.5
21
+ rendering = true
22
+ yield
23
+ end
24
+ }
25
+ end
26
+ module_function :on_terminal_resize
27
+
12
28
  class Base
13
29
  CLEAR = "\n----\n"
14
30
  YELLOW, BLUE, GREY, HIGHLIGHT = '0;33', '0;34', '0;90', '1;30;47'
@@ -16,9 +32,13 @@ module Omglog
16
32
  LOG_CMD = %{git log --all --date-order --graph --color --pretty="format: \2%h\3\2%d\3\2 %an, %ar\3\2 %s\3"}
17
33
  LOG_REGEX = /(.*)\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003/
18
34
 
35
+ def self.log_cmd
36
+ @log_cmd ||= [LOG_CMD].concat(ARGV).join(' ')
37
+ end
38
+
19
39
  def self.run
20
40
  rows, cols = `tput lines; tput cols`.scan(/\d+/).map(&:to_i)
21
- `#{LOG_CMD} -#{rows}`.tap {|log|
41
+ `#{log_cmd} -#{rows}`.tap {|log|
22
42
  print CLEAR + log.split("\n")[0...(rows - 1)].map {|l|
23
43
  commit = l.scan(LOG_REGEX).flatten.map(&:to_s)
24
44
  commit.any? ? render_commit(commit, cols) : l
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.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-22 00:00:00.000000000 Z
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rb-fsevent