rails_omnibar 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +7 -2
- data/lib/rails_omnibar/command/search.rb +1 -1
- data/lib/rails_omnibar/version.rb +1 -1
- data/spec/my_omnibar_template.rb +7 -2
- data/spec/system/rails_omnibar_spec.rb +4 -1
- 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: 6978b1e724000dd7beb343eb31b9f46f3c6f681a7620da852d76f5fc88c3cb96
|
4
|
+
data.tar.gz: aef4f21fc2bcbf32a7adfaf41d3dcca53d54f8cdad42d1d8ad711b3a3576baf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5a8c4d176582c042d753fb7dd4a4c00856eb7c7051efbcf46faaa388571c6316f765f81e0417214221963947b261682eb17df1bc61447c1022a29d58c9a8e6c
|
7
|
+
data.tar.gz: c97526c6d2a2e4b41316eb31c2292eef3ec582eda6bc7c6efaacb59efe1a2e4e2e01f2007a2f45c34ac575057636c411e66f9a838c85dd33b476210e7c8b6fda
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.1.0] - 2023-01-23
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- support for returning an Array of items from `itemizer:`
|
12
|
+
|
7
13
|
## [1.0.0] - 2023-01-22
|
8
14
|
|
9
15
|
Initial release.
|
data/README.md
CHANGED
@@ -143,13 +143,18 @@ MyOmnibar.add_record_search(
|
|
143
143
|
itemizer: ->(user) { { title: "Admin #{user.name}", url: admin_url(user) } }
|
144
144
|
)
|
145
145
|
|
146
|
-
# Custom search
|
146
|
+
# Custom search, plus mapping to multiple results
|
147
147
|
MyOmnibar.add_search(
|
148
148
|
description: 'Google',
|
149
149
|
pattern: /^g (.+)/,
|
150
150
|
example: 'g kittens',
|
151
151
|
finder: ->(value) { GoogleSearch.fetch(value) },
|
152
|
-
itemizer: ->(
|
152
|
+
itemizer: ->(res) do
|
153
|
+
[
|
154
|
+
{ title: res.title, url: res.url },
|
155
|
+
{ title: "#{res.title} @archive", url: "web.archive.org/web/#{res.url}" }
|
156
|
+
]
|
157
|
+
end,
|
153
158
|
)
|
154
159
|
|
155
160
|
# Completely custom command
|
@@ -16,7 +16,7 @@ class RailsOmnibar
|
|
16
16
|
resolver = ->(value, omnibar) do
|
17
17
|
findings = finder.call(value)
|
18
18
|
findings = Array(findings) unless findings.respond_to?(:first)
|
19
|
-
findings.first(omnibar.max_results).
|
19
|
+
findings.first(omnibar.max_results).flat_map(&itemizer)
|
20
20
|
end
|
21
21
|
|
22
22
|
super(resolver: resolver, **kwargs)
|
data/spec/my_omnibar_template.rb
CHANGED
@@ -20,8 +20,13 @@ MyOmnibar = RailsOmnibar.configure do |c|
|
|
20
20
|
c.add_search(
|
21
21
|
pattern: /^g (.+)/,
|
22
22
|
example: 'g kittens',
|
23
|
-
finder: ->(input) { [
|
24
|
-
itemizer: ->(entry)
|
23
|
+
finder: ->(input) { %i[fake_result_1 fake_result_2 fake_result_3] },
|
24
|
+
itemizer: ->(entry) do
|
25
|
+
[
|
26
|
+
{ title: entry, url: '/' },
|
27
|
+
{ title: entry.to_s.upcase, url: '/' },
|
28
|
+
]
|
29
|
+
end,
|
25
30
|
description: 'Google',
|
26
31
|
)
|
27
32
|
|
@@ -64,11 +64,14 @@ describe RailsOmnibar do
|
|
64
64
|
expect(page.current_url).to end_with '/users/2'
|
65
65
|
send_keys([:control, 'm']) # make omnibar visible again
|
66
66
|
|
67
|
-
# test generic search
|
67
|
+
# test generic search and multi-itemization
|
68
68
|
type('g foobar')
|
69
69
|
expect(page).to have_content 'fake_result_1'
|
70
|
+
expect(page).to have_content 'FAKE_RESULT_1'
|
70
71
|
expect(page).to have_content 'fake_result_2'
|
72
|
+
expect(page).to have_content 'FAKE_RESULT_2'
|
71
73
|
expect(page).to have_content 'fake_result_3'
|
74
|
+
expect(page).to have_content 'FAKE_RESULT_3'
|
72
75
|
|
73
76
|
# test custom command
|
74
77
|
type('count users')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_omnibar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: js_regex
|