this_is_ruby 0.1.1 → 0.2.1
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 +17 -0
- data/README.md +15 -14
- data/lib/this_is_ruby/attributes_file.rb +4 -11
- data/lib/this_is_ruby/cli.rb +6 -3
- data/lib/this_is_ruby/plan.rb +2 -2
- data/lib/this_is_ruby/rule.rb +4 -4
- data/lib/this_is_ruby/rules.rb +3 -3
- data/lib/this_is_ruby/version.rb +1 -1
- metadata +6 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bff23b66de82379dceeca467cd82002a835bb61bd1baa375f9ffa9e4ac3b4472
|
|
4
|
+
data.tar.gz: c4da4c93d536106e2f1219b9f64745e66d7f1ea3e131d9f63e33528e553d3158
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76512697bf98d76e819adf43b873c7c9a94d3b74aad80776d1fde073b88306b973546fa05ee7150dac80d797b7ddb675fa3203e9e5ea448729a6825c83c27c28
|
|
7
|
+
data.tar.gz: bfe3b0b9c49b7231e344fdcc4a1854855ba52dfd0b18ce7f042dc74e1a308e4c0ec3c86eeba84940036592e146a1c399c7cc134bc8c992d19029fed81827c7a8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
- The managed block is now just the patterns between its two markers, down from
|
|
6
|
+
16 lines to 8. The preamble was the block explaining itself on top of a marker
|
|
7
|
+
that already names the gem, and the per-group comments repeated what the
|
|
8
|
+
report says at more length. `check` reports the file as out of date once after
|
|
9
|
+
upgrading; re-running writes the shorter block.
|
|
10
|
+
|
|
11
|
+
## 0.2.0
|
|
12
|
+
|
|
13
|
+
- Frontend sources are vendored by default. Telling GitHub a project is Ruby is
|
|
14
|
+
what the gem is for, and it read oddly to name that after a flag most people
|
|
15
|
+
would never pass. `--fair` keeps them counted, marking only what a tool wrote
|
|
16
|
+
or a generator copied in, for a repository whose frontend really is the point. `--all-frontend` is still accepted and does
|
|
17
|
+
nothing, so an existing CI step keeps working.
|
|
18
|
+
- Reword the summary and description.
|
|
19
|
+
|
|
3
20
|
## 0.1.1
|
|
4
21
|
|
|
5
22
|
- The "now" column no longer counts files that are already out of GitHub's
|
data/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](https://rubygems.org/gems/this_is_ruby)
|
|
4
4
|
[](https://github.com/evilmartians/this_is_ruby/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
|
-
GitHub
|
|
6
|
+
Ruby is one of the most eloquent and efficient languages, but it gets punished for it by GitHub's language attribution. A repository's language there is whichever one has the most bytes, and a Rails app, carefully designed to require next to no boilerplate code, easily ends up with less Ruby than JS, TS or HTML (ERB).
|
|
7
7
|
|
|
8
|
-
This gem
|
|
8
|
+
This gem tells GitHub: this is Ruby, by marking your frontend as `linguist-vendored`. No side effects on diffs or other DX.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
@@ -40,24 +40,26 @@ $ this_is_ruby check # exit 1 when .gitattributes is out of date
|
|
|
40
40
|
| SimpleCov HTML reports, found by the report's own title | `linguist-generated` |
|
|
41
41
|
| `db/structure.sql`, matching how Rails already treats `db/schema.rb` | `linguist-generated` |
|
|
42
42
|
| shadcn/ui components, when `components.json` shows a generator put them there | `linguist-vendored` |
|
|
43
|
+
| your frontend sources: `app/javascript/`, `app/frontend/`, `frontend/` | `linguist-vendored` |
|
|
43
44
|
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
[irinanazarova/react-starter-kit-this-is-ruby][demo] is a fork of the Inertia Rails starter kit whose only change is the sixteen lines `this_is_ruby` wrote. Upstream, GitHub counts it as 60.6% TypeScript and 21.2% Ruby. The fork reads **82.6% Ruby, 1.1% TypeScript**. Compare its language bar with [the upstream one][irsk].
|
|
46
47
|
|
|
47
|
-
##
|
|
48
|
+
## If your frontend really is the point
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
Some repositories genuinely are TypeScript projects, and for those:
|
|
50
51
|
|
|
51
52
|
```console
|
|
52
|
-
$ this_is_ruby --
|
|
53
|
+
$ this_is_ruby --fair
|
|
53
54
|
```
|
|
54
|
-
On the same repository that marks `app/javascript/` as `linguist-vendored`, and
|
|
55
|
-
GitHub then counts it as **82.6% Ruby, 1.1% TypeScript**. That is not an
|
|
56
|
-
estimate: [irinanazarova/react-starter-kit-this-is-ruby][demo] is a fork of the
|
|
57
|
-
kit whose only change is the sixteen lines this command wrote. Compare its
|
|
58
|
-
language bar with [the upstream one][irsk].
|
|
59
55
|
|
|
60
|
-
|
|
56
|
+
That marks only the files nobody in the project wrote: every generated row in
|
|
57
|
+
the table above, plus the shadcn components a generator copied in. Your own
|
|
58
|
+
frontend keeps counting.
|
|
59
|
+
|
|
60
|
+
## Why vendored and not generated
|
|
61
|
+
|
|
62
|
+
The one line that matters is which attribute it uses. [Generated files are suppressed in diffs][docs]; vendored files are not. So your frontend is marked `linguist-vendored`, every source file keeps showing up in full in pull requests, and the only thing that changes is the color of the bar at the top of the page:
|
|
61
63
|
|
|
62
64
|
```console
|
|
63
65
|
$ git check-attr linguist-vendored linguist-generated -- app/javascript/pages/home/index.tsx
|
|
@@ -77,8 +79,7 @@ On GitHub itself:
|
|
|
77
79
|
plainly: these files "are suppressed in diffs". Reviewers get a "Load diff"
|
|
78
80
|
button instead of the patch. The gem uses this attribute only for tool
|
|
79
81
|
output; everything hand-written gets `linguist-vendored`, which leaves diffs
|
|
80
|
-
alone. That is why
|
|
81
|
-
marking it generated.
|
|
82
|
+
alone. That is why your frontend is vendored rather than marked generated.
|
|
82
83
|
- **Code search still indexes the files.** They stay findable, and GitHub adds
|
|
83
84
|
`is:generated` and `is:vendored` filters, so a query written as
|
|
84
85
|
`-is:vendored` will skip them.
|
|
@@ -11,12 +11,6 @@ module ThisIsRuby
|
|
|
11
11
|
END_MARKER = "# --- this_is_ruby: end ---"
|
|
12
12
|
BLOCK = /^#{Regexp.escape(BEGIN_MARKER)}\n.*?^#{Regexp.escape(END_MARKER)}\n?/m
|
|
13
13
|
|
|
14
|
-
PREAMBLE = [
|
|
15
|
-
"# Managed by this_is_ruby. Re-run it when your build setup changes.",
|
|
16
|
-
"# Every path below is excluded from this repository's language stats.",
|
|
17
|
-
"# Edit above or below this block, never inside it."
|
|
18
|
-
].freeze
|
|
19
|
-
|
|
20
14
|
attr_reader :path
|
|
21
15
|
|
|
22
16
|
def initialize(path)
|
|
@@ -65,13 +59,12 @@ module ThisIsRuby
|
|
|
65
59
|
match ? [match.pre_match, match.post_match] : [current, ""]
|
|
66
60
|
end
|
|
67
61
|
|
|
62
|
+
# Just the patterns, between two markers that name the gem. What each rule
|
|
63
|
+
# is for belongs in the report and the README, where there is room to say
|
|
64
|
+
# it properly, rather than as a comment in someone else's file.
|
|
68
65
|
def block(emissions)
|
|
69
66
|
body = "#{BEGIN_MARKER}\n"
|
|
70
|
-
|
|
71
|
-
emissions.chunk_while { |a, b| a.rule == b.rule }.each do |group|
|
|
72
|
-
body << "\n# #{group.first.rule.summary}\n"
|
|
73
|
-
group.each { |emission| body << emission.line << "\n" }
|
|
74
|
-
end
|
|
67
|
+
emissions.each { |emission| body << emission.line << "\n" }
|
|
75
68
|
body << END_MARKER << "\n"
|
|
76
69
|
end
|
|
77
70
|
|
data/lib/this_is_ruby/cli.rb
CHANGED
|
@@ -27,7 +27,7 @@ module ThisIsRuby
|
|
|
27
27
|
@argv = argv
|
|
28
28
|
@out = out
|
|
29
29
|
@err = err
|
|
30
|
-
@options = {path: ".",
|
|
30
|
+
@options = {path: ".", frontend: true, color: out.tty?}
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def call
|
|
@@ -38,7 +38,7 @@ module ThisIsRuby
|
|
|
38
38
|
|
|
39
39
|
repo = Repo.at(@options[:path])
|
|
40
40
|
attributes = AttributesFile.new(repo.root.join(".gitattributes"))
|
|
41
|
-
plan = Plan.build(repo, attributes:,
|
|
41
|
+
plan = Plan.build(repo, attributes:, frontend: @options[:frontend])
|
|
42
42
|
report = Report.new(plan, out: @out, color: @options[:color])
|
|
43
43
|
|
|
44
44
|
send(command, plan, attributes, report)
|
|
@@ -78,7 +78,10 @@ module ThisIsRuby
|
|
|
78
78
|
parser = OptionParser.new do |opts|
|
|
79
79
|
opts.banner = USAGE
|
|
80
80
|
opts.on("--path DIR", "repository to inspect (default: .)") { |dir| @options[:path] = dir }
|
|
81
|
-
opts.on("--
|
|
81
|
+
opts.on("--fair", "exclude only what a tool wrote or a generator copied in") { @options[:frontend] = false }
|
|
82
|
+
# 0.1.x asked for today's default with a flag. Accept the old name and
|
|
83
|
+
# do nothing, rather than break a CI step that still passes it.
|
|
84
|
+
opts.on("--all-frontend", "deprecated alias, now the default") { @options[:frontend] = true }
|
|
82
85
|
opts.on("--[no-]color", "colourise output") { |on| @options[:color] = on }
|
|
83
86
|
opts.on("-v", "--version", "print the version") do
|
|
84
87
|
@out.puts VERSION
|
data/lib/this_is_ruby/plan.rb
CHANGED
|
@@ -7,9 +7,9 @@ module ThisIsRuby
|
|
|
7
7
|
|
|
8
8
|
attr_reader :repo, :emissions, :declared
|
|
9
9
|
|
|
10
|
-
def self.build(repo, attributes:,
|
|
10
|
+
def self.build(repo, attributes:, frontend: true)
|
|
11
11
|
spoken_for = spoken_for(attributes.existing_attributes)
|
|
12
|
-
found = Rules.for_level(
|
|
12
|
+
found = Rules.for_level(frontend:).flat_map { |rule| rule.apply(repo) }
|
|
13
13
|
declared, emissions = found.partition do |emission|
|
|
14
14
|
spoken_for.any? { |pattern| covers?(pattern, emission.pattern) }
|
|
15
15
|
end
|
data/lib/this_is_ruby/rule.rb
CHANGED
|
@@ -7,10 +7,10 @@ module ThisIsRuby
|
|
|
7
7
|
# Rules never guess: when the evidence is not on disk they return nothing,
|
|
8
8
|
# so a project that has no coverage report gets no line about one.
|
|
9
9
|
#
|
|
10
|
-
# :safe rules find files a tool produced
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
10
|
+
# :safe rules find files a tool produced. :frontend rules find hand-written
|
|
11
|
+
# sources, which is a claim about what the repository is rather than about
|
|
12
|
+
# who typed the file; both run by default, and --fair drops the second group
|
|
13
|
+
# for a project whose frontend really is the point.
|
|
14
14
|
class Rule
|
|
15
15
|
LEVELS = %i[safe frontend].freeze
|
|
16
16
|
|
data/lib/this_is_ruby/rules.rb
CHANGED
|
@@ -121,7 +121,7 @@ module ThisIsRuby
|
|
|
121
121
|
Rule.new(
|
|
122
122
|
key: :frontend_sources,
|
|
123
123
|
attribute: "linguist-vendored",
|
|
124
|
-
summary: "frontend sources
|
|
124
|
+
summary: "frontend sources (pass --fair to keep them counted)",
|
|
125
125
|
level: :frontend
|
|
126
126
|
) do |repo|
|
|
127
127
|
present = FRONTEND_ROOTS.select { |dir| under(repo, dir).any? }
|
|
@@ -129,8 +129,8 @@ module ThisIsRuby
|
|
|
129
129
|
end
|
|
130
130
|
].freeze
|
|
131
131
|
|
|
132
|
-
def for_level(
|
|
133
|
-
|
|
132
|
+
def for_level(frontend:)
|
|
133
|
+
frontend ? ALL : ALL.select(&:safe?)
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
end
|
data/lib/this_is_ruby/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: this_is_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Irina Nazarova
|
|
@@ -9,12 +9,10 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
they routinely outweigh the app's own Ruby. this_is_ruby finds them and
|
|
17
|
-
writes the .gitattributes overrides Linguist already understands.
|
|
12
|
+
description: |-
|
|
13
|
+
Ruby is one of the most eloquent and efficient languages, but it gets punished for it by GitHub's language attribution. Even more so, a Rails app, carefully designed to require next to no boilerplate code, easily ends up with less Ruby than JS, TS or HTML (ERB).
|
|
14
|
+
|
|
15
|
+
This gem tells GitHub: this is Ruby, by marking your frontend as "linguist-vendored". No side effects on diffs or other DX.
|
|
18
16
|
email:
|
|
19
17
|
- inazarova@evilmartians.com
|
|
20
18
|
executables:
|
|
@@ -61,5 +59,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
61
59
|
requirements: []
|
|
62
60
|
rubygems_version: 3.6.7
|
|
63
61
|
specification_version: 4
|
|
64
|
-
summary: Tell GitHub
|
|
62
|
+
summary: Tell GitHub your project is Ruby.
|
|
65
63
|
test_files: []
|