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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d34fc49a0962e25e0c01aad9ddfee2ec4351cda88ebd923152f53bf3a2b8c5cd
4
- data.tar.gz: b10a548832859cfa683ac89c95f422505e01e4c12682c0f39b8143d4cef0e903
3
+ metadata.gz: 6978b1e724000dd7beb343eb31b9f46f3c6f681a7620da852d76f5fc88c3cb96
4
+ data.tar.gz: aef4f21fc2bcbf32a7adfaf41d3dcca53d54f8cdad42d1d8ad711b3a3576baf9
5
5
  SHA512:
6
- metadata.gz: 9c7b45a37d84c0bd7ed91328b7e3b7f4bfb2d6d4ce79940bf1c01b1b34193962e0fdb3141a14b52d5b97b7e7fad8ce039482f2b13f80a594e3bcc78bfda720f3
7
- data.tar.gz: 6fee2904692473c952fc4de509288025ac00d018cc5e166dcd49ddef9d1560e7bd0be2705c5755ab11d52b3e59465a43712b889e74eff924c4385c44d5de136b
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: ->(entry) { { title: entry.title, url: entry.url } },
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).map(&itemizer)
19
+ findings.first(omnibar.max_results).flat_map(&itemizer)
20
20
  end
21
21
 
22
22
  super(resolver: resolver, **kwargs)
@@ -1,3 +1,3 @@
1
1
  class RailsOmnibar
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -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) { [:fake_result_1, :fake_result_2, :fake_result_3] },
24
- itemizer: ->(entry) { { title: entry, url: "/#{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.0.0
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-22 00:00:00.000000000 Z
11
+ date: 2023-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: js_regex