Skip to content

Commit 9795a09

Browse files
authored
Merge pull request #178 from DannyBen/fix/split-config-validation
Fix validation when using split config
2 parents 1dc57c5 + 3014746 commit 9795a09

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

lib/bashly/commands/generate.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module Bashly
22
module Commands
33
class Generate < Base
4-
using ComposeRefinements
5-
64
help "Generate the bash script and required files"
75

86
usage "bashly generate [--force --quiet --upgrade --wrap FUNCTION]"
@@ -118,7 +116,7 @@ def master_script_path
118116
end
119117

120118
def config
121-
@config ||= Config.new("#{Settings.source_dir}/bashly.yml").compose
119+
@config ||= Config.new "#{Settings.source_dir}/bashly.yml"
122120
end
123121

124122
def command

lib/bashly/config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ module Bashly
44
# A convenience class to use either a hash or a filename as a configuration
55
# source
66
class Config
7+
using ComposeRefinements
8+
79
attr_reader :config
810

911
def self.new(config)
1012
if config.is_a? String
11-
YAML.load_file config
13+
YAML.load_file(config).compose
1214
else
1315
config
1416
end

lib/bashly/libraries/completions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def command
77
end
88

99
def config
10-
@config ||= Bashly::Config.new "#{Settings.source_dir}/bashly.yml"
10+
@config ||= Config.new "#{Settings.source_dir}/bashly.yml"
1111
end
1212
end
1313
end

spec/bashly/config_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@
1818

1919
context "with a string argument" do
2020
let(:config) { "spec/fixtures/config.yml" }
21+
2122
it "treats the string as a path to YAML and loads it" do
22-
expect(subject["loaded"]).to eq "yes indeed"
23+
expect(subject["loaded"]).to eq "yes indeed"
24+
end
25+
26+
context "when the loaded YAML contains import directives" do
27+
let(:config) { "spec/fixtures/import.yml" }
28+
29+
it "evaluates them" do
30+
expect(subject["commands"].first['loaded']).to eq "yes indeed"
31+
end
2332
end
2433
end
2534

spec/fixtures/import.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
commands:
2+
- import: spec/fixtures/config.yml
3+

0 commit comments

Comments
 (0)