Module | Kernel |
In: |
lib/merb-core/core_ext/kernel.rb
|
i<Fixnum>: | The caller number. Defaults to 1. |
Array[Array]: | The file, line and method of the caller. |
__caller_info__(1) # => ['/usr/lib/ruby/1.8/irb/workspace.rb', '52', 'irb_binding']
file<String>: | The file to read. |
line<Fixnum>: | The line number to look for. |
size<Fixnum>: | Number of lines to include above and below the the line to look for. Defaults to 4. |
Array[Array]: | Triplets containing the line number, the line and whether this was the searched line. |
__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 ] ]
Takes a block, profiles the results of running the block specified number of times and generates HTML report.
name<~to_s>: | The file name. The result will be written out to Merb.root/"log/#{name}.html". |
min<Fixnum>: | Minimum percentage of the total time a method must take for it to be included in the result. Defaults to 1. |
String: | The result of the profiling. |
Requires ruby-prof (sudo gem install ruby-prof)
__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.
Loads both gem and library dependencies that are passed in as arguments. Execution is deferred to the Merb::BootLoader::Dependencies.run during bootup.
*args<String, Hash, Array>: | The dependencies to load. |
Loads the given string as a gem. Execution is deferred to the Merb::BootLoader::Dependencies.run during bootup.
name<String>: | The name of the gem to load. |
*ver<Gem::Requirement, Gem::Version, Array, ~to_str>: | Version requirements to be passed to Gem.activate. |
Checks that the given objects quack like the given conditions.
opts<Hash>: | Conditions to enforce. Each key will receive a quacks_like? call with the value (see Object#quacks_like? for details). |
ArgumentError: | An object failed to quack like a condition. |
Extracts an options hash if it is the last item in the args array. Used internally in methods that take *args.
args<Array>: | The arguments to extract the hash from. |
def render(*args,&blk) opts = extract_options_from_args!(args) || {} # [...] end
Loads both gem and library dependencies that are passed in as arguments.
*args<String, Hash, Array>: | The dependencies to load. |
Each argument can be:
String: | Single dependency. |
Hash: | Multiple dependencies where the keys are names and the values versions. |
Array: | Multiple string dependencies. |
dependencies "RedCloth" # Loads the the RedCloth gem dependencies "RedCloth", "merb_helpers" # Loads RedCloth and merb_helpers dependencies "RedCloth" => "3.0" # Loads RedCloth 3.0
Loads the given string as a gem.
name<String>: | The name of the gem to load. |
*ver<Gem::Requirement, Gem::Version, Array, ~to_str>: | Version requirements to be passed to Gem.activate. |
If the gem cannot be found, the method will attempt to require the string as a library.
This new version tries to load the file via ROOT/gems first before moving off to the system gems (so if you have a lower version of a gem in ROOT/gems, it‘ll still get loaded).
Registers ORM at generator scope.
orm<~to_sym>: | ORM alias, like :activerecord, :datamapper or :sequel. |
Register test framework at generator scope. Currently Merb has plugins to support RSpec and Test::Unit.
test_framework<Symbol>: | The test framework to check. Currently only supports :rspec and :test_unit but the check is performed before registration if you use API. |
Use to check whether given ORM already registred at generator scope
orm<~to_sym>: | ORM alias, like :activerecord, :datamapper or :sequel. |
Boolean: | true if ORM is already registred, false otherwise |
Does a basic require, and prints a message if an error occurs.
library<~to_s>: | The library to attempt to include. |
message<String>: | The error to add to the log upon failure. Defaults to nil. |
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.
orm<~to_s>: | The ORM to use. |
# This line goes in dependencies.yml use_orm :datamapper # This will use the DataMapper generator for your ORM $ ruby script/generate model MyModel
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.
test_framework<Symbol>: | The test framework to use. Currently only supports :rspec and :test_unit. |
# This line goes in dependencies.yml use_test :rspec # This will now use the RSpec generator for tests $ ruby script/generate controller MyController