piko-quick-lib 0.0.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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/dry-system-1.2.5/CHANGELOG.md +1311 -0
  3. data/dry-system-1.2.5/LICENSE +21 -0
  4. data/dry-system-1.2.5/README.md +17 -0
  5. data/dry-system-1.2.5/dry-system.gemspec +42 -0
  6. data/dry-system-1.2.5/lib/dry/system/auto_registrar.rb +45 -0
  7. data/dry-system-1.2.5/lib/dry/system/component.rb +190 -0
  8. data/dry-system-1.2.5/lib/dry/system/component_dir.rb +171 -0
  9. data/dry-system-1.2.5/lib/dry/system/config/component_dir.rb +228 -0
  10. data/dry-system-1.2.5/lib/dry/system/config/component_dirs.rb +285 -0
  11. data/dry-system-1.2.5/lib/dry/system/config/namespace.rb +75 -0
  12. data/dry-system-1.2.5/lib/dry/system/config/namespaces.rb +192 -0
  13. data/dry-system-1.2.5/lib/dry/system/constants.rb +13 -0
  14. data/dry-system-1.2.5/lib/dry/system/container.rb +685 -0
  15. data/dry-system-1.2.5/lib/dry/system/errors.rb +132 -0
  16. data/dry-system-1.2.5/lib/dry/system/identifier.rb +176 -0
  17. data/dry-system-1.2.5/lib/dry/system/importer.rb +144 -0
  18. data/dry-system-1.2.5/lib/dry/system/indirect_component.rb +63 -0
  19. data/dry-system-1.2.5/lib/dry/system/loader/autoloading.rb +24 -0
  20. data/dry-system-1.2.5/lib/dry/system/loader.rb +84 -0
  21. data/dry-system-1.2.5/lib/dry/system/magic_comments_parser.rb +31 -0
  22. data/dry-system-1.2.5/lib/dry/system/manifest_registrar.rb +57 -0
  23. data/dry-system-1.2.5/lib/dry/system/plugins/bootsnap.rb +47 -0
  24. data/dry-system-1.2.5/lib/dry/system/plugins/dependency_graph/strategies.rb +66 -0
  25. data/dry-system-1.2.5/lib/dry/system/plugins/dependency_graph.rb +53 -0
  26. data/dry-system-1.2.5/lib/dry/system/plugins/env.rb +30 -0
  27. data/dry-system-1.2.5/lib/dry/system/plugins/logging.rb +73 -0
  28. data/dry-system-1.2.5/lib/dry/system/plugins/monitoring/proxy.rb +51 -0
  29. data/dry-system-1.2.5/lib/dry/system/plugins/monitoring.rb +45 -0
  30. data/dry-system-1.2.5/lib/dry/system/plugins/notifications.rb +27 -0
  31. data/dry-system-1.2.5/lib/dry/system/plugins/plugin.rb +61 -0
  32. data/dry-system-1.2.5/lib/dry/system/plugins/zeitwerk/compat_inflector.rb +22 -0
  33. data/dry-system-1.2.5/lib/dry/system/plugins/zeitwerk.rb +109 -0
  34. data/dry-system-1.2.5/lib/dry/system/plugins.rb +70 -0
  35. data/dry-system-1.2.5/lib/dry/system/provider/source.rb +281 -0
  36. data/dry-system-1.2.5/lib/dry/system/provider/source_dsl.rb +55 -0
  37. data/dry-system-1.2.5/lib/dry/system/provider.rb +291 -0
  38. data/dry-system-1.2.5/lib/dry/system/provider_registrar.rb +289 -0
  39. data/dry-system-1.2.5/lib/dry/system/provider_source_registry.rb +67 -0
  40. data/dry-system-1.2.5/lib/dry/system/provider_sources/settings/config.rb +73 -0
  41. data/dry-system-1.2.5/lib/dry/system/provider_sources/settings/loader.rb +44 -0
  42. data/dry-system-1.2.5/lib/dry/system/provider_sources/settings.rb +40 -0
  43. data/dry-system-1.2.5/lib/dry/system/provider_sources.rb +6 -0
  44. data/dry-system-1.2.5/lib/dry/system/stubs.rb +39 -0
  45. data/dry-system-1.2.5/lib/dry/system/version.rb +7 -0
  46. data/dry-system-1.2.5/lib/dry/system.rb +62 -0
  47. data/dry-system-1.2.5/lib/dry-system.rb +3 -0
  48. data/piko-quick-lib.gemspec +11 -0
  49. metadata +87 -0
@@ -0,0 +1,192 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/system/errors"
4
+
5
+ module Dry
6
+ module System
7
+ module Config
8
+ # The configured namespaces for a ComponentDir
9
+ #
10
+ # @see Config::ComponentDir#namespaces
11
+ #
12
+ # @api private
13
+ class Namespaces
14
+ include Dry::Equalizer(:namespaces)
15
+
16
+ # @api private
17
+ attr_reader :namespaces
18
+
19
+ # @api private
20
+ def initialize
21
+ @namespaces = {}
22
+ end
23
+
24
+ # @api private
25
+ def initialize_copy(source)
26
+ super
27
+ @namespaces = source.namespaces.dup
28
+ end
29
+
30
+ # Returns the namespace configured for the path, or nil if no such namespace has
31
+ # been configured
32
+ #
33
+ # @return [Namespace, nil] the namespace, if configured
34
+ #
35
+ # @api public
36
+ def namespace(path)
37
+ namespaces[path]
38
+ end
39
+ alias_method :[], :namespace
40
+
41
+ # Returns the namespace configured for the root path, or nil if the root namespace
42
+ # has not been configured
43
+ #
44
+ # @return [Namespace, nil] the root namespace, if configured
45
+ #
46
+ # @api public
47
+ def root
48
+ namespaces[Namespace::ROOT_PATH]
49
+ end
50
+
51
+ # Adds a component dir namespace
52
+ #
53
+ # A namespace encompasses a given sub-directory of the component dir, and
54
+ # determines (1) the leading segments of its components' registered identifiers,
55
+ # and (2) the expected constant namespace of their class constants.
56
+ #
57
+ # A namespace for a path can only be added once.
58
+ #
59
+ # @example Adding a namespace with top-level identifiers
60
+ # # Components defined within admin/ (e.g. admin/my_component.rb) will be:
61
+ # #
62
+ # # - Registered with top-level identifiers ("my_component")
63
+ # # - Expected to have constants in `Admin`, matching the namespace's path (Admin::MyComponent)
64
+ #
65
+ # namespaces.add "admin", key: nil
66
+ #
67
+ # @example Adding a namespace with top-level class constants
68
+ # # Components defined within adapters/ (e.g. adapters/my_adapter.rb) will be:
69
+ # #
70
+ # # - Registered with leading identifiers matching the namespace's path ("adapters.my_adapter")
71
+ # # - Expected to have top-level constants (::MyAdapter)
72
+ #
73
+ # namespaces.add "adapters", const: nil
74
+ #
75
+ # @example Adding a namespace with distinct identifiers and class constants
76
+ # # Components defined within `bananas/` (e.g. bananas/banana_split.rb) will be:
77
+ # #
78
+ # # - Registered with the given leading identifier ("desserts.banana_split")
79
+ # # - Expected to have constants within the given namespace (EatMe::Now::BananaSplit)
80
+ #
81
+ # namespaces.add "bananas", key: "desserts", const: "eat_me/now"
82
+ #
83
+ # @param path [String] the path to the sub-directory of source files to which this
84
+ # namespace should apply, relative to the component dir
85
+ # @param key [String, nil] the leading namespace to apply to the container keys
86
+ # for the components. Set `nil` for the keys to be top-level.
87
+ # @param const [String, nil] the Ruby constant namespace to expect for constants
88
+ # defined within the components. This should be provided in underscored string
89
+ # form, e.g. "hello_there/world" for a Ruby constant of `HelloThere::World`. Set
90
+ # `nil` for the constants to be top-level.
91
+ #
92
+ # @return [Namespace] the added namespace
93
+ #
94
+ # @see Namespace
95
+ #
96
+ # @api public
97
+ def add(path, key: path, const: path)
98
+ raise NamespaceAlreadyAddedError, path if namespaces.key?(path)
99
+
100
+ namespaces[path] = Namespace.new(path: path, key: key, const: const)
101
+ end
102
+
103
+ # Adds a root component dir namespace
104
+ #
105
+ # @see #add
106
+ #
107
+ # @api public
108
+ def add_root(key: nil, const: nil)
109
+ add(Namespace::ROOT_PATH, key: key, const: const)
110
+ end
111
+
112
+ # Deletes the configured namespace for the given path and returns the namespace
113
+ #
114
+ # If no namespace was previously configured for the given path, returns nil
115
+ #
116
+ # @param path [String] the path for the namespace
117
+ #
118
+ # @return [Namespace, nil]
119
+ #
120
+ # @api public
121
+ def delete(path)
122
+ namespaces.delete(path)
123
+ end
124
+
125
+ # Deletes the configured root namespace and returns the namespace
126
+ #
127
+ # If no root namespace was previously configured, returns nil
128
+ #
129
+ # @return [Namespace, nil]
130
+ #
131
+ # @api public
132
+ def delete_root
133
+ delete(Namespace::ROOT_PATH)
134
+ end
135
+
136
+ # Returns the paths of the configured namespaces
137
+ #
138
+ # @return [Array<String,nil>] the namespace paths, with nil representing the root
139
+ # namespace
140
+ #
141
+ # @api public
142
+ def paths
143
+ namespaces.keys
144
+ end
145
+
146
+ # Returns the count of configured namespaces
147
+ #
148
+ # @return [Integer]
149
+ #
150
+ # @api public
151
+ def length
152
+ namespaces.length
153
+ end
154
+ alias_method :size, :length
155
+
156
+ # Returns true if there are no configured namespaces
157
+ #
158
+ # @return [Boolean]
159
+ #
160
+ # @api public
161
+ def empty?
162
+ namespaces.empty?
163
+ end
164
+
165
+ # Returns the configured namespaces as an array
166
+ #
167
+ # Adds a default root namespace to the end of the array if one was not added
168
+ # explicitly. This fallback ensures that all components in the component dir can
169
+ # be loaded.
170
+ #
171
+ # @return [Array<Namespace>] the namespaces
172
+ #
173
+ # @api public
174
+ def to_a
175
+ namespaces.values.tap do |arr|
176
+ arr << Namespace.default_root unless arr.any?(&:root?)
177
+ end
178
+ end
179
+
180
+ # Calls the given block once for each configured namespace, passing the namespace
181
+ # as an argument.
182
+ #
183
+ # @yieldparam namespace [Namespace] the yielded namespace
184
+ #
185
+ # @api public
186
+ def each(&)
187
+ to_a.each(&)
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dry
4
+ module System
5
+ include Dry::Core::Constants
6
+
7
+ RB_EXT = ".rb"
8
+ RB_GLOB = "*.rb"
9
+ PATH_SEPARATOR = File::SEPARATOR
10
+ KEY_SEPARATOR = "."
11
+ WORD_REGEX = /\w+/
12
+ end
13
+ end