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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cb3f275dd3475b96089c47a5dbef85a28240daae468e08fbac08e283afd6c96
4
- data.tar.gz: 5ac450e2705dafa4176d89960356825d47511faeaf79e0f6420022bf18b403e3
3
+ metadata.gz: bff23b66de82379dceeca467cd82002a835bb61bd1baa375f9ffa9e4ac3b4472
4
+ data.tar.gz: c4da4c93d536106e2f1219b9f64745e66d7f1ea3e131d9f63e33528e553d3158
5
5
  SHA512:
6
- metadata.gz: 275d332b9ff9b7b8039a58c77875f539d9e9769322df96b7cddfe1bb7e640ee0074312641e1fd0855b95b331563a71115c5bce3d8b4b51bb9bebb8326c1f4b89
7
- data.tar.gz: fa0bbf5a22382f4da346e9c5725cd982635a9ab7dd2130efb19a98465b0a34f7eb20a0537e56a50d57d5a4ad86c9164c4335d7ba0600e611f663ee5f99846c04
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
  [![Gem](https://img.shields.io/gem/v/this_is_ruby)](https://rubygems.org/gems/this_is_ruby)
4
4
  [![CI](https://github.com/evilmartians/this_is_ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/evilmartians/this_is_ruby/actions/workflows/ci.yml)
5
5
 
6
- GitHub decides a repository's language by counting bytes. Ruby code can often be outnumbered by sheer volume of JS/TS/HTML boilerplate. So GitHub labels the repo HTML or TypeScript.
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 gives you controls.
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
- By default the gem only points at files a tool produced. On [inertia-rails/react-starter-kit][irsk], where GitHub counts TypeScript at 60.6%, that clears the HTML but leaves TypeScript the primary language.
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
- ## Make it Ruby
48
+ ## If your frontend really is the point
48
49
 
49
- If you think that despite a huge amount of hand-written JS/TS/HTML, the important work in your repository is Ruby, you can say so:
50
+ Some repositories genuinely are TypeScript projects, and for those:
50
51
 
51
52
  ```console
52
- $ this_is_ruby --all-frontend
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
- The one line that matters is which attribute it uses. [Generated files are suppressed in diffs][docs]; vendored files are not. So `--all-frontend` emits `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:
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 `--all-frontend` vendors your frontend rather than
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
- PREAMBLE.each { |line| body << line << "\n" }
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
 
@@ -27,7 +27,7 @@ module ThisIsRuby
27
27
  @argv = argv
28
28
  @out = out
29
29
  @err = err
30
- @options = {path: ".", all_frontend: false, color: out.tty?}
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:, all_frontend: @options[:all_frontend])
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("--all-frontend", "also mark hand-written frontend sources as vendored") { @options[:all_frontend] = true }
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
@@ -7,9 +7,9 @@ module ThisIsRuby
7
7
 
8
8
  attr_reader :repo, :emissions, :declared
9
9
 
10
- def self.build(repo, attributes:, all_frontend: false)
10
+ def self.build(repo, attributes:, frontend: true)
11
11
  spoken_for = spoken_for(attributes.existing_attributes)
12
- found = Rules.for_level(all_frontend:).flat_map { |rule| rule.apply(repo) }
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
@@ -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, and always run. :frontend rules
11
- # find hand-written sources, and run only with --all-frontend, because
12
- # excluding those is the owner's call about what their repository is rather
13
- # than a fact about who typed the file.
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
 
@@ -121,7 +121,7 @@ module ThisIsRuby
121
121
  Rule.new(
122
122
  key: :frontend_sources,
123
123
  attribute: "linguist-vendored",
124
- summary: "frontend sources, excluded at your request (--all-frontend)",
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(all_frontend:)
133
- all_frontend ? ALL : ALL.select(&:safe?)
132
+ def for_level(frontend:)
133
+ frontend ? ALL : ALL.select(&:safe?)
134
134
  end
135
135
  end
136
136
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ThisIsRuby
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
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.1.1
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
- GitHub picks a repository's language by counting bytes, and a Rails app
14
- carries plenty it never authored: generated error pages, compiled assets,
15
- coverage reports, components copied in by a frontend generator. Together
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 which files in your Ruby project nobody wrote
62
+ summary: Tell GitHub your project is Ruby.
65
63
  test_files: []