skyward-core 0.4.0 → 0.4.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: e3fd98462e9c708fda03399e73fd8ecfdd78377ac8e627c1b932b91a6f8a28d7
4
- data.tar.gz: 3eefa7cd5299ef5ab7eec622619ea731fa5684e97bdf8c4d9b15ac757a5951fb
3
+ metadata.gz: 90a38b5373fe97c93e3ce56ace2d25fd96953ab9ab5bfa7b0c412b275d279ee3
4
+ data.tar.gz: 4731d96668ceb7b7263805cac269d3991d5c8c9d1d42aa63c51b7fc036c1608b
5
5
  SHA512:
6
- metadata.gz: 1df469b179dbedd31e0736b436f5aeaebcc560e662a43ba46a8424e69b6bdd759a00c84801bd0ccb22b2d85ae1a561c0d9df5568c50466e6e1e562a01ef86d9b
7
- data.tar.gz: bf50ced3df262eb2b0d45a93592e5147d32ea0862cfe392b9ba9d50f1b7bb8e152e9ea8d161df68ea85b7a30004b398ea807b80312e6196689782a20fd70fd09
6
+ metadata.gz: ec5d6f85473cb330e80af6f3ca4766afd0f529181558916aa4f13ee644759aaae8c363b03bc62f19e9ad42b7ae73c6771020917d8bc69282950d62b679a1e155
7
+ data.tar.gz: 4b1b885bac1b45e2b36d0a89f28527e2753c86e214391221a59be20f7e03eae9f4434b274f2e45c8fc2059e4523a8d734115f7963a71d9df7c0817f2e1091c4b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jake Bottrall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -9,7 +9,7 @@ The plumbing that [Skyward API](../skyward-api/README.md) and [Skyward ORM](../s
9
9
 
10
10
  - **The `Skyward` namespace.** Skyward Core opens it, and every Skyward gem's Zeitwerk loader extends it. Each gem's names live in that gem's own namespace there: `Skyward::Core`, `Skyward::API` and `Skyward::ORM`.
11
11
  - **The `skyward` command.** It comes with Skyward Core, so it's there whichever Skyward gems you install. Each gem adds its own commands to it.
12
- - **Loading RBS signatures.** One loader finds your app's signatures and those of the gems it uses, for every Skyward gem.
12
+ - **Loading RBS signatures.** One loader finds your app's signatures and those of the gems it uses, for every Skyward gem. It reads them when your app boots, every boot, from the `sig/` you deployed, and loads each signatures directory once, for Skyward API and Skyward ORM to share. So `rbs` is a runtime dependency and your app ships its `sig/`: production doesn't boot from types compiled at deploy time. A process pays for the load once, and what boots is what you deployed.
13
13
  - **Keeping `sig/generated` current.** One function regenerates your app's `sig/generated` from its Ruby with rbs-inline, and the Skyward commands that read types call it first, so you never run rbs-inline by hand. `skyward check` only checks it's current, for CI.
14
14
  - **Reading RBS types.** One reader turns a signature into values that Skyward API and Skyward ORM each build their own mappings on, so a `Todo` read from the database and a `Todo` sent as JSON are the same thing.
15
15
  - **`Skyward::Core::BootError`**, which every Skyward gem raises when your app can't boot, saying why.
@@ -20,7 +20,7 @@ The plumbing that [Skyward API](../skyward-api/README.md) and [Skyward ORM](../s
20
20
  The `skyward` executable finds each installed gem's `lib/skyward/<gem>/commands.rb` with `Gem.find_files` and loads it, and that file registers the gem's commands:
21
21
 
22
22
  ```ruby
23
- Skyward::Core::CLI.register("routes", "List every route and the method that serves it") do |args|
23
+ Skyward::Core::CLI.register('routes', 'List every route and the method that serves it') do |args|
24
24
  # ...
25
25
  end
26
26
  ```
@@ -36,7 +36,7 @@ Skyward supports every Ruby that isn't end-of-life (3.3 and later, as of Novembe
36
36
  This README is the spec, and this section lists each part of it that's built, as it lands. The gem opens the `Skyward` namespace and sets up its loader.
37
37
 
38
38
  - **The `skyward` command.** The executable loads each installed gem's `commands.rb`, `Skyward::Core::CLI.register` adds a command, and `skyward` lists them and runs one, as [Adding commands](#adding-commands) describes. For the commands to run other gems' executables, `Skyward::Core::CLI::Executable.find(name, feature: name)` returns the path of gem `name`'s executable `name` when `feature` can be required in the bundle `skyward` runs in, or `nil` otherwise, and `Skyward::Core::CLI::Executable::CAPTURE` runs a command with an environment in a directory and returns its output, errors included, and whether it succeeded.
39
- - **Loading RBS signatures.** `Skyward::Core::Signatures.load(directory)` returns an `RBS::DefinitionBuilder` over every `.rbs` file under `directory`, the `sig/` of each Skyward gem that has registered it with `Skyward::Core::Signatures.register(path)`, and the `date`, `time` and `bigdecimal` libraries. Skyward Core registers its own. A directory that doesn't exist contributes nothing. A file that doesn't parse, a name declared twice, or a class whose declarations disagree on its type parameters raises `Skyward::Core::BootError` with an excerpt: carets under the token that doesn't parse (`Syntax error: <RBS's message>.`), under each declaration's name (`Todo is declared twice.`), or under the name of the declaration RBS names.
39
+ - **Loading RBS signatures.** `Skyward::Core::Signatures.load(directory)` returns an `RBS::DefinitionBuilder` over every `.rbs` file under `directory`, the `sig/` of each Skyward gem that has registered it with `Skyward::Core::Signatures.register(path)`, and the `date`, `time` and `bigdecimal` libraries. Skyward Core registers its own. A load of signatures that haven't changed, the same directory however it's spelled, the same registered gems' `sig/` and every `.rbs` file under them with the same path and contents, returns the builder still in use, so Skyward API and Skyward ORM share one environment. Anything else loads them again. The loader keeps only the builder it last returned, and weakly, so it's shared while a reader uses it and collected once none does, and then loads again. A directory that doesn't exist contributes nothing. A file that doesn't parse, a name declared twice, or a class whose declarations disagree on its type parameters raises `Skyward::Core::BootError` with an excerpt: carets under the token that doesn't parse (`Syntax error: <RBS's message>.`), under each declaration's name (`Todo is declared twice.`), or under the name of the declaration RBS names. A load that fails keeps nothing, so every load raises it until the signatures change.
40
40
  - **Keeping `sig/generated` current.** `Skyward::Core::Signatures::Inline.generate(directory, rbs_inline:, capture:)` runs the rbs-inline executable at `rbs_inline` through `capture`, in `directory` and in its default opt-in mode, which reads only files marked `# rbs_inline: enabled`, over every `.rb` file there outside `test/`, `spec/`, `vendor/`, `tmp/` and hidden directories, into a scratch directory, as `skyward check` does. It then writes each file whose content differs to `directory`'s `sig/generated`, leaving the others untouched, removes each file there that rbs-inline no longer generates, and any directory that leaves empty, and returns `nil`. When rbs-inline fails, it changes nothing and returns a message with rbs-inline's output, for the command to report. With no `rbs_inline`, as in a bundle without rbs-inline, it runs nothing and returns `nil`, so the app runs with `sig/generated` as committed.
41
41
  - **Reading RBS types.** `Skyward::Core::Types::Reader.new(builder, refinements: {})` takes the `RBS::DefinitionBuilder` that `Skyward::Core::Signatures.load` returns, and `read(type)` turns an RBS type into a frozen `Data` value from `Skyward::Core::Types`: a `Scalar` (`:integer`, `:float`, `:string`, `:bool`, `:date`, `:time`, `:decimal` (a `BigDecimal`) or `:untyped`), a `Literal` (a String, Integer, boolean or `nil`), an `Enum` of Symbols, a `Nullable`, an `ArrayOf`, a `HashOf` (a `Hash[String, T]`, of its values' type), a `Record` or `Named` class with `Field`s (a name, a type and whether it's required), a `Union`, or a `Refined`. It expands aliases, generic ones included, reads `T?` and `T | nil` as `Nullable` and a union of symbol literals as one `Enum`, and flattens nested unions, dropping duplicates. `refinements:` maps an alias's full name (`"::Skyward::ORM::uuid"`) to a Symbol (`:uuid`), so a gem can tell which alias a type was written with: an alias in it reads as a `Refined` of what the alias expands to (`type`) and that Symbol (`as`), wherever it's reached, directly, through another alias of it, or inside a `T?` (a `Nullable` of the `Refined`), an `Array[T]` or a record. Every other alias, and every alias when `refinements:` is left out, expands to what it names and keeps nothing of it. A class is `Named` when its RBS declares public instance `attr_reader`s, rbs-inline's `Data.define` output included: its fields come from its own declarations, in written order, across every file that reopens it, skipping `private` sections. A type it can't read, such as an interface, a tuple, a proc, a `Hash` whose keys aren't `String`s or a class with no readers, comes back as an `Unreadable` naming the type, the class and reader it was found at (`Todo#tags`), what to use instead, and its `suggestion`: for a class name no loaded signature declares (`attr_reader list: Lisst`), the closest declared class name, and otherwise `nil`, for the caller to raise `Skyward::Core::BootError` with its own context. A class with no loaded Ruby class raises `Skyward::Core::BootError` with an excerpt of its declaration, carets under its name, and a type that refers to itself raises it naming the cycle. `type_name(klass)` finds a Ruby class's RBS declaration (none for an anonymous class), and `method_type(type_name, method)` a method's signature, raising `Skyward::Core::BootError` when RBS can't build the class. When RBS's error has a location, the message is RBS's without it, plus an excerpt, and a type name RBS can't find adds `Did you mean ...?` with the closest declared name of the same kind.
42
42
  - **`Skyward::Core::BootError`**, for any Skyward gem to raise when an app can't boot.
data/exe/skyward CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "skyward/core"
4
+ require 'skyward/core'
5
5
 
6
- Skyward::Core::CLI.first_per_gem(Gem.find_files("skyward/*/commands.rb")).each { |file| load file }
6
+ Skyward::Core::CLI.first_per_gem(Gem.find_files('skyward/*/commands.rb')).each { |file| load file }
7
7
  exit Skyward::Core::CLI.run(ARGV, registry: Skyward::Core::CLI::REGISTRY, out: $stdout)
@@ -19,7 +19,7 @@ module Skyward::Core::CLI
19
19
  def run(argv, registry:, out:)
20
20
  name, *args = argv
21
21
  case name
22
- when nil, "help", "--help", "-h"
22
+ when nil, 'help', '--help', '-h'
23
23
  out.write(help(registry))
24
24
  0
25
25
  else
@@ -3,7 +3,7 @@
3
3
  module Skyward::Core::Diagnostics::Excerpt
4
4
  extend self
5
5
 
6
- INDENT = " " #: String
6
+ INDENT = ' ' #: String
7
7
 
8
8
  # @rbs spots: Array[Skyward::Core::Diagnostics::Spot]
9
9
  # @rbs directory: String
@@ -25,7 +25,7 @@ module Skyward::Core::Diagnostics::Excerpt
25
25
  indent = texts.reject { |text| text.strip.empty? }.map { |text| text[/\A\s*/].to_s.size }.min || 0
26
26
  header = lines.find { |(_, on_line)| on_line.any?(&:columns) } || lines.fetch(0)
27
27
  body = lines.each_with_index.flat_map do |(line, on_line), index|
28
- gap = "..." if index.positive? && lines.fetch(index - 1).first != line - 1
28
+ gap = '...' if index.positive? && lines.fetch(index - 1).first != line - 1
29
29
  [gap, texts.fetch(index)[indent..].to_s, *carets(on_line, indent)].compact
30
30
  end
31
31
  ["#{path}:#{header.first}", *body].map { |row| "#{INDENT}#{row}".rstrip }.join("\n")
@@ -38,14 +38,14 @@ module Skyward::Core::Diagnostics::Excerpt
38
38
  columns = spots.flat_map { |spot| spot.columns.to_a }.map { |column| column - indent }
39
39
  return [] if columns.empty?
40
40
 
41
- [(0..columns.max.to_i).map { |column| columns.include?(column) ? "^" : " " }.join]
41
+ [(0..columns.max.to_i).map { |column| columns.include?(column) ? '^' : ' ' }.join]
42
42
  end
43
43
 
44
44
  # @rbs path: String
45
45
  # @rbs directory: String
46
46
  # @rbs return: String
47
47
  def relative(path, directory)
48
- prefix = File.join(File.expand_path(directory), "")
48
+ prefix = File.join(File.expand_path(directory), '')
49
49
  expanded = File.expand_path(path, directory)
50
50
  expanded.start_with?(prefix) ? expanded.delete_prefix(prefix) : path
51
51
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "prism"
3
+ require 'prism'
4
4
 
5
5
  module Skyward::Core::Diagnostics::Spots
6
6
  extend self
@@ -9,7 +9,7 @@ module Skyward::Core::Diagnostics::Spots
9
9
  # @rbs return: Skyward::Core::Diagnostics::Spot
10
10
  def rbs(location)
11
11
  line = location.start_line
12
- text = location.buffer.lines.fetch(line - 1, "")
12
+ text = location.buffer.lines.fetch(line - 1, '')
13
13
  finish = location.end_line == line ? location.end_column : text.size
14
14
  spot(location.buffer.name.to_s, line, text, location.start_column...finish)
15
15
  end
@@ -77,9 +77,9 @@ module Skyward::Core::Diagnostics::Spots
77
77
  next unless call(result, line, :attr_reader)
78
78
 
79
79
  comment = result.comments.find do |found|
80
- found.location.start_line == line && found.location.slice.start_with?("#:")
80
+ found.location.start_line == line && found.location.slice.start_with?('#:')
81
81
  end
82
- within(comment.location, comment.location.slice.delete_prefix("#:").strip) if comment
82
+ within(comment.location, comment.location.slice.delete_prefix('#:').strip) if comment
83
83
  end
84
84
  end
85
85
 
@@ -107,7 +107,7 @@ module Skyward::Core::Diagnostics::Spots
107
107
  return unless location
108
108
 
109
109
  line = location.start_line
110
- text = source.lines.fetch(line - 1, "").chomp
110
+ text = source.lines.fetch(line - 1, '').chomp
111
111
  finish = location.end_line == line ? location.end_character_column : text.size
112
112
  spot(path, line, text, location.start_character_column...finish)
113
113
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Ruby run with --disable-did_you_mean doesn't load it.
4
- require "did_you_mean"
4
+ require 'did_you_mean'
5
5
 
6
6
  module Skyward::Core::Diagnostics::Suggestion
7
7
  extend self
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "fileutils"
4
- require "tmpdir"
3
+ require 'fileutils'
4
+ require 'tmpdir'
5
5
 
6
6
  module Skyward::Core::Signatures::Inline
7
7
  extend self
8
8
 
9
- OUTPUT = "sig/generated" #: String
9
+ OUTPUT = 'sig/generated' #: String
10
10
 
11
11
  # None holds the app's contract: its tests, its installed gems and scratch.
12
12
  UNCHECKED = %w[test spec vendor tmp].freeze #: Array[String]
@@ -35,7 +35,7 @@ module Skyward::Core::Signatures::Inline
35
35
  # @rbs capture: Skyward::Core::CLI::Executable::capture
36
36
  # @rbs return: Hash[String, String] | String
37
37
  def run(directory, rbs_inline:, capture:)
38
- Dir.mktmpdir("skyward-signatures") do |output|
38
+ Dir.mktmpdir('skyward-signatures') do |output|
39
39
  log, ok = capture.call({}, [Gem.ruby, rbs_inline, "--output=#{output}", *sources(directory)], directory)
40
40
  ok ? rbs_files(output) : log
41
41
  end
@@ -44,15 +44,15 @@ module Skyward::Core::Signatures::Inline
44
44
  # @rbs directory: String
45
45
  # @rbs return: Array[String]
46
46
  def sources(directory)
47
- roots = Dir.glob("*/", base: directory).map { |root| root.delete_suffix("/") } - UNCHECKED
48
- files = Dir.glob("*.rb", base: directory)
47
+ roots = Dir.glob('*/', base: directory).map { |root| root.delete_suffix('/') } - UNCHECKED
48
+ files = Dir.glob('*.rb', base: directory)
49
49
  [*files, *roots.reject { |root| Dir.glob("#{root}/**/*.rb", base: directory).empty? }].sort
50
50
  end
51
51
 
52
52
  # @rbs directory: String
53
53
  # @rbs return: Hash[String, String]
54
54
  def rbs_files(directory)
55
- Dir.glob("**/*.rbs", base: directory).to_h { |file| [file, File.read(File.join(directory, file))] }
55
+ Dir.glob('**/*.rbs', base: directory).to_h { |file| [file, File.read(File.join(directory, file))] }
56
56
  end
57
57
 
58
58
  private
@@ -69,7 +69,7 @@ module Skyward::Core::Signatures::Inline
69
69
  end
70
70
  (current.keys - files.keys).each { |file| File.delete(File.join(generated, file)) }
71
71
  # Deepest first, so a directory emptied of directories goes too.
72
- Dir.glob("**/*/", base: generated).sort.reverse_each do |dir|
72
+ Dir.glob('**/*/', base: generated).sort.reverse_each do |dir|
73
73
  path = File.join(generated, dir)
74
74
  Dir.rmdir(path) if Dir.empty?(path)
75
75
  end
@@ -1,9 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rbs"
3
+ require 'digest'
4
+ require 'rbs'
5
+ require 'weakref'
4
6
 
5
7
  class Skyward::Core::Signatures::Loader
6
8
  # @rbs @gems: Array[String]
9
+ # @rbs @key: Hash[String, Hash[String, String]]?
10
+ # @rbs @builder: WeakRef?
7
11
 
8
12
  # @rbs return: void
9
13
  def initialize
@@ -19,18 +23,25 @@ class Skyward::Core::Signatures::Loader
19
23
  # @rbs directory: String
20
24
  # @rbs return: RBS::DefinitionBuilder
21
25
  def load(directory)
26
+ key = contents(directory)
27
+ kept = @builder
28
+ return kept.__getobj__ if key == @key && kept&.weakref_alive?
29
+
22
30
  loader = RBS::EnvironmentLoader.new
23
31
  [directory, *@gems].each { |path| loader.add(path: Pathname(path)) }
24
32
  %w[date time bigdecimal].each { |library| loader.add(library:, version: nil) }
25
33
  env = RBS::Environment.from_loader(loader).resolve_type_names
26
34
  # RBS otherwise defers this conflict until a definition is built, past boot.
27
35
  env.validate_type_params
28
- RBS::DefinitionBuilder.new(env:)
36
+ builder = RBS::DefinitionBuilder.new(env:)
37
+ @key = key
38
+ @builder = WeakRef.new(builder)
39
+ builder
29
40
  rescue RBS::ParsingError => e
30
41
  raise Skyward::Core::BootError, failure("Syntax error: #{e.error_message}.", [e.location])
31
42
  rescue RBS::DuplicatedDeclarationError => e
32
43
  names = e.decls.filter_map { |decl| name_location(decl) }
33
- raise Skyward::Core::BootError, failure("#{e.name.to_s.delete_prefix("::")} is declared twice.", names)
44
+ raise Skyward::Core::BootError, failure("#{e.name.to_s.delete_prefix('::')} is declared twice.", names)
34
45
  rescue RBS::GenericParameterMismatchError => e
35
46
  location = e.decl.location
36
47
  message = e.message.delete_prefix("#{RBS::Location.to_string(location)}: ")
@@ -39,6 +50,16 @@ class Skyward::Core::Signatures::Loader
39
50
 
40
51
  private
41
52
 
53
+ # @rbs directory: String
54
+ # @rbs return: Hash[String, Hash[String, String]]
55
+ def contents(directory)
56
+ [File.expand_path(directory), *@gems].to_h do |root|
57
+ files = RBS::FileFinder.each_file(Pathname(root), skip_hidden: false).map(&:to_s)
58
+ # By contents, since a file rewritten within the same tick keeps its modification time.
59
+ [root, files.to_h { |file| [file, Digest::SHA256.file(file).hexdigest] }]
60
+ end
61
+ end
62
+
42
63
  # @rbs decl: RBS::DuplicatedDeclarationError::declaration
43
64
  # @rbs return: RBS::Location[untyped, untyped]?
44
65
  def name_location(decl)
@@ -5,12 +5,12 @@ class Skyward::Core::Types::Reader
5
5
  # @rbs @refinements: Hash[String, Symbol]
6
6
 
7
7
  SCALARS = {
8
- "::Integer" => :integer,
9
- "::Float" => :float,
10
- "::String" => :string,
11
- "::Date" => :date,
12
- "::Time" => :time,
13
- "::BigDecimal" => :decimal
8
+ '::Integer' => :integer,
9
+ '::Float' => :float,
10
+ '::String' => :string,
11
+ '::Date' => :date,
12
+ '::Time' => :time,
13
+ '::BigDecimal' => :decimal
14
14
  }.freeze #: Hash[String, Skyward::Core::Types::scalar]
15
15
 
16
16
  NIL_LITERAL = Skyward::Core::Types::Literal.new(value: nil) #: Skyward::Core::Types::Literal
@@ -98,7 +98,7 @@ class Skyward::Core::Types::Reader
98
98
  when RBS::Types::Alias then alias_type(type, path)
99
99
  when RBS::Types::Record then record(type, path)
100
100
  when RBS::Types::ClassInstance then instance(type, path)
101
- when RBS::Types::Tuple then unreadable(type, "Array[T], or a record")
101
+ when RBS::Types::Tuple then unreadable(type, 'Array[T], or a record')
102
102
  else unreadable(type)
103
103
  end
104
104
  end
@@ -164,12 +164,12 @@ class Skyward::Core::Types::Reader
164
164
  name = type.name.to_s
165
165
  scalar = SCALARS.fetch(name, nil)
166
166
  if scalar then Skyward::Core::Types::Scalar.new(name: scalar)
167
- elsif name == "::Array" && type.args.size != 1 then unreadable(type, "Array[T]")
168
- elsif name == "::Array"
167
+ elsif name == '::Array' && type.args.size != 1 then unreadable(type, 'Array[T]')
168
+ elsif name == '::Array'
169
169
  all_readable(type.args.map { |arg| read_within(arg, path) }) do |items|
170
170
  Skyward::Core::Types::ArrayOf.new(type: items.fetch(0))
171
171
  end
172
- elsif name == "::Hash" then hash_of(type, path)
172
+ elsif name == '::Hash' then hash_of(type, path)
173
173
  else named(type, path)
174
174
  end
175
175
  end
@@ -180,7 +180,7 @@ class Skyward::Core::Types::Reader
180
180
  def hash_of(type, path)
181
181
  key, *values = type.args.map { |arg| read_within(arg, path) }
182
182
  unless key == Skyward::Core::Types::Scalar.new(name: :string) && values.size == 1
183
- return unreadable(type, "Hash[String, T] (only String keys are supported)")
183
+ return unreadable(type, 'Hash[String, T] (only String keys are supported)')
184
184
  end
185
185
 
186
186
  all_readable(values) { |read| Skyward::Core::Types::HashOf.new(type: read.fetch(0)) }
@@ -253,7 +253,7 @@ class Skyward::Core::Types::Reader
253
253
  return [*path, name] unless path.include?(name)
254
254
 
255
255
  cycle = [*path.drop_while { |entered| entered != name }, name]
256
- raise Skyward::Core::BootError, "Can't read #{name}: it refers to itself through #{cycle.join(" -> ")}"
256
+ raise Skyward::Core::BootError, "Can't read #{name}: it refers to itself through #{cycle.join(' -> ')}"
257
257
  end
258
258
 
259
259
  # @rbs keys: Array[[Symbol, bool]]
@@ -287,10 +287,10 @@ class Skyward::Core::Types::Reader
287
287
  # @rbs instead: String
288
288
  # @rbs suggestion: String?
289
289
  # @rbs return: Skyward::Core::Types::Unreadable
290
- def unreadable(type, instead = "a record, or a class with public typed attr_readers", suggestion: nil)
290
+ def unreadable(type, instead = 'a record, or a class with public typed attr_readers', suggestion: nil)
291
291
  Skyward::Core::Types::Unreadable.new(type: written(type), at: nil, instead:, suggestion:)
292
292
  end
293
293
 
294
294
  # @rbs (_ToS name) -> String
295
- def written(name) = name.to_s.gsub(/(?<!\w)::/, "")
295
+ def written(name) = name.to_s.gsub(/(?<!\w)::/, '')
296
296
  end
@@ -4,7 +4,7 @@ module Skyward
4
4
  module Core
5
5
  # x-release-please-start-version
6
6
 
7
- VERSION = "0.4.0" #: String
7
+ VERSION = '0.4.1' #: String
8
8
 
9
9
  # x-release-please-end
10
10
  end
data/lib/skyward/core.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "zeitwerk"
4
- require_relative "core/version"
3
+ require 'zeitwerk'
4
+ require_relative 'core/version'
5
5
 
6
6
  # Skyward Core owns the Skyward namespace: its version.rb opens it, and every
7
7
  # Skyward gem's loader, this one included, extends it.
8
8
  loader = Zeitwerk::Loader.for_gem_extension(Skyward)
9
- loader.inflector.inflect("cli" => "CLI")
9
+ loader.inflector.inflect('cli' => 'CLI')
10
10
  # The skyward executable loads it, and it defines no constant.
11
11
  loader.ignore("#{__dir__}/core/commands.rb")
12
12
  loader.setup
13
13
 
14
14
  dir = __dir__ #: String
15
- Skyward::Core::Signatures.register(File.expand_path("../../sig", dir))
15
+ Skyward::Core::Signatures.register(File.expand_path('../../sig', dir))
@@ -0,0 +1,7 @@
1
+ class WeakRef
2
+ def initialize: (untyped orig) -> void
3
+
4
+ def __getobj__: () -> untyped
5
+
6
+ def weakref_alive?: () -> boolish
7
+ end
@@ -3,6 +3,10 @@
3
3
  class Skyward::Core::Signatures::Loader
4
4
  @gems: Array[String]
5
5
 
6
+ @key: Hash[String, Hash[String, String]]?
7
+
8
+ @builder: WeakRef?
9
+
6
10
  # @rbs return: void
7
11
  def initialize: () -> void
8
12
 
@@ -16,6 +20,10 @@ class Skyward::Core::Signatures::Loader
16
20
 
17
21
  private
18
22
 
23
+ # @rbs directory: String
24
+ # @rbs return: Hash[String, Hash[String, String]]
25
+ def contents: (String directory) -> Hash[String, Hash[String, String]]
26
+
19
27
  # @rbs decl: RBS::DuplicatedDeclarationError::declaration
20
28
  # @rbs return: RBS::Location[untyped, untyped]?
21
29
  def name_location: (RBS::DuplicatedDeclarationError::declaration decl) -> RBS::Location[untyped, untyped]?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyward-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall
@@ -58,6 +58,7 @@ executables:
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - LICENSE
61
62
  - README.md
62
63
  - exe/skyward
63
64
  - lib/skyward/core.rb
@@ -75,6 +76,7 @@ files:
75
76
  - lib/skyward/core/types.rb
76
77
  - lib/skyward/core/types/reader.rb
77
78
  - lib/skyward/core/version.rb
79
+ - sig/_private/weakref.rbs
78
80
  - sig/generated/skyward/core.rbs
79
81
  - sig/generated/skyward/core/boot_error.rbs
80
82
  - sig/generated/skyward/core/cli.rbs