howzit 2.1.13 → 2.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.irbrc +6 -0
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/howzit/buildnote.rb +1 -1
- data/lib/howzit/stringutils.rb +80 -0
- data/lib/howzit/version.rb +1 -1
- data/spec/buildnote_spec.rb +14 -2
- data/spec/cli_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/src/_README.md +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa016c0fa681b1f07238f643dcdffd1fe9679a0362dd18a99ad5c9280282a66
|
4
|
+
data.tar.gz: 2e171f199e644a56046121b4a2b7bc803196bee9b026f619939c51f70828ec13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5178be93f700a6d51ddee37f1ea239d65eab8c79f60773d4a8faa9f6dc191a195d43e725cb9980532b2ab177a332c86fe0b914d64051c1eb67c80df0f1c61104
|
7
|
+
data.tar.gz: 58490e3f05c46aba51248dc857f1835b8146f9bfcd7b76fa0640175140046676825a4d1e25f1824bac5415875857da0078a95d2f4dbc783e0bf69d90e42c3c05
|
data/.irbrc
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
# Howzit
|
3
3
|
|
4
4
|
[![Gem](https://img.shields.io/gem/v/howzit.svg)](https://rubygems.org/gems/howzit)
|
5
|
-
[![Travis](https://api.travis-ci.com/ttscoff/howzit.svg?branch=main)](https://travis-ci.org/makenew/ruby-gem)
|
6
5
|
[![GitHub license](https://img.shields.io/github/license/ttscoff/howzit.svg)](./LICENSE.txt)
|
7
6
|
|
8
7
|
A command-line reference tool for tracking project build systems
|
9
8
|
|
10
9
|
Howzit is a tool that allows you to keep Markdown-formatted notes about a project's tools and procedures. It functions as an easy lookup for notes about a particular task, as well as a task runner to automatically execute appropriate commands.
|
11
10
|
|
11
|
+
|
12
12
|
## Features
|
13
13
|
|
14
14
|
- Match topic titles with any portion of title
|
data/lib/howzit/buildnote.rb
CHANGED
@@ -780,7 +780,7 @@ module Howzit
|
|
780
780
|
when :first
|
781
781
|
topic_matches.push(matches[0])
|
782
782
|
when :best
|
783
|
-
topic_matches.push(matches.
|
783
|
+
topic_matches.push(matches.sort_by { |a| [a.title.comp_distance(s), a.title.length] })
|
784
784
|
when :all
|
785
785
|
topic_matches.concat(matches)
|
786
786
|
else
|
data/lib/howzit/stringutils.rb
CHANGED
@@ -3,6 +3,86 @@
|
|
3
3
|
module Howzit
|
4
4
|
# String Extensions
|
5
5
|
module StringUtils
|
6
|
+
## Compare strings and return a distance
|
7
|
+
##
|
8
|
+
## @param other [String] The string to compare
|
9
|
+
## @param term [String] The search term
|
10
|
+
##
|
11
|
+
## @return [Float] distance
|
12
|
+
def comp_distance(term)
|
13
|
+
chars = term.split(//)
|
14
|
+
contains_count(chars) + distance(chars)
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
## Number of matching characters the string contains
|
19
|
+
##
|
20
|
+
## @param chars [String|Array] The characters
|
21
|
+
##
|
22
|
+
def contains_count(chars)
|
23
|
+
chars = chars.split(//) if chars.is_a?(String)
|
24
|
+
count = 0
|
25
|
+
chars.each { |char| count += 1 if self =~ /#{char}/i }
|
26
|
+
count
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
## Determine if characters are in order
|
31
|
+
##
|
32
|
+
## @param chars [String|Array] The characters
|
33
|
+
##
|
34
|
+
## @return [Boolean] characters are in order
|
35
|
+
##
|
36
|
+
def in_order(chars)
|
37
|
+
chars = chars.split(//) if chars.is_a?(String)
|
38
|
+
position = 0
|
39
|
+
in_order = 0
|
40
|
+
chars.each do |char|
|
41
|
+
new_pos = self[position..] =~ /#{char}/i
|
42
|
+
if new_pos
|
43
|
+
position += new_pos
|
44
|
+
in_order += 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
in_order
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
## Determine if a series of characters are all within a given distance of
|
52
|
+
## each other in the String
|
53
|
+
##
|
54
|
+
## @param chars [String|Array] The characters
|
55
|
+
## @param distance [Number] The distance
|
56
|
+
##
|
57
|
+
## @return [Boolean] true if within distance
|
58
|
+
##
|
59
|
+
def in_distance?(chars, distance)
|
60
|
+
chars = chars.split(//) if chars.is_a?(String)
|
61
|
+
rx = Regexp.new(chars.join(".{,#{distance}}"), 'i')
|
62
|
+
self =~ rx ? true : false
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
## Determine the minimum distance between characters that they all still
|
67
|
+
## fall within
|
68
|
+
##
|
69
|
+
## @param chars [Array] The characters
|
70
|
+
##
|
71
|
+
## @return [Number] distance
|
72
|
+
##
|
73
|
+
def distance(chars)
|
74
|
+
distance = 0
|
75
|
+
max = self.length - chars.length
|
76
|
+
return max unless in_order(chars) == chars.length
|
77
|
+
|
78
|
+
while distance < max
|
79
|
+
return distance if in_distance?(chars, distance)
|
80
|
+
|
81
|
+
distance += 1
|
82
|
+
end
|
83
|
+
distance
|
84
|
+
end
|
85
|
+
|
6
86
|
##
|
7
87
|
## Test if the filename matches the conditions to be a build note
|
8
88
|
##
|
data/lib/howzit/version.rb
CHANGED
data/spec/buildnote_spec.rb
CHANGED
@@ -27,43 +27,55 @@ describe Howzit::BuildNote do
|
|
27
27
|
expect(matches.count).to eq 1
|
28
28
|
expect(matches[0].title).to eq 'Topic Tropic'
|
29
29
|
end
|
30
|
+
|
30
31
|
it "fuzzy matches" do
|
31
32
|
Howzit.options[:matching] = 'fuzzy'
|
32
33
|
matches = how.find_topic('trpc')
|
33
34
|
expect(matches.count).to eq 1
|
34
35
|
expect(matches[0].title).to eq 'Topic Tropic'
|
35
36
|
end
|
37
|
+
|
36
38
|
it "succeeds with partial match" do
|
37
39
|
Howzit.options[:matching] = 'partial'
|
38
40
|
matches = how.find_topic('trop')
|
39
41
|
expect(matches.count).to eq 1
|
40
42
|
expect(matches[0].title).to eq 'Topic Tropic'
|
41
43
|
end
|
44
|
+
|
42
45
|
it "succeeds with beginswith match" do
|
43
46
|
Howzit.options[:matching] = 'beginswith'
|
44
47
|
matches = how.find_topic('topic')
|
45
48
|
expect(matches.count).to eq 3
|
46
49
|
expect(matches[0].title).to eq 'Topic Balogna'
|
47
50
|
end
|
51
|
+
|
48
52
|
it "succeeds with exact match" do
|
49
53
|
Howzit.options[:matching] = 'exact'
|
50
54
|
matches = how.find_topic('topic tropic')
|
51
55
|
expect(matches.count).to eq 1
|
52
56
|
expect(matches[0].title).to eq 'Topic Tropic'
|
53
57
|
end
|
58
|
+
|
54
59
|
it "fails with incomplete exact match" do
|
55
60
|
Howzit.options[:matching] = 'exact'
|
56
61
|
matches = how.find_topic('topic trop')
|
57
62
|
expect(matches.count).to eq 0
|
58
63
|
end
|
64
|
+
|
65
|
+
it "Handles multiple matches with best match" do
|
66
|
+
Howzit.options[:matching] = 'fuzzy'
|
67
|
+
Howzit.options[:multiple_matches] = :best
|
68
|
+
matches = how.find_topic('banana')
|
69
|
+
expect(matches.first.title).to match(/banana/i)
|
70
|
+
end
|
59
71
|
end
|
60
72
|
|
61
73
|
describe ".topics" do
|
62
74
|
it "contains 4 topics" do
|
63
|
-
expect(how.list_topics.count).to eq
|
75
|
+
expect(how.list_topics.count).to eq 4
|
64
76
|
end
|
65
77
|
it "outputs a newline-separated string for completion" do
|
66
|
-
expect(how.list_completions.scan(/\n/).count).to eq
|
78
|
+
expect(how.list_completions.scan(/\n/).count).to eq 3
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe 'CLI' do
|
|
15
15
|
execute_script('bin/howzit', use_bundler: true, args: %w[-L])
|
16
16
|
expect(last_execution).to be_successful
|
17
17
|
expect(last_execution.stdout).to match(/Topic Balogna/)
|
18
|
-
expect(last_execution.stdout.split(/\n/).count).to eq
|
18
|
+
expect(last_execution.stdout.split(/\n/).count).to eq 4
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'lists available tasks' do
|
data/spec/spec_helper.rb
CHANGED
data/src/_README.md
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
# Howzit
|
3
3
|
|
4
4
|
[![Gem](https://img.shields.io/gem/v/howzit.svg)](https://rubygems.org/gems/howzit)
|
5
|
-
[![Travis](https://api.travis-ci.com/ttscoff/howzit.svg?branch=main)](https://travis-ci.org/makenew/ruby-gem)
|
6
5
|
[![GitHub license](https://img.shields.io/github/license/ttscoff/howzit.svg)](./LICENSE.txt)
|
7
|
-
|
6
|
+
|
8
7
|
A command-line reference tool for tracking project build systems
|
9
8
|
|
10
9
|
Howzit is a tool that allows you to keep Markdown-formatted notes about a project's tools and procedures. It functions as an easy lookup for notes about a particular task, as well as a task runner to automatically execute appropriate commands.
|
10
|
+
<!--END GITHUB-->
|
11
11
|
|
12
12
|
## Features
|
13
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: howzit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- ".github/FUNDING.yml"
|
295
295
|
- ".gitignore"
|
296
296
|
- ".howzit.taskpaper.bak"
|
297
|
+
- ".irbrc"
|
297
298
|
- ".rspec"
|
298
299
|
- ".rubocop.yml"
|
299
300
|
- ".travis.yml"
|