@@ -17,10 +17,12 @@ def result
1717 if run == :success
1818 config . merge ( { status : run } )
1919 else
20- config . merge ( { status : :failure , got : run } )
20+ config . merge ( { status : :failure , got : err_msg ( run ) } )
2121 end
2222 end
2323
24+ def job_data = @job_data ||= get_job_data
25+
2426 private
2527
2628 def initialization_logic ( config , data = nil )
@@ -32,8 +34,6 @@ def initialization_logic(config, data = nil)
3234
3335 def config = @config
3436
35- def job_data = @job_data ||= get_job_data
36-
3737 def validate_config ( config )
3838 unless config . key? ( :path )
3939 fail ( "#{ self . class . name } requires a :path key in its config" )
@@ -58,9 +58,31 @@ def validate_config_keys(config)
5858 "#{ missing . join ( ", " ) } " )
5959 end
6060
61+ def err_msg_prefix
62+ parts = [ ]
63+ parts << loc if respond_to? ( :loc )
64+ parts << desc if respond_to? ( :desc )
65+ return if parts . empty?
66+
67+ parts << "Got"
68+ parts . join ( "\n " )
69+ end
70+
71+ def err_msg ( val ) = [ err_msg_prefix , val ] . compact . join ( ": " )
72+
6173 def generate_instance_variable ( key , val )
6274 iv = :"@#{ key } "
63- instance_variable_set ( iv , val )
75+ conv = if respond_to? ( :key_conversions )
76+ if key_conversions . key? ( key )
77+ val . send ( key_conversions [ key ] )
78+ else
79+ val
80+ end
81+ else
82+ val
83+ end
84+
85+ instance_variable_set ( iv , conv )
6486 self . class . define_method ( key ) { instance_variable_get ( iv ) }
6587 end
6688 end
0 commit comments