irbs 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile +1 -3
- data/Gemfile.lock +11 -5
- data/README.md +3 -1
- data/Rakefile +4 -4
- data/Steepfile +1 -1
- data/example/app.rb +4 -0
- data/example/{irbs.rbs → isig.rbs} +4 -0
- data/example/typeprof.rbs +4 -0
- data/irbs.gemspec +1 -0
- data/lib/irbs/cli.rb +6 -5
- data/lib/irbs/core.rb +7 -1
- data/lib/irbs/monkey_patch.rb +20 -0
- data/lib/irbs/rbs_generator.rb +3 -3
- data/lib/irbs/template.rb +3 -1
- data/lib/irbs/version.rb +1 -1
- data/lib/irbs.rb +1 -0
- data/{isig/irbs.rbs → sig/isig.rbs} +7 -3
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c600bd915ecb07b4f4e420784092414e5222435aaef223e562e4db59af8a0cda
|
4
|
+
data.tar.gz: 594d0ee52c06c33e800795512b1ada463fdabfd4bde64e2fb82f3cea49f90e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e6f22ca1f7f711185c51155ac7d154741dd2a62a5355e3d90de33c415e09c5d85d4d410d0fef909c6c40441278151fc7a7f77a286ae4dc905bc30eb21d56488
|
7
|
+
data.tar.gz: 3ac944dc1f0d1e04c97d500b91071bf449cc15eb7c472d16568e24d6b8996cd553dd7c47ac446c0429a002544e4c479132463c9bcb2578e5c492ca7739b4dbea
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
irbs (0.2.1)
|
5
|
+
yard (~> 0.9.28)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
@@ -21,14 +27,14 @@ GEM
|
|
21
27
|
logger (1.5.1)
|
22
28
|
minitest (5.16.3)
|
23
29
|
parallel (1.22.1)
|
24
|
-
parser (3.1.
|
30
|
+
parser (3.1.3.0)
|
25
31
|
ast (~> 2.4.1)
|
26
32
|
rainbow (3.1.1)
|
27
33
|
rake (13.0.6)
|
28
34
|
rb-fsevent (0.11.2)
|
29
35
|
rb-inotify (0.10.1)
|
30
36
|
ffi (~> 1.0)
|
31
|
-
rbs (2.
|
37
|
+
rbs (2.8.1)
|
32
38
|
regexp_parser (2.6.1)
|
33
39
|
rexml (3.2.5)
|
34
40
|
rubocop (1.39.0)
|
@@ -45,7 +51,7 @@ GEM
|
|
45
51
|
parser (>= 3.1.1.0)
|
46
52
|
ruby-progressbar (1.11.0)
|
47
53
|
securerandom (0.2.0)
|
48
|
-
steep (1.
|
54
|
+
steep (1.3.0)
|
49
55
|
activesupport (>= 5.1)
|
50
56
|
csv (>= 3.0.9)
|
51
57
|
fileutils (>= 1.1.0)
|
@@ -56,7 +62,7 @@ GEM
|
|
56
62
|
parallel (>= 1.0.0)
|
57
63
|
parser (>= 3.1)
|
58
64
|
rainbow (>= 2.2.2, < 4.0)
|
59
|
-
rbs (>= 2.
|
65
|
+
rbs (>= 2.8.0)
|
60
66
|
securerandom (>= 0.1)
|
61
67
|
strscan (>= 1.0.0)
|
62
68
|
terminal-table (>= 2, < 4)
|
@@ -74,11 +80,11 @@ PLATFORMS
|
|
74
80
|
arm64-darwin-21
|
75
81
|
|
76
82
|
DEPENDENCIES
|
83
|
+
irbs!
|
77
84
|
minitest (~> 5.0)
|
78
85
|
rake (~> 13.0)
|
79
86
|
rubocop (~> 1.21)
|
80
87
|
steep
|
81
|
-
yard
|
82
88
|
|
83
89
|
BUNDLED WITH
|
84
90
|
2.3.18
|
data/README.md
CHANGED
@@ -26,6 +26,8 @@ module App
|
|
26
26
|
arg.to_s
|
27
27
|
end
|
28
28
|
|
29
|
+
private
|
30
|
+
|
29
31
|
# @sig (String) -> Integer
|
30
32
|
def some_private_method(arg)
|
31
33
|
arg.to_i
|
@@ -48,7 +50,7 @@ end
|
|
48
50
|
See example task in [`Rakefile`](https://github.com/diaphragm/irbs/tree/master/Rakefile) and [`exmaple/`](https://github.com/diaphragm/irbs/tree/master/example) for more examples.
|
49
51
|
|
50
52
|
This library uses itself for type checking.
|
51
|
-
See typecheck task in [`Rakefile`](https://github.com/diaphragm/irbs/tree/master/Rakefile) and [`isig/irbs.rbs`](https://github.com/diaphragm/irbs/tree/master/isig
|
53
|
+
See typecheck task in [`Rakefile`](https://github.com/diaphragm/irbs/tree/master/Rakefile) and [`isig/irbs.rbs`](https://github.com/diaphragm/irbs/tree/master/sig/isig.rbs)
|
52
54
|
|
53
55
|
## Development
|
54
56
|
|
data/Rakefile
CHANGED
@@ -22,15 +22,15 @@ end
|
|
22
22
|
|
23
23
|
desc 'typecheck'
|
24
24
|
task :typecheck do
|
25
|
-
sh 'mkdir -p
|
25
|
+
sh 'mkdir -p sig'
|
26
26
|
|
27
|
-
sh 'exe/irbs "lib/**/*.rb" -o isig
|
27
|
+
sh 'exe/irbs "lib/**/*.rb" -o sig/isig.rbs'
|
28
28
|
sh 'steep check lib'
|
29
29
|
end
|
30
30
|
|
31
31
|
desc 'Example of usage with TypeProf and Steep'
|
32
32
|
task :example do
|
33
|
-
sh 'exe/irbs example/app.rb -o example/
|
34
|
-
sh 'typeprof example/app.rb example/
|
33
|
+
sh 'exe/irbs example/app.rb -o example/isig.rbs --ignore-constant'
|
34
|
+
sh 'typeprof example/app.rb example/isig.rbs -o example/typeprof.rbs'
|
35
35
|
sh 'steep check example'
|
36
36
|
end
|
data/Steepfile
CHANGED
data/example/app.rb
CHANGED
data/example/typeprof.rbs
CHANGED
data/irbs.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
# Uncomment to register a new dependency of your gem
|
36
36
|
# spec.add_dependency "example-gem", "~> 1.0"
|
37
|
+
spec.add_dependency 'yard', '~> 0.9.28'
|
37
38
|
|
38
39
|
# For more information and examples about making a new gem, check out our
|
39
40
|
# guide at: https://bundler.io/guides/creating_gem.html
|
data/lib/irbs/cli.rb
CHANGED
@@ -5,17 +5,18 @@ require 'optparse'
|
|
5
5
|
module Irbs
|
6
6
|
class CLI
|
7
7
|
# @sig String
|
8
|
-
|
8
|
+
IGNORE_CONSTANT_HELP_MESSAGE = 'Generate no constant signatures. ' \
|
9
9
|
'For using TypeProf. ' \
|
10
10
|
'(TypeProf genarate duplicate constant signature even if already exists.)'
|
11
|
-
private_constant :
|
11
|
+
private_constant :IGNORE_CONSTANT_HELP_MESSAGE
|
12
12
|
|
13
13
|
class << self
|
14
14
|
# @sig (Array[String]) -> void
|
15
15
|
def run(argv)
|
16
16
|
config = parse_opt(argv)
|
17
17
|
Core.new(config).generate
|
18
|
-
|
18
|
+
ensure
|
19
|
+
config&.stdout&.close
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
@@ -25,10 +26,10 @@ module Irbs
|
|
25
26
|
config = Irbs::Config.new
|
26
27
|
opt = OptionParser.new
|
27
28
|
|
28
|
-
opt.on('-o output', '
|
29
|
+
opt.on('-o output', 'Output filename. (Default: stdout)') do
|
29
30
|
config.stdout = File.open(_1, 'w')
|
30
31
|
end
|
31
|
-
opt.on('--ignore-constant',
|
32
|
+
opt.on('--ignore-constant', IGNORE_CONSTANT_HELP_MESSAGE) do
|
32
33
|
config.ingore_constant = _1
|
33
34
|
end
|
34
35
|
config.paths = opt.parse(argv)
|
data/lib/irbs/core.rb
CHANGED
@@ -11,9 +11,15 @@ module Irbs
|
|
11
11
|
def initialize(config)
|
12
12
|
@config = config
|
13
13
|
|
14
|
+
# YARD::Parser::SourceParser.after_parse_file do |parser|
|
15
|
+
# next unless parser.file == 'example/app.rb'
|
16
|
+
# $parser = parser.instance_variable_get(:@parser)
|
17
|
+
# end
|
18
|
+
|
14
19
|
YARD::Tags::Library.define_tag('Signature', :sig)
|
15
20
|
YARD::Tags::Library.define_tag('Raw rbs code', :rbs)
|
16
|
-
|
21
|
+
|
22
|
+
YARD::Parser::SourceParser.parse(config.paths)
|
17
23
|
YARD::Registry.load_all
|
18
24
|
end
|
19
25
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Irbs
|
4
|
+
# @rbs def statement: () -> untyped
|
5
|
+
module MonkeyPatch
|
6
|
+
protected
|
7
|
+
|
8
|
+
def process_mixin(mixin)
|
9
|
+
super.tap do
|
10
|
+
i = statement.method_name(true) == :include ? 0 : -1
|
11
|
+
ident = statement[0].source
|
12
|
+
_1[i].instance_variable_set(:@__ident, ident)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class YARD::Handlers::Ruby::MixinHandler # rubocop:disable Style/ClassAndModuleChildren
|
19
|
+
prepend ::Irbs::MonkeyPatch
|
20
|
+
end
|
data/lib/irbs/rbs_generator.rb
CHANGED
@@ -45,10 +45,10 @@ module Irbs
|
|
45
45
|
end
|
46
46
|
|
47
47
|
# @sig () -> String
|
48
|
-
def to_rbs # rubocop:todo Metrics/AbcSize
|
48
|
+
def to_rbs # rubocop:todo Metrics/AbcSize
|
49
49
|
[
|
50
50
|
namespace_definition,
|
51
|
-
|
51
|
+
raw_rbses.map{ Template.rbs(_1) },
|
52
52
|
class_mixins.map{ Template.extend(_1) },
|
53
53
|
instance_mixins.map{ Template.include(_1) },
|
54
54
|
config.ingore_constant ? nil : constants.map{ Template.constant(_1) },
|
@@ -64,7 +64,7 @@ module Irbs
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# @sig () -> Array[YARD::Tags::Tag]
|
67
|
-
def
|
67
|
+
def raw_rbses
|
68
68
|
obj.tags(:rbs)
|
69
69
|
end
|
70
70
|
|
data/lib/irbs/template.rb
CHANGED
@@ -24,7 +24,9 @@ module Irbs
|
|
24
24
|
|
25
25
|
# @sig (YARD::CodeObjects::ModuleObject) -> String
|
26
26
|
def include(mod)
|
27
|
-
|
27
|
+
ident = mod.instance_variable_get(:@__ident)
|
28
|
+
|
29
|
+
" #{ident} ::#{mod.path}"
|
28
30
|
end
|
29
31
|
|
30
32
|
# @sig (YARD::CodeObjects::ModuleObject) -> String
|
data/lib/irbs/version.rb
CHANGED
data/lib/irbs.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'irbs/attribute_wrapper'
|
|
4
4
|
require_relative 'irbs/cli'
|
5
5
|
require_relative 'irbs/config'
|
6
6
|
require_relative 'irbs/core'
|
7
|
+
require_relative 'irbs/monkey_patch'
|
7
8
|
require_relative 'irbs/rbs_generator'
|
8
9
|
require_relative 'irbs/template'
|
9
10
|
require_relative 'irbs/version'
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# Irbs 0.1
|
1
|
+
# Irbs 0.2.1
|
2
2
|
|
3
3
|
module ::Irbs
|
4
4
|
VERSION: String
|
5
5
|
end
|
6
6
|
|
7
7
|
class ::Irbs::CLI
|
8
|
-
|
8
|
+
IGNORE_CONSTANT_HELP_MESSAGE: String
|
9
9
|
public def self.run: (Array[String]) -> void
|
10
10
|
private def self.parse_opt: (Array[String]) -> Irbs::Config
|
11
11
|
end
|
@@ -32,6 +32,10 @@ module ::Irbs::Template
|
|
32
32
|
public def self.rbs: (YARD::Tags::Tag) -> String
|
33
33
|
end
|
34
34
|
|
35
|
+
module ::Irbs::MonkeyPatch
|
36
|
+
def statement: () -> untyped
|
37
|
+
end
|
38
|
+
|
35
39
|
class ::Irbs::RbsGenerator
|
36
40
|
extend ::Forwardable
|
37
41
|
private attr_reader obj: YARD::CodeObjects::NamespaceObject
|
@@ -44,7 +48,7 @@ class ::Irbs::RbsGenerator
|
|
44
48
|
private def writeout: () -> void
|
45
49
|
private def to_rbs: () -> String
|
46
50
|
private def namespace_definition: () -> String
|
47
|
-
private def
|
51
|
+
private def raw_rbses: () -> Array[YARD::Tags::Tag]
|
48
52
|
private def child_namespaces: () -> Array[YARD::CodeObjects::NamespaceObject]
|
49
53
|
private def constants: () -> Array[YARD::CodeObjects::ConstantObject]
|
50
54
|
private def meths: () -> Array[YARD::CodeObjects::MethodObject]
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- diaphragm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.28
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.28
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- 7163746+diaphragm@users.noreply.github.com
|
@@ -26,21 +40,22 @@ files:
|
|
26
40
|
- Rakefile
|
27
41
|
- Steepfile
|
28
42
|
- example/app.rb
|
29
|
-
- example/
|
43
|
+
- example/isig.rbs
|
30
44
|
- example/typeprof.rbs
|
31
45
|
- exe/irbs
|
32
46
|
- irbs.gemspec
|
33
|
-
- isig/irbs.rbs
|
34
47
|
- lib/irbs.rb
|
35
48
|
- lib/irbs/attribute_wrapper.rb
|
36
49
|
- lib/irbs/cli.rb
|
37
50
|
- lib/irbs/config.rb
|
38
51
|
- lib/irbs/core.rb
|
52
|
+
- lib/irbs/monkey_patch.rb
|
39
53
|
- lib/irbs/rbs_generator.rb
|
40
54
|
- lib/irbs/template.rb
|
41
55
|
- lib/irbs/version.rb
|
42
56
|
- rbs_collection.lock.yaml
|
43
57
|
- rbs_collection.yaml
|
58
|
+
- sig/isig.rbs
|
44
59
|
homepage: https://github.com/diaphragm/irbs
|
45
60
|
licenses:
|
46
61
|
- MIT
|