grepfruit 2.0.3 → 2.0.4

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: 523ee40a32ea4bc5c0d6b91ca60d147985a8d79b84396b17c3fd4b49f629f121
4
- data.tar.gz: 84ee19de06fbb489a6dc9ac32365cc92a00b23fe11337b7d2c236f12ffa509c0
3
+ metadata.gz: 510715dadc6ac5afba47b5a02b122eb6ae53e46dcb4454a3d83adf7374615b1e
4
+ data.tar.gz: 4797c7612d6f0ab3e0ec3c15a3c48941984f9eba4837a919ba98f10551d3c4fb
5
5
  SHA512:
6
- metadata.gz: 76821e2d3b8967d931491d66c7d25cbea24b8998d9c4d2603c13a8597c04484d6eb0cb046e5ad9470d9c546ca70ec729b3929447db66dbf7ccceba3767393575
7
- data.tar.gz: 766456777c31d8c58a4e2ee6d4f6891ac8c280130c9c671894dd56d6e7e1c64e65ad512f0a73497ac6f94ab19653a7267d394fea152aca9a451cbfa874754e83
6
+ metadata.gz: a62a669cb08f455f3105ee73b4f70d991216c7b34e68477adf6546d922e43e5994ff9a9cfca38671adf69b90cb89edf1960019b8d5dd2fb3bb8df5602f6ccc2c
7
+ data.tar.gz: b85bd902107f90713cd14be4ce8662250975c76dfd95e7757a12f36da4004261098545e7929abe103c9b8204b7c457c011d129ff5daff5cc5dafa5e4aa163b34
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v2.0.4
2
+ - Fixed path resolution bug where searching in relative directories such as `.`, `./`, or `..` did not work correctly
3
+
1
4
  ## v2.0.3
2
5
 
3
6
  - Updated gemspec metadata to include the correct homepage URL
data/README.md CHANGED
@@ -1,97 +1,151 @@
1
- # Grepfruit
1
+ # Grepfruit: File Pattern Search Tool for Ruby
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/grepfruit.svg)](http://badge.fury.io/rb/grepfruit)
4
4
  [![Github Actions badge](https://github.com/brownboxdev/grepfruit/actions/workflows/ci.yml/badge.svg)](https://github.com/brownboxdev/grepfruit/actions/workflows/ci.yml)
5
5
 
6
- Grepfruit is a Ruby gem for searching files within a directory for a specified regular expression pattern, with options to exclude certain files or directories from the search and colorized output for better readability.
6
+ Grepfruit is a Ruby gem for searching files within a directory for specified regular expression patterns, with intelligent exclusion options and colorized output for enhanced readability. Originally designed for CI/CD pipelines to search for `TODO` comments in Ruby on Rails applications, Grepfruit provides more user-friendly output than the standard `grep` command while maintaining the flexibility for diverse search scenarios.
7
7
 
8
- <img width="431" alt="Screenshot 2024-12-26 at 18 01 39" src="https://github.com/user-attachments/assets/e3fdb4f7-c4d9-4c8d-9a5a-228f2be55d52" />
8
+ **Key Features:**
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.
10
+ - Regular expression search within files and directories
11
+ - Intelligent file and directory exclusion capabilities
12
+ - Colorized output for improved readability
13
+ - Hidden file and directory search support
14
+ - Configurable output truncation
15
+ - CI/CD pipeline friendly with meaningful exit codes
16
+ - Line-specific exclusion for precise control
17
+
18
+ ## Table of Contents
19
+
20
+ **Gem Usage:**
21
+ - [Installation](#installation)
22
+ - [Basic Usage](#basic-usage)
23
+ - [Command Line Options](#command-line-options)
24
+ - [Usage Examples](#usage-examples)
25
+ - [Exit Status](#exit-status)
26
+
27
+ **Community Resources:**
28
+ - [Contributing](#contributing)
29
+ - [License](#license)
30
+ - [Code of Conduct](#code-of-conduct)
11
31
 
12
32
  ## Installation
13
33
 
14
- Add this line to your application's Gemfile:
34
+ Add Grepfruit to your Gemfile:
15
35
 
16
- ```ruby
36
+ ```rb
17
37
  gem "grepfruit"
18
38
  ```
19
39
 
20
- And then execute:
40
+ Install the gem:
21
41
 
22
- ```shell
42
+ ```bash
23
43
  bundle install
24
44
  ```
25
45
 
26
- Or install it yourself as:
46
+ Or install it directly:
27
47
 
28
- ```shell
48
+ ```bash
29
49
  gem install grepfruit
30
50
  ```
31
51
 
32
- ## Usage
52
+ ## Basic Usage
33
53
 
34
- You can use Grepfruit from the command line to search for a regex pattern within files in a specified directory.
54
+ Search for regex patterns within files in a specified directory:
35
55
 
36
- ```shell
56
+ ```bash
37
57
  grepfruit [options] PATH
38
58
  ```
39
59
 
40
- If no matches are found, Grepfruit returns exit status 0; otherwise, it returns exit status 1.
60
+ If no PATH is specified, Grepfruit searches the current directory.
61
+
62
+ ## Command Line Options
63
+
64
+ | Option | Description |
65
+ |--------|-------------|
66
+ | `-r, --regex REGEX` | Regex pattern to search for (required) |
67
+ | `-e, --exclude x,y,z` | Comma-separated list of files, directories, or lines to exclude |
68
+ | `-t, --truncate N` | Truncate search result output to N characters |
69
+ | `--search-hidden` | Include hidden files and directories in search |
70
+
71
+ ## Usage Examples
72
+
73
+ ### Basic Pattern Search
41
74
 
42
- ### Options
75
+ Search for `TODO` comments in the current directory:
43
76
 
44
- - `-r, --regex REGEX`: Regex pattern to search for (required).
45
- - `-e, --exclude x,y,z`: Comma-separated list of files, directories, or lines to exclude from the search.
46
- - `-t, --truncate N`: Truncate the output of the search results to N characters.
47
- - `--search-hidden`: Search hidden files and directories.
77
+ ```bash
78
+ grepfruit -r 'TODO'
79
+ ```
48
80
 
49
- ### Examples
81
+ ### Excluding Directories
50
82
 
51
- Search for the pattern `/TODO/` in the current directory, excluding `log`, `tmp`, `vendor`, `node_modules`, and `assets` directories:
83
+ Search for `TODO` patterns while excluding common build and dependency directories:
52
84
 
53
- ```shell
85
+ ```bash
54
86
  grepfruit -r 'TODO' -e 'log,tmp,vendor,node_modules,assets'
55
87
  ```
56
88
 
57
- Search for the pattern `/FIXME|TODO/` in `dev/grepfruit` directory, excluding `bin`, `tmp/log`, and `Gemfile.lock` files and directories:
89
+ ### Multiple Pattern Search Excluding Both Directories and Files
90
+
91
+ Search for both `FIXME` and `TODO` comments in a specific directory:
58
92
 
59
- ```shell
93
+ ```bash
60
94
  grepfruit -r 'FIXME|TODO' -e 'bin,tmp/log,Gemfile.lock' dev/grepfruit
61
95
  ```
62
96
 
63
- Search for the pattern `/FIXME|TODO/` in the current directory, excluding line 18 of `README.md`:
97
+ ### Line-Specific Exclusion
64
98
 
65
- ```shell
99
+ Exclude specific lines from search results:
100
+
101
+ ```bash
66
102
  grepfruit -r 'FIXME|TODO' -e 'README.md:18'
67
103
  ```
68
104
 
69
- Search for the pattern `/FIXME|TODO/` in the current directory, truncating the output of the search results to 50 characters:
105
+ ### Output Truncation
106
+
107
+ Limit output length for cleaner results:
70
108
 
71
- ```shell
109
+ ```bash
72
110
  grepfruit -r 'FIXME|TODO' -t 50
73
111
  ```
74
112
 
75
- Search for the pattern `/FIXME|TODO/` in the current directory, including hidden files and directories:
113
+ ### Including Hidden Files
76
114
 
77
- ```shell
115
+ Search hidden files and directories:
116
+
117
+ ```bash
78
118
  grepfruit -r 'FIXME|TODO' --search-hidden
79
119
  ```
80
120
 
81
- ## Problems?
82
-
83
- Facing a problem or want to suggest an enhancement?
84
-
85
- - **Open a Discussion**: If you have a question, experience difficulties using the gem, or have a suggestion for improvements, feel free to use the Discussions section.
121
+ ## Exit Status
86
122
 
87
- Encountered a bug?
123
+ Grepfruit returns meaningful exit codes for CI/CD integration:
88
124
 
89
- - **Create an Issue**: If you've identified a bug, please create an issue. Be sure to provide detailed information about the problem, including the steps to reproduce it.
90
- - **Contribute a Solution**: Found a fix for the issue? Feel free to create a pull request with your changes.
125
+ - **Exit code 0**: No matches found
126
+ - **Exit code 1**: Pattern matches were found
91
127
 
92
128
  ## Contributing
93
129
 
94
- Before creating an issue or a pull request, please read the [contributing guidelines](https://github.com/brownboxdev/grepfruit/blob/master/CONTRIBUTING.md).
130
+ ### Getting Help
131
+ Have a question or need assistance? Open a discussion in our [discussions section](https://github.com/brownboxdev/grepfruit/discussions) for:
132
+ - Usage questions
133
+ - Implementation guidance
134
+ - Feature suggestions
135
+
136
+ ### Reporting Issues
137
+ Found a bug? Please [create an issue](https://github.com/brownboxdev/grepfruit/issues) with:
138
+ - A clear description of the problem
139
+ - Steps to reproduce the issue
140
+ - Your environment details (Ruby version, OS, etc.)
141
+
142
+ ### Contributing Code
143
+ Ready to contribute? You can:
144
+ - Fix bugs by submitting pull requests
145
+ - Improve documentation
146
+ - Add new features (please discuss first in our [discussions section](https://github.com/brownboxdev/grepfruit/discussions))
147
+
148
+ Before contributing, please read the [contributing guidelines](https://github.com/brownboxdev/grepfruit/blob/master/CONTRIBUTING.md)
95
149
 
96
150
  ## License
97
151
 
data/exe/grepfruit CHANGED
@@ -6,7 +6,7 @@ require "optparse"
6
6
  require "grepfruit"
7
7
 
8
8
  options = {
9
- dir: Dir.pwd,
9
+ dir: ".",
10
10
  regex: nil,
11
11
  exclude: [],
12
12
  truncate: nil,
@@ -1,5 +1,6 @@
1
1
  require "pathname"
2
2
  require "find"
3
+ require "byebug"
3
4
 
4
5
  require_relative "decorator"
5
6
 
@@ -10,7 +11,7 @@ module Grepfruit
10
11
  attr_reader :dir, :regex, :excluded_paths, :excluded_lines, :truncate, :search_hidden
11
12
 
12
13
  def initialize(dir:, regex:, exclude:, truncate:, search_hidden:)
13
- @dir = dir
14
+ @dir = File.expand_path(dir)
14
15
  @regex = regex
15
16
  @excluded_lines, @excluded_paths = exclude.map { _1.split("/") }.partition { _1.last.include?(":") }
16
17
  @truncate = truncate
@@ -1,3 +1,3 @@
1
1
  module Grepfruit
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grepfruit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - enjaku4
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-16 00:00:00.000000000 Z
10
+ date: 2025-05-30 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  executables:
13
13
  - grepfruit