belt 0.0.5 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9445afac3a832595238e015620913022c6cdfa6fb8f45e4d37b59f7215a34f25
4
- data.tar.gz: 88b09d9faf70b253c2ac50429a3e4c54bd2cc3ebd4c9e59f2e7887e833d8d543
3
+ metadata.gz: 14240a12050757c9936f1f57d941d98d23f79d0fc82b54f3c9d75217a5a00677
4
+ data.tar.gz: d8c545b345c138d8d84ca2dc170ea99ad8b5404310620cdf17c8092263a2f7fc
5
5
  SHA512:
6
- metadata.gz: 186ffe088baefe51b1535a0be897053d61d5ae717d06720afd6f1862decd7b0074f85b47de5ec27d6e8e3e7104d35ed390b64e8e20a4a270efd1ed14c00e73ea
7
- data.tar.gz: c43ac53938a4642699bda126b97b703b72bd5f98470333e6cb889ac9fef21528bc5da791a9bb20bd50f7908442e2bb93c967cdb75fb2ee725e7f5bd3c8de9a58
6
+ metadata.gz: 6bf259163e8b4c50e4d544fc671f8ed5408b6996563392ff5301de7c5e26ac9098e149d0eeadae028fe455ef92e409e8c187130a6c12b2652673c77be7c6afae
7
+ data.tar.gz: 93bd5dc850ad6bb17e771c9a12982b4b89f2df06b048404f0b66dec83d7cff74720ee2e0e9359b00fb85341834b0c774faf51539afbec5c9fcbf01815eb7cf7d
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.7
4
+
5
+ - Fixed `discover_gem_paths` to use `Gem.loaded_specs` instead of `Gem::Specification.each` — the latter silently returns nothing on Lambda's vendored bundle layout, causing gem controllers/models to not be found
6
+
3
7
  ## 0.0.5
4
8
 
5
9
  - Eliminated regex from `Belt::ActionRouter` — uses pure segment-by-segment string comparison (resolves CodeQL alerts)
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.7'
5
5
  end
data/lib/belt.rb CHANGED
@@ -5,7 +5,6 @@ require_relative 'belt/parameters'
5
5
  require_relative 'belt/observability'
6
6
  require_relative 'belt/lambda_handler'
7
7
  require_relative 'belt/action_router'
8
- require_relative 'belt/holster'
9
8
 
10
9
  module Belt
11
10
  class AuthenticationError < StandardError; end
@@ -17,24 +16,39 @@ module Belt
17
16
  class << self
18
17
  attr_reader :controller_paths
19
18
 
20
- # Collects all controller paths: app-defined + holster-provided
19
+ # Auto-discover lambda/controllers dirs in all loaded gems
20
+ def gem_controller_paths
21
+ @gem_controller_paths ||= discover_gem_paths('lambda/controllers')
22
+ end
23
+
24
+ # Auto-discover lambda/models dirs in all loaded gems
25
+ def gem_model_paths
26
+ @gem_model_paths ||= discover_gem_paths('lambda/models')
27
+ end
28
+
29
+ # All controller paths: app-defined + gem-discovered
21
30
  def all_controller_paths
22
- controller_paths + holsters.select { |h| File.directory?(h.controllers_path) }.map(&:controllers_path)
31
+ controller_paths + gem_controller_paths
23
32
  end
24
33
 
25
- # Collects all model paths from holsters
26
- def all_models_paths
27
- holsters.select { |h| File.directory?(h.models_path) }.map(&:models_path)
34
+ # All gem model paths that exist on disk
35
+ def all_model_paths
36
+ gem_model_paths
28
37
  end
29
38
 
30
- # Collects all routes files from holsters
31
- def all_routes_paths
32
- holsters.select { |h| File.exist?(h.routes_path) }.map(&:routes_path)
39
+ # Reset cached paths (useful in tests)
40
+ def reset_gem_paths!
41
+ @gem_controller_paths = nil
42
+ @gem_model_paths = nil
33
43
  end
34
44
 
35
- # Collects all schema files from holsters
36
- def all_schema_paths
37
- holsters.select { |h| File.exist?(h.schema_path) }.map(&:schema_path)
45
+ private
46
+
47
+ def discover_gem_paths(subdir)
48
+ Gem.loaded_specs.each_value.filter_map do |spec|
49
+ path = File.join(spec.gem_dir, subdir)
50
+ path if File.directory?(path)
51
+ end
38
52
  end
39
53
  end
40
54
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla
@@ -67,7 +67,6 @@ files:
67
67
  - lib/belt/helpers/cors_origin.rb
68
68
  - lib/belt/helpers/error_logging.rb
69
69
  - lib/belt/helpers/response.rb
70
- - lib/belt/holster.rb
71
70
  - lib/belt/lambda_handler.rb
72
71
  - lib/belt/observability.rb
73
72
  - lib/belt/parameters.rb
metadata.gz.sig CHANGED
Binary file
data/lib/belt/holster.rb DELETED
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Belt
4
- class Holster
5
- class << self
6
- def inherited(subclass)
7
- super
8
- Belt.holsters << subclass
9
- end
10
-
11
- # Convention: gem root is two levels up from the holster file
12
- def gem_root
13
- @gem_root ||= File.expand_path('../..', caller_locations(1, 1).first.path)
14
- end
15
-
16
- attr_writer :gem_root, :controllers_path, :models_path, :routes_path, :schema_path
17
-
18
- # Defaults follow Belt project structure conventions
19
- def controllers_path
20
- @controllers_path || File.join(gem_root, 'lambda', 'controllers')
21
- end
22
-
23
- def models_path
24
- @models_path || File.join(gem_root, 'lambda', 'models')
25
- end
26
-
27
- def routes_path
28
- @routes_path || File.join(gem_root, 'infrastructure', 'routes.tf.rb')
29
- end
30
-
31
- def schema_path
32
- @schema_path || File.join(gem_root, 'infrastructure', 'schema.tf.rb')
33
- end
34
-
35
- def holster_name
36
- name&.split('::')&.first&.downcase || 'unknown'
37
- end
38
- end
39
- end
40
-
41
- @holsters = []
42
-
43
- class << self
44
- attr_reader :holsters
45
- end
46
- end