grepfruit 0.2.0 → 1.0.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +12 -8
- data/exe/grepfruit +7 -2
- data/lib/grepfruit/version.rb +1 -1
- data/lib/grepfruit.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793a10b4b4676491d13d45fd598316ce327cfa660962ce37c7e3404a383f1a2e
|
4
|
+
data.tar.gz: 84f8ab7c8ff9350c95182dcc1127e7ec779b8f5a0f0f9567d845680275bda9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a329e3105b5ab178180fb415ca72af96c62ab91a47d18669a3ac8514f25a5380e0d5840f457863b3f00b76766d7ddba3ca53951cfa8010e86525bca445ed41
|
7
|
+
data.tar.gz: d94287b1c4f5954920853f9303586803fb918877c7f18146528add86457b53940a4cfcda47ca63794b8caf002a7b6d02b0b3e19b6c39d5b03d5bad32b1d7e8a8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v1.0.0
|
2
|
+
|
3
|
+
- Removed default values for `--exclude` and `--regex` options
|
4
|
+
- Made `--regex` option required
|
5
|
+
- Fixed an error that was raised when a symbolic link was encountered during the search
|
6
|
+
|
1
7
|
## v0.2.0
|
2
8
|
|
3
9
|
- Added `--search-hidden` option to search hidden files and directories
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@ Grepfruit is a Ruby gem for searching files within a directory for a specified r
|
|
7
7
|
|
8
8
|
<img width="416" alt="Screenshot 2024-07-28 at 03 52 37" src="https://github.com/user-attachments/assets/95b26b81-dcc1-430b-ac44-641251cb84b6">
|
9
9
|
|
10
|
+
Grepfruit was originally created to be used in CI/CD pipelines to search for `TODO` comments in Ruby on Rails applications and provide more user-friendly output than the standard `grep` command, but it is flexible enough to be used for other similar purposes as well.
|
11
|
+
|
10
12
|
## Installation
|
11
13
|
|
12
14
|
Add this line to your application's Gemfile:
|
@@ -31,25 +33,27 @@ bundle exec grepfruit [options] PATH
|
|
31
33
|
|
32
34
|
### Options
|
33
35
|
|
34
|
-
- `-r, --regex REGEX`: Regex pattern to search for.
|
35
|
-
- `-e, --exclude x,y,z`: Comma-separated list of files and directories to exclude from the search.
|
36
|
-
- `--search-hidden`: Search hidden files and directories.
|
36
|
+
- `-r, --regex REGEX`: Regex pattern to search for (required).
|
37
|
+
- `-e, --exclude x,y,z`: Comma-separated list of files and directories to exclude from the search.
|
38
|
+
- `--search-hidden`: Search hidden files and directories.
|
37
39
|
|
38
40
|
### Examples
|
39
41
|
|
40
|
-
Search for the pattern
|
42
|
+
Search for the pattern `/TODO/` in the current directory, excluding `log`, `tmp`, `vendor`, `node_modules`, and `assets` directories:
|
41
43
|
|
42
44
|
```shell
|
43
|
-
bundle exec grepfruit
|
45
|
+
bundle exec grepfruit -r 'TODO' -e 'log,tmp,vendor,node_modules,assets'
|
46
|
+
# or
|
47
|
+
bundle exec grepfruit --regex 'TODO' --exclude 'log,tmp,vendor,node_modules,assets'
|
44
48
|
```
|
45
49
|
|
46
|
-
Search for
|
50
|
+
Search for the pattern `/FIXME|TODO/` in `dev/grepfruit` directory, excluding `bin`, `tmp/log`, and `Gemfile.lock` files and directories:
|
47
51
|
|
48
52
|
```shell
|
49
|
-
bundle exec grepfruit -r 'FIXME|TODO' -e 'log,Gemfile.lock
|
53
|
+
bundle exec grepfruit -r 'FIXME|TODO' -e 'bin,tmp/log,Gemfile.lock' dev/grepfruit
|
50
54
|
```
|
51
55
|
|
52
|
-
Search for
|
56
|
+
Search for the pattern `/FIXME|TODO/` in the current directory, including hidden files and directories:
|
53
57
|
|
54
58
|
```shell
|
55
59
|
bundle exec grepfruit -r 'FIXME|TODO' --search-hidden
|
data/exe/grepfruit
CHANGED
@@ -7,8 +7,8 @@ require "grepfruit"
|
|
7
7
|
|
8
8
|
options = {
|
9
9
|
path: Dir.pwd,
|
10
|
-
regex:
|
11
|
-
exclude: [
|
10
|
+
regex: nil,
|
11
|
+
exclude: [],
|
12
12
|
search_hidden: false
|
13
13
|
}
|
14
14
|
|
@@ -28,6 +28,11 @@ OptionParser.new do |opts|
|
|
28
28
|
end
|
29
29
|
end.parse!
|
30
30
|
|
31
|
+
if options[:regex].nil?
|
32
|
+
puts "Error: You must specify a regex pattern using the -r or --regex option."
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
|
31
36
|
options[:path] = ARGV[0] if ARGV[0]
|
32
37
|
|
33
38
|
Grepfruit.run(**options)
|
data/lib/grepfruit/version.rb
CHANGED
data/lib/grepfruit.rb
CHANGED
@@ -13,7 +13,7 @@ module Grepfruit
|
|
13
13
|
Find.find(dir) do |pth|
|
14
14
|
Find.prune if exclude.any? { |e| pth.split("/").last(e.length) == e } || !search_hidden && File.basename(pth).start_with?(".")
|
15
15
|
|
16
|
-
next if File.directory?(pth)
|
16
|
+
next if File.directory?(pth) || File.symlink?(pth)
|
17
17
|
|
18
18
|
files += 1
|
19
19
|
|
@@ -34,7 +34,7 @@ module Grepfruit
|
|
34
34
|
puts "\n\n"
|
35
35
|
|
36
36
|
if lines.empty?
|
37
|
-
puts "#{files} files checked, \e[32mno matches found\e[0m"
|
37
|
+
puts "#{files} file#{'s' if files > 1} checked, \e[32mno matches found\e[0m"
|
38
38
|
exit(0)
|
39
39
|
else
|
40
40
|
puts "Matches:\n\n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grepfruit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- enjaku4
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
|
-
rubygems_version: 3.
|
50
|
+
rubygems_version: 3.5.11
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: A tool for searching text patterns in files with colorized output.
|