Sha256: e88d50ff46ecc8e1145ce3dad27ee3f93fd80813c455ac7e1a7335cacd1ca8a6

Contents?: true

Size: 847 Bytes

Versions: 50

Compression:

Stored size: 847 Bytes

Contents

require 'dply/helper'
require 'dplyr/stage'

module Dplyr
  class StagesConfig
    
    include ::Dply::Helper  
    attr_reader :config_file
    attr_accessor :current_stage

    def initialize(config_file = nil)
      @config_file = config_file || "stages.rb"
      @stages = {}
    end

    def stage(name, &block)
      name = name.to_sym
      stage = Stage.new(name)
      stage.config_proc = block
      @stages[name] = stage
    end

    def read_from_file
      return if @read
      error "#{config_file} not readable" if not File.readable? config_file
      instance_eval(File.read(config_file), config_file)
    rescue NoMethodError => e
       error "invalid option used in config: #{e.name} #{e.message}"
    ensure
      @read = true
    end

    def fetch(stage)
      read_from_file
      @stages[stage.to_sym]
    end

  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dplyr/stages_config.rb
dply-0.3.14 lib/dplyr/stages_config.rb
dply-0.3.13 lib/dplyr/stages_config.rb
dply-0.3.12 lib/dplyr/stages_config.rb
dply-0.3.11 lib/dplyr/stages_config.rb
dply-0.3.10 lib/dplyr/stages_config.rb
dply-0.3.9 lib/dplyr/stages_config.rb
dply-0.3.8 lib/dplyr/stages_config.rb
dply-0.3.7 lib/dplyr/stages_config.rb
dply-0.3.6 lib/dplyr/stages_config.rb
dply-0.3.5 lib/dplyr/stages_config.rb
dply-0.3.4 lib/dplyr/stages_config.rb
dply-0.3.3 lib/dplyr/stages_config.rb
dply-0.3.2 lib/dplyr/stages_config.rb
dply-0.3.1 lib/dplyr/stages_config.rb
dply-0.3.0 lib/dplyr/stages_config.rb
dply-0.2.19 lib/dplyr/stages_config.rb
dply-0.2.18 lib/dplyr/stages_config.rb
dply-0.2.17 lib/dplyr/stages_config.rb
dply-0.2.16 lib/dplyr/stages_config.rb