search_ui 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bd55ce81380bd3c0eb0d1567dc0b6e5954ca128d8256e77b093d4dca158bf74
4
- data.tar.gz: 49975f652e6579eb3a51bb8f11cb1c2ab66cbcb8cc05dc0f6ae7f657cb085f79
3
+ metadata.gz: e1bf8a8f5b6d093cff6036196558bfbe4a476be367d1b3af6f724affc6b90db0
4
+ data.tar.gz: 87813d2915c78f6b7a3f67090264e41ceec84eb0ecf0c80260dd78f22b8c81a3
5
5
  SHA512:
6
- metadata.gz: d88362379d5e903b82d267dd1db8f8062f2f3b675423af826e21945ad935a3e4246c4c1639dfa205f97ea02c7dbab02618e02930af777547014038a221e919df
7
- data.tar.gz: c347e48ea327460c68a57092fef8910a91fb1fbaf69a2289e328d1e9d81e7d0791f71efee0a59d82db037bb74952c71acf2c1e2abe63b71f5cf5420029f5a9e5
6
+ metadata.gz: 866af2546d78cd716c13e79340a7a1c66ffaa57a4eb379e527adcc77ef3907b00870f0bda7044d96cd4b7dab392b01670d2abe8294eb9376a6bb37302e5fd2bb
7
+ data.tar.gz: 84e92c9c5815d5b232133d15dedb84e6b69a8577fc49ae2d0b459a5276b09ea32c33ad619d917f546c67ccb049fd954f56282c52ab8a5a4911d649b4b31a1353
data/README.md CHANGED
@@ -1,20 +1,81 @@
1
- # SearchUI - Searching things in console
1
+ # SearchUI 🔍 - Searching things in console
2
2
 
3
3
  ## Description
4
4
 
5
- This library allows a user to search an array of objects
6
- interactively in the console by matching the pattern a user inputs to an
7
- array of objects and pick one of the remaining objects.
5
+ A Ruby library for creating interactive console-based search interfaces 🎯
8
6
 
9
- ## Download
7
+ ## Features
10
8
 
11
- The homepage of this library is located at http://github.com/flori/search\_ui
9
+ - **Interactive Navigation** 🎮: Arrow key navigation through search results
10
+ - **Real-time Filtering** ⚡: Instant search updates as you type
11
+ - **Flexible Configuration** 🔧: Customizable matching, display, and selection logic
12
+ - **Terminal-aware** 🖥️: Properly handles terminal input and display management
13
+ - **Minimal Dependencies** 📦: Lightweight implementation using standard Ruby libraries
14
+
15
+ ## Installation
16
+
17
+ Add this gem to your Gemfile:
18
+
19
+ ```ruby
20
+ gem 'search_ui'
21
+ ```
22
+
23
+ And install it using Bundler:
24
+
25
+ ```bash
26
+ bundle install
27
+ ```
28
+
29
+ Or install the gem directly:
30
+
31
+ ```bash
32
+ gem install search_ui
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### Library Usage
38
+
39
+ For programmatic usage, create a custom search interface:
40
+
41
+ ```ruby
42
+ require 'search_ui'
43
+
44
+ items = ['apple', 'banana', 'cherry', 'date']
45
+
46
+ result = SearchUI::Search.new(
47
+ match: ->(pattern) { items.select { |item| item.include?(pattern) } },
48
+ query: ->(answer, matches, selector) {
49
+ matches.each_with_index.map do |match, i|
50
+ if i == selector
51
+ "→ #{match}"
52
+ else
53
+ " #{match}"
54
+ end
55
+ end.join("\n")
56
+ },
57
+ found: ->(answer, matches, selector) { matches[selector] }
58
+ ).start
59
+
60
+ puts "Selected: #{result}"
61
+ ```
62
+
63
+ ### Command Line Tool
64
+
65
+ The `search_it` binary provides a ready-to-use search interface:
66
+
67
+ ```bash
68
+ # Search through command-line arguments 🚀
69
+ ./bin/search_it apple banana cherry
70
+
71
+ # Search through a file 📄
72
+ ./bin/search_it -f items.txt
73
+ ```
12
74
 
13
75
  ## Author
14
76
 
15
- Florian Frank mailto:flori@ping.de
77
+ [Florian Frank](mailto:flori@ping.de) 👨‍💻
16
78
 
17
79
  ## License
18
80
 
19
- This software is licensed under the X11 (or MIT) license:
20
- http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3
81
+ [MIT License](./LICENSE) 📄
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -55,7 +55,7 @@ class SearchUI::Search
55
55
  def start
56
56
  @output.print reset
57
57
  @matches = @match.(@answer)
58
- @selector = [ 0, [ @selector, @matches.size - 1 ].min ].max
58
+ @selector = @selector.clamp(0, [ @matches.size - 1, 0 ].max)
59
59
  result = @query.(@answer, @matches, @selector)
60
60
  loop do
61
61
  @output.print clear_screen
@@ -72,7 +72,7 @@ class SearchUI::Search
72
72
  return nil
73
73
  end
74
74
  @matches = @match.(@answer)
75
- @selector = @selector.clamp(0, @matches.size - 1)
75
+ @selector = @selector.clamp(0, [ @matches.size - 1, 0 ].max)
76
76
  result = @query.(@answer, @matches, @selector)
77
77
  end
78
78
  end
@@ -1,6 +1,6 @@
1
1
  module SearchUi
2
2
  # SearchUi version
3
- VERSION = '0.0.6'
3
+ VERSION = '0.0.7'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/search_ui.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: search_ui 0.0.6 ruby lib
2
+ # stub: search_ui 0.0.7 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "search_ui".freeze
6
- s.version = "0.0.6".freeze
6
+ s.version = "0.0.7".freeze
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]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank