rbr 0.3.1 → 0.3.2
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/README.md +60 -66
- data/lib/rbr/matchers.rb +1 -1
- data/lib/rbr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b7d0b6b8d0cf90f5663842f750f2a54aca82bbeac46ab4ba6c542889a1dea98
|
4
|
+
data.tar.gz: f54146ad71167e7dd56d4038457c7388f130e67d539c179490f5ee773b642e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab183917580958f97adfbd4e2144f501561c16eb4e330f0c0c806f33407d6402cb3fe87cc85f393f3083ab35dc975cb2ed6e5636cdc430b0b47c5e01ed2e11f3
|
7
|
+
data.tar.gz: 2cf02448bf77d5c58f8f7f6d68067085ec424d723d7a5515254ba50975e687b2f19681f65a30a1b8fa717b9a2ac392ea2ec2a0bbe0fca73662186f877581355c
|
data/README.md
CHANGED
@@ -1,87 +1,87 @@
|
|
1
1
|
# Rbr
|
2
2
|
|
3
|
-
Rbr is a code search tool that parses Ruby code so you can query over certain semantic
|
4
|
-
|
3
|
+
Rbr is a code search tool that parses Ruby code so you can query over certain semantic constructs.
|
4
|
+
|
5
|
+
This differs from a file contents search (like grep) in that rbr understands Ruby grammar. This allows you to search your codebase for, say, every place that a method is called without matching the method definition or other occurrences of the method name.
|
5
6
|
|
6
7
|
## Usage examples
|
7
8
|
|
8
|
-
|
9
|
+
- Find all assignments to an lvalue named `@author`, but not any other references to that variable.
|
9
10
|
|
10
|
-
```sh
|
11
|
-
$ rbr assignment :@author test/fixtures/book.rb
|
12
|
-
test/fixtures/book.rb:5: @author = author
|
13
|
-
```
|
11
|
+
```sh
|
12
|
+
$ rbr assignment :@author test/fixtures/book.rb
|
13
|
+
test/fixtures/book.rb:5: @author = author
|
14
|
+
```
|
14
15
|
|
15
|
-
int or float with value `5
|
16
|
+
- Find any int or float with value `5`, but not any strings or comments that contain 5.
|
16
17
|
|
17
|
-
```sh
|
18
|
-
$ rbr number 5 test/fixtures/book.rb
|
19
|
-
test/fixtures/book.rb:12: 5
|
20
|
-
```
|
18
|
+
```sh
|
19
|
+
$ rbr number 5 test/fixtures/book.rb
|
20
|
+
test/fixtures/book.rb:12: 5
|
21
|
+
```
|
21
22
|
|
22
|
-
|
23
|
+
- Find all strings matching the pattern `/ring/`.
|
23
24
|
|
24
|
-
```sh
|
25
|
-
$ rbr string ring test/fixtures/book.rb
|
26
|
-
test/fixtures/book.rb:13: "a string!"
|
27
|
-
```
|
25
|
+
```sh
|
26
|
+
$ rbr string ring test/fixtures/book.rb
|
27
|
+
test/fixtures/book.rb:13: "a string!"
|
28
|
+
```
|
28
29
|
|
29
|
-
|
30
|
+
- Find all literals (int, float, or string) with the value `5`.
|
30
31
|
|
31
|
-
```sh
|
32
|
-
$ rbr literal 5 test/fixtures/book.rb
|
33
|
-
test/fixtures/book.rb:12: 5
|
34
|
-
test/fixtures/book.rb:49: "5"
|
35
|
-
```
|
32
|
+
```sh
|
33
|
+
$ rbr literal 5 test/fixtures/book.rb
|
34
|
+
test/fixtures/book.rb:12: 5
|
35
|
+
test/fixtures/book.rb:49: "5"
|
36
|
+
```
|
36
37
|
|
37
|
-
|
38
|
+
- Find all comments matching the pattern `/great/`, but not any uncommented Ruby code.
|
38
39
|
|
39
|
-
```sh
|
40
|
-
$ rbr comment great test/fixtures/book.rb
|
41
|
-
test/fixtures/book.rb:1: # This is a great class
|
42
|
-
```
|
40
|
+
```sh
|
41
|
+
$ rbr comment great test/fixtures/book.rb
|
42
|
+
test/fixtures/book.rb:1: # This is a great class
|
43
|
+
```
|
43
44
|
|
44
|
-
|
45
|
+
- Find all calls of a method named `great_method`, but not the definition or any other appearances of that identifier.
|
45
46
|
|
46
|
-
```sh
|
47
|
-
$ rbr method_call :great_method test/fixtures/book.rb
|
48
|
-
test/fixtures/book.rb:27: book.great_method
|
49
|
-
test/fixtures/book.rb:50: book.send(:great_method)
|
50
|
-
```
|
47
|
+
```sh
|
48
|
+
$ rbr method_call :great_method test/fixtures/book.rb
|
49
|
+
test/fixtures/book.rb:27: book.great_method
|
50
|
+
test/fixtures/book.rb:50: book.send(:great_method)
|
51
|
+
```
|
51
52
|
|
52
|
-
|
53
|
+
- Find all statements that update an ActiveRecord model attribute named `title`.
|
53
54
|
|
54
|
-
```sh
|
55
|
-
$ rbr ar_update :title test/fixtures/book.rb
|
56
|
-
test/fixtures/book.rb:21: book.title = "Great Title"
|
57
|
-
test/fixtures/book.rb:27: book.update!(title: "Great Title")
|
58
|
-
test/fixtures/book.rb:31: book.send(:update_column, :title, "Great Title")
|
59
|
-
```
|
55
|
+
```sh
|
56
|
+
$ rbr ar_update :title test/fixtures/book.rb
|
57
|
+
test/fixtures/book.rb:21: book.title = "Great Title"
|
58
|
+
test/fixtures/book.rb:27: book.update!(title: "Great Title")
|
59
|
+
test/fixtures/book.rb:31: book.send(:update_column, :title, "Great Title")
|
60
|
+
```
|
60
61
|
|
61
|
-
rbr is the wrong tool for the following situations:
|
62
|
+
### rbr is the *wrong tool* for the following situations:
|
62
63
|
|
63
|
-
appearance of
|
64
|
+
- Find all appearance of "author" in a codebase.
|
64
65
|
|
65
|
-
```sh
|
66
|
-
$ grep "author"
|
67
|
-
```
|
66
|
+
```sh
|
67
|
+
$ grep "author"
|
68
|
+
```
|
68
69
|
|
69
|
-
symbol
|
70
|
+
- Find all occurrences of the symbol `:author`. Symbols are easy to match in Ruby syntax, so you can use grep.
|
70
71
|
|
71
|
-
```sh
|
72
|
-
$ grep ":author"
|
73
|
-
```
|
72
|
+
```sh
|
73
|
+
$ grep ":author\b"
|
74
|
+
```
|
74
75
|
|
75
|
-
definition of any function named
|
76
|
+
- Find the definition of any function named `publish`. Definitions are easy to match in Ruby syntax, so you can use grep.
|
76
77
|
|
77
|
-
```sh
|
78
|
-
$ grep "def publish"
|
79
|
-
```
|
78
|
+
```sh
|
79
|
+
$ grep "def publish\b"
|
80
|
+
```
|
80
81
|
|
81
82
|
## Installation
|
82
83
|
|
83
|
-
Rbr is intended to be used as a command-line program. Install the executable `rbr`
|
84
|
-
with:
|
84
|
+
Rbr is intended to be used as a command-line program. Install the executable `rbr` with:
|
85
85
|
|
86
86
|
```
|
87
87
|
gem install rbr
|
@@ -89,18 +89,12 @@ gem install rbr
|
|
89
89
|
|
90
90
|
## Development
|
91
91
|
|
92
|
-
After checking out the repo, run `bundle install` to install dependencies. Then,
|
93
|
-
run `rake test` to run the tests or `bundle exec rbr` to run the local copy.
|
92
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests or `bundle exec rbr` to run the local copy.
|
94
93
|
|
95
94
|
## License
|
96
95
|
|
97
|
-
This program is free software: you can redistribute it and/or modify it under the
|
98
|
-
terms of the GNU General Public License as published by the Free Software Foundation,
|
99
|
-
either version 3 of the License, or (at your option) any later version.
|
96
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
100
97
|
|
101
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
102
|
-
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
103
|
-
PURPOSE. See the GNU General Public License for more details.
|
98
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
104
99
|
|
105
|
-
You should have received a copy of the GNU General Public License along with this
|
106
|
-
program. If not, see <https://www.gnu.org/licenses/>.
|
100
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
data/lib/rbr/matchers.rb
CHANGED
data/lib/rbr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eddie Lebow
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|