kennel 1.162.0 → 1.163.0

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: 0b07d4f21ef18f6f89875f4bdb1f4ba86144d4291180ffeff34ef6c8c8b6ad01
4
+ data.tar.gz: e90f0c27577b343baf745b342b6eea95053b029a788bdaf740c9a1e717da0303
5
5
  SHA512:
6
- metadata.gz: 320fbf356dbfb89826f99b7a3b90f3f41af07022b8ab783b546af7cb6a7430081fa955431bfd642fbda50de31e6308b863912c9c6d0af768622ff2f9b302b4e1
7
- data.tar.gz: ef91e1bebe47fd623d65a5a308c726930e077632ac3b993241986f8625b695312789675e2bc5de4ee55ea2bfc1828252e110fbc65f81b91307ba0f6773efaf9f
6
+ metadata.gz: 4aa14e50c3b4c17690de793c84889e0a92fa48c6d59b491226cc487de75922ec98300cdaded30781ac22f1845c14a834aa9fec0bffe2b31d72fc4726a7948d95
7
+ data.tar.gz: 95b2a1d28f5f98703c7ba448cf865009e9d53989bb7aec3492adddde172f032ebdae447688615e29a1d47055f785a50ee8ea9fe7278ab7c88436b5e418529c7e
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,6 +4,10 @@ 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.
@@ -39,33 +43,34 @@ module Kennel
39
43
  loader.push_dir("projects")
40
44
  loader.setup
41
45
 
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
-
46
+ if (projects = @filter.project_filter)
49
47
  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"
48
+ known_paths = loader.all_expected_cpaths.keys.select! { |path| path.start_with?(projects_path) }
49
+
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
+ 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)/
56
+
57
+ if (project_path = known_paths.grep(search).sort.min_by { |path| path.count("/") })
58
+ require project_path
59
+ elsif autoload != "abort"
60
+ Kennel.err.puts(
61
+ "No projects/ file matching #{search} found" \
62
+ ", falling back to slow loading of all projects instead"
63
+ )
64
+ loader.eager_load
65
+ break
66
+ else
67
+ raise AutoloadFailed, "No projects/ file matching #{search} found"
68
+ end
64
69
  end
65
70
  else # all projects needed
66
71
  loader.eager_load
67
72
  end
68
- else # old style without autoload
73
+ else # old style without autoload to be removed eventually
69
74
  loader.setup
70
75
  loader.eager_load # TODO: this should not be needed but we see hanging CI processes when it's not added
71
76
  # 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.0"
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.0
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-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs