This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from brandocorp/issue-1
add address DSL
- Loading branch information
Showing
8 changed files
with
122 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ | |
/tmp/ | ||
.kitchen/ | ||
.kitchen.local.yml | ||
.cocina.kitchen.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'kitchen/loader/yaml' | ||
require 'kitchen/util' | ||
|
||
module Kitchen | ||
module Loader | ||
class Cocina < YAML | ||
def initialize(options = {}) | ||
super | ||
@cocina_config_file = | ||
File.expand_path(options[:cocina_config] || default_cocina_config_file) | ||
@process_cocina = options.fetch(:process_cocina, true) | ||
end | ||
|
||
private | ||
|
||
# @return [String] the absolute path to the Cocina config YAML file | ||
# @api private | ||
attr_reader :cocina_config_file | ||
|
||
# Performed a prioritized recursive merge of several source Hashes and | ||
# returns a new merged Hash. There are 4 sources of configuration data: | ||
# | ||
# 1. cocina config | ||
# 2. local config | ||
# 3. project config | ||
# 4. global config | ||
# | ||
# The merge order is cocina -> local -> project -> global, meaning that | ||
# elements at the top of the above list will be merged last, and have greater | ||
# precedence than elements at the bottom of the list. | ||
# | ||
# @return [Hash] a new merged Hash | ||
# @api private | ||
def combined_hash | ||
{}.tap do |conf| | ||
conf.rmerge!(normalize(global_yaml)) if @process_global | ||
conf.rmerge!(normalize(yaml)) | ||
conf.rmerge!(normalize(local_yaml)) if @process_local | ||
conf.rmerge!(normalize(cocina_yaml)) if @process_cocina | ||
end | ||
end | ||
|
||
# Loads and returns the Cocina config YAML as a Hash. | ||
# | ||
# @return [Hash] the config hash | ||
# @api private | ||
def cocina_yaml | ||
parse_yaml_string(yaml_string(cocina_config_file), cocina_config_file) | ||
end | ||
|
||
# Determines the default absolute path to the Cocina config YAML file, | ||
# based on current working directory. | ||
# | ||
# @return [String] an absolute path to a Kitchen config YAML file | ||
# @api private | ||
def default_cocina_config_file | ||
File.join(Dir.pwd, '.cocina.kitchen.yml') | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters