File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 44
55gem "rake", ">= 12.3.3"
66
7+ group :sig do
8+ gem "rbs"
9+ gem "rbs-inline"
10+ end
11+
712group :test do
813 gem "simplecov", require: false, platforms: :ruby
914 gem "simplecov-cobertura", require: false, platforms: :ruby
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ # frozen_string_literal: true
3+
4+ require "fileutils"
5+ require "pathname"
6+
7+ root_path = Pathname . new ( File . expand_path ( "../" , __dir__ ) )
8+
9+ manifest_path = root_path . join ( "sig/manifest.yaml" )
10+ manifest = manifest_path . exist? ? manifest_path . read : "dependencies: []"
11+
12+ FileUtils . rm_rf ( root_path . join ( "sig" ) )
13+
14+ system "rbs-inline lib --opt-out --output=./sig"
15+
16+ EMPTY_COMMENT_BEFORE_CODE = /
17+ ^[ \t ]*\# [ \t ]*\n
18+ (?=^[ \t ]*[^#\s ])
19+ /mx
20+ EMPTY_STRING = ""
21+ GENERATED_LINE = /^ *# Generated from .+.rb with RBS::Inline *$/
22+ RBS_COMMENT_BLOCK = /
23+ ^[ \t ]*\# [ \t ]*@rbs.*\n
24+ (?:^[ \t ]*\# .*\n )*
25+ /x
26+
27+ root_path . glob ( "sig/**/*.rbs" ) . each do |file |
28+ contents = file . read
29+
30+ contents . gsub! ( GENERATED_LINE , EMPTY_STRING )
31+ &.gsub! ( RBS_COMMENT_BLOCK , EMPTY_STRING )
32+ &.gsub! ( EMPTY_COMMENT_BEFORE_CODE , EMPTY_STRING )
33+ &.strip
34+
35+ if contents . nil? || contents . strip . empty?
36+ File . delete ( file )
37+ else
38+ File . write ( file , "#{ contents } \n " )
39+ end
40+ end
41+
42+ File . write ( manifest_path , manifest )
You can’t perform that action at this time.
0 commit comments