lib/chronicle/etl/job_definition.rb in chronicle-etl-0.4.1 vs lib/chronicle/etl/job_definition.rb in chronicle-etl-0.4.2
- old
+ new
@@ -17,16 +17,35 @@
name: 'table',
options: {}
}
}.freeze
+ attr_reader :errors
attr_accessor :definition
def initialize()
@definition = SKELETON_DEFINITION
end
+ def validate
+ @errors = []
+
+ Chronicle::ETL::Registry::PHASES.each do |phase|
+ __send__("#{phase}_klass".to_sym)
+ rescue Chronicle::ETL::PluginError => e
+ @errors << e
+ end
+
+ @errors.empty?
+ end
+
+ def validate!
+ raise(Chronicle::ETL::JobDefinitionError.new(self), "Job definition is invalid") unless validate
+
+ true
+ end
+
# Add config hash to this definition
def add_config(config = {})
@definition = @definition.deep_merge(config)
load_credentials
validate
@@ -77,13 +96,9 @@
if credentials_name
credentials = Chronicle::ETL::Config.load_credentials(credentials_name)
@definition[phase][:options].deep_merge(credentials)
end
end
- end
-
- def validate
- return true # TODO
end
end
end
end