this_is_ruby 0.1.0 → 0.1.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 +13 -15
- data/README.md +6 -0
- data/lib/this_is_ruby/plan.rb +6 -2
- data/lib/this_is_ruby/repo.rb +26 -0
- data/lib/this_is_ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7cb3f275dd3475b96089c47a5dbef85a28240daae468e08fbac08e283afd6c96
|
|
4
|
+
data.tar.gz: 5ac450e2705dafa4176d89960356825d47511faeaf79e0f6420022bf18b403e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 275d332b9ff9b7b8039a58c77875f539d9e9769322df96b7cddfe1bb7e640ee0074312641e1fd0855b95b331563a71115c5bce3d8b4b51bb9bebb8326c1f4b89
|
|
7
|
+
data.tar.gz: fa0bbf5a22382f4da346e9c5725cd982635a9ab7dd2130efb19a98465b0a34f7eb20a0537e56a50d57d5a4ad86c9164c4335d7ba0600e611f663ee5f99846c04
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
- The "now" column no longer counts files that are already out of GitHub's
|
|
6
|
+
language bar. It asks `git check-attr`, so Rails' own `db/schema.rb` line and
|
|
7
|
+
anything written by hand are honoured, and it subtracts only what this run
|
|
8
|
+
claims, so re-running on a repository already converted still shows the
|
|
9
|
+
contrast rather than reporting that nothing would change.
|
|
10
|
+
|
|
3
11
|
## 0.1.0
|
|
4
12
|
|
|
5
13
|
Initial release.
|
|
@@ -8,18 +16,8 @@ Initial release.
|
|
|
8
16
|
Webpacker and Vite builds, SimpleCov reports, SQL structure dumps and
|
|
9
17
|
shadcn/ui components.
|
|
10
18
|
- Writes a managed block in `.gitattributes`, leaving the rest of the file
|
|
11
|
-
untouched, and stays quiet about anything already
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- Exit 1 on an unknown command or option instead of 0, so a typo in a CI step
|
|
17
|
-
fails rather than silently skipping `check`.
|
|
18
|
-
- Leave a path alone when its Linguist attribute is already decided, including
|
|
19
|
-
when it was explicitly unset (`-linguist-generated`) or made unspecified
|
|
20
|
-
(`!linguist-generated`). Writing our line after such a declaration reversed
|
|
21
|
-
it, because the last match wins.
|
|
22
|
-
- Rewrite the managed block where it already sits, so content below it stays
|
|
23
|
-
below it.
|
|
24
|
-
- Read `git rev-parse` from stdout alone: with `GIT_TRACE` set, or on any git
|
|
25
|
-
warning, the merged stream became part of the repository root.
|
|
19
|
+
untouched, and stays quiet about anything already decided there, including an
|
|
20
|
+
attribute the owner explicitly unset.
|
|
21
|
+
- Rewrites the block where it sits, so content below it stays below it.
|
|
22
|
+
- `plan`, `apply` and `check` commands; `--all-frontend` opt-in, which uses
|
|
23
|
+
`linguist-vendored` so diffs keep working.
|
data/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# this_is_ruby
|
|
2
2
|
|
|
3
|
+
[](https://rubygems.org/gems/this_is_ruby)
|
|
4
|
+
[](https://github.com/evilmartians/this_is_ruby/actions/workflows/ci.yml)
|
|
5
|
+
|
|
3
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.
|
|
4
7
|
|
|
5
8
|
This gem gives you controls.
|
|
@@ -12,6 +15,9 @@ group :development do
|
|
|
12
15
|
end
|
|
13
16
|
```
|
|
14
17
|
|
|
18
|
+
Or `gem install this_is_ruby` to run it against any repository without adding
|
|
19
|
+
it to a project.
|
|
20
|
+
|
|
15
21
|
## Use
|
|
16
22
|
|
|
17
23
|
```console
|
data/lib/this_is_ruby/plan.rb
CHANGED
|
@@ -65,8 +65,12 @@ module ThisIsRuby
|
|
|
65
65
|
@claimed_paths ||= emissions.flat_map(&:paths).to_set
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
# The bar without our block: what GitHub reports today, minus the paths this
|
|
69
|
+
# run is claiming. Asking git means Rails' own `db/schema.rb` line and
|
|
70
|
+
# anything hand-written are honoured, while re-running on a repository we
|
|
71
|
+
# already converted still shows the contrast rather than "nothing changes".
|
|
72
|
+
def before = @before ||= LanguageEstimate.of(repo, excluding: repo.already_excluded - claimed_paths)
|
|
69
73
|
|
|
70
|
-
def after = @after ||= LanguageEstimate.of(repo, excluding: claimed_paths)
|
|
74
|
+
def after = @after ||= LanguageEstimate.of(repo, excluding: repo.already_excluded | claimed_paths)
|
|
71
75
|
end
|
|
72
76
|
end
|
data/lib/this_is_ruby/repo.rb
CHANGED
|
@@ -17,6 +17,9 @@ module ThisIsRuby
|
|
|
17
17
|
# markers we check for all sit in the first few lines.
|
|
18
18
|
PEEK_BYTES = 4096
|
|
19
19
|
|
|
20
|
+
# The attributes that take a file out of GitHub's language statistics.
|
|
21
|
+
LINGUIST_EXCLUSIONS = %w[linguist-generated linguist-vendored linguist-documentation].freeze
|
|
22
|
+
|
|
20
23
|
attr_reader :root
|
|
21
24
|
|
|
22
25
|
def self.at(path)
|
|
@@ -55,6 +58,17 @@ module ThisIsRuby
|
|
|
55
58
|
full.open("rb") { |io| io.read(PEEK_BYTES) }
|
|
56
59
|
end
|
|
57
60
|
|
|
61
|
+
# Paths git already reports as excluded from Linguist's counts, whoever
|
|
62
|
+
# declared them: our own block, the lines Rails generates, or something
|
|
63
|
+
# written by hand. Resolving the patterns ourselves would mean
|
|
64
|
+
# reimplementing gitignore matching, so ask git, which owns the answer.
|
|
65
|
+
def already_excluded
|
|
66
|
+
@already_excluded ||= begin
|
|
67
|
+
paths = tracked
|
|
68
|
+
paths.empty? ? Set.new : Set.new(check_attr(paths))
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
58
72
|
def size(path)
|
|
59
73
|
full = root.join(path)
|
|
60
74
|
full.file? ? full.size : 0
|
|
@@ -62,6 +76,18 @@ module ThisIsRuby
|
|
|
62
76
|
|
|
63
77
|
private
|
|
64
78
|
|
|
79
|
+
# `check-attr --stdin -z` reads NUL-separated paths and answers with
|
|
80
|
+
# NUL-separated (path, attribute, value) triples.
|
|
81
|
+
def check_attr(paths)
|
|
82
|
+
out, _err, status = Open3.capture3(
|
|
83
|
+
"git", "-C", root.to_s, "check-attr", "--stdin", "-z", *LINGUIST_EXCLUSIONS,
|
|
84
|
+
stdin_data: paths.join("\0")
|
|
85
|
+
)
|
|
86
|
+
return [] unless status.success?
|
|
87
|
+
|
|
88
|
+
out.split("\0").each_slice(3).filter_map { |path, _attribute, value| path if value == "set" }
|
|
89
|
+
end
|
|
90
|
+
|
|
65
91
|
def tracked_set
|
|
66
92
|
@tracked_set ||= tracked.to_set
|
|
67
93
|
end
|
data/lib/this_is_ruby/version.rb
CHANGED