Module | Kernel
In: | lib/merb-core/test/test_ext/rspec.rb lib/merb-core/core_ext/kernel.rb

### Methods

__caller_info__ __caller_lines__ __profile__ debugger dependencies dependency enforce! extract_options_from_args! given use_orm use_template_engine use_test use_testing_framework

### Public Instance methods

__caller_info__(i = 1)

@param i<Fixnum> The caller number. Defaults to 1.

@return <Array[Array]> The file, line and method of the caller.

@example

      __caller_info__(1)
        # => ['/usr/lib/ruby/1.8/irb/workspace.rb', '52', 'irb_binding']

:api: private

__caller_lines__(file, line, size = 4) {|:error, "Template Error! Problem while rendering", false| ...}

@param file<String> The file to read. @param line<Fixnum> The line number to look for. @param size<Fixnum>

      Number of lines to include above and below the the line to look for.
      Defaults to 4.

@return <Array[Array]>

      Triplets containing the line number, the line and whether this was the
      searched line.

@example

      __caller_lines__('/usr/lib/ruby/1.8/debug.rb', 122, 2) # =>
        [
          [ 120, "  def check_suspend",                               false ],
          [ 121, "    return if Thread.critical",                     false ],
          [ 122, "    while (Thread.critical = true; @suspend_next)", true  ],
          [ 123, "      DEBUGGER__.waiting.push Thread.current",      false ],
          [ 124, "      @suspend_next = false",                       false ]
        ]

:api: private

__profile__(name, min=1, iter=100) {|| ...}

Takes a block, profiles the results of running the block specified number of times and generates HTML report.

@param name<to_s>

      The file name. The result will be written out to
      Merb.root/"log/#{name}.html".

@param min<Fixnum>

      Minimum percentage of the total time a method must take for it to be
      included in the result. Defaults to 1.

@return <String>

      The result of the profiling.

@note

      Requires ruby-prof (<tt>sudo gem install ruby-prof</tt>)

@example

      __profile__("MyProfile", 5, 30) do
        rand(10)**rand(10)
        puts "Profile run"
      end

      Assuming that the total time taken for #puts calls was less than 5% of the
      total time to run, #puts won't appear in the profile report.
      The code block will be run 30 times in the example above.

:api: private

debugger()

Define debugger method so that code even works if debugger was not requested. Drops a note to the logs that Debugger was not available.

dependencies(*args)

Loads both gem and library dependencies that are passed in as arguments.

:api: public @deprecated

dependency(name, *opts, &blk)

Loads the given string as a gem.

:api: public @deprecated

enforce!(opts = {})

Checks that the given objects quack like the given conditions.

@param opts<Hash>

      Conditions to enforce. Each key will receive a quacks_like? call with the
      value (see Object#quacks_like? for details).

@raise <ArgumentError>

      An object failed to quack like a condition.

:api: public

extract_options_from_args!(args)

Extracts an options hash if it is the last item in the args array. Used internally in methods that take *args.

@param args<Array> The arguments to extract the hash from.

@example

      def render(*args,&blk)
        opts = extract_options_from_args!(args) || {}
        # [...]
      end

:api: public

given(*args, &example_group_block)
use_orm(orm)

Used in Merb.root/config/init.rb to tell Merb which ORM (Object Relational Mapper) you wish to use. Currently Merb has plugins to support ActiveRecord, DataMapper, and Sequel.

#### Parameters

orm<Symbol>: | The ORM to use.

#### Returns

nil

#### Example

      use_orm :datamapper

      # This will use the DataMapper generator for your ORM
      $ merb-gen model ActivityEvent

#### Notes

      If for some reason this is called more than once, latter
      call takes over other.

:api: public

use_template_engine(template_engine)

Used in Merb.root/config/init.rb to tell Merb which template engine to prefer.

#### Parameters

template_engine<Symbol>

      The template engine to use.

#### Returns

nil

#### Example

      use_template_engine :haml

      # This will now use haml templates in generators where available.
      $ merb-gen resource_controller Project

:api: public

use_test(*args)
use_testing_framework(test_framework)

Used in Merb.root/config/init.rb to tell Merb which testing framework to use. Currently Merb has plugins to support RSpec and Test::Unit.

#### Parameters

test_framework<Symbol>: | The test framework to use. Currently only supports :rspec and :test_unit.

#### Returns

nil

#### Example

      use_test :rspec

      # This will now use the RSpec generator for tests
      $ merb-gen model ActivityEvent

:api: public

[Validate]