kangaru 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db7c4419e9f9d9661c4d12498fcb5450cde2f209958f0bb7249a39dec4a93b54
4
- data.tar.gz: 43b3237bf249c4c4a3ef59eddbd4328a7b03a0084d9c69296557bab93d0b1492
3
+ metadata.gz: 14de853c7d43559d44b5dab8ca97090305697c8cb14245b9647b1f67d17036a6
4
+ data.tar.gz: 96572ecb84ae6cc4a74833d0456678bf66b8dcfbe701977ba6c920236cba5c64
5
5
  SHA512:
6
- metadata.gz: c2c5dff9c5ecd0a4401261203f6c89d5837b7824dae3e88d8dd1ad7683f7ae9b65200892d81f4d20d181acca253c5b4dab9b48c24dae32c069dd3ddcea8fd5d9
7
- data.tar.gz: 6b1c7bbef5ef7a08437b5bd33b7fcfa8d2106bd29b52f8df7e56a228caff297fd22df609b96d8a6828390d6bc503bf4105fab52064efb1b4e146866e81a30162
6
+ metadata.gz: ad440db45f269703c52939c80b0534b527c54e3649e15f2206af920818b2f8b5529c52a9127364a74b7f72d38fe56976ee5a6d8fe610585365a67bcb46b30176
7
+ data.tar.gz: 67ca725ea8b804a30a0ea4769a0203af75601e546dcfe56dc237f308bda356cc6029e5c01921064044188d955c667e0d74e643f0d52cf309ebecf04403cf157c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kangaru (0.2.0)
4
+ kangaru (0.2.1)
5
5
  colorize (~> 1.1)
6
6
  erb (~> 4.0)
7
7
  sequel (~> 5.72)
@@ -24,11 +24,8 @@ module Kangaru
24
24
  @router ||= Router.new(namespace:)
25
25
  end
26
26
 
27
- # If called with no env, the config will be applied regardless of current
28
- # env. If multiple configure calls matching the current env are made, the
29
- # most recent calls will overwrite older changes.
30
- def configure(env = nil, &block)
31
- block.call(config) if current_env?(env)
27
+ def configure(&block)
28
+ block.call(config)
32
29
  end
33
30
 
34
31
  def configured?
@@ -62,13 +59,6 @@ module Kangaru
62
59
 
63
60
  private
64
61
 
65
- # Returns true if nil as this is represents all envs.
66
- def current_env?(env)
67
- return true if env.nil?
68
-
69
- Kangaru.env?(env)
70
- end
71
-
72
62
  def autoloader
73
63
  @autoloader ||= Zeitwerk::Loader.new.tap do |loader|
74
64
  loader.inflector = Zeitwerk::GemInflector.new(paths.source.to_s)
@@ -6,7 +6,7 @@ module Kangaru
6
6
  Kangaru.application = Application.new(source:, namespace:)
7
7
  Kangaru.eager_load(Initialisers)
8
8
 
9
- namespace.extend InjectedMethods
9
+ namespace.extend Interface
10
10
  end
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
1
  module Kangaru
2
- module InjectedMethods
2
+ module Interface
3
3
  def run!(*argv)
4
4
  Kangaru.application!.run!(*argv)
5
5
  end
@@ -8,11 +8,15 @@ module Kangaru
8
8
  Kangaru.application!.config
9
9
  end
10
10
 
11
- def configure(env = nil, &)
12
- Kangaru.application!.configure(env, &)
11
+ def configure(env: nil, &)
12
+ return unless env_applies?(env)
13
+
14
+ Kangaru.application!.configure(&)
13
15
  end
14
16
 
15
- def import_config_from!(path)
17
+ def config_path(path, env: nil)
18
+ return unless env_applies?(env)
19
+
16
20
  Kangaru.application!.config_path = path
17
21
  end
18
22
 
@@ -23,5 +27,13 @@ module Kangaru
23
27
  def database
24
28
  Kangaru.application!.database
25
29
  end
30
+
31
+ private
32
+
33
+ def env_applies?(env)
34
+ return true if env.nil?
35
+
36
+ Kangaru.env?(env)
37
+ end
26
38
  end
27
39
  end
@@ -1,3 +1,3 @@
1
1
  module Kangaru
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
@@ -16,7 +16,7 @@ module Kangaru
16
16
 
17
17
  def initialize: (source: String, namespace: Module) -> void
18
18
 
19
- def configure: (?Symbol?) { (Config) -> void } -> void
19
+ def configure: { (Config) -> void } -> void
20
20
 
21
21
  def configured?: -> bool
22
22
 
@@ -34,8 +34,6 @@ module Kangaru
34
34
 
35
35
  @configured: bool
36
36
 
37
- def current_env?: (Symbol?) -> bool
38
-
39
37
  attr_reader autoloader: Zeitwerk::Loader
40
38
 
41
39
  def validate_config!: -> void
@@ -1,9 +1,5 @@
1
1
  module Kangaru
2
2
  module Initialiser
3
- module InjectedMethods
4
- include Kangaru::_ApplicationMethods
5
- end
6
-
7
3
  def self.extended: (Module) -> void
8
4
  end
9
5
  end
@@ -0,0 +1,21 @@
1
+ module Kangaru
2
+ module Interface
3
+ type env = Symbol?
4
+
5
+ def run!: (*String) -> void
6
+
7
+ def config: -> Config
8
+
9
+ def configure: (?env: env) { (Config) -> void } -> void
10
+
11
+ def apply_config!: -> void
12
+
13
+ def config_path: (String, ?env: env) -> void
14
+
15
+ def database: -> Database?
16
+
17
+ private
18
+
19
+ def env_applies?: (Symbol?) -> bool
20
+ end
21
+ end
data/sig/kangaru.rbs CHANGED
@@ -21,9 +21,4 @@ module Kangaru
21
21
 
22
22
  def test?: -> bool
23
23
  end
24
-
25
- # Included in target applications that extend Kangaru::Initialiser.
26
- interface _ApplicationMethods
27
- include InjectedMethods::_InjectedMethods
28
- end
29
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kangaru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Welham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-12 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -127,7 +127,7 @@ files:
127
127
  - lib/kangaru/initialisers/rspec.rb
128
128
  - lib/kangaru/initialisers/rspec/kangaru_helper.rb
129
129
  - lib/kangaru/initialisers/rspec/request_helper.rb
130
- - lib/kangaru/injected_methods.rb
130
+ - lib/kangaru/interface.rb
131
131
  - lib/kangaru/model.rb
132
132
  - lib/kangaru/patches/constantise.rb
133
133
  - lib/kangaru/patches/inflections.rb
@@ -174,7 +174,7 @@ files:
174
174
  - sig/kangaru/inflectors/tokeniser.rbs
175
175
  - sig/kangaru/initialiser.rbs
176
176
  - sig/kangaru/initialisers/rspec.rbs
177
- - sig/kangaru/injected_methods.rbs
177
+ - sig/kangaru/interface.rbs
178
178
  - sig/kangaru/model.rbs
179
179
  - sig/kangaru/patches/constantise.rbs
180
180
  - sig/kangaru/patches/inflections.rbs
@@ -1,19 +0,0 @@
1
- module Kangaru
2
- module InjectedMethods
3
- interface _InjectedMethods
4
- def run!: (*String) -> void
5
-
6
- def config: -> Config
7
-
8
- def configure: (?Symbol?) { (Config) -> void } -> void
9
-
10
- def apply_config!: -> void
11
-
12
- def import_config_from!: (String) -> void
13
-
14
- def database: -> Database?
15
- end
16
-
17
- include _InjectedMethods
18
- end
19
- end