Module | Kernel |
In: |
lib/merb-core/core_ext/kernel.rb
lib/merb-core/test/test_ext/rspec.rb |
@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
@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
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
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.
Array[(Gem::Dependency, Array[Gem::Dependency])]: | Gem::Dependencies for the |
dependencies specified in args.
:api: public
Loads the given string as a gem. Execution is deferred until after the logger has been instantiated and the framework directory structure is defined.
If that has already happened, the gem will be activated immediately, but it will still be registered.
name<String> The name of the gem to load. *ver<Gem::Requirement, Gem::Version, Array, to_str>
Version requirements to be passed to Gem::Dependency.new. If the last argument is a Hash, extract the :immediate option, forcing a dependency to load immediately.
:immediate when true, gem is loaded immediately even if framework is not yet ready. :require_as file name to require for this gem.
See examples below.
If block is given, it is called after require is called. If you use a block to require multiple files, require first using :require_as option and the rest in the block.
Usage scenario is typically one of the following:
dependency "amqp"
dependency "ParseTree", :require_as => "parse_tree"
dependency "xmpp4r", :require_as => %w(xmpp4r/client xmpp4r/sasl xmpp4r/vcard)
dependency "RedCloth", "3.0.4"
dependency "syslog", :immediate => true
dependency "ruby-growl" do
g = Growl.new "localhost", "ruby-growl", ["ruby-growl Notification"] g.notify "ruby-growl Notification", "Ruby-Growl is set up", "Ruby-Growl is set up"
end
When specifying a gem version to use, you can use the same syntax RubyGems support, for instance, >= 3.0.2 or >~ 1.2.
See rubygems.org/read/chapter/16 for a complete reference.
Gem::Dependency: | The dependency information. |
:api: public
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
Loads both gem and library dependencies that are passed in as arguments.
@param *args<String, Hash, Array> The dependencies to load.
@note
Each argument can be: String:: Single dependency. Hash:: Multiple dependencies where the keys are names and the values versions. Array:: Multiple string dependencies.
@example dependencies "RedCloth" # Loads the the RedCloth gem @example dependencies "RedCloth", "merb_helpers" # Loads RedCloth and merb_helpers @example dependencies "RedCloth" => "3.0" # Loads RedCloth 3.0
:api: private
Loads the given string as a gem.
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).
@param name<String,Gem::Dependency>
The name or dependency object of the gem to load.
@param *ver<Gem::Requirement, Gem::Version, Array, to_str>
Version requirements to be passed to Gem.activate.
@note
If the gem cannot be found, the method will attempt to require the string as a library.
@return <Gem::Dependency> The dependency information.
:api: private
Does a basic require, and prints a message if an error occurs.
@param library<to_s> The library to attempt to include. @param message<String> The error to add to the log upon failure. Defaults to nil.
:api: private @deprecated
Keep track of all required dependencies.
@param name<String> The name of the gem to load. @param *ver<Gem::Requirement, Gem::Version, Array, to_str>
Version requirements to be passed to Gem::Dependency.new.
@return <Gem::Dependency> Dependency information
:api: private
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<Symbol>: | The ORM to use. |
nil
use_orm :datamapper # This will use the DataMapper generator for your ORM $ merb-gen model ActivityEvent
If for some reason this is called more than once, latter call takes over other.
:api: public
Used in Merb.root/config/init.rb to tell Merb which template engine to prefer.
template_engine<Symbol>
The template engine to use.
nil
use_template_engine :haml # This will now use haml templates in generators where available. $ merb-gen resource_controller Project
:api: public
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. |
nil
use_test :rspec # This will now use the RSpec generator for tests $ merb-gen model ActivityEvent
:api: public