kennel 1.163.1 → 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: 81d0c04d0d3a16c2c46d12aa217e5c5353702a613af3a0d3fea52832839ebd12
4
- data.tar.gz: 4619a82006932e5d0dc4782488b1caec8a789ab4614b8968185ba41defd768d7
3
+ metadata.gz: 9d1c9696c979e6a8bedf59a717376cb9d483164c86683a90e2208087694c1a83
4
+ data.tar.gz: f8c0b7f924cb4e8e3c0c3966406b47de23e472034e6fafaef5e5817826e12bb5
5
5
  SHA512:
6
- metadata.gz: 87bb834a983a635134521548d01f278dcd26c93cbb88c5e929ca3a7a454b241dfccd5e74ec65936c61120d9785dbab027c028c12a35fbb9b481efb0bd4bde157
7
- data.tar.gz: 94abdde8bf155cd9ea7a6ed74d3e7216937af142224b2e8e7766b0506874d7abfa9c494c05716f365644272e439bece107126c9edae038ca79e919fd00939db3
6
+ metadata.gz: 218aefed2969de6f3ce27c2bb94248a486fc9eae81eda0cf546d0016995b92e994e8561abbece9c9b87cf64f0de8c266769d0aefb13bdeed90f989b683b06559
7
+ data.tar.gz: 88c1cea6f02c9952ab27de289867d2df12bbbb5e3d6bf6053145b434b34efe350e7ec01060379adee1edf244ad25ec104f9bfe03cf1fd9b1ee1e0c9db0d44979
@@ -51,37 +51,18 @@ module Kennel
51
51
  projects_path = "#{File.expand_path("projects")}/"
52
52
  known_paths = loader.all_expected_cpaths.keys.select! { |path| path.start_with?(projects_path) }
53
53
 
54
- # - we support PROJECT being used for nested folders, to allow teams to easily group their projects
55
- # - when loading a project we need to find anything that could be a project source
56
- # sorting by name and nesting level to avoid confusion
57
54
  projects.each do |project|
58
- segments = project.tr("-", "_").split("_")
59
- 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
60
58
  found = known_paths.grep(search).sort.sort_by { |path| path.count("/") }
59
+
61
60
  if found.any?
62
61
  require found.first
63
- if loaded_projects.empty?
64
- found.map! { |path| path.sub("#{Dir.pwd}/", "") }
65
- raise(
66
- AutoloadFailed,
67
- <<~MSG
68
- No project found in loaded files!
69
- Ensure the project file you want to load is first in the list,
70
- list is sorted alphabetically and by nesting level.
71
-
72
- Loaded:
73
- #{found.first}
74
- After finding:
75
- #{found.join("\n")}
76
- With regex:
77
- #{search}
78
- MSG
79
- )
80
- end
62
+ assert_project_loaded search, found
81
63
  elsif autoload != "abort"
82
64
  Kennel.err.puts(
83
- "No projects/ file matching #{search} found" \
84
- ", 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"
85
66
  )
86
67
  loader.eager_load
87
68
  break
@@ -89,10 +70,12 @@ module Kennel
89
70
  raise AutoloadFailed, "No projects/ file matching #{search} found"
90
71
  end
91
72
  end
92
- else # all projects needed
73
+ else
74
+ # all projects needed
93
75
  loader.eager_load
94
76
  end
95
- else # old style without autoload to be removed eventually
77
+ else
78
+ # old style without autoload to be removed eventually
96
79
  loader.setup
97
80
  loader.eager_load # TODO: this should not be needed but we see hanging CI processes when it's not added
98
81
  # TODO: also auto-load projects and update expected path too
@@ -121,5 +104,33 @@ module Kennel
121
104
 
122
105
  raise
123
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
124
135
  end
125
136
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.163.1"
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.1
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-16 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