lib/bauxite/actions/tryload.rb in bauxite-0.6.4 vs lib/bauxite/actions/tryload.rb in bauxite-0.6.5

- old
+ new

@@ -18,10 +18,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. #++ +require 'pathname' + class Bauxite::Action # Load the specified file into an isolated variable context and execute # the actions specified. If the file does not exist, this action skips. # See #load for a similar action that fails if the file does not exist. # @@ -47,12 +49,12 @@ end end private def _load_file_action(file, *vars) - unless file == 'stdin' or File.exists? file + unless file == 'stdin' or (File.exists? file and Pathname.new(file).absolute?) current = @ctx.variables['__FILE__'] - current = (File.exists? current) ? File.dirname(current) : Dir.pwd + current = (current and File.exists? current) ? File.dirname(current) : Dir.pwd file = File.join(current, file) return nil unless File.exists? file end var_hash = vars.inject({}) do |h,v|