typeprof-task 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca7e7b06a15856ddbdbe3c053f22c6fba15977a1963894f0b2c13670fe7cafbc
4
- data.tar.gz: e381df67d8c5ecb97a4eacbbc90f8cf087d80ed1e66e3eef380172ca501f0473
3
+ metadata.gz: d5039791f8cec10859cfc53e82bc43bf33a00e0de1306a92f899cf673ae26912
4
+ data.tar.gz: 59a04a5dadfd979fc2a1cf012107212deacbe2b7c44b49aba5dafc353a7c696f
5
5
  SHA512:
6
- metadata.gz: fd9775e23baf707b461c3bbe7c6aa985961c66fa9ebbed6ad54254dfc936792cfdbf6734e6346f6c9c6c54490f1d8c9ccd86e650f2d4d2df3b46358aa645169a
7
- data.tar.gz: 69b3537d307837adc1cc13a75dc3af79a3f81d66739b74220ca31bb0001af27b59cf7a9bfd38f95e8569020d4dadc9d400e6b88d586d3a115db67123b7d05f5b
6
+ metadata.gz: f5c073c0d011c5a472eceffe6a728bf904e1ceb649a5ef06f55816648e3a5f9e9521f09bd52b163736ff1310d88c6849508670e1ed8fd363c018a4234a24b1cd
7
+ data.tar.gz: 117ef770b2acf4949accc3bba61a8dbbe6c1f677d47a8ef3176fafe7fdc36690260d962538cdaca269707b52f9c4947715791ebdee441af5ca8a44068da0da63
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use guix
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.1 - 2025-01-01
6
+
7
+ * Make some options accessible (read and write permissions): `files`,
8
+ `outfile`, `include`, `require`, `collection`, `include_dir`, `exclude_dir`
9
+ * Relax TypeProf version constraint. Support version 0.30.0 or later.
10
+
5
11
  ## 0.1.0 - 2024-12-31
6
12
 
7
13
  * 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,44 @@
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.1.1"
11
+ LOGGER = Logger.new($stderr)
10
12
 
11
13
  # Target files. By default, files under one of the require paths.
12
- attr_writer :files
14
+ attr_accessor :files
13
15
 
14
16
  # Output file path. <tt>sig/GEM_NAME.gen.rbs</tt> by default. See also
15
17
  # TypeProf's <tt>-o</tt> option.
16
- attr_writer :outfile
18
+ attr_accessor :outfile
17
19
 
18
20
  # Unspecified by default. See also TypeProf's <tt>--quiet</tt> option.
19
21
  attr_writer :quiet
20
22
 
21
- # None by default. See also TypeProf's <tt>-I</tt> option.
22
- attr_writer :include
23
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
24
+ # <tt>-I</tt> option.
25
+ attr_accessor :include
23
26
 
24
- # None by default. See also TypeProf's <tt>-r</tt> option.
25
- attr_writer :require
27
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
28
+ # <tt>-r</tt> option.
29
+ attr_accessor :require
26
30
 
27
31
  # None by default. See also TypeProf's <tt>--collection</tt> option.
28
- attr_writer :collection
32
+ attr_accessor :collection
29
33
 
30
- # None by default. See also TypeProf's <tt>--include-dir</tt> option.
31
- attr_writer :include_dir
34
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
35
+ # <tt>--include-dir</tt> option.
36
+ attr_accessor :include_dir
32
37
 
33
- # None by default. See also TypeProf's <tt>--exclude-dir</tt> option.
34
- attr_writer :exclude_dir
38
+ # Deprecated in TypeProf v0.30.0. None by default. See also TypeProf's
39
+ # <tt>--exclude-dir</tt> option.
40
+ attr_accessor :exclude_dir
35
41
 
36
- # Unspecified by default. See also TypeProf's <tt>--exclude-untyped</tt>
37
- # option.
42
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
43
+ # TypeProf's <tt>--exclude-untyped</tt> option.
38
44
  attr_writer :exclude_untyped
39
45
 
40
46
  # Unspecified by default. See also TypeProf's
@@ -45,8 +51,8 @@ module TypeProf
45
51
  # <tt>--verbose</tt>) option.
46
52
  attr_writer :show_errors
47
53
 
48
- # Unspecified by default. See also TypeProf's <tt>--show-untyped</tt>
49
- # option.
54
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
55
+ # TypeProf's <tt>--show-untyped</tt> option.
50
56
  attr_writer :show_untyped
51
57
 
52
58
  # Unspecified by default. See also TypeProf's
@@ -57,24 +63,24 @@ module TypeProf
57
63
  # <tt>--show-source-locations</tt> option.
58
64
  attr_writer :show_source_locations
59
65
 
60
- # Unspecified by default. See also TypeProf's <tt>--max-second</tt>
61
- # option.
66
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
67
+ # TypeProf's <tt>--max-second</tt> option.
62
68
  attr_writer :max_second
63
69
 
64
- # Unspecified by default. See also TypeProf's <tt>--max-iteration</tt>
65
- # option.
70
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
71
+ # TypeProf's <tt>--max-iteration</tt> option.
66
72
  attr_writer :max_iteration
67
73
 
68
- # Unspecified by default. See also TypeProf's <tt>--stub-execution</tt>
69
- # option.
74
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
75
+ # TypeProf's <tt>--stub-execution</tt> option.
70
76
  attr_writer :stub_execution
71
77
 
72
- # Unspecified by default. See also TypeProf's <tt>--type-depth-limit</tt>
73
- # option.
78
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
79
+ # TypeProf's <tt>--type-depth-limit</tt> option.
74
80
  attr_writer :type_depth_limit
75
81
 
76
- # Unspecified by default. See also TypeProf's
77
- # <tt>--union_width_limit</tt> option.
82
+ # Deprecated in TypeProf v0.30.0. Unspecified by default. See also
83
+ # TypeProf's <tt>--union-width-limit</tt> option.
78
84
  attr_writer :union_width_limit
79
85
 
80
86
  def initialize(name = :typeprof)
@@ -82,7 +88,9 @@ module TypeProf
82
88
  Dir["*.gemspec"] => [gemspec]
83
89
  spec = Gem::Specification.load(gemspec)
84
90
 
85
- @files = spec.lib_files
91
+ @typeprof0_30_0 = Gem::Version.new(TypeProf::VERSION) >= "0.30.0"
92
+
93
+ @files = @typeprof0_30_0 ? spec.require_paths : spec.lib_files
86
94
  @outfile = File.join("sig", "#{spec.name}.gen.rbs")
87
95
  @include = Set.new
88
96
  @require = Set.new
@@ -92,78 +100,107 @@ module TypeProf
92
100
 
93
101
  block_given? and yield self
94
102
 
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
103
+ @options = ["-o", @outfile]
104
+ @quiet and @options << "--quiet"
105
+ deprecated_set_option("include", flag: "-I")
106
+ deprecated_set_option("require", flag: "-r")
107
+ deprecated_set_option("collection")
108
+ deprecated_set_option("include_dir")
109
+ deprecated_set_option("exclude_dir")
110
+ deprecated_flag_option("exclude_untyped")
111
+ read_boolean_option("show-typeprof-version", attribute: :@show_version)
112
+ read_boolean_option("show-errors")
113
+ deprecated_boolean_option("show-untyped")
114
+ read_boolean_option("show-parameter-names")
115
+ read_boolean_option("show-source-locations")
116
+ deprecated_flag_with_value_option("max-second")
117
+ deprecated_flag_with_value_option("max-iteration")
118
+ deprecated_boolean_option("stub-execution")
119
+ deprecated_flag_with_value_option("type-depth-limit")
120
+ deprecated_flag_with_value_option("union-width-limit")
111
121
 
112
- if instance_variable_defined?(:@show_errors)
113
- if @show_errors
114
- options << "--show-errors"
122
+ outdir = File.dirname(@outfile)
123
+
124
+ desc "Analyze types for Ruby code"
125
+ task name => outdir do
126
+ argv = [*@options, *@files]
127
+ if @typeprof0_30_0
128
+ TypeProf::CLI::CLI.new(argv).run
115
129
  else
116
- options << "--no-show-errors"
130
+ config = TypeProf::CLI.parse(argv)
131
+ TypeProf.analyze(config)
117
132
  end
118
133
  end
119
134
 
120
- if instance_variable_defined?(:@show_untyped)
121
- if @show_untyped
122
- options << "--show-untyped"
123
- else
124
- options << "--no-show-untyped"
125
- end
135
+ directory outdir
136
+ end
137
+
138
+ private
139
+
140
+ def read_boolean_option(name, attribute: nil)
141
+ var = attribute || instance_variable_name(name)
142
+ instance_variable_defined?(var) or return
143
+ @options << instance_variable_get(var) ? "--#{name}" : "--no-#{name}"
144
+ end
145
+
146
+ def deprecated_boolean_option(name, attribute: nil)
147
+ var = attribute || instance_variable_name(name)
148
+ if @typeprof0_30_0 && instance_variable_defined?(var)
149
+ warn_ignored_option(name)
150
+ return
126
151
  end
127
152
 
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
153
+ read_boolean_option(name, attribute: var)
154
+ end
155
+
156
+ def deprecated_set_option(name, flag: nil)
157
+ value = instance_variable_get(:"@#{name}")
158
+
159
+ if @typeprof0_30_0 && !value.empty?
160
+ warn_ignored_option(name)
161
+ return
134
162
  end
135
163
 
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
164
+ unless flag
165
+ flag = name.gsub("_", "-")
166
+ flag = "--#{flag}"
142
167
  end
143
168
 
144
- @max_second and options.push("--max-second", @max_second)
145
- @max_iteration and options.push("--max-iteration", @max_iteration)
169
+ @options.concat(value.flat_map { |elem| [flag, elem] })
170
+ end
146
171
 
147
- if instance_variable_defined?(:@stub_execution)
148
- if @stub_execution
149
- options << "--stub-execution"
150
- else
151
- options << "--no-stub-execution"
152
- end
172
+ def deprecated_flag_option(name)
173
+ var = :"@#{name}"
174
+
175
+ if @typeprof0_30_0 && instance_variable_defined?(var)
176
+ warn_ignored_option(name)
177
+ return
153
178
  end
154
179
 
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)
180
+ value = instance_variable_get(var)
181
+ flag = name.gsub("_", "-")
182
+ value and @options << "--#{flag}"
183
+ end
157
184
 
158
- outdir = File.dirname(@outfile)
185
+ def deprecated_flag_with_value_option(name)
186
+ var = instance_variable_name(name)
159
187
 
160
- desc "Analyze types for Ruby code"
161
- task name => outdir do
162
- config = TypeProf::CLI.parse([*options, *@files])
163
- TypeProf.analyze(config)
188
+ if @typeprof0_30_0 && instance_variable_defined?(var)
189
+ warn_ignored_option(name)
190
+ return
164
191
  end
165
192
 
166
- directory outdir
193
+ value = instance_variable_get(var)
194
+ value and @options.push("--#{name}", value)
195
+ end
196
+
197
+ def instance_variable_name(name)
198
+ name = name.gsub("-", "_")
199
+ :"@#{name}"
200
+ end
201
+
202
+ def warn_ignored_option(name)
203
+ LOGGER.warn "Ignoring '#{name}' option for TypeProf v0.30.0 or later"
167
204
  end
168
205
  end
169
206
  end
data/manifest.scm ADDED
@@ -0,0 +1 @@
1
+ (specifications->manifest (list "ruby@3.1" "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,49 @@
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
+ @typeprof0_30_0: bool
17
+ @options: Array[String]
18
+
19
+ attr_accessor files: untyped
20
+ attr_accessor outfile: String
21
+ attr_writer quiet: bot
22
+ attr_accessor include: Set[bot]
23
+ attr_accessor require: Set[bot]
24
+ attr_accessor collection: Set[bot]
25
+ attr_accessor include_dir: Set[bot]
26
+ attr_accessor exclude_dir: Set[bot]
27
+ attr_writer exclude_untyped: untyped
28
+ attr_writer show_version: untyped
29
+ attr_writer show_errors: untyped
30
+ attr_writer show_untyped: untyped
31
+ attr_writer show_parameter_names: untyped
32
+ attr_writer show_source_locations: untyped
33
+ attr_writer max_second: untyped
34
+ attr_writer max_iteration: untyped
35
+ attr_writer stub_execution: untyped
36
+ attr_writer type_depth_limit: untyped
37
+ attr_writer union_width_limit: untyped
38
+ def initialize: (?:typeprof name) -> void
39
+
40
+ private
41
+ def read_boolean_option: (String name, ?attribute: (:@show_version | Symbol)?) -> String?
42
+ def deprecated_boolean_option: (String name, ?attribute: nil) -> String?
43
+ def deprecated_set_option: (String name, ?flag: String?) -> Array[String]?
44
+ def deprecated_flag_option: (String name) -> Array[String]?
45
+ def deprecated_flag_with_value_option: (String name) -> Array[String]?
46
+ def instance_variable_name: (String name) -> Symbol
47
+ def warn_ignored_option: (String name) -> true
48
+ end
49
+ 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,27 +1,27 @@
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.1.1
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-01-01 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
19
  version: 0.21.3
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
26
  version: 0.21.3
27
27
  - !ruby/object:Gem::Dependency
@@ -74,13 +74,19 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".document"
77
+ - ".envrc"
77
78
  - ".rdoc_options"
78
79
  - ".rubocop.yml"
79
80
  - CHANGELOG.md
80
81
  - LICENSE
81
82
  - README.md
82
83
  - Rakefile
84
+ - gemset.nix
83
85
  - lib/typeprof/task.rb
86
+ - manifest.scm
87
+ - shell.nix
88
+ - sig/typeprof-task.gen.rbs
89
+ - sig/typeprof-task.typeprof0_30_0.gen.rbs
84
90
  - sig/typeprof/task.rbs
85
91
  homepage: https://git.disroot.org/gemmaro/typeprof-task
86
92
  licenses: