railbow 0.4.0 → 0.6.0

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.
@@ -26,5 +26,35 @@ module Railbow
26
26
  end
27
27
  "#{truncated}..."
28
28
  end
29
+
30
+ # ANSI-aware counterpart to truncate_str: escape codes pass through
31
+ # unmeasured, and a color left open at the cut is closed before the
32
+ # ellipsis so it cannot leak into whatever follows the cell.
33
+ def truncate_ansi(str, max_width)
34
+ s = str.to_s
35
+ return s if display_width(strip_ansi(s)) <= max_width
36
+
37
+ result = +""
38
+ width = 0
39
+ open_color = false
40
+ i = 0
41
+ while i < s.length
42
+ if s[i] == "\e" && (close = s.index("m", i))
43
+ code = s[i..close]
44
+ result << code
45
+ open_color = (code != "\e[0m")
46
+ i = close + 1
47
+ else
48
+ ch = s[i]
49
+ ch_width = display_width(ch)
50
+ break if width + ch_width > max_width - 3
51
+ result << ch
52
+ width += ch_width
53
+ i += 1
54
+ end
55
+ end
56
+ result << "\e[0m" if open_color
57
+ "#{result}..."
58
+ end
29
59
  end
30
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Railbow
4
- VERSION = "0.4.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railbow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene M
@@ -92,6 +92,7 @@ files:
92
92
  - lib/railbow/logo.rb
93
93
  - lib/railbow/migration_formatter.rb
94
94
  - lib/railbow/migration_parser.rb
95
+ - lib/railbow/multi_db.rb
95
96
  - lib/railbow/name_collision_resolver.rb
96
97
  - lib/railbow/name_formatter.rb
97
98
  - lib/railbow/notes_formatter.rb
@@ -99,6 +100,11 @@ files:
99
100
  - lib/railbow/railtie.rb
100
101
  - lib/railbow/routes_formatter.rb
101
102
  - lib/railbow/stats_formatter.rb
103
+ - lib/railbow/status/ghosts.rb
104
+ - lib/railbow/status/git_data.rb
105
+ - lib/railbow/status/help.rb
106
+ - lib/railbow/status/printer.rb
107
+ - lib/railbow/status/section.rb
102
108
  - lib/railbow/table.rb
103
109
  - lib/railbow/table/column.rb
104
110
  - lib/railbow/table/renderer.rb