Skip to content

Commit 20a69e2

Browse files
committed
rename handler_dir to handler_plugin_dir
1 parent f78a1ef commit 20a69e2

File tree

5 files changed

+9
-77
lines changed

5 files changed

+9
-77
lines changed

lib/hooks/core/config_loader.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Core
88
# Loads and merges configuration from files and environment variables
99
class ConfigLoader
1010
DEFAULT_CONFIG = {
11-
handler_dir: "./handlers", # For backward compatibility
1211
handler_plugin_dir: "./handlers",
1312
auth_plugin_dir: nil,
1413
log_level: "info",
@@ -31,7 +30,6 @@ class ConfigLoader
3130
# @return [Hash] Merged configuration
3231
def self.load(config_path: nil)
3332
config = DEFAULT_CONFIG.dup
34-
default_handler_dir = config[:handler_dir]
3533

3634
# Load from file if path provided
3735
if config_path.is_a?(String) && File.exist?(config_path)
@@ -47,19 +45,6 @@ def self.load(config_path: nil)
4745
# Convert string keys to symbols for consistency
4846
config = symbolize_keys(config)
4947

50-
# Support backward compatibility for handler_dir <-> handler_plugin_dir
51-
# Check if values changed from default
52-
if config[:handler_plugin_dir] != default_handler_dir && config[:handler_dir] == default_handler_dir
53-
# Only handler_plugin_dir was changed, sync handler_dir
54-
config[:handler_dir] = config[:handler_plugin_dir]
55-
elsif config[:handler_dir] != default_handler_dir && config[:handler_plugin_dir] == default_handler_dir
56-
# Only handler_dir was changed, sync handler_plugin_dir
57-
config[:handler_plugin_dir] = config[:handler_dir]
58-
elsif config[:handler_plugin_dir] != default_handler_dir && config[:handler_dir] != default_handler_dir
59-
# Both changed, handler_plugin_dir takes precedence
60-
config[:handler_dir] = config[:handler_plugin_dir]
61-
end
62-
6348
if config[:environment] == "production"
6449
config[:production] = true
6550
else
@@ -120,7 +105,6 @@ def self.load_env_config
120105
env_config = {}
121106

122107
env_mappings = {
123-
"HOOKS_HANDLER_DIR" => :handler_dir, # For backward compatibility
124108
"HOOKS_HANDLER_PLUGIN_DIR" => :handler_plugin_dir,
125109
"HOOKS_AUTH_PLUGIN_DIR" => :auth_plugin_dir,
126110
"HOOKS_LOG_LEVEL" => :log_level,

spec/acceptance/config/hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Sample configuration for Hooks webhook server
2-
handler_dir: ./spec/acceptance/handlers
2+
handler_plugin_dir: ./spec/acceptance/handlers
33
log_level: debug
44

55
# Request handling

spec/integration/hooks_integration_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def app
1313
@app ||= Hooks.build(
1414
config: {
15-
handler_dir: "./spec/integration/tmp/handlers",
15+
handler_plugin_dir: "./spec/integration/tmp/handlers",
1616
log_level: "error", # Reduce noise in tests
1717
request_limit: 1048576,
1818
request_timeout: 15,

spec/unit/lib/hooks/app/auth/custom_auth_integration_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,14 @@ def error!(message, code)
103103

104104
expect(config[:auth_plugin_dir]).to eq("./custom/auth/plugins")
105105
expect(config[:handler_plugin_dir]).to eq("./custom/handlers")
106-
expect(config[:handler_dir]).to eq("./custom/handlers") # backward compatibility
107106
end
108107

109-
it "maintains backward compatibility with handler_dir" do
110-
# Test that old handler_dir configuration still works
108+
it "uses handler_plugin_dir configuration" do
109+
# Test that handler_plugin_dir configuration works
111110
config = Hooks::Core::ConfigLoader.load(config_path: {
112-
handler_dir: "./legacy/handlers"
111+
handler_plugin_dir: "./custom/handlers"
113112
})
114113

115-
expect(config[:handler_dir]).to eq("./legacy/handlers")
116-
expect(config[:handler_plugin_dir]).to eq("./legacy/handlers")
114+
expect(config[:handler_plugin_dir]).to eq("./custom/handlers")
117115
end
118116
end

spec/unit/lib/hooks/core/config_loader_spec.rb

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
config = described_class.load
88

99
expect(config).to include(
10-
handler_dir: "./handlers",
10+
handler_plugin_dir: "./handlers",
1111
log_level: "info",
1212
request_limit: 1_048_576,
1313
request_timeout: 30,
@@ -33,7 +33,7 @@
3333
expect(config[:log_level]).to eq("debug")
3434
expect(config[:environment]).to eq("test")
3535
expect(config[:production]).to be false # should be false when environment is test
36-
expect(config[:handler_dir]).to eq("./handlers") # defaults should remain
36+
expect(config[:handler_plugin_dir]).to eq("./handlers") # defaults should remain
3737
end
3838
end
3939

@@ -69,7 +69,7 @@
6969
expect(config[:environment]).to eq("development")
7070
expect(config[:request_timeout]).to eq(60)
7171
expect(config[:production]).to be false
72-
expect(config[:handler_dir]).to eq("./handlers") # defaults should remain
72+
expect(config[:handler_plugin_dir]).to eq("./handlers") # defaults should remain
7373
end
7474
end
7575

@@ -205,56 +205,6 @@
205205
end
206206
end
207207

208-
context "with handler directory backward compatibility" do
209-
it "uses handler_plugin_dir when both are set" do
210-
custom_config = {
211-
handler_dir: "./old/handlers",
212-
handler_plugin_dir: "./new/handlers"
213-
}
214-
215-
config = described_class.load(config_path: custom_config)
216-
217-
expect(config[:handler_dir]).to eq("./new/handlers") # backward compatibility
218-
expect(config[:handler_plugin_dir]).to eq("./new/handlers")
219-
end
220-
221-
it "sets handler_plugin_dir from handler_dir for backward compatibility" do
222-
custom_config = { handler_dir: "./legacy/handlers" }
223-
224-
config = described_class.load(config_path: custom_config)
225-
226-
expect(config[:handler_dir]).to eq("./legacy/handlers")
227-
expect(config[:handler_plugin_dir]).to eq("./legacy/handlers")
228-
end
229-
230-
it "sets handler_dir from handler_plugin_dir for backward compatibility" do
231-
custom_config = { handler_plugin_dir: "./new/handlers" }
232-
233-
config = described_class.load(config_path: custom_config)
234-
235-
expect(config[:handler_dir]).to eq("./new/handlers") # backward compatibility
236-
expect(config[:handler_plugin_dir]).to eq("./new/handlers")
237-
end
238-
239-
it "supports old HOOKS_HANDLER_DIR environment variable" do
240-
ENV["HOOKS_HANDLER_DIR"] = "/legacy/handlers"
241-
242-
config = described_class.load
243-
244-
expect(config[:handler_dir]).to eq("/legacy/handlers")
245-
expect(config[:handler_plugin_dir]).to eq("/legacy/handlers")
246-
end
247-
248-
it "supports new HOOKS_HANDLER_PLUGIN_DIR environment variable" do
249-
ENV["HOOKS_HANDLER_PLUGIN_DIR"] = "/new/handlers"
250-
251-
config = described_class.load
252-
253-
expect(config[:handler_dir]).to eq("/new/handlers") # backward compatibility
254-
expect(config[:handler_plugin_dir]).to eq("/new/handlers")
255-
end
256-
end
257-
258208
context "with production environment detection" do
259209
it "sets production to true when environment is production" do
260210
config = described_class.load(config_path: { environment: "production" })

0 commit comments

Comments
 (0)