git-wayback-machine 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d497bb36396eeaf2e06482ea9d9b003edc78f36
4
- data.tar.gz: 436e668de2a4a26ea8d9242a93cde335774465a1
3
+ metadata.gz: 2ff567727fc7b31ce89797333e5720de1a8c03c7
4
+ data.tar.gz: 6c9e361467df8be857437786d338c628490204c9
5
5
  SHA512:
6
- metadata.gz: c464a2dc0a2d2e0a147f2e781be0a2c41ad24da3383aca5534663e93a98e01a84c4d94ad08909b150911fe02dc74a16b6f36e2d22df5d3f9444ce8af08baa1e8
7
- data.tar.gz: 23bcb9cfdfbe56abb6bb805529c4f5ad715e814b02e27599e7cef21fbd44b0bedf824818f998ad742ef9616184697e9b323d5aff4a87ab4fd2218d92ed17b163
6
+ metadata.gz: edc453f42ab71cb372747e3b11aa0ca04be28eebcceef00595b5ca416bafa1132da4c915c09fcd9ade05b91253113d079f29c1290cc6914f63d9e0f725005888
7
+ data.tar.gz: 0544baf52a36270e4ffbcbb4511ebeb06ef2e59306f1624099d96fc20779b61efd8318bb373c7b5f793f5ed981a3798ba852618b53975bc62fe89e3e803d25d1
@@ -1,3 +1,5 @@
1
+ require "io/console"
2
+
1
3
  module GitWaybackMachine
2
4
 
3
5
  class Controls
@@ -20,25 +22,20 @@ module GitWaybackMachine
20
22
  private
21
23
 
22
24
  def read_key
23
- old_state = `stty -g`
24
- `stty raw -echo`
25
-
26
- c = STDIN.getc.chr
27
-
28
- if c == "\e" # reading escape sequences
29
- extra_thread = Thread.new do
30
- c += STDIN.getc.chr + STDIN.getc.chr
25
+ STDIN.raw do |io|
26
+ key = io.getc.chr
27
+
28
+ if key == "\e"
29
+ extra_thread = Thread.new do
30
+ key += io.getc.chr + io.getc.chr
31
+ end
32
+ extra_thread.join(0.001)
33
+ extra_thread.kill
31
34
  end
32
- extra_thread.join(0.001)
33
- extra_thread.kill
34
- end
35
35
 
36
- c
37
-
38
- ensure
39
- `stty #{old_state}`
36
+ key
37
+ end
40
38
  end
41
-
42
39
  end
43
40
 
44
41
  end
@@ -9,7 +9,13 @@ module GitWaybackMachine
9
9
 
10
10
  class Entry < Struct.new(:sha, :name, :time, :comment)
11
11
  def to_s
12
- "\e[33m#{sha}\e[37m | \e[35m#{name} \e[36m(#{time})\e[37m - #{comment}\e[0m"
12
+ meta = "\e[33m#{sha}\e[37m | \e[35m#{name.ljust(17)} \e[36m(#{time})\e[37m - "
13
+ size_so_far = meta.gsub(/\e\[\d+m/, "").size
14
+ terminal_width = `tput cols`.to_i
15
+ cut_comment = comment.slice(0, terminal_width - size_so_far - 3)
16
+ cut_comment << "…" if comment.size > cut_comment.size
17
+
18
+ "#{meta}#{cut_comment}\e[0m"
13
19
  end
14
20
  end
15
21
 
@@ -41,8 +41,9 @@ module GitWaybackMachine
41
41
 
42
42
  def cleanup
43
43
  navigator_size = entries_slice.size + 2
44
+ terminal_size = `tput cols`.to_i
44
45
  print "\r\e[#{navigator_size}A"
45
- print (" " * 120 + "\n") * navigator_size
46
+ print (" " * terminal_size + "\n") * navigator_size
46
47
  print "\r\e[#{navigator_size}A"
47
48
  end
48
49
 
@@ -1,3 +1,3 @@
1
1
  module GitWaybackMachine
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-wayback-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Nemshilov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler