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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '028c0f4cdd37b9257eb272c1dd961629c26da09a4353d7bafa42eb81314c14d1'
4
- data.tar.gz: 282d0e315b69db474eed1b27b1a7cd9b5cb693057c4125b81f4883db27c262d9
3
+ metadata.gz: 793a10b4b4676491d13d45fd598316ce327cfa660962ce37c7e3404a383f1a2e
4
+ data.tar.gz: 84f8ab7c8ff9350c95182dcc1127e7ec779b8f5a0f0f9567d845680275bda9c3
5
5
  SHA512:
6
- metadata.gz: 6e821650c6ff4777eff717d26a0d481928bb91bfa93af7336e359023f2fc7ccfddb6ae4bdc724ecd81c0d1a3799420605f6c66e09c756fbbf87ea5b64ba30527
7
- data.tar.gz: 8dacf807b6da4d56b1e7dfdc68dca009eb98f9b83b876e18415bab0803d52292cc19688081a2526cdeab1e041eddbb5025dc0b27d0093f340b4b72ea1754cf96
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. Defaults to /TODO/.
35
- - `-e, --exclude x,y,z`: Comma-separated list of files and directories to exclude from the search. Defaults to log, tmp, vendor, node_modules, assets.
36
- - `--search-hidden`: Search hidden files and directories. Defaults to false.
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 `TODO` in the current directory, excluding the default directories:
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 a custom pattern in another directory, while specifying files and directories to exclude:
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,foo/bar.baz' /path/to/directory
53
+ bundle exec grepfruit -r 'FIXME|TODO' -e 'bin,tmp/log,Gemfile.lock' dev/grepfruit
50
54
  ```
51
55
 
52
- Search for a pattern in the current directory, including hidden files and directories:
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: /TODO/,
11
- exclude: [["log"], ["tmp"], ["vendor"], ["node_modules"], ["assets"]],
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)
@@ -1,3 +1,3 @@
1
1
  module Grepfruit
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
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.2.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-28 00:00:00.000000000 Z
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.2.33
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.