search_ui 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/search_it +1 -1
- data/lib/search_ui/search.rb +2 -5
- data/lib/search_ui/version.rb +1 -1
- data/search_ui.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35af8d1543a7a7aceef95fd7212c4f0ea26ba16b26a0dff099796fdd0f6811d9
|
4
|
+
data.tar.gz: 3174844d7b3dda6798e110e72a7390d8542f3403d8f663782d55163a3518e38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c409e8a930dea22dc154a324743a2db09f48954802ff80c9c97243f71b4b9cc5206e79eef9b8277d4048e1535bcb5c8d393f6576afce7610bcd9bc2415dfff0
|
7
|
+
data.tar.gz: be4d585229c53f712bc995f17152be4b96e6f16a66c77ecc08a2c36994400e8effa268d59a8ced1f6b9882d488ada09c7c7c0a71803d6e6aba9a187e5c2b6e68
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/bin/search_it
CHANGED
@@ -12,7 +12,7 @@ exit if choices.empty?
|
|
12
12
|
found = Search.new(
|
13
13
|
match: -> answer {
|
14
14
|
matcher = Amatch::PairDistance.new(answer.downcase)
|
15
|
-
matches =
|
15
|
+
matches = choices.map { |n| [ n, -matcher.similar(n.downcase) ] }.
|
16
16
|
select { |_, s| s < 0 }.sort_by(&:last).map(&:first)
|
17
17
|
matches.empty? and matches = choices
|
18
18
|
matches.first(Tins::Terminal.lines - 1)
|
data/lib/search_ui/search.rb
CHANGED
@@ -26,10 +26,9 @@ class SearchUI::Search
|
|
26
26
|
@matches = @match.(@answer)
|
27
27
|
@selector = [ 0, [ @selector, @matches.size - 1 ].min ].max
|
28
28
|
result = @query.(@answer, @matches, @selector)
|
29
|
-
@output.print clear_screen
|
30
|
-
@output.print move_home { ?\n + result }
|
31
29
|
loop do
|
32
|
-
@output.print
|
30
|
+
@output.print clear_screen
|
31
|
+
@output.print move_home { @prompt % @answer + ?\n + result }
|
33
32
|
case getc
|
34
33
|
when true
|
35
34
|
@output.print clear_screen, move_home, reset
|
@@ -44,8 +43,6 @@ class SearchUI::Search
|
|
44
43
|
@matches = @match.(@answer)
|
45
44
|
@selector = [ 0, [ @selector, @matches.size - 1 ].min ].max
|
46
45
|
result = @query.(@answer, @matches, @selector)
|
47
|
-
@output.print clear_screen
|
48
|
-
@output.print move_home { ?\n + result }
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
data/lib/search_ui/version.rb
CHANGED
data/search_ui.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: search_ui 0.0.
|
2
|
+
# stub: search_ui 0.0.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "search_ui".freeze
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2020-02-
|
11
|
+
s.date = "2020-02-14"
|
12
12
|
s.description = "This library allows a user to search an array of objects\n interactively in the console by matching the pattern a user inputs to an\n array of objects and pick one of the remaining objects.".freeze
|
13
13
|
s.email = "flori@ping.de".freeze
|
14
14
|
s.executables = ["search_it".freeze]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: search_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|