typeprof-task 0.1.0 → 0.2.0

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: ca7e7b06a15856ddbdbe3c053f22c6fba15977a1963894f0b2c13670fe7cafbc
4
- data.tar.gz: e381df67d8c5ecb97a4eacbbc90f8cf087d80ed1e66e3eef380172ca501f0473
3
+ metadata.gz: 5725e727bdc9bd5a7f8c8483fee02f98ff9ced1aa340ab0db5a12fb3eefe9d76
4
+ data.tar.gz: 0dc327967b858392d7aa75398b927e9cb1a6113f23877747c93c994f92ca3cd3
5
5
  SHA512:
6
- metadata.gz: fd9775e23baf707b461c3bbe7c6aa985961c66fa9ebbed6ad54254dfc936792cfdbf6734e6346f6c9c6c54490f1d8c9ccd86e650f2d4d2df3b46358aa645169a
7
- data.tar.gz: 69b3537d307837adc1cc13a75dc3af79a3f81d66739b74220ca31bb0001af27b59cf7a9bfd38f95e8569020d4dadc9d400e6b88d586d3a115db67123b7d05f5b
6
+ metadata.gz: 0fc07652e86ef1bf785b1dce7efd47e166ec3b31f60171e7008ab9147fc2b8301d2aceb66c4a6daf9e47fb4341993ffa4630eeaeaa6720b8e2ea601c8566a7ae
7
+ data.tar.gz: 91cfe8e9bc75287c872c7f18c3e2590b2e1876f0350beaf4c0b30653cc88b73d2ccb4f3be00a096e36be1f574c4ed9dff6d0c07740e12dd28dff472ea24ccf0b
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use guix
data/.rubocop.yml CHANGED
@@ -1,8 +1,5 @@
1
- AllCops:
2
- TargetRubyVersion: 3.0
3
-
4
- Style/StringLiterals:
5
- EnforcedStyle: double_quotes
1
+ inherit_from: .rubocop_todo.yml
6
2
 
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
3
+ AllCops:
4
+ TargetRubyVersion: 3.1.4
5
+ NewCops: enable
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,100 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-01-01 05:17:16 UTC using RuboCop version 1.48.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Configuration parameters: EnforcedStyle, AllowedGems, Include.
11
+ # SupportedStyles: Gemfile, gems.rb, gemspec
12
+ # Include: **/*.gemspec, **/Gemfile, **/gems.rb
13
+ Gemspec/DevelopmentDependencies:
14
+ Exclude:
15
+ - 'typeprof-task.gemspec'
16
+
17
+ # Offense count: 2
18
+ # This cop supports safe autocorrection (--autocorrect).
19
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
20
+ # Include: **/*.gemspec
21
+ Gemspec/OrderedDependencies:
22
+ Exclude:
23
+ - 'typeprof-task.gemspec'
24
+
25
+ # Offense count: 6
26
+ # This cop supports safe autocorrection (--autocorrect).
27
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
28
+ # SupportedHashRocketStyles: key, separator, table
29
+ # SupportedColonStyles: key, separator, table
30
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
31
+ Layout/HashAlignment:
32
+ Exclude:
33
+ - 'typeprof-task.gemspec'
34
+
35
+ # Offense count: 1
36
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
37
+ Metrics/AbcSize:
38
+ Max: 18
39
+
40
+ # Offense count: 1
41
+ # Configuration parameters: CountComments, CountAsOne.
42
+ Metrics/ClassLength:
43
+ Max: 127
44
+
45
+ # Offense count: 2
46
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
47
+ Metrics/MethodLength:
48
+ Max: 18
49
+
50
+ # Offense count: 1
51
+ # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
52
+ # SupportedStyles: snake_case, normalcase, non_integer
53
+ # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
54
+ Naming/VariableNumber:
55
+ Exclude:
56
+ - 'lib/typeprof/task.rb'
57
+
58
+ # Offense count: 1
59
+ # This cop supports unsafe autocorrection (--autocorrect-all).
60
+ # Configuration parameters: EnforcedStyle.
61
+ # SupportedStyles: nested, compact
62
+ Style/ClassAndModuleChildren:
63
+ Exclude:
64
+ - 'test/typeprof/task_test.rb'
65
+
66
+ # Offense count: 1
67
+ # This cop supports unsafe autocorrection (--autocorrect-all).
68
+ Style/CommentedKeyword:
69
+ Exclude:
70
+ - 'lib/typeprof/task.rb'
71
+
72
+ # Offense count: 1
73
+ # Configuration parameters: AllowedConstants.
74
+ Style/Documentation:
75
+ Exclude:
76
+ - 'spec/**/*'
77
+ - 'test/**/*'
78
+ - 'lib/typeprof/task.rb'
79
+
80
+ # Offense count: 79
81
+ # This cop supports safe autocorrection (--autocorrect).
82
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
83
+ # SupportedStyles: single_quotes, double_quotes
84
+ Style/StringLiterals:
85
+ Exclude:
86
+ - 'Gemfile'
87
+ - 'Rakefile'
88
+ - 'bin/console'
89
+ - 'lib/typeprof/task.rb'
90
+ - 'test/test_helper.rb'
91
+ - 'test/typeprof/task_test.rb'
92
+ - 'typeprof-task.gemspec'
93
+
94
+ # Offense count: 1
95
+ # This cop supports safe autocorrection (--autocorrect).
96
+ # Configuration parameters: EnforcedStyle, MinSize, WordRegex.
97
+ # SupportedStyles: percent, brackets
98
+ Style/WordArray:
99
+ Exclude:
100
+ - 'Rakefile'
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.0 - 2025-11-29
6
+
7
+ * Update required TypeProf.
8
+
9
+ ## 0.1.1 - 2025-01-01
10
+
11
+ * Make some options accessible (read and write permissions): `files`,
12
+ `outfile`, `include`, `require`, `collection`, `include_dir`, `exclude_dir`
13
+ * Relax TypeProf version constraint. Support version 0.30.0 or later.
14
+
5
15
  ## 0.1.0 - 2024-12-31
6
16
 
7
17
  * Initial release
data/README.md CHANGED
@@ -21,8 +21,7 @@ gem install typeprof-task
21
21
 
22
22
  ## Usage
23
23
 
24
- Add below to your `Rakefile` and run `rake typeprof`. Please refer to the API
25
- documentation for options.
24
+ Add below to your `Rakefile` and run `rake typeprof`.
26
25
 
27
26
  ```ruby
28
27
  require "typeprof/task"
@@ -30,6 +29,44 @@ require "typeprof/task"
30
29
  TypeProf::Task.new
31
30
  ```
32
31
 
32
+ Or more complex example:
33
+
34
+ ```ruby
35
+ TypeProf::Task.new(:rbs) do |t|
36
+ t.outfile = "path/to/some.rbs"
37
+ t.require << "pathname"
38
+ end
39
+ ```
40
+
41
+ Here are options. See also the API documentation.
42
+
43
+ | name | type | default | TypeProf (< 0.30.0) | >= 0.30.0 |
44
+ |-------------------------|--------|---------|---------------------------|-------------------|
45
+ | `files` | array | (1) | _files..._ | _file or dirs..._ |
46
+ | `outfile` | string | (2) | `-o` | same |
47
+ | `quiet` | bool | - | `--quiet` | same |
48
+ | `include` | set | x | `-I` | x |
49
+ | `require` | set | x | `-r` | x |
50
+ | `collection` | set | x | `--collection` | same |
51
+ | `include_dir` | set | x | `--include-dir` | x |
52
+ | `exclude_dir` | set | x | `--exclude-dir` | x |
53
+ | `exclude_untyped` | bool | - | `--exclude-untyped` | x |
54
+ | `show_version` | bool | - | `--show-typeprof-version` | same |
55
+ | `show_errors` | bool | - | `--show-errors` | same |
56
+ | `show_untyped` | bool | - | `--show-untyped` | x |
57
+ | `show_parameter_names` | bool | - | `--show-parameter-names` | same |
58
+ | `show_source_locations` | bool | - | `--show-source-locations` | same |
59
+ | `max_second` | number | - | `--max-second` | x |
60
+ | `max_iteration` | number | - | `--max-iteration` | x |
61
+ | `stub_execution` | bool | - | `--stub-execution` | x |
62
+ | `type_depth_limit` | number | - | `--type-depth-limit` | x |
63
+ | `union_width_limit` | number | - | `--union-width-limit` | x |
64
+
65
+ * "-" means unspecified
66
+ * "x" means none
67
+ * (1) Files under one of the require paths.
68
+ * (2) `sig/GEM_NAME.gen.rbs`
69
+
33
70
  ## Development
34
71
 
35
72
  After checking out the repo, run `bin/setup` to install dependencies.
@@ -39,6 +76,15 @@ You can also run `bin/console` for an interactive prompt that will allow you to
39
76
  To install this gem onto your local machine, run `bundle exec rake install`.
40
77
  To release a new version, update the version number in the library file, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
78
 
79
+ For Nix users, `bundle config --with nix` in advance.
80
+
81
+ References:
82
+
83
+ * [NixOS Wiki - Packaging/Ruby](https://nixos.wiki/wiki/Packaging/Ruby)
84
+ * [Bundix GitHub repository](https://github.com/nix-community/bundix)
85
+ * [RubyGems.org Guides - Patterns](https://guides.rubygems.org/patterns/) for version check
86
+ * [`Gem::Specification`](https://docs.ruby-lang.org/en/master/Gem/Specification.html)
87
+
42
88
  ## Contributing
43
89
 
44
90
  Bug reports and pull requests are welcome.
data/Rakefile CHANGED
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ $LOAD_PATH << File.join(__dir__, "lib")
4
+
3
5
  require "bundler/gem_tasks"
4
6
  require "rake/testtask"
7
+ require "rubocop/rake_task"
8
+ require "typeprof/task"
5
9
 
6
10
  Rake::TestTask.new(:test) do |t|
7
11
  t.libs << "test"
@@ -9,8 +13,18 @@ Rake::TestTask.new(:test) do |t|
9
13
  t.test_files = FileList["test/**/*_test.rb"]
10
14
  end
11
15
 
12
- require "rubocop/rake_task"
13
-
14
16
  RuboCop::RakeTask.new
15
17
 
16
18
  task default: %i[test rubocop]
19
+
20
+ file "gemset.nix" => "Gemfile.lock" do
21
+ sh "bundix"
22
+ end
23
+
24
+ file "Gemfile.lock" => "typeprof-task.gemspec" do
25
+ sh "bundler lock --update"
26
+ end
27
+
28
+ TypeProf::Task.new do |t|
29
+ t.require.merge(["rake", "rake", "set"])
30
+ end
data/gemset.nix ADDED
@@ -0,0 +1,219 @@
1
+ {
2
+ ast = {
3
+ groups = ["default" "development"];
4
+ platforms = [];
5
+ source = {
6
+ remotes = ["https://rubygems.org"];
7
+ sha256 = "04nc8x27hlzlrr5c2gn7mar4vdr0apw5xg22wp6m8dx3wqr04a0y";
8
+ type = "gem";
9
+ };
10
+ version = "2.4.2";
11
+ };
12
+ json = {
13
+ groups = ["default" "development"];
14
+ platforms = [];
15
+ source = {
16
+ remotes = ["https://rubygems.org"];
17
+ sha256 = "048danb0x10mpch6mf88mky35zjn6wk4hpbqq68ssbq58i3fzgfj";
18
+ type = "gem";
19
+ };
20
+ version = "2.9.1";
21
+ };
22
+ language_server-protocol = {
23
+ groups = ["default" "development"];
24
+ platforms = [];
25
+ source = {
26
+ remotes = ["https://rubygems.org"];
27
+ sha256 = "0gvb1j8xsqxms9mww01rmdl78zkd72zgxaap56bhv8j45z05hp1x";
28
+ type = "gem";
29
+ };
30
+ version = "3.17.0.3";
31
+ };
32
+ logger = {
33
+ groups = ["default"];
34
+ platforms = [];
35
+ source = {
36
+ remotes = ["https://rubygems.org"];
37
+ sha256 = "1rrf3y8j3fjjmn74d2i3l85pjm7yhvl8xgz7684hac92j8fbj9xn";
38
+ type = "gem";
39
+ };
40
+ version = "1.6.4";
41
+ };
42
+ parallel = {
43
+ groups = ["default" "development"];
44
+ platforms = [];
45
+ source = {
46
+ remotes = ["https://rubygems.org"];
47
+ sha256 = "1vy7sjs2pgz4i96v5yk9b7aafbffnvq7nn419fgvw55qlavsnsyq";
48
+ type = "gem";
49
+ };
50
+ version = "1.26.3";
51
+ };
52
+ parser = {
53
+ dependencies = ["ast" "racc"];
54
+ groups = ["default" "development"];
55
+ platforms = [];
56
+ source = {
57
+ remotes = ["https://rubygems.org"];
58
+ sha256 = "0fxw738al3qxa4s4ghqkxb908sav03i3h7xflawwmxzhqiyfdm15";
59
+ type = "gem";
60
+ };
61
+ version = "3.3.6.0";
62
+ };
63
+ power_assert = {
64
+ groups = ["default" "development"];
65
+ platforms = [];
66
+ source = {
67
+ remotes = ["https://rubygems.org"];
68
+ sha256 = "08y3bc9f0jbrlbnrqs98y2xzai4695j6h595dlrmgsmqbfw13db3";
69
+ type = "gem";
70
+ };
71
+ version = "2.0.5";
72
+ };
73
+ prism = {
74
+ groups = ["nix"];
75
+ platforms = [];
76
+ source = {
77
+ remotes = ["https://rubygems.org"];
78
+ sha256 = "0fi7hvrm2wzbhm21d3w87z5nrqx6z0gwhilvdizcpc9ik21205mi";
79
+ type = "gem";
80
+ };
81
+ version = "1.3.0";
82
+ };
83
+ racc = {
84
+ groups = ["default" "development"];
85
+ platforms = [];
86
+ source = {
87
+ remotes = ["https://rubygems.org"];
88
+ sha256 = "0byn0c9nkahsl93y9ln5bysq4j31q8xkf2ws42swighxd4lnjzsa";
89
+ type = "gem";
90
+ };
91
+ version = "1.8.1";
92
+ };
93
+ rainbow = {
94
+ groups = ["default" "development"];
95
+ platforms = [];
96
+ source = {
97
+ remotes = ["https://rubygems.org"];
98
+ sha256 = "0smwg4mii0fm38pyb5fddbmrdpifwv22zv3d3px2xx497am93503";
99
+ type = "gem";
100
+ };
101
+ version = "3.1.1";
102
+ };
103
+ rake = {
104
+ groups = ["default"];
105
+ platforms = [];
106
+ source = {
107
+ remotes = ["https://rubygems.org"];
108
+ sha256 = "17850wcwkgi30p7yqh60960ypn7yibacjjha0av78zaxwvd3ijs6";
109
+ type = "gem";
110
+ };
111
+ version = "13.2.1";
112
+ };
113
+ rbs = {
114
+ dependencies = ["logger"];
115
+ groups = ["default"];
116
+ platforms = [];
117
+ source = {
118
+ remotes = ["https://rubygems.org"];
119
+ sha256 = "07cwjkx7b3ssy8ccqq1s34sc5snwvgxan2ikmp9y2rz2a9wy6v1b";
120
+ type = "gem";
121
+ };
122
+ version = "3.8.1";
123
+ };
124
+ regexp_parser = {
125
+ groups = ["default" "development"];
126
+ platforms = [];
127
+ source = {
128
+ remotes = ["https://rubygems.org"];
129
+ sha256 = "0qccah61pjvzyyg6mrp27w27dlv6vxlbznzipxjcswl7x3fhsvyb";
130
+ type = "gem";
131
+ };
132
+ version = "2.10.0";
133
+ };
134
+ rubocop = {
135
+ dependencies = ["json" "language_server-protocol" "parallel" "parser" "rainbow" "regexp_parser" "rubocop-ast" "ruby-progressbar" "unicode-display_width"];
136
+ groups = ["development"];
137
+ platforms = [];
138
+ source = {
139
+ remotes = ["https://rubygems.org"];
140
+ sha256 = "1f2bj93f60757xyk7h3v0s7xz8d22lc9zlw88l2zd6rp1brv0bvn";
141
+ type = "gem";
142
+ };
143
+ version = "1.69.2";
144
+ };
145
+ rubocop-ast = {
146
+ dependencies = ["parser"];
147
+ groups = ["default" "development"];
148
+ platforms = [];
149
+ source = {
150
+ remotes = ["https://rubygems.org"];
151
+ sha256 = "10604xc4bcji3ca43anlc89xwxb4wkzk69cia95x04zima4aq4wm";
152
+ type = "gem";
153
+ };
154
+ version = "1.37.0";
155
+ };
156
+ ruby-progressbar = {
157
+ groups = ["default" "development"];
158
+ platforms = [];
159
+ source = {
160
+ remotes = ["https://rubygems.org"];
161
+ sha256 = "0cwvyb7j47m7wihpfaq7rc47zwwx9k4v7iqd9s1xch5nm53rrz40";
162
+ type = "gem";
163
+ };
164
+ version = "1.13.0";
165
+ };
166
+ test-unit = {
167
+ dependencies = ["power_assert"];
168
+ groups = ["development"];
169
+ platforms = [];
170
+ source = {
171
+ remotes = ["https://rubygems.org"];
172
+ sha256 = "08cjs9hidab1izrkzgkx7jzw01glcfq20g5lc6iq9silffgvnhn3";
173
+ type = "gem";
174
+ };
175
+ version = "3.6.7";
176
+ };
177
+ typeprof = {
178
+ dependencies = ["rbs"];
179
+ groups = ["default"];
180
+ platforms = [];
181
+ source = {
182
+ remotes = ["https://rubygems.org"];
183
+ sha256 = "0x8f0dhsggbxmfab2z422azzhfcrb81swzbsrgkxhl1hn3d75zrj";
184
+ type = "gem";
185
+ };
186
+ version = "0.30.1";
187
+ };
188
+ typeprof-task = {
189
+ dependencies = ["rake" "typeprof"];
190
+ groups = ["default"];
191
+ platforms = [];
192
+ source = {
193
+ path = ./.;
194
+ type = "path";
195
+ };
196
+ version = "0.1.0";
197
+ };
198
+ unicode-display_width = {
199
+ dependencies = ["unicode-emoji"];
200
+ groups = ["default" "development"];
201
+ platforms = [];
202
+ source = {
203
+ remotes = ["https://rubygems.org"];
204
+ sha256 = "0hn9jm6crk17gnh4j5klhgxxxwbdmld9k3rdb39sah99vkyv1fyv";
205
+ type = "gem";
206
+ };
207
+ version = "3.1.3";
208
+ };
209
+ unicode-emoji = {
210
+ groups = ["default" "development"];
211
+ platforms = [];
212
+ source = {
213
+ remotes = ["https://rubygems.org"];
214
+ sha256 = "0ajk6rngypm3chvl6r0vwv36q1931fjqaqhjjya81rakygvlwb1c";
215
+ type = "gem";
216
+ };
217
+ version = "4.0.4";
218
+ };
219
+ }
data/lib/typeprof/task.rb CHANGED
@@ -3,38 +3,45 @@
3
3
  require "typeprof"
4
4
  require "rake/tasklib"
5
5
  require "set"
6
+ require "logger"
6
7
 
7
8
  module TypeProf
8
9
  class Task < Rake::TaskLib
9
- VERSION = "0.1.0"
10
+ VERSION = "0.2.0"
11
+ LOGGER = Logger.new($stderr)
12
+ TYPEPROF0_30_0 = Gem::Version.new(TypeProf::VERSION) >= "0.30.0"
10
13
 
11
14
  # Target files. By default, files under one of the require paths.
12
- attr_writer :files
15
+ attr_accessor :files
13
16
 
14
17
  # Output file path. <tt>sig/GEM_NAME.gen.rbs</tt> by default. See also
15
18
  # TypeProf's <tt>-o</tt> option.
16
- attr_writer :outfile
19
+ attr_accessor :outfile
17
20
 
18
21
  # Unspecified by default. See also TypeProf's <tt>--quiet</tt> option.
19
22
  attr_writer :quiet
20
23
 
21
- # None by default. See also TypeProf's <tt>-I</tt> option.
22
- attr_writer :include
24
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
25
+ # <tt>-I</tt> option.
26
+ attr_accessor :include
23
27
 
24
- # None by default. See also TypeProf's <tt>-r</tt> option.
25
- attr_writer :require
28
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
29
+ # <tt>-r</tt> option.
30
+ attr_accessor :require
26
31
 
27
32
  # None by default. See also TypeProf's <tt>--collection</tt> option.
28
- attr_writer :collection
33
+ attr_accessor :collection
29
34
 
30
- # None by default. See also TypeProf's <tt>--include-dir</tt> option.
31
- attr_writer :include_dir
35
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
36
+ # <tt>--include-dir</tt> option.
37
+ attr_accessor :include_dir
32
38
 
33
- # None by default. See also TypeProf's <tt>--exclude-dir</tt> option.
34
- attr_writer :exclude_dir
39
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
40
+ # <tt>--exclude-dir</tt> option.
41
+ attr_accessor :exclude_dir
35
42
 
36
- # Unspecified by default. See also TypeProf's <tt>--exclude-untyped</tt>
37
- # option.
43
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
44
+ # TypeProf's <tt>--exclude-untyped</tt> option.
38
45
  attr_writer :exclude_untyped
39
46
 
40
47
  # Unspecified by default. See also TypeProf's
@@ -45,8 +52,8 @@ module TypeProf
45
52
  # <tt>--verbose</tt>) option.
46
53
  attr_writer :show_errors
47
54
 
48
- # Unspecified by default. See also TypeProf's <tt>--show-untyped</tt>
49
- # option.
55
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
56
+ # TypeProf's <tt>--show-untyped</tt> option.
50
57
  attr_writer :show_untyped
51
58
 
52
59
  # Unspecified by default. See also TypeProf's
@@ -57,113 +64,153 @@ module TypeProf
57
64
  # <tt>--show-source-locations</tt> option.
58
65
  attr_writer :show_source_locations
59
66
 
60
- # Unspecified by default. See also TypeProf's <tt>--max-second</tt>
61
- # option.
67
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
68
+ # TypeProf's <tt>--max-second</tt> option.
62
69
  attr_writer :max_second
63
70
 
64
- # Unspecified by default. See also TypeProf's <tt>--max-iteration</tt>
65
- # option.
71
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
72
+ # TypeProf's <tt>--max-iteration</tt> option.
66
73
  attr_writer :max_iteration
67
74
 
68
- # Unspecified by default. See also TypeProf's <tt>--stub-execution</tt>
69
- # option.
75
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
76
+ # TypeProf's <tt>--stub-execution</tt> option.
70
77
  attr_writer :stub_execution
71
78
 
72
- # Unspecified by default. See also TypeProf's <tt>--type-depth-limit</tt>
73
- # option.
79
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
80
+ # TypeProf's <tt>--type-depth-limit</tt> option.
74
81
  attr_writer :type_depth_limit
75
82
 
76
- # Unspecified by default. See also TypeProf's
77
- # <tt>--union_width_limit</tt> option.
83
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
84
+ # TypeProf's <tt>--union-width-limit</tt> option.
78
85
  attr_writer :union_width_limit
79
86
 
80
- def initialize(name = :typeprof)
87
+ def initialize(name = :typeprof) # :yield: self
88
+ super()
89
+ @name = name
90
+ defaults
91
+ block_given? and yield self
92
+ read_options
93
+ define_tasks
94
+ end
95
+
96
+ private
97
+
98
+ def defaults
81
99
  # TODO: Support multiple gemspecs and custom path options
82
100
  Dir["*.gemspec"] => [gemspec]
83
101
  spec = Gem::Specification.load(gemspec)
84
102
 
85
- @files = spec.lib_files
103
+ @files = TYPEPROF0_30_0 ? spec.require_paths : spec.lib_files
86
104
  @outfile = File.join("sig", "#{spec.name}.gen.rbs")
87
105
  @include = Set.new
88
106
  @require = Set.new
89
107
  @collection = Set.new
90
108
  @include_dir = Set.new
91
109
  @exclude_dir = Set.new
110
+ end
92
111
 
93
- block_given? and yield self
112
+ def read_options
113
+ @options = ["-o", @outfile]
114
+ @quiet and @options << "--quiet"
115
+ deprecated_set_option("include", flag: "-I")
116
+ deprecated_set_option("require", flag: "-r")
117
+ deprecated_set_option("collection")
118
+ deprecated_set_option("include_dir")
119
+ deprecated_set_option("exclude_dir")
120
+ deprecated_flag_option("exclude_untyped")
121
+ read_boolean_option("show-typeprof-version", attribute: :@show_version)
122
+ read_boolean_option("show-errors")
123
+ deprecated_boolean_option("show-untyped")
124
+ read_boolean_option("show-parameter-names")
125
+ read_boolean_option("show-source-locations")
126
+ deprecated_flag_with_value_option("max-second")
127
+ deprecated_flag_with_value_option("max-iteration")
128
+ deprecated_boolean_option("stub-execution")
129
+ deprecated_flag_with_value_option("type-depth-limit")
130
+ deprecated_flag_with_value_option("union-width-limit")
131
+ end
94
132
 
95
- options = ["-o", @outfile]
96
- @quiet and options << "--quiet"
97
- options.concat(@include.flat_map { |dir| ["-I", dir] })
98
- options.concat(@require.flat_map { |gem| ["-r", gem] })
99
- options.concat(@collection.flat_map { |conf| ["--collection", conf] })
100
- options.concat(@include_dir.flat_map { |dir| ["--include-dir", dir] })
101
- options.concat(@exclude_dir.flat_map { |dir| ["--exclude-dir", dir] })
102
- @exclude_untyped and options << "--exclude-untyped"
103
-
104
- if instance_variable_defined?(:@show_version)
105
- if @show_version
106
- options << "--show-typeprof-version"
107
- else
108
- options << "--no-show-typeprof-version"
109
- end
110
- end
133
+ def define_tasks
134
+ outdir = File.dirname(@outfile)
111
135
 
112
- if instance_variable_defined?(:@show_errors)
113
- if @show_errors
114
- options << "--show-errors"
136
+ desc "Analyze types for Ruby code"
137
+ task @name => outdir do
138
+ argv = [*@options, *@files]
139
+ if TYPEPROF0_30_0
140
+ TypeProf::CLI::CLI.new(argv).run
115
141
  else
116
- options << "--no-show-errors"
142
+ config = TypeProf::CLI.parse(argv)
143
+ TypeProf.analyze(config)
117
144
  end
118
145
  end
119
146
 
120
- if instance_variable_defined?(:@show_untyped)
121
- if @show_untyped
122
- options << "--show-untyped"
123
- else
124
- options << "--no-show-untyped"
125
- end
147
+ directory outdir
148
+ end
149
+
150
+ def read_boolean_option(name, attribute: nil)
151
+ var = attribute || instance_variable_name(name)
152
+ instance_variable_defined?(var) or return
153
+ @options << instance_variable_get(var) ? "--#{name}" : "--no-#{name}"
154
+ end
155
+
156
+ def deprecated_boolean_option(name, attribute: nil)
157
+ var = attribute || instance_variable_name(name)
158
+ if TYPEPROF0_30_0 && instance_variable_defined?(var)
159
+ warn_ignored_option(name)
160
+ return
126
161
  end
127
162
 
128
- if instance_variable_defined?(:@show_parameter_names)
129
- if @show_parameter_names
130
- options << "--show-parameter-names"
131
- else
132
- options << "--no-show-parameter-names"
133
- end
163
+ read_boolean_option(name, attribute: var)
164
+ end
165
+
166
+ def deprecated_set_option(name, flag: nil)
167
+ value = instance_variable_get(:"@#{name}")
168
+
169
+ if TYPEPROF0_30_0 && !value.empty?
170
+ warn_ignored_option(name)
171
+ return
134
172
  end
135
173
 
136
- if instance_variable_defined?(:@show_source_locations)
137
- if @show_source_locations
138
- options << "--show-source-locations"
139
- else
140
- options << "--no-show-source-locations"
141
- end
174
+ unless flag
175
+ flag = name.gsub("_", "-")
176
+ flag = "--#{flag}"
142
177
  end
143
178
 
144
- @max_second and options.push("--max-second", @max_second)
145
- @max_iteration and options.push("--max-iteration", @max_iteration)
179
+ @options.concat(value.flat_map { |elem| [flag, elem] })
180
+ end
146
181
 
147
- if instance_variable_defined?(:@stub_execution)
148
- if @stub_execution
149
- options << "--stub-execution"
150
- else
151
- options << "--no-stub-execution"
152
- end
182
+ def deprecated_flag_option(name)
183
+ var = :"@#{name}"
184
+
185
+ if TYPEPROF0_30_0 && instance_variable_defined?(var)
186
+ warn_ignored_option(name)
187
+ return
153
188
  end
154
189
 
155
- @type_depth_limit and options.push("--type-depth-limit", @type_depth_limit)
156
- @union_width_limit and options.push("--union-width-limit", @union_width_limit)
190
+ value = instance_variable_get(var)
191
+ flag = name.gsub("_", "-")
192
+ value and @options << "--#{flag}"
193
+ end
157
194
 
158
- outdir = File.dirname(@outfile)
195
+ def deprecated_flag_with_value_option(name)
196
+ var = instance_variable_name(name)
159
197
 
160
- desc "Analyze types for Ruby code"
161
- task name => outdir do
162
- config = TypeProf::CLI.parse([*options, *@files])
163
- TypeProf.analyze(config)
198
+ if TYPEPROF0_30_0 && instance_variable_defined?(var)
199
+ warn_ignored_option(name)
200
+ return
164
201
  end
165
202
 
166
- directory outdir
203
+ value = instance_variable_get(var)
204
+ value and @options.push("--#{name}", value)
205
+ end
206
+
207
+ def instance_variable_name(name)
208
+ name = name.gsub("-", "_")
209
+ :"@#{name}"
210
+ end
211
+
212
+ def warn_ignored_option(name)
213
+ LOGGER.warn "Ignoring '#{name}' option for TypeProf v0.30.0 or later"
167
214
  end
168
215
  end
169
216
  end
data/manifest.scm ADDED
@@ -0,0 +1 @@
1
+ (specifications->manifest (list "ruby@3.3" "ruby-rubocop"))
data/shell.nix ADDED
@@ -0,0 +1,16 @@
1
+ with import <nixpkgs> {};
2
+ let
3
+ gems = bundlerEnv {
4
+ name = "typeprof-task";
5
+ inherit ruby;
6
+ gemdir = ./.;
7
+ };
8
+ in stdenv.mkDerivation {
9
+ name = "env";
10
+ buildInputs = [
11
+ ruby_3_3
12
+ bundler
13
+ bundix
14
+ gems
15
+ ];
16
+ }
@@ -0,0 +1,53 @@
1
+ # TypeProf 0.21.3
2
+
3
+ # Revealed types
4
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/import.rb:481 #=> untyped
5
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/analyzer.rb:955 #=> [String, String]
6
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/analyzer.rb:960 #=> [String, String]
7
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/analyzer.rb:1735 #=> :break | :next | :none | :redo | :retry | :return
8
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/container-type.rb:326 #=> untyped
9
+ # /gnu/store/zf9bhxgzqlqjlnv9x5975rjzvjvjy39z-ruby-3.1.4/lib/ruby/gems/3.1.0/gems/typeprof-0.21.3/lib/typeprof/lsp.rb:377 #=> [:ignored, untyped]
10
+
11
+ # Classes
12
+ module TypeProf
13
+ class Task < Rake::TaskLib
14
+ VERSION: String
15
+ LOGGER: Logger
16
+ @name: :typeprof
17
+ @typeprof0_30_0: bool
18
+ @options: Array[String]
19
+
20
+ attr_accessor files: untyped
21
+ attr_accessor outfile: String
22
+ attr_writer quiet: bot
23
+ attr_accessor include: Set[bot]
24
+ attr_accessor require: Set[bot]
25
+ attr_accessor collection: Set[bot]
26
+ attr_accessor include_dir: Set[bot]
27
+ attr_accessor exclude_dir: Set[bot]
28
+ attr_writer exclude_untyped: untyped
29
+ attr_writer show_version: untyped
30
+ attr_writer show_errors: untyped
31
+ attr_writer show_untyped: untyped
32
+ attr_writer show_parameter_names: untyped
33
+ attr_writer show_source_locations: untyped
34
+ attr_writer max_second: untyped
35
+ attr_writer max_iteration: untyped
36
+ attr_writer stub_execution: untyped
37
+ attr_writer type_depth_limit: untyped
38
+ attr_writer union_width_limit: untyped
39
+ def initialize: (?:typeprof name) -> void
40
+
41
+ private
42
+ def defaults: -> Set[bot]
43
+ def read_options: -> Array[String]?
44
+ def define_tasks: -> untyped
45
+ def read_boolean_option: (String name, ?attribute: (:@show_version | Symbol)?) -> String?
46
+ def deprecated_boolean_option: (String name, ?attribute: nil) -> String?
47
+ def deprecated_set_option: (String name, ?flag: String?) -> Array[String]?
48
+ def deprecated_flag_option: (String name) -> Array[String]?
49
+ def deprecated_flag_with_value_option: (String name) -> Array[String]?
50
+ def instance_variable_name: (String name) -> Symbol
51
+ def warn_ignored_option: (String name) -> true
52
+ end
53
+ end
@@ -0,0 +1,31 @@
1
+ # TypeProf 0.30.1
2
+
3
+ # lib/typeprof/task.rb
4
+ module TypeProf
5
+ class TypeProf::Task # failed to identify its superclass
6
+ TypeProf::Task::VERSION: String
7
+ TypeProf::Task::LOGGER: untyped
8
+ def files: -> untyped
9
+ def files=: (untyped) -> untyped
10
+ def outfile: -> String
11
+ def outfile=: (untyped) -> String
12
+ def include: -> Set[untyped]
13
+ def include=: (untyped) -> Set[untyped]
14
+ def require: -> Set[untyped]
15
+ def require=: (untyped) -> Set[untyped]
16
+ def collection: -> Set[untyped]
17
+ def collection=: (untyped) -> Set[untyped]
18
+ def include_dir: -> Set[untyped]
19
+ def include_dir=: (untyped) -> Set[untyped]
20
+ def exclude_dir: -> Set[untyped]
21
+ def exclude_dir=: (untyped) -> Set[untyped]
22
+ def initialize: (?:typeprof) { (TypeProf::Task) -> untyped } -> untyped
23
+ def read_boolean_option: (String, ?attribute: (:@show_version | Symbol)?) -> String?
24
+ def deprecated_boolean_option: (String, ?attribute: nil) -> String?
25
+ def deprecated_set_option: (String, ?flag: String?) -> Array[String]?
26
+ def deprecated_flag_option: (String) -> [String, String]?
27
+ def deprecated_flag_with_value_option: (String) -> Array[String]?
28
+ def instance_variable_name: (String) -> Symbol
29
+ def warn_ignored_option: (String) -> untyped
30
+ end
31
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typeprof-task
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gemmaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-31 00:00:00.000000000 Z
11
+ date: 2025-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typeprof
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.21.3
19
+ version: 0.31.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.21.3
26
+ version: 0.31.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,13 +74,20 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".document"
77
+ - ".envrc"
77
78
  - ".rdoc_options"
78
79
  - ".rubocop.yml"
80
+ - ".rubocop_todo.yml"
79
81
  - CHANGELOG.md
80
82
  - LICENSE
81
83
  - README.md
82
84
  - Rakefile
85
+ - gemset.nix
83
86
  - lib/typeprof/task.rb
87
+ - manifest.scm
88
+ - shell.nix
89
+ - sig/typeprof-task.gen.rbs
90
+ - sig/typeprof-task.typeprof0_30_0.gen.rbs
84
91
  - sig/typeprof/task.rbs
85
92
  homepage: https://git.disroot.org/gemmaro/typeprof-task
86
93
  licenses:
@@ -108,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
115
  - !ruby/object:Gem::Version
109
116
  version: '0'
110
117
  requirements: []
111
- rubygems_version: 3.3.26
118
+ rubygems_version: 3.5.22
112
119
  signing_key:
113
120
  specification_version: 4
114
121
  summary: TypeProf for Rake task