omnibar 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/README.md +17 -3
- data/lib/omnibar.rb +5 -1
- data/lib/omnibar/app.rb +2 -1
- data/lib/omnibar/github.rb +6 -17
- data/lib/omnibar/popular.rb +7 -10
- data/lib/omnibar/version.rb +1 -1
- data/omnibar.gemspec +2 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41a9526e32d5ec2113bb75da77b7f2ffc6fc255
|
4
|
+
data.tar.gz: 7917caf73613169b4a9fca688fd124c38d78bae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93dd41173672b03dd6aed59afb6e5a0600abc90f35763e856b85e43c520b33df92751ad8e5645ebff82b8ecdcfb27195890e4ad8f588f23ff5d38eaf6e33414d
|
7
|
+
data.tar.gz: f7141936b728964078c79924ca5ff4908e6c20e92ea7b6ee8966c636dfe2d0acdfe5e7673e6b82224b59fd6086ecc04bca4faac79dc512180ca992653c3d1727
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omnibar (0.0.
|
4
|
+
omnibar (0.0.3)
|
5
5
|
dry-configurable (~> 0.7.0)
|
6
|
+
fuzzy_match (~> 2.1.0)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -10,6 +11,7 @@ GEM
|
|
10
11
|
concurrent-ruby (1.0.5)
|
11
12
|
dry-configurable (0.7.0)
|
12
13
|
concurrent-ruby (~> 1.0)
|
14
|
+
fuzzy_match (2.1.0)
|
13
15
|
rake (10.5.0)
|
14
16
|
|
15
17
|
PLATFORMS
|
data/README.md
CHANGED
@@ -16,11 +16,25 @@ Install as:
|
|
16
16
|
|
17
17
|
Run `bin/omnibar` and start typing. Use the arrow keys to select the result you like, and press enter to go!
|
18
18
|
|
19
|
-
##
|
19
|
+
## Configuration
|
20
20
|
|
21
|
-
|
21
|
+
Omnibar looks at the file `~/.omnibar` to configure the app. This file is executed as ruby.
|
22
22
|
|
23
|
-
|
23
|
+
```ruby
|
24
|
+
#!/usr/bin/env ruby
|
25
|
+
|
26
|
+
Omnibar.configure do |omnibar|
|
27
|
+
omnibar.key = "value"
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
| Config Key | Type | Default |
|
32
|
+
|------------|------|---------|
|
33
|
+
| github.repos | Array | `[]` |
|
34
|
+
| render.prompt | Lambda / String | `->(width) { ('-' * width) << '>' }` |
|
35
|
+
| render.highlight.fg | Symbol | `:black` |
|
36
|
+
| render.highlight.bg | Symbol | `:yellow` |
|
37
|
+
| events.after_perform | Lambda | `-> {}` |
|
24
38
|
|
25
39
|
## Contributing
|
26
40
|
|
data/lib/omnibar.rb
CHANGED
@@ -6,8 +6,8 @@ require 'omnibar/app'
|
|
6
6
|
require 'omnibar/calculate'
|
7
7
|
require 'omnibar/github'
|
8
8
|
require 'omnibar/popular'
|
9
|
-
require 'omnibar/google'
|
10
9
|
require 'omnibar/duck_duck_go'
|
10
|
+
require 'omnibar/google'
|
11
11
|
|
12
12
|
module Omnibar
|
13
13
|
extend Dry::Configurable
|
@@ -16,6 +16,10 @@ module Omnibar
|
|
16
16
|
setting :repos, []
|
17
17
|
end
|
18
18
|
|
19
|
+
setting :popular do
|
20
|
+
setting :sites, []
|
21
|
+
end
|
22
|
+
|
19
23
|
setting :render do
|
20
24
|
setting :prompt, ->(width) { ('-' * width) << '>' }
|
21
25
|
|
data/lib/omnibar/app.rb
CHANGED
@@ -51,6 +51,8 @@ module Omnibar
|
|
51
51
|
self.selection = [selection - 1, 0].max
|
52
52
|
when "\e[B"
|
53
53
|
self.selection = [selection + 1, visible_queries.count - 1].min
|
54
|
+
when "\e\e"
|
55
|
+
self.input = ""
|
54
56
|
when "\r"
|
55
57
|
perform_action!
|
56
58
|
else
|
@@ -68,7 +70,6 @@ module Omnibar
|
|
68
70
|
visible_queries[selection]&.perform!
|
69
71
|
self.input = ""
|
70
72
|
Omnibar.config.events.after_perform.call
|
71
|
-
# TODO: after_perform callback
|
72
73
|
end
|
73
74
|
|
74
75
|
def queries
|
data/lib/omnibar/github.rb
CHANGED
@@ -1,25 +1,15 @@
|
|
1
|
-
class String
|
2
|
-
def &(other)
|
3
|
-
self == other[0...length]
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
1
|
module Omnibar
|
8
2
|
class Github < Query
|
9
|
-
def repos
|
10
|
-
Omnibar.config.github.repos
|
11
|
-
end
|
12
|
-
|
13
3
|
def result
|
14
|
-
|
15
|
-
|
16
|
-
name ||= ''
|
17
|
-
return repo if (input & repo or input & user or input & name)
|
18
|
-
end
|
19
|
-
|
4
|
+
repo = search.find(input)
|
5
|
+
return repo if repo
|
20
6
|
return input if input.match?(/^[\w-]+\/[\w-]+$/)
|
21
7
|
end
|
22
8
|
|
9
|
+
def search
|
10
|
+
@fm = FuzzyMatch.new(Omnibar.config.github.repos)
|
11
|
+
end
|
12
|
+
|
23
13
|
def perform!
|
24
14
|
param = result.downcase.gsub(/\s/, '-')
|
25
15
|
open_in_browser "https://github.com/#{param}"
|
@@ -27,5 +17,4 @@ module Omnibar
|
|
27
17
|
end
|
28
18
|
end
|
29
19
|
|
30
|
-
# TODO: assume name/name is a github repo
|
31
20
|
# TODO: add task for fetching user's repos https://api.github.com/users/:username/repos
|
data/lib/omnibar/popular.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
+
require 'fuzzy_match'
|
2
|
+
|
1
3
|
module Omnibar
|
2
4
|
class Popular < Query
|
3
5
|
def result
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
when /^fac?e?b?o?o?k?/
|
10
|
-
"[facebook] you're bad and you should feel bad"
|
11
|
-
when /^twit?t?e?r?/
|
12
|
-
'twitter.com'
|
13
|
-
end
|
6
|
+
search.find(input)
|
7
|
+
end
|
8
|
+
|
9
|
+
def search
|
10
|
+
@fm ||= FuzzyMatch.new(Omnibar.config.popular.sites)
|
14
11
|
end
|
15
12
|
|
16
13
|
def perform!
|
data/lib/omnibar/version.rb
CHANGED
data/omnibar.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'omnibar/version'
|
@@ -22,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
22
21
|
spec.require_paths = ['lib']
|
23
22
|
|
24
23
|
spec.add_dependency 'dry-configurable', '~> 0.7.0'
|
24
|
+
spec.add_dependency 'fuzzy_match', '~> 2.1.0'
|
25
|
+
|
25
26
|
spec.add_development_dependency 'bundler', '~> 1.16.a'
|
26
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omnibar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Evan Shreve
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fuzzy_match
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|