orthoses 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0520f0eccc23c9e57186592193f7c30175b59aa1364bcf5de49f1bcbff0a68d5
4
- data.tar.gz: deaeb9dd3baed337b22a0b6990bbddd98df1c282c1dc6269edeb3a78060abae1
3
+ metadata.gz: 758b4661d8c0df218aa722a78505efee6dec692b601aad81e660c86444389f5e
4
+ data.tar.gz: bcfbe10b12f0d3ef2444a7461d2a5004410b89b8d88ef3c100fb6e88f3325e6d
5
5
  SHA512:
6
- metadata.gz: 94037bb0ff51e74b055e8282048d818ca051a102fdcdb16f64dc00c1a83194bcd4a721d68c9dbf43e47a691b66ef7b992b319a69fff4b0afc9374cdf8001d0a2
7
- data.tar.gz: 27611b811fead68b26ccd941d5111039ad7fddb0fdaad6d0509bf9b5d6bdfc29783daab517a959389a95890eba75ce57b5933a9c26158f17b3a2d8d0ab2948ff
6
+ metadata.gz: 3b8813677299e76fe253d87e0ab8460ba596c0c6805225767525c60c7f9845bc62cdd9e4f491cb8a2a6197ae473deacd15e78ce29f209305e7e3b1a86a391661
7
+ data.tar.gz: b3979ddfbc4f209ce221c2e93e0a80c7d7120d0ef541d6f0061777db7f30b290170fae324aa3d3c4e6d99fbbd37c96a166473aefcc10b404647a5b4bfa0250f3
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orthoses (1.2.0)
4
+ orthoses (1.3.0)
5
5
  rbs (~> 2.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.3.1)
10
+ activesupport (7.0.4)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
@@ -17,7 +17,7 @@ GEM
17
17
  ffi (1.15.5)
18
18
  i18n (1.12.0)
19
19
  concurrent-ruby (~> 1.0)
20
- language_server-protocol (3.17.0.0)
20
+ language_server-protocol (3.17.0.1)
21
21
  listen (3.7.1)
22
22
  rb-fsevent (~> 0.10, >= 0.10.3)
23
23
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -27,25 +27,27 @@ GEM
27
27
  ast (~> 2.4.1)
28
28
  rainbow (3.1.1)
29
29
  rake (13.0.6)
30
- rb-fsevent (0.11.1)
30
+ rb-fsevent (0.11.2)
31
31
  rb-inotify (0.10.1)
32
32
  ffi (~> 1.0)
33
- rbs (2.6.0)
33
+ rbs (2.7.0)
34
34
  rgot (1.1.0)
35
- steep (1.1.1)
35
+ securerandom (0.2.0)
36
+ steep (1.2.0)
36
37
  activesupport (>= 5.1)
37
38
  language_server-protocol (>= 3.15, < 4.0)
38
39
  listen (~> 3.0)
39
40
  parallel (>= 1.0.0)
40
41
  parser (>= 3.1)
41
42
  rainbow (>= 2.2.2, < 4.0)
42
- rbs (>= 2.3.2)
43
+ rbs (>= 2.7.0)
44
+ securerandom (>= 0.1)
43
45
  terminal-table (>= 2, < 4)
44
46
  terminal-table (3.0.2)
45
47
  unicode-display_width (>= 1.1.1, < 3)
46
48
  tzinfo (2.0.5)
47
49
  concurrent-ruby (~> 1.0)
48
- unicode-display_width (2.2.0)
50
+ unicode-display_width (2.3.0)
49
51
 
50
52
  PLATFORMS
51
53
  ruby
@@ -27,13 +27,16 @@ module Orthoses
27
27
  @body = []
28
28
  @header = nil
29
29
  @comment = nil
30
+ @uniq = false
30
31
  end
31
32
 
32
33
  def <<(line)
34
+ @uniq = false
33
35
  @body << line
34
36
  end
35
37
 
36
38
  def concat(other)
39
+ @uniq = false
37
40
  @body.concat(other)
38
41
  end
39
42
 
@@ -41,7 +44,12 @@ module Orthoses
41
44
  @body.empty?
42
45
  end
43
46
 
47
+ def interface?
48
+ @name.split('::').last.start_with?('_')
49
+ end
50
+
44
51
  def delete(val)
52
+ @uniq = false
45
53
  @body.delete(val)
46
54
  end
47
55
 
@@ -107,7 +115,10 @@ module Orthoses
107
115
  end
108
116
  parsed_decl = parsed_decls.first or raise
109
117
  parsed_decl.tap do |decl|
110
- DuplicationChecker.new(decl).update_decl
118
+ if !@uniq
119
+ DuplicationChecker.new(decl).update_decl
120
+ @uniq = true
121
+ end
111
122
  end
112
123
  rescue RBS::ParsingError
113
124
  Orthoses.logger.error "```rbs\n#{original_rbs}```"
@@ -123,7 +134,7 @@ module Orthoses
123
134
 
124
135
  return unless @header.nil?
125
136
 
126
- if name.split('::').last.start_with?('_')
137
+ if interface?
127
138
  self.header = "interface #{name}"
128
139
  return
129
140
  end
@@ -28,7 +28,7 @@ module Orthoses
28
28
  out.puts @header
29
29
  out.puts
30
30
  end
31
- out.puts content.original_rbs
31
+ out.puts content.to_rbs
32
32
  end
33
33
  Orthoses.logger.info("Generate file to #{file_path.to_s}")
34
34
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ module Outputable
5
+ # Constantizable is an internal middleware
6
+ # It's using on orthoses/outputable.rb
7
+ class ConstantizableFilter
8
+ def initialize(loader)
9
+ @loader = loader
10
+ end
11
+
12
+ def call
13
+ @loader.call.tap do |store|
14
+ failures = []
15
+ store.each do |name, content|
16
+ next if content.header
17
+ next if content.interface?
18
+
19
+ begin
20
+ Object.const_get(name)
21
+ rescue NameError, LoadError => err
22
+ Orthoses.logger.error(err.inspect)
23
+ failures << name
24
+ next
25
+ end
26
+ end
27
+ failures.each { |name| store.delete(name) }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -12,12 +12,7 @@ module Orthoses
12
12
  def call
13
13
  @loader.call.tap do |store|
14
14
  store.each do |name, content|
15
- begin
16
- content.uniq!
17
- rescue NameError, LoadError => err
18
- Orthoses.logger.error(err.inspect)
19
- next
20
- end
15
+ content.uniq!
21
16
  end
22
17
  end
23
18
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'orthoses/outputable/avoid_recursive_ancestor_error'
4
+ require 'orthoses/outputable/constantizable_filter'
4
5
  require 'orthoses/outputable/uniq_content_body'
5
6
 
6
7
  module Orthoses
@@ -16,6 +17,7 @@ module Orthoses
16
17
  module Outputable
17
18
  def call
18
19
  @loader = AvoidRecursiveAncestorError.new(@loader)
20
+ @loader = ConstantizableFilter.new(@loader)
19
21
  @loader = UniqContentBody.new(@loader)
20
22
  super
21
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthoses
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -2,7 +2,10 @@
2
2
 
3
3
  module Orthoses::Attribute::Hook
4
4
  def attr: (*untyped names) -> untyped
5
+
5
6
  def attr_accessor: (*untyped names) -> untyped
7
+
6
8
  def attr_reader: (*untyped names) -> untyped
9
+
7
10
  def attr_writer: (*untyped names) -> untyped
8
11
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Orthoses::CallTracer::Capturable
4
4
  def build_capture: (untyped tp) -> untyped
5
+
5
6
  private def build_method: (untyped tp) -> untyped
7
+
6
8
  private def build_argument: (untyped tp) -> untyped
7
9
  end
@@ -5,6 +5,7 @@ class Orthoses::Content
5
5
  def <<: (String) -> void
6
6
  def concat: (Array[String]) -> void
7
7
  def empty?: () -> untyped
8
+ def interface?: () -> untyped
8
9
  def delete: (untyped val) -> untyped
9
10
  def to_rbs: () -> String
10
11
  def to_decl: () -> untyped
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Orthoses::Mixin::Hook
4
4
  def include: (*untyped modules) -> untyped
5
+
5
6
  def extend: (*untyped modules) -> untyped
7
+
6
8
  def prepend: (*untyped modules) -> untyped
7
9
  end
@@ -0,0 +1,6 @@
1
+ # THIS IS GENERATED CODE from `$ rake generate_self_sig`
2
+
3
+ class Orthoses::Outputable::ConstantizableFilter
4
+ def initialize: (untyped loader) -> void
5
+ def call: () -> untyped
6
+ end
@@ -2,16 +2,28 @@
2
2
 
3
3
  module Orthoses::Utils
4
4
  def self.unautoload!: () -> untyped
5
+
5
6
  def self.each_const_recursive: (Module root, ?cache: Hash[untyped, true], ?on_error: ^(Orthoses::ConstLoadError) -> void) ?{ (Module, Symbol, untyped) -> void } -> void
7
+
6
8
  def self.rbs_defined_const?: (String name, ?library: (String | Array[String])?, ?collection: boolish) -> bool
9
+
7
10
  def self.rbs_defined_class?: (String name, ?library: (String | Array[String])?, ?collection: boolish) -> bool
11
+
8
12
  def self.rbs_type_name: (String) -> RBS::TypeName
13
+
9
14
  def self.rbs_environment: (?library: String | Array[String] | nil, ?collection: boolish, ?cache: boolish) -> RBS::Environment
15
+
10
16
  def self.object_to_rbs: (untyped object, strict: bool) -> String
17
+
11
18
  def self.module_name: (Module mod) -> String?
19
+
12
20
  def self.module_to_type_name: (Module) -> RBS::TypeName?
21
+
13
22
  def self.known_type_params: (Module | String) -> Array[RBS::AST::TypeParam]?
23
+
14
24
  def self.new_store: () -> Orthoses::store
25
+
15
26
  UNBOUND_NAME_METHOD: UnboundMethod
27
+
16
28
  attr_accessor self.rbs_collection_pathname: Pathname
17
29
  end
data/sig/orthoses.rbs CHANGED
@@ -1,9 +1,13 @@
1
1
  # THIS IS GENERATED CODE from `$ rake generate_self_sig`
2
2
 
3
3
  module Orthoses
4
- VERSION: "1.2.0"
4
+ VERSION: "1.3.0"
5
+
5
6
  attr_accessor self.logger: ::Logger
7
+
6
8
  type store = Hash[String, Orthoses::Content]
9
+
7
10
  INSTANCE_METHOD_METHOD: UnboundMethod
11
+
8
12
  METHOD_METHOD: UnboundMethod
9
13
  end
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: 1.2.0
4
+ version: 1.3.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-10-08 00:00:00.000000000 Z
11
+ date: 2022-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -60,6 +60,7 @@ files:
60
60
  - lib/orthoses/object_space_all.rb
61
61
  - lib/orthoses/outputable.rb
62
62
  - lib/orthoses/outputable/avoid_recursive_ancestor_error.rb
63
+ - lib/orthoses/outputable/constantizable_filter.rb
63
64
  - lib/orthoses/outputable/uniq_content_body.rb
64
65
  - lib/orthoses/path_helper.rb
65
66
  - lib/orthoses/pp.rb
@@ -105,6 +106,7 @@ files:
105
106
  - sig/orthoses/object_space_all.rbs
106
107
  - sig/orthoses/outputable.rbs
107
108
  - sig/orthoses/outputable/avoid_recursive_ancestor_error.rbs
109
+ - sig/orthoses/outputable/constantizable_filter.rbs
108
110
  - sig/orthoses/outputable/uniq_content_body.rbs
109
111
  - sig/orthoses/path_helper.rbs
110
112
  - sig/orthoses/pp.rbs