kennel 1.162.0 → 1.163.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8412928c5e979ad1f46ac333e0f51a9d2601fa435a6ec2951390211515b0b35b
4
- data.tar.gz: 2d25fbf232b3d784f3ea04ff51a38aeea2c7f034969e2065c4ddbb6dbbd3ea99
3
+ metadata.gz: 81d0c04d0d3a16c2c46d12aa217e5c5353702a613af3a0d3fea52832839ebd12
4
+ data.tar.gz: 4619a82006932e5d0dc4782488b1caec8a789ab4614b8968185ba41defd768d7
5
5
  SHA512:
6
- metadata.gz: 320fbf356dbfb89826f99b7a3b90f3f41af07022b8ab783b546af7cb6a7430081fa955431bfd642fbda50de31e6308b863912c9c6d0af768622ff2f9b302b4e1
7
- data.tar.gz: ef91e1bebe47fd623d65a5a308c726930e077632ac3b993241986f8625b695312789675e2bc5de4ee55ea2bfc1828252e110fbc65f81b91307ba0f6773efaf9f
6
+ metadata.gz: 87bb834a983a635134521548d01f278dcd26c93cbb88c5e929ca3a7a454b241dfccd5e74ec65936c61120d9785dbab027c028c12a35fbb9b481efb0bd4bde157
7
+ data.tar.gz: 94abdde8bf155cd9ea7a6ed74d3e7216937af142224b2e8e7766b0506874d7abfa9c494c05716f365644272e439bece107126c9edae038ca79e919fd00939db3
data/lib/kennel/filter.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Kennel
4
4
  class Filter
5
+ attr_reader :project_filter
6
+
5
7
  def initialize
6
8
  # read early so we fail fast on invalid user input
7
9
  @tracking_id_filter = read_tracking_id_filter_from_env
@@ -39,7 +41,7 @@ module Kennel
39
41
 
40
42
  private
41
43
 
42
- attr_reader :project_filter, :tracking_id_filter
44
+ attr_reader :tracking_id_filter
43
45
 
44
46
  # needs to be called after read_tracking_id_filter_from_env
45
47
  def read_project_filter_from_env
@@ -4,12 +4,16 @@ module Kennel
4
4
  class AutoloadFailed < StandardError
5
5
  end
6
6
 
7
+ def initialize(filter:)
8
+ @filter = filter
9
+ end
10
+
7
11
  # @return [Array<Models::Project>]
8
12
  # All projects in the system. This is a slow operation.
9
13
  # Use `projects` to get all projects in the system.
10
14
  def all_projects
11
15
  load_all
12
- Models::Project.recursive_subclasses.map(&:new)
16
+ loaded_projects.map(&:new)
13
17
  end
14
18
 
15
19
  # @return [Array<Models::Project>]
@@ -17,11 +21,15 @@ module Kennel
17
21
 
18
22
  def projects
19
23
  load_all
20
- Models::Project.recursive_subclasses.map(&:new)
24
+ loaded_projects.map(&:new)
21
25
  end
22
26
 
23
27
  private
24
28
 
29
+ def loaded_projects
30
+ Models::Project.recursive_subclasses
31
+ end
32
+
25
33
  # load_all's purpose is to "require" all the .rb files under './projects',
26
34
  # while allowing them to resolve reference to ./teams and ./parts via autoload
27
35
  def load_all
@@ -39,33 +47,52 @@ module Kennel
39
47
  loader.push_dir("projects")
40
48
  loader.setup
41
49
 
42
- if (project = ENV["PROJECT"]) # TODO: use project filter instead and also support TRACKING_ID
43
- # we support PROJECT being used for nested folders, to allow teams to easily group their projects
44
- # so when loading a project we need to find anything that could be a project source
45
- # sorting by name and nesting level to avoid confusion
46
- segments = project.split("_")
47
- search = /#{segments[0...-1].map { |p| "#{p}[_/]" }.join}#{segments[-1]}(\.rb|\/project\.rb|\/base\.rb)/
48
-
50
+ if (projects = @filter.project_filter)
49
51
  projects_path = "#{File.expand_path("projects")}/"
50
- known_paths = loader.all_expected_cpaths.keys
51
- project_path = known_paths.select do |path|
52
- path.start_with?(projects_path) && path.match?(search)
53
- end.sort.min_by { |p| p.count("/") }
54
- if project_path
55
- require project_path
56
- elsif autoload != "abort"
57
- Kennel.err.puts(
58
- "No projects/ file matching #{search} found" \
59
- ", falling back to slow loading of all projects instead"
60
- )
61
- loader.eager_load
62
- else
63
- raise AutoloadFailed, "No projects/ file matching #{search} found"
52
+ known_paths = loader.all_expected_cpaths.keys.select! { |path| path.start_with?(projects_path) }
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
+ 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)/
60
+ found = known_paths.grep(search).sort.sort_by { |path| path.count("/") }
61
+ if found.any?
62
+ 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
81
+ elsif autoload != "abort"
82
+ Kennel.err.puts(
83
+ "No projects/ file matching #{search} found" \
84
+ ", falling back to slow loading of all projects instead"
85
+ )
86
+ loader.eager_load
87
+ break
88
+ else
89
+ raise AutoloadFailed, "No projects/ file matching #{search} found"
90
+ end
64
91
  end
65
92
  else # all projects needed
66
93
  loader.eager_load
67
94
  end
68
- else # old style without autoload
95
+ else # old style without autoload to be removed eventually
69
96
  loader.setup
70
97
  loader.eager_load # TODO: this should not be needed but we see hanging CI processes when it's not added
71
98
  # TODO: also auto-load projects and update expected path too
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.162.0"
3
+ VERSION = "1.163.1"
4
4
  end
data/lib/kennel.rb CHANGED
@@ -107,7 +107,7 @@ module Kennel
107
107
  def generated(**kwargs)
108
108
  @generated ||= begin
109
109
  projects = Progress.progress "Loading projects", **kwargs do
110
- projects = ProjectsProvider.new.projects
110
+ projects = ProjectsProvider.new(filter: filter).projects
111
111
  filter.filter_projects projects
112
112
  end
113
113
 
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.162.0
4
+ version: 1.163.1
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-04-26 00:00:00.000000000 Z
11
+ date: 2025-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs