Skip to content

Commit 04c9c16

Browse files
committed
refactor config to use compose internally
1 parent 2d9373e commit 04c9c16

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
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/commands/preview.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 Preview < Base
4-
using ComposeRefinements
5-
64
help "Generate the bash script to STDOUT"
75

86
usage "bashly preview"
@@ -11,7 +9,7 @@ class Preview < Base
119
environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
1210

1311
def run
14-
config = Config.new("#{Settings.source_dir}/bashly.yml").compose
12+
config = Config.new "#{Settings.source_dir}/bashly.yml"
1513
command = Script::Command.new(config)
1614
script = Script::Wrapper.new command
1715
puts script.code

lib/bashly/commands/validate.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 Validate < Base
4-
using ComposeRefinements
5-
64
help "Scan the configuration file for errors"
75

86
usage "bashly validate"
@@ -11,7 +9,7 @@ class Validate < Base
119
environment "BASHLY_SOURCE_DIR", "The path containing the bashly configuration and source files [default: src]"
1210

1311
def run
14-
config = Config.new("#{Settings.source_dir}/bashly.yml").compose
12+
config = Config.new "#{Settings.source_dir}/bashly.yml"
1513
validator = ConfigValidator.new config
1614
validator.validate
1715
say "!txtgrn!OK"

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
module Bashly
22
module Libraries
33
class Completions < Base
4-
using ComposeRefinements
5-
64
protected
75
def command
86
@command ||= Script::Command.new config
97
end
108

119
def config
12-
@config ||= Bashly::Config.new("#{Settings.source_dir}/bashly.yml").compose
10+
@config ||= Bashly::Config.new "#{Settings.source_dir}/bashly.yml"
1311
end
1412
end
1513
end

0 commit comments

Comments
 (0)