Sha256: fe35e64d087c2809b0981bb9d175e691c515a286c6846e9401775b3cd1f7d7e0

Contents?: true

Size: 1.17 KB

Versions: 50

Compression:

Stored size: 1.17 KB

Contents

#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

module Ohai
  module Mixin
    module FromFile
    
      # Loads a given ruby file, and runs instance_eval against it in the context of the current 
      # object.  
      #
      # Raises an IOError if the file cannot be found, or is not readable.
      def from_file(filename)
        if File.exists?(filename) && File.readable?(filename)
          self.instance_eval(IO.read(filename), filename, 1)
        else
          raise IOError, "Cannot open or read #{filename}!"
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 3 rubygems

Version Path
ohai-6.24.2 lib/ohai/mixin/from_file.rb
ohai-6.24.0 lib/ohai/mixin/from_file.rb
opscode-ohai-0.1.2 lib/ohai/mixin/from_file.rb
rightscale-ohai-0.3.3.1 lib/ohai/mixin/from_file.rb
rightscale-ohai-0.3.3.2 lib/ohai/mixin/from_file.rb
rightscale-ohai-0.3.3.3 lib/ohai/mixin/from_file.rb
ohai-6.24.0.rc.0 lib/ohai/mixin/from_file.rb
ohai-6.22.0 lib/ohai/mixin/from_file.rb
ohai-6.22.0.rc.0 lib/ohai/mixin/from_file.rb
ohai-6.20.0 lib/ohai/mixin/from_file.rb
ohai-6.20.0.rc.1 lib/ohai/mixin/from_file.rb
ohai-6.18.0 lib/ohai/mixin/from_file.rb
ohai-6.18.0.rc.4 lib/ohai/mixin/from_file.rb
ohai-6.18.0.rc.3 lib/ohai/mixin/from_file.rb
ohai-6.18.0.rc.1 lib/ohai/mixin/from_file.rb
ohai-6.18.0.rc.0 lib/ohai/mixin/from_file.rb
ohai-6.16.0 lib/ohai/mixin/from_file.rb
ohai-6.16.0.beta.2 lib/ohai/mixin/from_file.rb
ohai-6.16.0.beta.1 lib/ohai/mixin/from_file.rb
ohai-6.14.0 lib/ohai/mixin/from_file.rb