orthoses 0.11.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +39 -19
- data/examples/minitest/Rakefile +2 -2
- data/lib/orthoses/constant.rb +1 -1
- data/lib/orthoses/content/duplication_checker.rb +10 -5
- data/lib/orthoses/filter.rb +7 -5
- data/lib/orthoses/version.rb +1 -1
- data/sig/orthoses/constant.rbs +1 -1
- data/sig/orthoses/filter.rbs +2 -1
- data/sig/orthoses.rbs +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8718c01d3ca0c5ea18285c9082218c526e280626d15da555b17773ec8d582ac3
|
4
|
+
data.tar.gz: 2541364526894cb9f2870a4a69169418ca57ad042911507bd96557e54df1abfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8dbc5aaeda5a1943a61bfc8b0190994373284e5c4712d2ffe710fe31fe95949406b8d2a3929dfad09b573b14c19d81c7f558cbc7ac197055d128596e2625272
|
7
|
+
data.tar.gz: 465cff7f5fa29e7b599549a790b85ba1d597e820e6437811ead5e8de031fee797ef07746bba448451b2b73715511e8bd59a65cb8b32bf86ab1d09832a06ac3a7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
Orthoses is a framework for RBS generation.
|
4
4
|
The Rack architecture keeps your code organized and extensible.
|
5
5
|
|
6
|
+
- You can choose which middleware to use.
|
7
|
+
- You can write your own middleware to use.
|
8
|
+
- You can publish your middleware and share it with the world.
|
9
|
+
|
6
10
|
## PoC
|
7
11
|
|
8
12
|
https://gist.github.com/ksss/00592da24f28774bf8fc5db08331666e
|
@@ -19,28 +23,38 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
19
23
|
|
20
24
|
## Usage
|
21
25
|
|
26
|
+
For example, You can write script in Rakefile.
|
27
|
+
|
22
28
|
```rb
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
require 'orthoses'
|
30
|
+
|
31
|
+
namespace :rbs do
|
32
|
+
desc "build RBS to sig/out"
|
33
|
+
task :build do
|
34
|
+
Orthoses::Builder.new do
|
35
|
+
use Orthoses::CreateFileByName
|
36
|
+
base_dir: Rails.root.join("sig/out"),
|
37
|
+
header: "# !!! GENERATED CODE !!!"
|
38
|
+
use Orthoses::Filter do |name, _content|
|
39
|
+
path, _lineno = Object.const_source_location(name)
|
40
|
+
return false unless path
|
41
|
+
%r{app/models}.match?(path)
|
42
|
+
end
|
43
|
+
use YourCustom::Middleware
|
44
|
+
use Orthoses::Mixin
|
45
|
+
use Orthoses::Constant
|
46
|
+
use Orthoses::Walk,
|
47
|
+
root: "Foo"
|
48
|
+
run -> {
|
49
|
+
# load library or application
|
50
|
+
}
|
51
|
+
end.call
|
52
|
+
end
|
53
|
+
end
|
42
54
|
```
|
43
55
|
|
56
|
+
Then, you can see the result files under `sig/out`.
|
57
|
+
|
44
58
|
## Utils
|
45
59
|
|
46
60
|
`Orthoses::Utils` is a collection of useful methods.
|
@@ -177,3 +191,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
177
191
|
## Code of Conduct
|
178
192
|
|
179
193
|
Everyone interacting in the Orthoses project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ksss/orthoses/blob/main/CODE_OF_CONDUCT.md).
|
194
|
+
|
195
|
+
# TODO
|
196
|
+
|
197
|
+
- Share middleware sets for commonly used use cases.
|
198
|
+
- For library.
|
199
|
+
- For application.
|
data/examples/minitest/Rakefile
CHANGED
@@ -13,9 +13,9 @@ task :minitest => :src do
|
|
13
13
|
Orthoses::Builder.new do
|
14
14
|
use Orthoses::CreateFileByName,
|
15
15
|
base_dir: out.to_s
|
16
|
-
use Orthoses::Filter
|
16
|
+
use Orthoses::Filter do |name, content|
|
17
17
|
name.start_with?("Minitest") || name == "Kernel"
|
18
|
-
|
18
|
+
end
|
19
19
|
use Orthoses::Constant,
|
20
20
|
strict: false,
|
21
21
|
if: ->(current, const, val, rbs){
|
data/lib/orthoses/constant.rb
CHANGED
@@ -11,11 +11,16 @@ module Orthoses
|
|
11
11
|
return unless @decl.respond_to?(:members)
|
12
12
|
uniq_map = {}
|
13
13
|
@decl.members.each do |member|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
if member.instance_of?(RBS::AST::Members::MethodDefinition) && member.overload
|
15
|
+
# avoid to duplicate and keep order
|
16
|
+
uniq_map[Object.new] = member
|
17
|
+
else
|
18
|
+
key = member_key(member)
|
19
|
+
drop_member = uniq_map[key]
|
20
|
+
uniq_map[key] = member
|
21
|
+
if drop_member
|
22
|
+
Orthoses.logger.info("#{@decl.name} \"#{member.location.source}\" was droped since duplication")
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
drop_known_method_definition(uniq_map)
|
data/lib/orthoses/filter.rb
CHANGED
@@ -2,19 +2,21 @@
|
|
2
2
|
|
3
3
|
module Orthoses
|
4
4
|
# Filter current store.
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# filter stored key and value if proc return true
|
6
|
+
# use Orthoses::Filter do |name, content|
|
7
|
+
# Orthoses.rbs_defined_class?(name)
|
8
|
+
# end
|
8
9
|
class Filter
|
9
|
-
def initialize(loader, if:)
|
10
|
+
def initialize(loader, if: nil, &block)
|
10
11
|
@loader = loader
|
11
12
|
@if = binding.local_variable_get(:if)
|
13
|
+
@block = block || @if || raise(ArgumentError, "should give a block")
|
12
14
|
end
|
13
15
|
|
14
16
|
def call
|
15
17
|
@loader.call.tap do |store|
|
16
18
|
store.filter! do |name, content|
|
17
|
-
@
|
19
|
+
@block.call(name, content).tap do
|
18
20
|
Orthoses.logger.debug("Filter pass [#{name}]")
|
19
21
|
end
|
20
22
|
end
|
data/lib/orthoses/version.rb
CHANGED
data/sig/orthoses/constant.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Constant
|
4
|
-
def initialize: (Orthoses::_Call loader, strict: bool, ?if: ^(Module, Symbol, untyped) -> boolish, ?on_error: ^(Orthoses::ConstLoadError) -> void) -> void
|
4
|
+
def initialize: (Orthoses::_Call loader, ?strict: bool, ?if: ^(Module, Symbol, untyped) -> boolish | nil, ?on_error: ^(Orthoses::ConstLoadError) -> void | nil) -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
6
|
@loader: Orthoses::_Call
|
7
7
|
@strict: bool
|
data/sig/orthoses/filter.rbs
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Filter
|
4
|
-
def initialize: (Orthoses::_Call loader
|
4
|
+
def initialize: (Orthoses::_Call loader) { (String, Orthoses::Content) -> boolish } -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
6
|
@loader: Orthoses::_Call
|
7
|
+
@block: ^(String, Orthoses::Content) -> boolish
|
7
8
|
end
|
data/sig/orthoses.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orthoses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|