kennel 1.163.0 → 1.163.2

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: 0b07d4f21ef18f6f89875f4bdb1f4ba86144d4291180ffeff34ef6c8c8b6ad01
4
- data.tar.gz: e90f0c27577b343baf745b342b6eea95053b029a788bdaf740c9a1e717da0303
3
+ metadata.gz: 9d1c9696c979e6a8bedf59a717376cb9d483164c86683a90e2208087694c1a83
4
+ data.tar.gz: f8c0b7f924cb4e8e3c0c3966406b47de23e472034e6fafaef5e5817826e12bb5
5
5
  SHA512:
6
- metadata.gz: 4aa14e50c3b4c17690de793c84889e0a92fa48c6d59b491226cc487de75922ec98300cdaded30781ac22f1845c14a834aa9fec0bffe2b31d72fc4726a7948d95
7
- data.tar.gz: 95b2a1d28f5f98703c7ba448cf865009e9d53989bb7aec3492adddde172f032ebdae447688615e29a1d47055f785a50ee8ea9fe7278ab7c88436b5e418529c7e
6
+ metadata.gz: 218aefed2969de6f3ce27c2bb94248a486fc9eae81eda0cf546d0016995b92e994e8561abbece9c9b87cf64f0de8c266769d0aefb13bdeed90f989b683b06559
7
+ data.tar.gz: 88c1cea6f02c9952ab27de289867d2df12bbbb5e3d6bf6053145b434b34efe350e7ec01060379adee1edf244ad25ec104f9bfe03cf1fd9b1ee1e0c9db0d44979
@@ -13,7 +13,7 @@ module Kennel
13
13
  # Use `projects` to get all projects in the system.
14
14
  def all_projects
15
15
  load_all
16
- Models::Project.recursive_subclasses.map(&:new)
16
+ loaded_projects.map(&:new)
17
17
  end
18
18
 
19
19
  # @return [Array<Models::Project>]
@@ -21,11 +21,15 @@ module Kennel
21
21
 
22
22
  def projects
23
23
  load_all
24
- Models::Project.recursive_subclasses.map(&:new)
24
+ loaded_projects.map(&:new)
25
25
  end
26
26
 
27
27
  private
28
28
 
29
+ def loaded_projects
30
+ Models::Project.recursive_subclasses
31
+ end
32
+
29
33
  # load_all's purpose is to "require" all the .rb files under './projects',
30
34
  # while allowing them to resolve reference to ./teams and ./parts via autoload
31
35
  def load_all
@@ -47,19 +51,18 @@ module Kennel
47
51
  projects_path = "#{File.expand_path("projects")}/"
48
52
  known_paths = loader.all_expected_cpaths.keys.select! { |path| path.start_with?(projects_path) }
49
53
 
50
- # - we support PROJECT being used for nested folders, to allow teams to easily group their projects
51
- # - when loading a project we need to find anything that could be a project source
52
- # sorting by name and nesting level to avoid confusion
53
54
  projects.each do |project|
54
- segments = project.tr("-", "_").split("_")
55
- search = /#{segments[0...-1].map { |part| "#{part}[_/]" }.join}#{segments[-1]}(\.rb|\/project\.rb|\/base\.rb)/
55
+ search = project_search project
56
+
57
+ # sort by name and nesting level to pick the best candidate
58
+ found = known_paths.grep(search).sort.sort_by { |path| path.count("/") }
56
59
 
57
- if (project_path = known_paths.grep(search).sort.min_by { |path| path.count("/") })
58
- require project_path
60
+ if found.any?
61
+ require found.first
62
+ assert_project_loaded search, found
59
63
  elsif autoload != "abort"
60
64
  Kennel.err.puts(
61
- "No projects/ file matching #{search} found" \
62
- ", falling back to slow loading of all projects instead"
65
+ "No projects/ file matching #{search} found, falling back to slow loading of all projects instead"
63
66
  )
64
67
  loader.eager_load
65
68
  break
@@ -67,10 +70,12 @@ module Kennel
67
70
  raise AutoloadFailed, "No projects/ file matching #{search} found"
68
71
  end
69
72
  end
70
- else # all projects needed
73
+ else
74
+ # all projects needed
71
75
  loader.eager_load
72
76
  end
73
- else # old style without autoload to be removed eventually
77
+ else
78
+ # old style without autoload to be removed eventually
74
79
  loader.setup
75
80
  loader.eager_load # TODO: this should not be needed but we see hanging CI processes when it's not added
76
81
  # TODO: also auto-load projects and update expected path too
@@ -99,5 +104,33 @@ module Kennel
99
104
 
100
105
  raise
101
106
  end
107
+
108
+ # - support PROJECT being used for nested folders, to allow teams to easily group their projects
109
+ # - support PROJECT.rb but also PROJECT/base.rb or PROJECT/project.rb
110
+ def project_search(project)
111
+ suffixes = ["base.rb", "project.rb"]
112
+ project_match = Regexp.escape(project.tr("-", "_")).gsub("_", "[-_/]")
113
+ /\/#{project_match}(\.rb|#{suffixes.map { |s| Regexp.escape "/#{s}" }.join("|")})$/
114
+ end
115
+
116
+ def assert_project_loaded(search, paths)
117
+ return if loaded_projects.any?
118
+ paths = paths.map { |path| path.sub("#{Dir.pwd}/", "") }
119
+ raise(
120
+ AutoloadFailed,
121
+ <<~MSG
122
+ No project found in loaded files!
123
+ Ensure the project file you want to load is first in the list,
124
+ list is sorted alphabetically and by nesting level.
125
+
126
+ Loaded:
127
+ #{paths.first}
128
+ After finding:
129
+ #{paths.join("\n")}
130
+ With regex:
131
+ #{search}
132
+ MSG
133
+ )
134
+ end
102
135
  end
103
136
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.163.0"
3
+ VERSION = "1.163.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.163.0
4
+ version: 1.163.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-13 00:00:00.000000000 Z
11
+ date: 2025-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs