djinni 2.1.4 → 2.2.0

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 +13 -2
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0b573e13648862cb4ab07d9ff470787c19ba7678aea2ff079a1c2c76b1de1be
4
- data.tar.gz: dc1ec0636b4220a01e7403ceabface4ad304b4790ac8f94c9a196ffef46505c8
3
+ metadata.gz: 66736812763e4cf4aadf25e3f8042963243ef8505519bf818c79f043fa07794d
4
+ data.tar.gz: fd78fe60b747299b7406e99295b8b532b31205027552508d516eebc190f62e7b
5
5
  SHA512:
6
- metadata.gz: aa030601976c1782d6b9b40224ce9908473ba0beb59f464a511a61471f4d2be6d7b60180c084d614b53703aaf8e5284865d284fe3bbc7f4f46443bcaa4197a55
7
- data.tar.gz: 077d029e9e7ff958b5df61a67f98726c9f8057d12b38b8d87f4f985f1e52ee8f47d5bab49f72d3de207aa62ba350140ae0f580af76480cbe1e1e199050780e70
6
+ metadata.gz: 7e92e4bafec00ef0f5dd3d4ac8018a5e3fc32b6804844e132ada460df369eac2cc28611785ba54ba3d130662527d6d338a0f5d2b0cce091f43d34ef738666db3
7
+ data.tar.gz: 21bd6987550f8fe399b3a52ff7fe505175ed7c15f75440dbfdd99fe9e0c4c6f5aff03b6107b521291d70f0690ed650b5e0c76e8abb0d939461f2dc8949fab5c5
data/lib/djinni.rb CHANGED
@@ -2,6 +2,8 @@ require "fagin"
2
2
  require "io/console"
3
3
 
4
4
  class Djinni
5
+ attr_accessor :fallback
6
+
5
7
  def grant_wish(input, djinni_env = {})
6
8
  return "" if (input.nil? || input.empty?)
7
9
 
@@ -184,12 +186,13 @@ class Djinni
184
186
  end
185
187
 
186
188
  def initialize(interactive = false)
187
- @wishes = Hash.new
188
- @history = Array.new
189
+ @fallback = nil
189
190
  @hist_index = nil
191
+ @history = Array.new
190
192
  @interactive = interactive
191
193
  @loaded_from = Array.new
192
194
  @width = %x(tput cols).to_i
195
+ @wishes = Hash.new
193
196
 
194
197
  Signal.trap(
195
198
  "SIGWINCH",
@@ -264,8 +267,16 @@ class Djinni
264
267
  end
265
268
  system("stty -raw echo")
266
269
  prev_len = remove_colors(buff).length
270
+ save = buff
267
271
  buff = grant_wish(buff + input, djinni_env)
268
272
 
273
+ if (buff.nil? && !@fallback.nil? && !@fallback.empty?)
274
+ puts "\e[2A"
275
+ buff = grant_wish(
276
+ @fallback + " " + save + input, djinni_env
277
+ )
278
+ end
279
+
269
280
  if (buff.nil?)
270
281
  puts "Command not found!"
271
282
  buff = ""
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.1.4
4
+ version: 2.2.0
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-03-04 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.7.3
109
+ rubygems_version: 2.7.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: A Ruby command handler