fuzzyfinder 0.0.1 → 0.0.3

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
  SHA1:
3
- metadata.gz: 017b1cdc9a590e44e4792766e57e9dfe8ab248b3
4
- data.tar.gz: 430498df1dac01bb7e97da23eda1ad19b933c914
3
+ metadata.gz: dac4c542aeef6ae42e264734f146267e6c14e562
4
+ data.tar.gz: cf62f980a3dc364563a16890bba7b5cc607bc685
5
5
  SHA512:
6
- metadata.gz: 4b52dde5a4fe59b97983960db2353113b18ecb890c9965443b250a71997b9ed8032fe1a9581dfd011e316760799bc9030452ec47ffd892064588b9f5d4b21034
7
- data.tar.gz: b748689fc24d7132b75a3c0ce8840c56a280aa7b814b4358339e9402dbc3d8899e64c8e4d8de9851efcfd924b4e79de0a6c72f6f8e1289d2e6989d264d91eca7
6
+ metadata.gz: 54c002829d62b7268ae2fbb1a64efd8a26947fb285477ac27df4a5da819570cafcef8d68de93d2a110a84a2c1398adf07827aaee985b0ca96e1194e508f9fab7
7
+ data.tar.gz: 8457cc19625c29c28ab202721738462c666a5834e3744f028f9ab33b1366679a62fa2a74172ea87ee39d363fed0f7774bb6366833b20466ec4309cb81488bb1b
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler -v '~> 1.5'
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.2.1
7
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fuzzyfinder.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Matheus Rosa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,50 @@
1
+ # fuzzyfinder
2
+ [![Build Status](https://travis-ci.org/mdsrosa/fuzzyfinder.svg?branch=master)](https://travis-ci.org/mdsrosa/fuzzyfinder)
3
+
4
+ Fuzzy Finder implemented in Ruby. Matches partial string entries from a list of strings. Works similar to fuzzy finder in SublimeText, Atom and Vim's Ctrl-P plugin.
5
+
6
+
7
+ ## How does it work
8
+ See Amjith Ramanujam's blog post describing the algorithm: [http://blog.amjith.com/fuzzyfinder-in-10-lines-of-python](http://blog.amjith.com/fuzzyfinder-in-10-lines-of-python)
9
+
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ # Add to your Gemfile
16
+ gem 'fuzzyfinder'
17
+
18
+ # or install manually
19
+ gem install fuzzyfinder
20
+ ```
21
+
22
+ ## Usage
23
+ ```ruby
24
+ 2.2.1 :001 > require 'fuzzyfinder'
25
+ => true
26
+
27
+ 2.2.1 :002 > Fuzzyfinder::Fuzzyfinder.find('user', ['api_user.doc', 'user_doc.doc', 'django_migrations.py', 'migrations.py'])
28
+ => ["user_doc.doc", "api_user.doc"]
29
+
30
+ 2.2.1 :003 > Fuzzyfinder::Fuzzyfinder.find('djm', ['api_user.doc', 'user_doc.doc', 'django_migrations.py', 'migrations.py'])
31
+ => ["django_migrations.py"]
32
+
33
+ 2.2.1 :004 > Fuzzyfinder::Fuzzyfinder.find('mig', ['api_user.doc', 'user_doc.doc', 'django_migrations.py', 'migrations.py'])
34
+ => ["migrations.py", "django_migrations.py"]
35
+ ```
36
+
37
+ # Contributing
38
+
39
+ 1. Fork it ( https://github.com/[my-github-username]/fuzzyfinder/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
44
+
45
+ # Inspired by
46
+ Amjith Ramanujam's implementation: [https://github.com/amjith/fuzzyfinder](https://github.com/amjith/fuzzyfinder)
47
+
48
+
49
+ # License
50
+ See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "fuzzyfinder"
3
+ spec.version = "0.0.3"
4
+ spec.date = "2015-10-06"
5
+ spec.summary = "Fuzzy Finder"
6
+ spec.description = "Matches partial string entries from a list of strings."
7
+ spec.authors = ["Matheus Rosa"]
8
+ spec.email = "matheusdsrosa@gmail.com"
9
+ spec.homepage = "https://rubygems.org/gems/fuzzyfinder"
10
+ spec.license = "MIT"
11
+ spec.files = `git ls-files -z`.split("\x0")
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_development_dependency "bundler", "~> 1.7"
17
+ spec.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
18
+ end
@@ -1,15 +1,4 @@
1
- class Fuzzyfinder
2
- def self.find(user_input, collection)
3
- user_input = user_input.to_s if user_input.is_a? Numeric
4
- temporary_suggestions, suggestions = [], []
5
- pattern = user_input.split('').join('.*?')
6
- collection.each do |item|
7
- matches = item.scan(/#{pattern}/)
8
- if matches.any?
9
- temporary_suggestions.push([matches.last.length, Regexp.last_match.begin(0), item])
10
- end
11
- end
12
- temporary_suggestions.sort!.each { |e| suggestions.push(e.last) }
13
- suggestions
14
- end
15
- end
1
+ require 'fuzzyfinder/fuzzyfinder'
2
+
3
+ module Fuzzyfinder
4
+ end
@@ -0,0 +1,17 @@
1
+ module Fuzzyfinder
2
+ class Fuzzyfinder
3
+ def self.find(user_input, collection)
4
+ user_input = user_input.to_s if user_input.is_a? Numeric
5
+ temporary_suggestions, suggestions = [], []
6
+ pattern = user_input.split('').join('.*?')
7
+ collection.each do |item|
8
+ matches = item.scan(/#{pattern}/)
9
+ if matches.any?
10
+ temporary_suggestions.push([matches.last.length, Regexp.last_match.begin(0), item])
11
+ end
12
+ end
13
+ temporary_suggestions.sort!.each { |e| suggestions.push(e.last) }
14
+ suggestions
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Fuzzyfinder
2
+ version = "0.0.3"
3
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe Fuzzyfinder::Fuzzyfinder do
4
+ let(:fuzzyfinder) { described_class }
5
+
6
+ before :all do
7
+ @collection = [
8
+ "django_migration.py",
9
+ "main_group.rb",
10
+ "api_user.rb",
11
+ "user_doc.rb",
12
+ "migration.rb",
13
+ "admin.rb",
14
+ "admin22.rb"
15
+ ]
16
+ end
17
+
18
+ describe ".find" do
19
+ let(:user_input) { "mig" }
20
+
21
+ it "returns a list with matching results" do
22
+ result = fuzzyfinder.find(user_input, @collection)
23
+ expect(result).to be_a(Array)
24
+ expect(result).not_to be_empty
25
+ end
26
+
27
+ context "the closest matching result" do
28
+ let(:user_input_one) { "djm" }
29
+ let(:user_input_two) { "user" }
30
+
31
+ it "and returns a list with the first item as the closest result" do
32
+ result = fuzzyfinder.find(user_input_one, @collection)
33
+ expect(result[0]).to eq("django_migration.py")
34
+
35
+ result = fuzzyfinder.find(user_input_two, @collection)
36
+ expect(result[0]).to eq("user_doc.rb")
37
+ end
38
+ end
39
+
40
+ context "receives a integer from user input" do
41
+ let(:user_input_number) { 22 }
42
+
43
+ it "returns a list with matching results" do
44
+ result = fuzzyfinder.find(user_input_number, @collection)
45
+ expect(result).to be_a(Array)
46
+ expect(result).not_to be_empty
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,2 @@
1
+ require_relative '../lib/fuzzyfinder'
2
+ require 'yaml'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzyfinder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Rosa
@@ -9,17 +9,61 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-10-06 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.0.0
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.0.0
13
47
  description: Matches partial string entries from a list of strings.
14
48
  email: matheusdsrosa@gmail.com
15
49
  executables: []
16
50
  extensions: []
17
51
  extra_rdoc_files: []
18
52
  files:
53
+ - ".gitignore"
54
+ - ".travis.yml"
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - fuzzyfinder.gemspec
19
59
  - lib/fuzzyfinder.rb
60
+ - lib/fuzzyfinder/fuzzyfinder.rb
61
+ - lib/fuzzyfinder/version.rb
62
+ - spec/fuzzyfinder/fuzzyfinder_spec.rb
63
+ - spec/spec_helper.rb
20
64
  homepage: https://rubygems.org/gems/fuzzyfinder
21
65
  licenses:
22
- - mit
66
+ - MIT
23
67
  metadata: {}
24
68
  post_install_message:
25
69
  rdoc_options: []
@@ -41,4 +85,6 @@ rubygems_version: 2.4.6
41
85
  signing_key:
42
86
  specification_version: 4
43
87
  summary: Fuzzy Finder
44
- test_files: []
88
+ test_files:
89
+ - spec/fuzzyfinder/fuzzyfinder_spec.rb
90
+ - spec/spec_helper.rb