referral 0.0.4 → 0.0.6
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/.github/workflows/ruby.yml +34 -0
- data/.standard.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -23
- data/README.md +62 -0
- data/lib/referral/ensures_working_ruby.rb +2 -1
- data/lib/referral/filters_tokens.rb +11 -0
- data/lib/referral/parses_options.rb +1 -0
- data/lib/referral/prints_results.rb +3 -0
- data/lib/referral/scans_tokens.rb +1 -1
- data/lib/referral/sorts_tokens.rb +4 -4
- data/lib/referral/token_types.rb +8 -6
- data/lib/referral/tokenizes_identifiers.rb +1 -1
- data/lib/referral/translates_node_to_token.rb +2 -1
- data/lib/referral/value/node_type.rb +1 -0
- data/lib/referral/value/options.rb +2 -2
- data/lib/referral/value/token.rb +10 -6
- data/lib/referral/version.rb +1 -1
- data/lib/referral.rb +2 -2
- data/referral.gemspec +10 -14
- metadata +7 -66
- data/.circleci/config.yml +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbff70f9e9188e6af17f3bc5be2c2f144a3fce7eaf48dcb3cd67f7a860073ebc
|
|
4
|
+
data.tar.gz: f3b4e46e334bf865d84f517efc1b30d662f807eb27e02a44cd00bdc20619ba7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de81b47bd2e9fbc0858d086e86b37429bd35be1bc6f6b54133c81bb014ea77e52cb3e47a01c28105042e21b3777dd3b7b613181f959660633af2f78a80c09d13
|
|
7
|
+
data.tar.gz: c450251c20c43d50d48f557ea18a7160cd1fb65dd38419a62f9d513b433361a150f848daa1992f52eb65b3f12e0839955afb502251b4ff7b41dce31ed4d7cf5f
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: Ruby
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [ main ]
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [ main ]
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
ruby-version: ['2.7', '3.0', '3.3', '3.4', '4.0']
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v7
|
|
26
|
+
with:
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
- name: Set up Ruby
|
|
29
|
+
uses: ruby/setup-ruby@v1
|
|
30
|
+
with:
|
|
31
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
32
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
33
|
+
- name: Run tests
|
|
34
|
+
run: bundle exec rake
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.0.6
|
|
4
|
+
|
|
5
|
+
- Fixed `Token#id` output on Ruby 3.4+: Ruby 3.4 changed `Hash#inspect`'s
|
|
6
|
+
format, which had silently changed the `id` column's output (and the
|
|
7
|
+
sort order it ties into) on those newer versions. `id` now matches
|
|
8
|
+
what Ruby 2.7-3.3 have always produced.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,42 +1,66 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
referral (0.0.
|
|
4
|
+
referral (0.0.6)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
ast (2.4.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
ast (2.4.3)
|
|
10
|
+
json (2.21.2)
|
|
11
|
+
language_server-protocol (3.17.0.6)
|
|
12
|
+
lint_roller (1.1.0)
|
|
13
|
+
minitest (5.26.1)
|
|
14
|
+
parallel (1.28.0)
|
|
15
|
+
parser (3.3.12.0)
|
|
16
|
+
ast (~> 2.4.1)
|
|
17
|
+
racc
|
|
18
|
+
prism (1.9.0)
|
|
19
|
+
racc (1.8.1)
|
|
20
|
+
rainbow (3.1.1)
|
|
21
|
+
rake (13.4.2)
|
|
22
|
+
regexp_parser (2.12.0)
|
|
23
|
+
rexml (3.4.4)
|
|
24
|
+
rubocop (1.64.1)
|
|
25
|
+
json (~> 2.3)
|
|
26
|
+
language_server-protocol (>= 3.17.0)
|
|
20
27
|
parallel (~> 1.10)
|
|
21
|
-
parser (>=
|
|
22
|
-
psych (>= 3.1.0)
|
|
28
|
+
parser (>= 3.3.0.2)
|
|
23
29
|
rainbow (>= 2.2.2, < 4.0)
|
|
30
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
31
|
+
rexml (>= 3.2.5, < 4.0)
|
|
32
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
24
33
|
ruby-progressbar (~> 1.7)
|
|
25
|
-
unicode-display_width (>=
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
35
|
+
rubocop-ast (1.50.0)
|
|
36
|
+
parser (>= 3.3.7.2)
|
|
37
|
+
prism (~> 1.7)
|
|
38
|
+
rubocop-performance (1.21.1)
|
|
39
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
40
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
41
|
+
ruby-progressbar (1.13.0)
|
|
42
|
+
standard (1.37.0)
|
|
43
|
+
language_server-protocol (~> 3.17.0.2)
|
|
44
|
+
lint_roller (~> 1.0)
|
|
45
|
+
rubocop (~> 1.64.0)
|
|
46
|
+
standard-custom (~> 1.0.0)
|
|
47
|
+
standard-performance (~> 1.4)
|
|
48
|
+
standard-custom (1.0.2)
|
|
49
|
+
lint_roller (~> 1.0)
|
|
50
|
+
rubocop (~> 1.50)
|
|
51
|
+
standard-performance (1.4.0)
|
|
52
|
+
lint_roller (~> 1.1)
|
|
53
|
+
rubocop-performance (~> 1.21.0)
|
|
54
|
+
unicode-display_width (2.6.0)
|
|
30
55
|
|
|
31
56
|
PLATFORMS
|
|
32
57
|
ruby
|
|
33
58
|
|
|
34
59
|
DEPENDENCIES
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
rake (~> 12.3)
|
|
60
|
+
minitest
|
|
61
|
+
rake
|
|
38
62
|
referral!
|
|
39
63
|
standard
|
|
40
64
|
|
|
41
65
|
BUNDLED WITH
|
|
42
|
-
|
|
66
|
+
2.4.22
|
data/README.md
CHANGED
|
@@ -204,6 +204,23 @@ app/lib/presents_review_result.rb:60:2: 2019-06-02T02:38:01Z def item_result(s
|
|
|
204
204
|
|
|
205
205
|
`find` couldn't have told me that (I don't think)!
|
|
206
206
|
|
|
207
|
+
### Recipe: Find calls that have more than 1 argument
|
|
208
|
+
|
|
209
|
+
[Recently I was upgrading the i18n gem](http://blog.testdouble.com/posts/2019-10-15-lets-hash-this-out/) and came across some bugs introduced by [this change](https://github.com/ruby-i18n/i18n/commit/5eeaad7fb35f9a30f654e3bdeb6933daa7fd421d#diff-14d9864ac07456d554843dc2a3b174a4L179). To fix the issue, I started looking at all the places `I18n.t` was called from:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
referral --type call --exact-name I18n.t -c location,source
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Unfortunately, this produces 250+ false positives because the predominant usage was to pass a single argument to `t`. Only calls with more than 1 argument are affected by this change. `--pattern` doesn't work very well in this codebase, because calls to `t` with multiple arguments are more likely to be multiline.
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
referral --type call --exact-name I18n.t --arity 2+ -c location,source,arity
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This produced 27 results I could quickly skim through.
|
|
222
|
+
|
|
223
|
+
|
|
207
224
|
## Options
|
|
208
225
|
|
|
209
226
|
Referral provides a lot of options. The help output of `referral --help` will
|
|
@@ -219,6 +236,7 @@ Usage: referral [options] files
|
|
|
219
236
|
--scope [SCOPE] Scope(s) in which to filter (e.g. Hastack#hide)
|
|
220
237
|
-p, --pattern [PATTERN] Regex pattern to filter
|
|
221
238
|
-t, --type [TYPES] Include only certain types. See Referral::TOKEN_TYPES.
|
|
239
|
+
--arity [ARITY] Number of arguments to a method call. (e.g. 2+)
|
|
222
240
|
--include-unnamed Include reference without identifiers (default: false)
|
|
223
241
|
-s, --sort {file,scope} (default: file). See Referral::SORT_FUNCTIONS
|
|
224
242
|
--print-headers Print header names (default: false)
|
|
@@ -231,6 +249,11 @@ A few things to note:
|
|
|
231
249
|
* Each of `--name`, `--exact-name`, `--full-name`, `--scope`, `--type`, and `--columns`
|
|
232
250
|
accept comma-separated arrays (e.g. `--name foo,bar,baz`)
|
|
233
251
|
|
|
252
|
+
* `--arity` accepts a number with an optional `+` or `-`.
|
|
253
|
+
* `--arity 0` Match calls with 0 arguments
|
|
254
|
+
* `--arity 1+` Match calls with 1 or more arguments
|
|
255
|
+
* `--arity 1-` Match calls with 1 or fewer arguments
|
|
256
|
+
|
|
234
257
|
* You can browse available sort functions [in
|
|
235
258
|
Referral::SORT_FUNCTIONS](/lib/referral/sorts_tokens.rb) for use with
|
|
236
259
|
`--sort`. Each key is the name to be specified on the command line. (If you're
|
|
@@ -255,6 +278,45 @@ A few things to note:
|
|
|
255
278
|
the result set twice: once when parsing the AST, and again when printing
|
|
256
279
|
results
|
|
257
280
|
|
|
281
|
+
## Running with Ruby version managers
|
|
282
|
+
|
|
283
|
+
Referral requires Ruby version >= 2.6, but your codebase may be running on something
|
|
284
|
+
older. You have a few options for using `referral`. You could 1) change your project's
|
|
285
|
+
ruby while you run `referral` and then change it back, but this seems cumbersome and
|
|
286
|
+
likely to cause annoyance. There are better ways.
|
|
287
|
+
|
|
288
|
+
## Run from outside your project's working directory
|
|
289
|
+
|
|
290
|
+
If you `cd ..` from your project's working directory (assuming in that context
|
|
291
|
+
you are running Ruby 2.6.x), you can run `referral` commands on your codebase by passing
|
|
292
|
+
the path to that codebase to referral:
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
$ referral MyAwesomeProject/
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
This works for many of `referrals` features, but isn't ideal when it comes to git;
|
|
299
|
+
columns like `git_sha`, `git_author` or `git_commit_at` will show empty results.
|
|
300
|
+
|
|
301
|
+
## Running with `rbenv`
|
|
302
|
+
|
|
303
|
+
If you're using `rbenv`, you _could_ temporarily switch your project's ruby to 2.6.x,
|
|
304
|
+
but you'd have to remember to switch it back again before running any of the code in
|
|
305
|
+
the project. To instantaneously switch to 2.6 and then back again (after the `referral`
|
|
306
|
+
command finishes), do this (from your `MyAwsomeProject` directory):
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
$ RBENV_VERSION=2.6.3 referral
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Running with RVM
|
|
313
|
+
|
|
314
|
+
The corresponding way to do this with `rvm` would be:
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
$ rvm 2.6.3 do referral
|
|
318
|
+
```
|
|
319
|
+
|
|
258
320
|
## Code of Conduct
|
|
259
321
|
|
|
260
322
|
This project follows Test Double's [code of
|
|
@@ -4,7 +4,8 @@ module Referral
|
|
|
4
4
|
class EnsuresWorkingRuby
|
|
5
5
|
def call
|
|
6
6
|
major, minor = RUBY_VERSION.split(".").map(&:to_i)
|
|
7
|
-
|
|
7
|
+
supported = major >= 3 || (major == 2 && minor >= 6)
|
|
8
|
+
unless supported
|
|
8
9
|
warn <<-ERROR.gsub(/^ {10}/, "")
|
|
9
10
|
Error: referral must be run with Ruby 2.6 or later, but this is #{RUBY_VERSION}.
|
|
10
11
|
You can often analyze older Ruby code by running this CLI with a newer
|
|
@@ -35,6 +35,17 @@ module Referral
|
|
|
35
35
|
true
|
|
36
36
|
end
|
|
37
37
|
},
|
|
38
|
+
arity: ->(token, arity) {
|
|
39
|
+
if token.arity.nil?
|
|
40
|
+
false
|
|
41
|
+
elsif arity.end_with? "+"
|
|
42
|
+
token.arity.to_i >= arity.to_i
|
|
43
|
+
elsif arity.end_with? "-"
|
|
44
|
+
token.arity.to_i <= arity.to_i
|
|
45
|
+
else
|
|
46
|
+
token.arity.to_i == arity.to_i
|
|
47
|
+
end
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
class FiltersTokens
|
|
40
51
|
def call(tokens, options)
|
|
@@ -25,6 +25,7 @@ module Referral
|
|
|
25
25
|
op.on("--scope [SCOPE]", Array, "Scope(s) in which to filter (e.g. Hastack#hide)")
|
|
26
26
|
op.on("-p", "--pattern [PATTERN]", Regexp, "Regex pattern to filter")
|
|
27
27
|
op.on("-t", "--type [TYPES]", Array, "Include only certain types. See Referral::TOKEN_TYPES.")
|
|
28
|
+
op.on("--arity [ARITY]", "Number of arguments to a method call. (e.g. 2+)")
|
|
28
29
|
op.on("--include-unnamed", TrueClass, "Include reference without identifiers (default: false)")
|
|
29
30
|
op.on("-s", "--sort {file,scope}", "(default: file). See Referral::SORT_FUNCTIONS")
|
|
30
31
|
op.on("--print-headers", TrueClass, "Print header names (default: false)")
|
|
@@ -31,7 +31,7 @@ module Referral
|
|
|
31
31
|
|
|
32
32
|
if (token = @translates_node_to_token.call(node, parent, file))
|
|
33
33
|
@tokenizes_identifiers.call(node, token)
|
|
34
|
-
[token, *find_tokens(node.children[1
|
|
34
|
+
[token, *find_tokens(node.children[1..], token, file)]
|
|
35
35
|
else
|
|
36
36
|
find_tokens(node.children, parent, file)
|
|
37
37
|
end
|
|
@@ -13,7 +13,7 @@ module Referral
|
|
|
13
13
|
names = token.scope_and_names.map { |fq| fq.name.to_s }
|
|
14
14
|
[
|
|
15
15
|
*names.fill("", names.size...max_length),
|
|
16
|
-
token.file, token.line, token.column, token.id
|
|
16
|
+
token.file, token.line, token.column, token.id
|
|
17
17
|
]
|
|
18
18
|
}
|
|
19
19
|
},
|
|
@@ -21,7 +21,7 @@ module Referral
|
|
|
21
21
|
tokens.sort_by do |token|
|
|
22
22
|
[
|
|
23
23
|
GitStore.time(token.file, token.line).to_i,
|
|
24
|
-
token.file, token.line, token.column, token.id
|
|
24
|
+
token.file, token.line, token.column, token.id
|
|
25
25
|
]
|
|
26
26
|
end
|
|
27
27
|
},
|
|
@@ -29,10 +29,10 @@ module Referral
|
|
|
29
29
|
tokens.sort_by { |token|
|
|
30
30
|
[
|
|
31
31
|
-1 * GitStore.time(token.file, token.line).to_i,
|
|
32
|
-
token.file, token.line, token.column, token.id
|
|
32
|
+
token.file, token.line, token.column, token.id
|
|
33
33
|
]
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
class SortsTokens
|
|
38
38
|
def call(tokens, options)
|
data/lib/referral/token_types.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Referral
|
|
|
5
5
|
double_colon: "::",
|
|
6
6
|
dot: ".",
|
|
7
7
|
hash: "#",
|
|
8
|
-
tilde: "~"
|
|
8
|
+
tilde: "~"
|
|
9
9
|
}
|
|
10
10
|
TOKEN_TYPES = {
|
|
11
11
|
module: Value::NodeType.new(
|
|
@@ -15,7 +15,7 @@ module Referral
|
|
|
15
15
|
token_type: :definition,
|
|
16
16
|
reverse_identifiers: false,
|
|
17
17
|
good_parent: true,
|
|
18
|
-
name_finder: ->(node) {
|
|
18
|
+
name_finder: ->(node) {}
|
|
19
19
|
),
|
|
20
20
|
class: Value::NodeType.new(
|
|
21
21
|
name: :class,
|
|
@@ -24,7 +24,7 @@ module Referral
|
|
|
24
24
|
token_type: :definition,
|
|
25
25
|
reverse_identifiers: false,
|
|
26
26
|
good_parent: true,
|
|
27
|
-
name_finder: ->(node) {
|
|
27
|
+
name_finder: ->(node) {}
|
|
28
28
|
),
|
|
29
29
|
constant_def: Value::NodeType.new(
|
|
30
30
|
name: :constant_declaration,
|
|
@@ -108,7 +108,8 @@ module Referral
|
|
|
108
108
|
token_type: :reference,
|
|
109
109
|
reverse_identifiers: true,
|
|
110
110
|
good_parent: true,
|
|
111
|
-
name_finder: ->(node) { node.children[1] }
|
|
111
|
+
name_finder: ->(node) { node.children[1] },
|
|
112
|
+
arity_finder: ->(node) { node.children.last&.children&.compact&.count || 0 }
|
|
112
113
|
),
|
|
113
114
|
function_call: Value::NodeType.new(
|
|
114
115
|
name: :function_call,
|
|
@@ -117,7 +118,8 @@ module Referral
|
|
|
117
118
|
token_type: :reference,
|
|
118
119
|
reverse_identifiers: true,
|
|
119
120
|
good_parent: false,
|
|
120
|
-
name_finder: ->(node) { node.children[0] }
|
|
121
|
+
name_finder: ->(node) { node.children[0] },
|
|
122
|
+
arity_finder: ->(node) { node.children.last&.children&.compact&.count || 0 }
|
|
121
123
|
),
|
|
122
124
|
local_var: Value::NodeType.new(
|
|
123
125
|
name: :local_var,
|
|
@@ -181,6 +183,6 @@ module Referral
|
|
|
181
183
|
reverse_identifiers: true,
|
|
182
184
|
good_parent: false,
|
|
183
185
|
name_finder: ->(node) { node.children[0] }
|
|
184
|
-
)
|
|
186
|
+
)
|
|
185
187
|
}
|
|
186
188
|
end
|
|
@@ -10,6 +10,7 @@ module Referral
|
|
|
10
10
|
:pattern,
|
|
11
11
|
:type,
|
|
12
12
|
:include_unnamed,
|
|
13
|
+
:arity,
|
|
13
14
|
# Sorting
|
|
14
15
|
:sort,
|
|
15
16
|
# Printing
|
|
@@ -18,7 +19,6 @@ module Referral
|
|
|
18
19
|
:delimiter,
|
|
19
20
|
keyword_init: true
|
|
20
21
|
)
|
|
21
|
-
|
|
22
22
|
def self.default(overrides = {})
|
|
23
23
|
DEFAULT.merge({files: Dir["**/*.rb"]}.merge(overrides))
|
|
24
24
|
end
|
|
@@ -28,7 +28,7 @@ module Referral
|
|
|
28
28
|
delimiter: " ",
|
|
29
29
|
include_unnamed: false,
|
|
30
30
|
sort: "file",
|
|
31
|
-
print_headers: false
|
|
31
|
+
print_headers: false
|
|
32
32
|
).freeze
|
|
33
33
|
|
|
34
34
|
def merge(new_opts)
|
data/lib/referral/value/token.rb
CHANGED
|
@@ -3,14 +3,13 @@ require "digest/sha1"
|
|
|
3
3
|
module Referral
|
|
4
4
|
module Value
|
|
5
5
|
class Token < Struct.new(
|
|
6
|
-
:name, :identifiers, :node_type, :parent, :file, :line, :column,
|
|
6
|
+
:name, :identifiers, :node_type, :parent, :file, :line, :column, :arity,
|
|
7
7
|
keyword_init: true
|
|
8
8
|
)
|
|
9
|
-
|
|
10
9
|
def scope_and_names
|
|
11
10
|
[
|
|
12
11
|
*parent&.scope_and_names,
|
|
13
|
-
*literal_name_tokens
|
|
12
|
+
*literal_name_tokens
|
|
14
13
|
].compact
|
|
15
14
|
end
|
|
16
15
|
|
|
@@ -36,7 +35,7 @@ module Referral
|
|
|
36
35
|
def full_name_tokens
|
|
37
36
|
[
|
|
38
37
|
*(include_parents_in_full_name? ? parent&.scope_and_names : []),
|
|
39
|
-
*literal_name_tokens
|
|
38
|
+
*literal_name_tokens
|
|
40
39
|
].compact
|
|
41
40
|
end
|
|
42
41
|
|
|
@@ -57,11 +56,16 @@ module Referral
|
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
def id
|
|
60
|
-
|
|
59
|
+
h = to_h.merge(
|
|
61
60
|
parent: nil,
|
|
62
61
|
identifiers: identifiers&.map(&:id),
|
|
63
62
|
node_type: node_type.name
|
|
64
|
-
)
|
|
63
|
+
)
|
|
64
|
+
# Hand-rolled instead of Hash#inspect: Ruby 3.4 changed that format
|
|
65
|
+
# (`:key=>value` -> `key: value`), which would change `id` output
|
|
66
|
+
# depending on which Ruby version generated it.
|
|
67
|
+
serialized = "{#{h.map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(", ")}}"
|
|
68
|
+
Digest::SHA1.hexdigest(serialized)[0..6]
|
|
65
69
|
end
|
|
66
70
|
|
|
67
71
|
protected
|
data/lib/referral/version.rb
CHANGED
data/lib/referral.rb
CHANGED
|
@@ -2,11 +2,11 @@ require "referral/version"
|
|
|
2
2
|
require "referral/error"
|
|
3
3
|
|
|
4
4
|
module Referral
|
|
5
|
-
def self.run(
|
|
5
|
+
def self.run(...)
|
|
6
6
|
require "referral/ensures_working_ruby"
|
|
7
7
|
Referral::EnsuresWorkingRuby.new.call
|
|
8
8
|
|
|
9
9
|
require "referral/runner"
|
|
10
|
-
Runner.new.call(
|
|
10
|
+
Runner.new.call(...)
|
|
11
11
|
end
|
|
12
12
|
end
|
data/referral.gemspec
CHANGED
|
@@ -3,27 +3,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
3
3
|
require "referral/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name
|
|
7
|
-
spec.version
|
|
8
|
-
spec.authors
|
|
9
|
-
spec.email
|
|
6
|
+
spec.name = "referral"
|
|
7
|
+
spec.version = Referral::VERSION
|
|
8
|
+
spec.authors = ["Justin Searls"]
|
|
9
|
+
spec.email = ["searls@gmail.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary
|
|
12
|
-
spec.homepage
|
|
13
|
-
spec.license
|
|
11
|
+
spec.summary = "Scan for definitions and references in your Ruby code."
|
|
12
|
+
spec.homepage = "https://github.com/testdouble/referral"
|
|
13
|
+
spec.license = "MIT"
|
|
14
14
|
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
16
16
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
|
17
18
|
|
|
18
19
|
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
|
19
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
20
21
|
end
|
|
21
|
-
spec.bindir
|
|
22
|
-
spec.executables
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
24
|
spec.require_paths = ["lib"]
|
|
24
|
-
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.17.3"
|
|
26
|
-
spec.add_development_dependency "rake", "~> 12.3"
|
|
27
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
|
28
|
-
spec.add_development_dependency "standard"
|
|
29
25
|
end
|
metadata
CHANGED
|
@@ -1,72 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: referral
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Searls
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 1.17.3
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 1.17.3
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '12.3'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '12.3'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: minitest
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '5.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '5.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: standard
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
|
-
description:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
70
12
|
email:
|
|
71
13
|
- searls@gmail.com
|
|
72
14
|
executables:
|
|
@@ -74,9 +16,10 @@ executables:
|
|
|
74
16
|
extensions: []
|
|
75
17
|
extra_rdoc_files: []
|
|
76
18
|
files:
|
|
77
|
-
- ".
|
|
19
|
+
- ".github/workflows/ruby.yml"
|
|
78
20
|
- ".gitignore"
|
|
79
21
|
- ".standard.yml"
|
|
22
|
+
- CHANGELOG.md
|
|
80
23
|
- Gemfile
|
|
81
24
|
- Gemfile.lock
|
|
82
25
|
- LICENSE.txt
|
|
@@ -114,7 +57,6 @@ licenses:
|
|
|
114
57
|
metadata:
|
|
115
58
|
homepage_uri: https://github.com/testdouble/referral
|
|
116
59
|
source_code_uri: https://github.com/testdouble/referral
|
|
117
|
-
post_install_message:
|
|
118
60
|
rdoc_options: []
|
|
119
61
|
require_paths:
|
|
120
62
|
- lib
|
|
@@ -122,15 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
122
64
|
requirements:
|
|
123
65
|
- - ">="
|
|
124
66
|
- !ruby/object:Gem::Version
|
|
125
|
-
version:
|
|
67
|
+
version: 2.7.0
|
|
126
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
69
|
requirements:
|
|
128
70
|
- - ">="
|
|
129
71
|
- !ruby/object:Gem::Version
|
|
130
72
|
version: '0'
|
|
131
73
|
requirements: []
|
|
132
|
-
rubygems_version:
|
|
133
|
-
signing_key:
|
|
74
|
+
rubygems_version: 4.0.21
|
|
134
75
|
specification_version: 4
|
|
135
76
|
summary: Scan for definitions and references in your Ruby code.
|
|
136
77
|
test_files: []
|
data/.circleci/config.yml
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Ruby CircleCI 2.0 configuration file
|
|
2
|
-
#
|
|
3
|
-
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
|
4
|
-
#
|
|
5
|
-
version: 2
|
|
6
|
-
jobs:
|
|
7
|
-
build:
|
|
8
|
-
docker:
|
|
9
|
-
- image: circleci/ruby:2.6
|
|
10
|
-
|
|
11
|
-
working_directory: ~/repo
|
|
12
|
-
|
|
13
|
-
steps:
|
|
14
|
-
- checkout
|
|
15
|
-
|
|
16
|
-
- restore_cache:
|
|
17
|
-
keys:
|
|
18
|
-
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
19
|
-
- v1-dependencies-
|
|
20
|
-
|
|
21
|
-
- run:
|
|
22
|
-
name: install dependencies
|
|
23
|
-
command: |
|
|
24
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
|
25
|
-
|
|
26
|
-
- save_cache:
|
|
27
|
-
paths:
|
|
28
|
-
- ./vendor/bundle
|
|
29
|
-
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
30
|
-
|
|
31
|
-
- run: bundle exec rake
|
|
32
|
-
|