djinni 2.2.3 → 2.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/djinni.rb +23 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fcd7ceeb81b894886dcca48088eea5012cef7a750f3df0ffe39beb1baf012aa
4
- data.tar.gz: d3d8ea9414e871314a41d1d2fd3ee07ee6d5433d188eac3caf55b699a44f6bd8
3
+ metadata.gz: 65fbf5d61e83c40690ef71ba3ac5e50a765bed3484538c259bb552be8510873b
4
+ data.tar.gz: 41b1874ab97cf60ef517676c0900ddd1b829b83888b54905128b2b9b07c9a30b
5
5
  SHA512:
6
- metadata.gz: b6f740be301aebd532a4799db0ff56e2fc1527e7d77c1b02310153ac45a5b1585dabbfb574d9e095861bfe8cc1c7a8a7fb47a69a231f6a0e008f1fc7d2b49bef
7
- data.tar.gz: 2078235c6392ea62d2b2011a6689f3960dcff358977b60d848c1224dcdafa22a88a344e38d6382a695e733b529130c051e0d59534cc3495009e1bb89565ed2aa
6
+ metadata.gz: 86f50f88bfc700809dcbb9ef428a4ec54dfdfabd886d51c78408cb1ab4d841ec4d22e6c4d0542680e7e05d616ecaece0b8cb1cfddd266eecb2559c593c8aa7ce
7
+ data.tar.gz: 5c2b77fdfd136f203f89f1b68b573cec8d5e49a29bf1a48854641ae237d3fccb234bc26ab4891fd64381ebfb39347333b263eaed095412f5339fe46588fafb91
data/lib/djinni.rb CHANGED
@@ -57,21 +57,23 @@ class Djinni
57
57
  end
58
58
 
59
59
  max = completions.keys.max_by(&:length).length
60
+ nlfill = ""
61
+ nlfill = " " * (max + space) if ((max + space) > 0)
60
62
  width = @width - (max + space) - 2
61
63
 
62
64
  puts
63
65
  completions.each do |item, desc|
64
- fill = " " * (max + space - item.length)
65
- lines = ""
66
- nlfill = " " * (max + space)
67
- if (desc)
68
- lines = desc.scan(
69
- /\S.{0,#{width}}\S(?=\s|$)|\S+/
70
- )
66
+ desc ||= ""
67
+ fill = ""
68
+ if ((max + space - item.length) > 0)
69
+ fill = " " * (max + space - item.length)
71
70
  end
71
+ lines = desc.scan(
72
+ /\S.{0,#{width}}\S(?=\s|$)|\S+/
73
+ )
72
74
 
73
75
  if (lines.empty?)
74
- puts "#{item}"
76
+ puts item
75
77
  else
76
78
  start = lines.delete_at(0)
77
79
  puts "#{item}#{fill}#{start}"
@@ -81,10 +83,9 @@ class Djinni
81
83
  end
82
84
  end
83
85
 
84
- return input.gsub(
85
- /#{replace}$/,
86
- longest_common_substring(completions.keys)
87
- )
86
+ longest = longest_common_substring(completions.keys)
87
+ return input if (longest.empty?)
88
+ return input.gsub(/#{replace}$/, longest)
88
89
  else
89
90
  wishes = @wishes.select do |aliaz, w|
90
91
  aliaz.start_with?(input)
@@ -97,20 +98,24 @@ class Djinni
97
98
  end
98
99
 
99
100
  max = wishes.keys.max_by(&:length).length
101
+ nlfill = ""
102
+ nlfill = " " * (max + space) if ((max + space) > 0)
100
103
  width = @width - (max + space) - 2
101
104
 
102
105
  puts
103
106
  wishes.sort do |a, b|
104
107
  a.first.downcase <=> b.first.downcase
105
108
  end.each do |aliaz, w|
106
- fill = " " * (max + space - aliaz.length)
109
+ fill = ""
110
+ if ((max + space - aliaz.length) > 0)
111
+ fill = " " * (max + space - aliaz.length)
112
+ end
107
113
  lines = w.description.scan(
108
114
  /\S.{0,#{width}}\S(?=\s|$)|\S+/
109
115
  )
110
- nlfill = " " * (max + space)
111
116
 
112
117
  if (lines.empty?)
113
- puts "#{aliaz}"
118
+ puts aliaz
114
119
  else
115
120
  start = lines.delete_at(0)
116
121
  puts "#{aliaz}#{fill}#{start}"
@@ -228,6 +233,7 @@ class Djinni
228
233
 
229
234
  def longest_common_substring(array)
230
235
  compare = array.min_by(&:length)
236
+ compare ||= ""
231
237
  loop do
232
238
  break if (compare.empty?)
233
239
  all = array.all? do |item|
@@ -248,7 +254,8 @@ class Djinni
248
254
  buff = ""
249
255
  loop do
250
256
  djinni_prompt = djinni_env["djinni_prompt"]
251
- blank_line = " " * @width
257
+ blank_line = ""
258
+ blank_line = " " * @width if (@width > 0)
252
259
 
253
260
  # Handle long lines that get wrapped
254
261
  buff_len = remove_colors(djinni_prompt).length + prev_len
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djinni
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest