Class Yapra::Config
In: lib/yapra/config.rb
Parent: Object

Config Examples

Config file for yapra.

Format 1: Pragger like.

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

Format 2: Python habu like.

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

Format 3: Mixed type.

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

Methods

create_logger   new  

Attributes

env  [R] 
pipeline_commands  [R] 

Public Class methods

[Source]

    # 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

Public Instance methods

[Source]

     # 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

[Validate]