Class | Yapra::Config |
In: |
lib/yapra/config.rb
|
Parent: | Object |
Config file for yapra.
A simplest. You can run one pipeline without global config.
- module: Module:name config: a: 3 - module: Module:name2 config: a: b - module: Module:name3 config: a: 88
You can run a lot of pipelines with global config.
global: log: out: stderr level: warn pipeline: pipeline1: - module: Module:name config: a: 3 - module: Module:name2 config: a: b pipeline2: - module: Module:name config: a: 3 - module: Module:name2 config: a: b
You can run sigle pipeline with global config.
global: log: out: stderr level: warn pipeline: - module: Module:name config: a: 3 - module: Module:name2 config: a: b
env | [R] | |
pipeline_commands | [R] |
# File lib/yapra/config.rb, line 66 66: def initialize config={} 67: if config.kind_of?(Hash) 68: @env = config['global'] || {} 69: if config['pipeline'] 70: if config['pipeline'].kind_of?(Hash) 71: @pipeline_commands = config['pipeline'] 72: elsif config['pipeline'].kind_of?(Array) 73: @pipeline_commands = { 'default' => config['pipeline'] } 74: end 75: end 76: raise 'config["global"]["pipeline"] is invalid!' unless @pipeline_commands 77: elsif config.kind_of?(Array) 78: @env = {} 79: @pipeline_commands = { 'default' => config } 80: else 81: raise 'config file is invalid!' 82: end 83: end
# File lib/yapra/config.rb, line 85 85: def create_logger 86: logger = nil 87: if env['log'] && env['log']['out'] 88: if env['log']['out'].index('file://') 89: logger = Logger.new(URI.parse(env['log']['out']).path) 90: else 91: logger = Logger.new(Yapra::Inflector.constantize(env['log']['out'].upcase)) 92: end 93: else 94: logger = Logger.new(STDOUT) 95: end 96: 97: if env['log'] && env['log']['level'] 98: logger.level = Yapra::Inflector.constantize("Logger::#{env['log']['level'].upcase}") 99: else 100: logger.level = Logger::WARN 101: end 102: logger 103: end