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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f7677005fd87a28c0d3bb2d9fbb462b22d4d68
4
- data.tar.gz: 1eaf5de0c345a7e64eaa9b029e9d489d40537891
3
+ metadata.gz: b41a9526e32d5ec2113bb75da77b7f2ffc6fc255
4
+ data.tar.gz: 7917caf73613169b4a9fca688fd124c38d78bae3
5
5
  SHA512:
6
- metadata.gz: 4883f22dee50d40b30d002303ba70b27e5550c14c25e444adb79e5708a9e6727ccf6b2c727e385ea1a83e0e4a43f1741d1b6cf432564efa1454c35bd89f017d6
7
- data.tar.gz: 2f65245d5dc3b705beef56f8843f932e94e70f73416346b270f1f799b42cc342639d5e44a5ae3c97fed9e48b652422cea3fe9d4a04ee59ccae675cc3ae62eab9
6
+ metadata.gz: 93dd41173672b03dd6aed59afb6e5a0600abc90f35763e856b85e43c520b33df92751ad8e5645ebff82b8ecdcfb27195890e4ad8f588f23ff5d38eaf6e33414d
7
+ data.tar.gz: f7141936b728964078c79924ca5ff4908e6c20e92ea7b6ee8966c636dfe2d0acdfe5e7673e6b82224b59fd6086ecc04bca4faac79dc512180ca992653c3d1727
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omnibar (0.0.2)
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
- ## Development
19
+ ## Configuration
20
20
 
21
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
21
+ Omnibar looks at the file `~/.omnibar` to configure the app. This file is executed as ruby.
22
22
 
23
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
 
@@ -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
 
@@ -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
@@ -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
- repos.each do |repo|
15
- user, name = repo.split('/')
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
@@ -1,16 +1,13 @@
1
+ require 'fuzzy_match'
2
+
1
3
  module Omnibar
2
4
  class Popular < Query
3
5
  def result
4
- case input
5
- when /^news/
6
- 'news.ycombinator.com'
7
- when /^redd?i?t?/
8
- 'reddit.com'
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!
@@ -1,3 +1,3 @@
1
1
  module Omnibar
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -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.3
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