Sha256: ba73a245475332f453b95842c6047d17f933c40f0d89ef147961537d33c1ef53

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'rake/dsl_definition'

module Rake

  # Rakefile are evaluated in the Rake::Environment module space.  Top
  # level rake functions (e.g. :task, :file) are available in this
  # environment.
  module Environment
    extend Rake::DSL

    class << self
      # Load a rakefile from the given path.  The Rakefile is loaded
      # in an environment that includes the Rake DSL methods.
      def load_rakefile(rakefile_path)
        rakefile = open(rakefile_path) { |f| f.read }
        load_string(rakefile, rakefile_path)
      end

      # Run a block of code in the Rake DSL environment.
      def run(&block)
        block.call
      end

      # Load a string of code in the Rake DSL environment.  If the
      # string comes from a file, include the file path so that proper
      # line numbers references may be retained.
      def load_string(code, file_name=nil)
        eval(code, binding, file_name)
      end
    end
  end

  # Run the code block in an environment including the Rake DSL
  # commands.
  def DSL.environment(&block)
    Rake::Environment.run(&block)
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rake-0.9.0.beta.4 lib/rake/environment.rb
rake-0.9.0.beta.2 lib/rake/environment.rb