kirei 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -24
- data/bin/kirei +1 -1
- data/kirei.gemspec +4 -3
- data/lib/cli/commands/new_app/base_directories.rb +1 -1
- data/lib/cli/commands/new_app/execute.rb +3 -2
- data/lib/cli/commands/new_app/files/app.rb +9 -3
- data/lib/cli/commands/new_app/files/config_ru.rb +1 -1
- data/lib/cli/commands/new_app/files/db_rake.rb +51 -3
- data/lib/cli/commands/new_app/files/irbrc.rb +1 -1
- data/lib/cli/commands/new_app/files/rakefile.rb +1 -1
- data/lib/cli/commands/new_app/files/routes.rb +49 -12
- data/lib/cli/commands/new_app/files/sorbet_config.rb +25 -0
- data/lib/kirei/app.rb +73 -56
- data/lib/kirei/controller.rb +44 -0
- data/lib/kirei/logger.rb +8 -8
- data/lib/kirei/{base_model.rb → model.rb} +5 -5
- data/lib/kirei/routing/base.rb +156 -0
- data/lib/kirei/routing/nilable_hooks_type.rb +10 -0
- data/lib/kirei/{middleware.rb → routing/rack_env_type.rb} +1 -10
- data/lib/kirei/routing/rack_response_type.rb +15 -0
- data/lib/kirei/routing/router.rb +86 -0
- data/lib/kirei/version.rb +1 -1
- data/lib/kirei.rb +27 -2
- data/sorbet/rbi/shims/base_model.rbi +1 -1
- metadata +29 -13
- data/lib/boot.rb +0 -23
- data/lib/kirei/app_base.rb +0 -72
- data/lib/kirei/base_controller.rb +0 -16
- data/lib/kirei/router.rb +0 -61
data/lib/kirei/router.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require("singleton")
|
5
|
-
|
6
|
-
module Kirei
|
7
|
-
#
|
8
|
-
# Usage:
|
9
|
-
#
|
10
|
-
# Router.add_routes([
|
11
|
-
# Route.new(
|
12
|
-
# verb: "GET",
|
13
|
-
# path: "/livez",
|
14
|
-
# controller: Controllers::HealthController,
|
15
|
-
# action: "livez",
|
16
|
-
# ),
|
17
|
-
# ])
|
18
|
-
#
|
19
|
-
class Router
|
20
|
-
extend T::Sig
|
21
|
-
include ::Singleton
|
22
|
-
|
23
|
-
class Route < T::Struct
|
24
|
-
const :verb, String
|
25
|
-
const :path, String
|
26
|
-
const :controller, T.class_of(BaseController)
|
27
|
-
const :action, String
|
28
|
-
end
|
29
|
-
|
30
|
-
RoutesHash = T.type_alias do
|
31
|
-
T::Hash[String, Route]
|
32
|
-
end
|
33
|
-
|
34
|
-
sig { void }
|
35
|
-
def initialize
|
36
|
-
@routes = T.let({}, RoutesHash)
|
37
|
-
end
|
38
|
-
|
39
|
-
sig { returns(RoutesHash) }
|
40
|
-
attr_reader :routes
|
41
|
-
|
42
|
-
sig do
|
43
|
-
params(
|
44
|
-
verb: String,
|
45
|
-
path: String,
|
46
|
-
).returns(T.nilable(Route))
|
47
|
-
end
|
48
|
-
def get(verb, path)
|
49
|
-
key = "#{verb} #{path}"
|
50
|
-
routes[key]
|
51
|
-
end
|
52
|
-
|
53
|
-
sig { params(routes: T::Array[Route]).void }
|
54
|
-
def self.add_routes(routes)
|
55
|
-
routes.each do |route|
|
56
|
-
key = "#{route.verb} #{route.path}"
|
57
|
-
instance.routes[key] = route
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|