Class: Dplyr::StagesConfig
- Inherits:
-
Object
- Object
- Dplyr::StagesConfig
- Includes:
- Dply::Helper
- Defined in:
- lib/dplyr/stages_config.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#current_stage ⇒ Object
Returns the value of attribute current_stage.
Instance Method Summary collapse
- #fetch(stage) ⇒ Object
-
#initialize(config_file = nil) ⇒ StagesConfig
constructor
A new instance of StagesConfig.
- #read_from_file ⇒ Object
- #stage(name, &block) ⇒ Object
Methods included from Dply::Helper
#cmd, #error, #git, #logger, #sh, #symlink
Constructor Details
#initialize(config_file = nil) ⇒ StagesConfig
Returns a new instance of StagesConfig.
11 12 13 14 |
# File 'lib/dplyr/stages_config.rb', line 11 def initialize(config_file = nil) @config_file = config_file || "stages.rb" @stages = {} end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
8 9 10 |
# File 'lib/dplyr/stages_config.rb', line 8 def config_file @config_file end |
#current_stage ⇒ Object
Returns the value of attribute current_stage.
9 10 11 |
# File 'lib/dplyr/stages_config.rb', line 9 def current_stage @current_stage end |
Instance Method Details
#fetch(stage) ⇒ Object
33 34 35 36 |
# File 'lib/dplyr/stages_config.rb', line 33 def fetch(stage) read_from_file @stages[stage.to_sym] end |
#read_from_file ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/dplyr/stages_config.rb', line 23 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 |
#stage(name, &block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/dplyr/stages_config.rb', line 16 def stage(name, &block) name = name.to_sym stage = Stage.new(name) stage.config_proc = block @stages[name] = stage end |