hanami 2.0.0.alpha1 → 2.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +70 -5
  3. data/FEATURES.md +9 -1
  4. data/LICENSE.md +1 -1
  5. data/README.md +4 -5
  6. data/hanami.gemspec +11 -11
  7. data/lib/hanami.rb +19 -18
  8. data/lib/hanami/application.rb +322 -26
  9. data/lib/hanami/application/autoloader/inflector_adapter.rb +22 -0
  10. data/lib/hanami/application/container/boot/inflector.rb +7 -0
  11. data/lib/hanami/application/container/boot/logger.rb +8 -0
  12. data/lib/hanami/application/container/boot/rack_logger.rb +19 -0
  13. data/lib/hanami/application/container/boot/rack_monitor.rb +12 -0
  14. data/lib/hanami/application/container/boot/settings.rb +7 -0
  15. data/lib/hanami/application/router.rb +59 -0
  16. data/lib/hanami/application/routing/middleware/stack.rb +89 -0
  17. data/lib/hanami/application/routing/resolver.rb +82 -0
  18. data/lib/hanami/application/routing/resolver/node.rb +50 -0
  19. data/lib/hanami/application/routing/resolver/trie.rb +59 -0
  20. data/lib/hanami/application/settings.rb +23 -0
  21. data/lib/hanami/application/settings/definition.rb +26 -0
  22. data/lib/hanami/application/settings/loader.rb +97 -0
  23. data/lib/hanami/application/settings/struct.rb +65 -0
  24. data/lib/hanami/boot.rb +1 -2
  25. data/lib/hanami/cli/application/cli.rb +40 -0
  26. data/lib/hanami/cli/application/command.rb +47 -0
  27. data/lib/hanami/cli/application/commands.rb +16 -0
  28. data/lib/hanami/cli/application/commands/console.rb +81 -0
  29. data/lib/hanami/cli/base_command.rb +48 -0
  30. data/lib/hanami/cli/commands.rb +3 -2
  31. data/lib/hanami/cli/commands/command.rb +4 -4
  32. data/lib/hanami/configuration.rb +129 -64
  33. data/lib/hanami/configuration/middleware.rb +2 -2
  34. data/lib/hanami/configuration/router.rb +50 -0
  35. data/lib/hanami/init.rb +5 -0
  36. data/lib/hanami/setup.rb +9 -0
  37. data/lib/hanami/slice.rb +138 -0
  38. data/lib/hanami/version.rb +1 -1
  39. data/lib/hanami/web/rack_logger.rb +96 -0
  40. metadata +92 -54
  41. data/bin/hanami +0 -8
  42. data/lib/hanami/configuration/cookies.rb +0 -24
  43. data/lib/hanami/configuration/security.rb +0 -141
  44. data/lib/hanami/container.rb +0 -107
  45. data/lib/hanami/frameworks.rb +0 -28
  46. data/lib/hanami/routes.rb +0 -31
@@ -1,107 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/system/container"
4
- require "pathname"
5
-
6
- module Hanami
7
- # Hanami private IoC
8
- #
9
- # @since 2.0.0
10
- class Container < Dry::System::Container
11
- configure do |config|
12
- config.root = Pathname.new(Dir.pwd)
13
- end
14
-
15
- boot(:env) do |c|
16
- init do
17
- begin
18
- require "dotenv"
19
- rescue LoadError # rubocop:disable Lint/HandleExceptions
20
- end
21
-
22
- Dotenv.load(c.root.join(".env")) if defined?(Dotenv)
23
- end
24
- end
25
-
26
- boot(:lib) do |c|
27
- init do
28
- $LOAD_PATH.unshift c.root.join("lib")
29
- Hanami::Utils.require!(c.root.join("lib", "**", "*.rb"))
30
- end
31
- end
32
-
33
- boot(:configuration) do |c|
34
- init do
35
- require c.root.join("config", "application").to_s
36
- end
37
-
38
- start do
39
- register(:configuration, Hanami.application.configuration.finalize)
40
- end
41
- end
42
-
43
- boot(:logger) do |c|
44
- init do
45
- require "hanami/logger"
46
- end
47
-
48
- start do
49
- use :configuration
50
- register(:logger, Hanami::Logger.new(c[:configuration].logger))
51
- end
52
- end
53
-
54
- boot(:routes) do |c|
55
- init do
56
- require c.root.join("config", "routes").to_s
57
- end
58
-
59
- start do
60
- register(:routes, Hanami.application.routes)
61
- end
62
- end
63
-
64
- boot(:apps) do |c|
65
- start do
66
- use :routes
67
-
68
- register(:apps, c[:routes].apps)
69
- end
70
- end
71
-
72
- boot(:actions) do |c|
73
- init do
74
- use :configuration
75
- use :apps
76
-
77
- c[:apps].each do |app|
78
- require c.root.join("apps", app.to_s, "action")
79
-
80
- namespace = Utils::String.classify("#{app}::Actions")
81
- namespace = Utils::Class.load!(namespace)
82
-
83
- configuration = Controller::Configuration.new do |config|
84
- config.cookies = c[:configuration].cookies.options
85
- config.default_headers = c[:configuration].security.to_hash
86
- config.default_request_format = c[:configuration].default_request_format
87
- config.default_response_format = c[:configuration].default_response_format
88
- end
89
-
90
- register(:"apps.#{app}.actions.namespace", namespace)
91
- register(:"apps.#{app}.actions.configuration", configuration)
92
- end
93
- end
94
- end
95
-
96
- boot(:code) do |c|
97
- init do
98
- use :configuration
99
- use :apps
100
- use :actions
101
-
102
- apps = c[:apps].join(",")
103
- Hanami::Utils.require!(c.root.join("apps", "{#{apps}}", "**", "*.rb"))
104
- end
105
- end
106
- end
107
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "hanami/utils"
4
- require "hanami/router"
5
- require "hanami/controller"
6
- require "hanami/utils/string"
7
- require "hanami/utils/class"
8
-
9
- # Hanami
10
- #
11
- # @since 0.1.0
12
- module Hanami
13
- # Hanami::Router enhancements
14
- #
15
- # @since 2.0.0
16
- class Router
17
- # rubocop:disable Metrics/ParameterLists
18
- def mount(app, at:, host: nil, container: Hanami::Container, **args, &blk)
19
- super(app, at: at, host: host, **args, &blk) unless app.is_a?(Symbol)
20
-
21
- namespace = container["apps.#{app}.actions.namespace"]
22
- configuration = container["apps.#{app}.actions.configuration"]
23
-
24
- scope(at, namespace: namespace, configuration: configuration, &blk)
25
- end
26
- # rubocop:enable Metrics/ParameterLists
27
- end
28
- end
data/lib/hanami/routes.rb DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hanami
4
- # Hanami application routes
5
- #
6
- # @since 2.0.0
7
- class Routes
8
- attr_reader :apps
9
-
10
- def initialize(&blk)
11
- @blk = blk
12
- @apps = []
13
- instance_eval(&blk)
14
- end
15
-
16
- def to_proc
17
- @blk
18
- end
19
-
20
- def mount(app, **)
21
- @apps << app if app.is_a?(Symbol)
22
- end
23
-
24
- # rubocop:disable Style/MethodMissingSuper
25
- # rubocop:disable Style/MissingRespondToMissing
26
- def method_missing(*)
27
- end
28
- # rubocop:enable Style/MissingRespondToMissing
29
- # rubocop:enable Style/MethodMissingSuper
30
- end
31
- end