This repository has been archived by the owner on Apr 6, 2021. 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.
- add methods to resolve plugin name in the Plugin class - add the name of the plugin as the default plugin tag - add a command line task to display the enabled plugin names - add a global command line option to imput global configuration - refactor env so configuration is in a separate class - make the config class return OpenStructs instead of a hash
- Loading branch information
janstenpickle
committed
Sep 28, 2015
1 parent
cc80c66
commit a6ac2dd
Showing
25 changed files
with
304 additions
and
43 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
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,47 @@ | ||
require 'shenanigans/hash/to_ostruct' | ||
require 'deep_merge' | ||
|
||
module Shanty | ||
# Public: Configuration class for shanty | ||
class Config | ||
CONFIG_FILE = '.shanty.yml' | ||
|
||
def initialize(root, environment) | ||
@root = root | ||
@environment = environment | ||
end | ||
|
||
def merge!(new_config) | ||
@config = config_hash.clone.deep_merge(new_config) | ||
end | ||
|
||
def [](key) | ||
to_ostruct[key] | ||
end | ||
|
||
def method_missing(m) | ||
to_ostruct.send(m) || OpenStruct.new | ||
end | ||
|
||
def respond_to?(method_sym, include_private = false) | ||
super || to_ostruct.respond_to?(method_sym, include_private) | ||
end | ||
|
||
def to_ostruct | ||
config_hash.to_ostruct | ||
end | ||
|
||
private | ||
|
||
def config_hash | ||
return @config unless @config.nil? | ||
return @config = {} unless File.exist?(config_path) | ||
config = YAML.load_file(config_path) || {} | ||
@config = config[@environment] || {} | ||
end | ||
|
||
def config_path | ||
"#{@root}/#{CONFIG_FILE}" | ||
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
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
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
Oops, something went wrong.