torikago 0.0.1 → 0.1.0

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.
data/sig/torikago.rbs ADDED
@@ -0,0 +1,440 @@
1
+ module Torikago
2
+ VERSION: String
3
+
4
+ def self.configuration: () -> Configuration
5
+ def self.configure: () { (Configuration) -> untyped } -> Configuration
6
+ def self.gateway: () -> Gateway
7
+ def self.registry: () -> Registry
8
+ def self.action: (Symbol | String module_name, String controller_name, Symbol | String action_name) -> ControllerEndpoint
9
+ def self.version: () -> String
10
+
11
+ def version: () -> String
12
+
13
+ def self.rails_app?: () -> bool
14
+ def self.ruby_box_enabled?: () -> bool
15
+ def self.warn_if_ruby_box_is_disabled_in_rails!: () -> nil
16
+ def self.reset_runtime_state!: () -> nil
17
+
18
+ class Configuration
19
+ class Definition
20
+ attr_accessor name: Symbol
21
+ attr_accessor root: Pathname
22
+ attr_accessor entrypoint: String?
23
+ attr_accessor rails_engine: bool
24
+ attr_accessor setup: String?
25
+ attr_accessor gemfile: String?
26
+
27
+ def initialize: (?name: Symbol, ?root: Pathname, ?entrypoint: String?, ?rails_engine: bool, ?setup: String?, ?gemfile: String?) -> void
28
+ end
29
+
30
+ def initialize: () -> void
31
+ def register: (Symbol | String name, root: Pathname | String, ?entrypoint: String?, ?rails_engine: bool, ?setup: String?, ?gemfile: String?) -> Definition
32
+ def registered?: (Symbol | String name) -> bool
33
+ def each_definition: () -> untyped
34
+ | () { (Definition) -> untyped } -> untyped
35
+ def fetch: (Symbol | String name) -> Definition
36
+ end
37
+
38
+ module CurrentExecution
39
+ STORAGE_KEY: Symbol
40
+
41
+ def current_box: () -> Symbol?
42
+ def with_box: [A] (Symbol | String box_name) { () -> A } -> A
43
+
44
+ def self.current_box: () -> Symbol?
45
+ def self.with_box: [A] (Symbol | String box_name) { () -> A } -> A
46
+ end
47
+
48
+ class Gateway
49
+ def self.build: (String public_api_class_name, *untyped, **untyped) -> Invocation
50
+ def self.invoke: (String public_api_class_name, Symbol | String method_name, *untyped, **untyped) -> untyped
51
+
52
+ def initialize: (registry: Registry, configuration: Configuration, ?manifest_loader: untyped) -> void
53
+ def build: (String public_api_class_name, *untyped, **untyped) -> Invocation
54
+ def invoke: (String public_api_class_name, Symbol | String method_name, *untyped, **untyped) -> untyped
55
+ def dispatch: (
56
+ public_api_class_name: String,
57
+ method_name: Symbol | String,
58
+ constructor_args: Array[untyped],
59
+ constructor_kwargs: Hash[Symbol, untyped],
60
+ method_args: Array[untyped],
61
+ method_kwargs: Hash[Symbol, untyped]
62
+ ) -> untyped
63
+
64
+ private
65
+
66
+ attr_reader configuration: Configuration
67
+ attr_reader manifest_loader: untyped
68
+ attr_reader manifests: Hash[Symbol, Hash[String, untyped]]
69
+ attr_reader registry: Registry
70
+
71
+ def validate_public_api!: (Symbol target_module, String public_api_class_name, Symbol | String method_name, Symbol? caller_module) -> nil
72
+ def load_manifest: (Configuration::Definition definition) -> Hash[String, untyped]
73
+ def package_api_manifest_path: (Configuration::Definition definition) -> Pathname
74
+ def infer_target_module: (String public_api_class_name) -> Symbol
75
+ def exported_package_apis: (Hash[String, untyped] manifest) -> Hash[String, untyped]
76
+ def dependency_allowed?: (untyped public_api_entry, Symbol caller_name) -> bool
77
+ def exported_methods: (untyped public_api_entry) -> Array[String]
78
+ def allowed_callers: (untyped public_api_entry) -> Array[untyped]
79
+ end
80
+
81
+ class Invocation
82
+ def initialize: (
83
+ gateway: Gateway,
84
+ public_api_class_name: String,
85
+ constructor_args: Array[untyped],
86
+ constructor_kwargs: Hash[Symbol, untyped]
87
+ ) -> void
88
+ def invoke: (Symbol | String method_name, *untyped, **untyped) -> untyped
89
+
90
+ private
91
+
92
+ attr_reader constructor_args: Array[untyped]
93
+ attr_reader constructor_kwargs: Hash[Symbol, untyped]
94
+ attr_reader gateway: Gateway
95
+ attr_reader public_api_class_name: String
96
+ end
97
+
98
+ class Registry
99
+ def initialize: (configuration: Configuration) ?{ (Configuration::Definition) -> EngineContainer } -> void
100
+ def resolve: (Symbol | String name) -> EngineContainer
101
+
102
+ private
103
+
104
+ def build_container: (Configuration::Definition definition) -> EngineContainer
105
+ end
106
+
107
+ class RackEndpoint
108
+ def initialize: (Symbol | String module_name, ?registry: Registry?) -> void
109
+ def call: (Hash[String, untyped] env) -> untyped
110
+
111
+ private
112
+
113
+ attr_reader module_name: Symbol
114
+ def registry: () -> Registry
115
+ end
116
+
117
+ class ControllerEndpoint
118
+ def initialize: (
119
+ Symbol | String module_name,
120
+ String controller_name,
121
+ Symbol | String action_name,
122
+ ?registry: Registry?
123
+ ) -> void
124
+ def call: (Hash[String, untyped] env) -> untyped
125
+
126
+ private
127
+
128
+ attr_reader action_name: Symbol
129
+ attr_reader controller_name: String
130
+ attr_reader module_name: Symbol
131
+ def registry: () -> Registry
132
+ end
133
+
134
+ class RootConstantResolver
135
+ UNRESOLVED: Object
136
+
137
+ attr_reader unresolved: Object
138
+
139
+ def initialize: (registered_roots: Array[Pathname | String], ?main_box: untyped) -> void
140
+ def resolve: (Symbol | String name) -> untyped
141
+
142
+ private
143
+
144
+ attr_reader main_box: untyped
145
+ attr_reader registered_roots: Array[String]
146
+
147
+ def registered_source?: (String? source_path) -> bool
148
+ def registered_descendant?: (Module namespace, ?Hash[Module, bool] visited) -> bool
149
+ def normalize_path: (Pathname | String path) -> String
150
+ end
151
+
152
+ class EngineContainer
153
+ BUNDLER_SETUP_ENV_MUTEX: Mutex
154
+ TORIKAGO_RUNTIME_CONSTANTS: Array[Symbol]
155
+ FRAMEWORK_CONSTANTS: Array[Symbol]
156
+
157
+ def initialize: (
158
+ name: Symbol | String,
159
+ module_root: Pathname | String,
160
+ ?entrypoint: String?,
161
+ ?rails_engine: bool,
162
+ ?setup: String?,
163
+ ?gemfile: String?,
164
+ ?registered_roots: Array[Pathname | String]?,
165
+ ?box_factory: untyped,
166
+ ?gemfile_dependency_loader: untyped,
167
+ ?gem_activator: untyped,
168
+ ?root_constant_resolver: RootConstantResolver?
169
+ ) -> void
170
+
171
+ def invoke: (
172
+ String public_api_class_name,
173
+ Symbol | String method_name,
174
+ constructor_args: Array[untyped],
175
+ constructor_kwargs: Hash[Symbol, untyped],
176
+ method_args: Array[untyped],
177
+ method_kwargs: Hash[Symbol, untyped]
178
+ ) -> untyped
179
+ def call: (Hash[String, untyped] env) -> untyped
180
+ def dispatch_controller: (
181
+ Hash[String, untyped] env,
182
+ controller_name: String,
183
+ action_name: Symbol | String
184
+ ) -> untyped
185
+
186
+ private
187
+
188
+ attr_reader box_factory: untyped
189
+ attr_reader entrypoint: String?
190
+ attr_reader gem_activator: untyped
191
+ attr_reader gemfile: String?
192
+ attr_reader gemfile_dependency_loader: untyped
193
+ attr_reader module_root: Pathname
194
+ attr_reader name: Symbol | String
195
+ attr_reader registered_roots: Array[Pathname | String]
196
+ attr_reader root_constant_resolver: RootConstantResolver?
197
+ attr_reader setup: String?
198
+
199
+ def boot_runtime!: () -> untyped
200
+ def boot_controller_runtime!: () -> untyped
201
+ def load_runtime_files_into_box!: (Array[String] files) -> untyped
202
+ def dispatch_controller_action: (
203
+ Hash[String, untyped] env,
204
+ untyped controller,
205
+ Symbol | String action_name,
206
+ Hash[Symbol | String, untyped] path_parameters
207
+ ) -> untyped
208
+ def attach_rails_helpers!: () -> untyped
209
+ def prepare_rails_application_controller_in_box!: () -> untyped
210
+ def normalize_rails_constant_name!: (String path) -> untyped
211
+ def rails_constant_name_for: (String path) -> String?
212
+ def recognize_route: (Hash[String, untyped] env) -> untyped
213
+ def recognize_rails_route: (untyped routes, Hash[String, untyped] env) -> untyped
214
+ def camelize_controller: (String controller_path) -> String
215
+ def load_setup_hook!: () -> untyped
216
+ def apply_gemfile_overrides!: () -> untyped
217
+ def prepend_gemfile_require_paths_to_box!: () -> untyped
218
+ def gemfile_dependencies: () -> Array[Hash[Symbol | String, untyped]]
219
+ def resolve_public_api_class: (String class_name) -> untyped
220
+ def resolve_runtime_class: (String class_name) -> untyped
221
+ def runtime_files: () -> Array[String]
222
+ def rails_runtime_files: () -> Array[String]
223
+ def controller_runtime_files: () -> Array[String]
224
+ def rails_controller_files: () -> Array[String]
225
+ def public_api_root: () -> Pathname
226
+ def gemfile_path: () -> Pathname?
227
+ def setup_path: () -> Pathname?
228
+ def ensure_root_namespace!: () -> untyped
229
+ def ensure_root_namespace_in_box!: () -> untyped
230
+ def isolated_box_enabled?: () -> bool
231
+ def box: () -> untyped
232
+ def with_box_runtime_errors: [A] () { () -> A } -> A
233
+ def prepare_box!: () -> untyped
234
+ def install_torikago_runtime_bridges!: () -> untyped
235
+ def install_root_constant_fallback!: () -> untyped
236
+ def install_host_runtime_bridges!: () -> untyped
237
+ def install_rails_runtime_support!: () -> untyped
238
+ def install_host_constant_bridge!: (Symbol constant_name) -> untyped
239
+ def gateway_model_files: () -> Array[String]
240
+ def rails_model_file?: (String path) -> bool
241
+ def load_setup_hook_into_box!: () -> untyped
242
+ def library_files: () -> Array[String]
243
+ def rails_engine_entrypoint_files: () -> Array[String]
244
+ def rails_engine?: () -> bool
245
+ def ruby_box_runtime_available?: () -> bool
246
+ def camelize: (String segment) -> String
247
+ def load_gemfile_dependencies: (Pathname path) -> Array[Hash[Symbol, untyped]]
248
+ def load_path_gem_dependencies: (Pathname path) -> Array[Hash[Symbol, untyped]]
249
+ def load_bundler_gem_dependencies: (Pathname path) -> Array[Hash[Symbol, untyped]]
250
+ def load_installed_gem_dependencies: (Pathname path) -> Array[Hash[Symbol, untyped]]
251
+ def installed_specs_for: (String gem_name, String requirement) -> Array[Gem::Specification]
252
+ def exact_version_gemfile_dependencies: (Pathname path) -> Array[Hash[Symbol, String]]
253
+ def activate_gem_dependency: (Hash[Symbol, untyped] dependency) -> untyped
254
+ def without_bundler_setup_env: [A] () { () -> A } -> A
255
+ def without_bundler_setup_env_unsynchronized: [A] () { () -> A } -> A
256
+ end
257
+
258
+ class Checker
259
+ class Result
260
+ attr_accessor errors: Array[String]
261
+ attr_accessor scanned_file_count: Integer
262
+ attr_accessor gateway_call_count: Integer
263
+ attr_accessor dynamic_gateway_call_count: Integer
264
+ attr_accessor manifest_count: Integer
265
+
266
+ def initialize: (?errors: Array[String], ?scanned_file_count: Integer, ?gateway_call_count: Integer, ?dynamic_gateway_call_count: Integer, ?manifest_count: Integer) -> void
267
+ def ok?: () -> bool
268
+ end
269
+
270
+ class GatewayCall
271
+ attr_accessor class_name: String
272
+ attr_accessor method_name: Symbol
273
+
274
+ def initialize: (class_name: String, method_name: Symbol) -> void
275
+ end
276
+
277
+ class GatewayCallExtractor
278
+ attr_reader calls: Array[GatewayCall]
279
+ attr_reader dynamic_call_count: Integer
280
+
281
+ def initialize: (String source) -> void
282
+ def call: () -> GatewayCallExtractor
283
+
284
+ private
285
+
286
+ attr_reader sexp: untyped
287
+
288
+ def walk: (untyped node) -> void
289
+ def extract: (untyped node) -> void
290
+ def record: (String? class_name, Symbol? method_name) -> untyped
291
+ def build_call?: (untyped node) -> bool
292
+ def gateway_constant?: (untyped node) -> bool
293
+ def constant_name: (untyped node) -> String?
294
+ def arguments_from: (untyped node) -> Array[untyped]
295
+ def string_literal: (untyped node) -> String?
296
+ def symbol_literal: (untyped node) -> Symbol?
297
+ def token_value: (untyped token) -> String?
298
+ end
299
+
300
+ def initialize: (configuration: Configuration, source_roots: untyped) -> void
301
+ def call: () -> Result
302
+ def errors: () -> Array[String]
303
+
304
+ private
305
+
306
+ attr_reader configuration: Configuration
307
+ attr_reader manifests: Hash[Symbol, Hash[String, untyped]]
308
+ attr_reader source_roots: Array[Pathname]
309
+
310
+ def source_files: () -> Array[String]
311
+ def scan_gateway_calls: (String path, Array[String] errors) -> [Integer, Integer]
312
+ def validate_manifest_entries: (Configuration::Definition definition, Array[String] errors) -> untyped
313
+ def public_api_entry_for: (Symbol box_name, String class_name) -> untyped
314
+ def load_manifest: (Configuration::Definition definition) -> Hash[String, untyped]
315
+ def expected_public_api_path: (Configuration::Definition definition, String class_name) -> Pathname
316
+ def infer_box_name: (String class_name) -> Symbol
317
+ def infer_caller_box_from_path: (String path) -> Symbol?
318
+ def exported_package_apis: (Hash[String, untyped] manifest) -> Hash[String, untyped]
319
+ def allowed_callers: (untyped manifest_entry) -> Array[untyped]
320
+ def exported_methods: (untyped manifest_entry) -> Array[String]
321
+ def public_instance_methods: (Pathname path, String class_name) -> [Array[String], bool]
322
+ def class_body_methods: (untyped body) -> { methods: Array[String], dynamic: bool }
323
+ def bare_call_name: (untyped node) -> String?
324
+ def contains_call?: (untyped node, String method_name) -> bool
325
+ def qualified_constant_name: (untyped node, String? namespace) -> String?
326
+ def constant_name: (untyped node) -> String?
327
+ def underscore: (String name) -> String
328
+ def public_api_root: (Configuration::Definition definition) -> Pathname
329
+ end
330
+
331
+ class PackageApiUpdater
332
+ def initialize: (configuration: Configuration) -> void
333
+ def call: (?Symbol | String | nil module_name) -> Hash[Symbol, Pathname]
334
+
335
+ private
336
+
337
+ attr_reader configuration: Configuration
338
+
339
+ def definitions_for: (Symbol | String? module_name) -> Array[Configuration::Definition]
340
+ def load_manifest: (Pathname path) -> Hash[String, untyped]
341
+ def build_manifest: (Configuration::Definition definition, Hash[String, untyped] existing_manifest) -> Hash[String, untyped]
342
+ def exported_package_apis: (Hash[String, untyped] manifest) -> Hash[String, untyped]
343
+ def allowed_callers: (untyped manifest_entry) -> Array[untyped]
344
+ def exported_methods: (untyped manifest_entry) -> Array[String]
345
+ def render_manifest: (Hash[String, untyped] manifest) -> String
346
+ def discover_public_api_classes: (Configuration::Definition definition) -> Array[String]
347
+ def public_api_root: (Configuration::Definition definition) -> Pathname
348
+ def class_name_from: (String relative_path) -> String
349
+ def camelize: (String segment) -> String
350
+ end
351
+
352
+ class CLI
353
+ HELP_TEXT: String
354
+
355
+ def initialize: (?stdin: untyped, ?stdout: untyped, ?stderr: untyped) -> void
356
+ def run: (Array[String] argv) -> Integer
357
+
358
+ private
359
+
360
+ attr_reader stderr: untyped
361
+ attr_reader stdin: untyped
362
+ attr_reader stdout: untyped
363
+
364
+ def run_init: () -> Integer
365
+ def run_check: () -> Integer
366
+ def run_update_package_api: (String? module_name) -> Integer
367
+ def discover_configuration: () -> Configuration
368
+ def ask: (String prompt, default: String) -> String
369
+ | (String prompt, ?default: String?) -> String?
370
+ def discover_module_directories: (Pathname modules_root) -> Array[Pathname]
371
+ def load_yaml_file: (Pathname path) -> Hash[String, untyped]
372
+ def render_initializer: (Configuration configuration) -> String
373
+ def render_package_api_manifest: (Hash[String, untyped] manifest) -> String
374
+ def yes?: (String? input) -> bool
375
+ end
376
+
377
+ class Error < StandardError
378
+ end
379
+
380
+ class DependencyError < Error
381
+ end
382
+
383
+ class BoxUnavailableError < Error
384
+ end
385
+
386
+ class PublicApiError < Error
387
+ end
388
+
389
+ class GemfileOverrideError < Error
390
+ end
391
+ end
392
+
393
+ module Ruby
394
+ class Box
395
+ def self.new: () -> Box
396
+ def load_path: () -> Array[String]
397
+ def require: (String feature) -> untyped
398
+ def load: (String path) -> untyped
399
+ def eval: (String source) -> untyped
400
+ def const_defined?: (String name, bool inherit) -> bool
401
+ def const_source_location: (String name, bool inherit) -> [String, Integer]?
402
+ def const_set: (String name, untyped value) -> untyped
403
+ def const_get: (String name, ?bool inherit) -> untyped
404
+ end
405
+ end
406
+
407
+ module Rails
408
+ def self.respond_to?: (Symbol name) -> bool
409
+ def self.application: () -> untyped
410
+ def self.root: () -> Pathname
411
+ end
412
+
413
+ module Bundler
414
+ class BundlerError < StandardError
415
+ end
416
+
417
+ class Definition
418
+ def self.build: (String gemfile, String? lockfile, nil unlock) -> untyped
419
+ end
420
+ end
421
+
422
+ module YAML
423
+ def self.safe_load: (String yaml, ?permitted_classes: Array[untyped], ?aliases: bool) -> Hash[String, untyped]?
424
+ def self.dump: (Hash[String, untyped] object) -> String
425
+ end
426
+
427
+ module FileUtils
428
+ def self.mkdir_p: (Pathname | String path) -> untyped
429
+ end
430
+
431
+ class Gem::Specification
432
+ def self.load: (String path) -> Gem::Specification?
433
+ def self.find_all_by_name: (String name, String requirement) -> Array[Gem::Specification]
434
+ def self.dirs: () -> Array[String]
435
+
436
+ def name: () -> String
437
+ def version: () -> Gem::Version
438
+ def require_paths: () -> Array[String]
439
+ def full_require_paths: () -> Array[String]
440
+ end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "minitest/autorun"
2
2
 
3
- ENV["RUBY_BOX"] = "1"
4
3
  ENV["RAILS_ENV"] = "test"
5
4
 
6
5
  lib_dir = File.expand_path("../lib", __dir__)