From 2ae76e55f11ce56a1173702bcfcb6af25abdb852 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 23 Jul 2014 15:17:41 -0400 Subject: [PATCH] add Runtime.read --- runtime/lib/runtime.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/runtime/lib/runtime.rb b/runtime/lib/runtime.rb index 7524aa1..2efec0f 100644 --- a/runtime/lib/runtime.rb +++ b/runtime/lib/runtime.rb @@ -35,6 +35,22 @@ module Runtime path end + # Find and read a runtime file. + # + # @param type [Symbol] + # Type of runtime file to find. See {#find} for available types. + # @param name [String] + # Name of the runtime file to locate. + # + # @return [String] + # Contents of the runtime file, or +nil+ if not found. + def read(type, name) + path = find(type, name) + if path + File.read(path, mode: "rb") + end + end + private # Return the default runtime paths.