Release 0.4.2
Wednesday, April 2nd, 2008Another week, another release, eh? That seems to be the M.O. and today doesn’t seem to be any difference. This week’s release has a few new cool things in it, but overall isn’t the sexiest of releases, but definitely one I would highly recommend downloading.
Initializers
First up, the config/initializers directory. Any .rb files you put in this directory will be loaded up as part of the initialization process
Current Mack initialization load order:
- Configuration files.
- Logging.
- Orm Support, if any.
- Mack libraries.
- Routes.
- Initializers.
- Gems.
- Plugins.
- ‘app’ files.
- ‘lib’ files.
- Helpers.
In a future release you’ll be able to re-order this list as part of step #1, but that’s a bit of a ways off for right now. Let’s focus on what you can do right now.
Gems
When you create a new Mack app you will find a file called gems.rb in config/initializers. There you can ‘require’ gems into your application.
Example:
require_gems do |gem| gem.add :redgreen, :version => "1.2.2", :libs => :redgreen gem.add :termios gem.add :rubyzip, :source => "http://gems.rubyforge.org" end
When the application gets loaded up it will call the ‘gem’ method for each of the gems defined, and with specific versions, if defined. If the optional arrary ‘libs’ is present it will ‘require’ each of those files after the ‘gem’ method has been called.
There are also two rake tasks that help with gems:
- gems:list – This lists all the gems required by the app.
- gems:install – This will install all the gems required by the app. If a version is specified the task will attempt to install that specific version. If a source is specified then the source will be used to install the gem.
Filters
In previous versions of Mack if you had a controller inherit from another controller and you had filters defined in the parent’s controller they would not get run on the child controller. This has now been fixed.
Example:
class TopController < Mack::Controller::Base
before_filter :log
protected
def log
# do some logging here...
end
end
class BottomController < TopController
end
The ‘log’ filter method will now be called on actions in the BottomController class.
Changelog:
- Added config/initializers directory. All files in this directory will be required at start up time.
- Gems can now be required simply using the initializers/gems.rb file and the require_gems method.
- Added gems:list and gems:install rake tasks. The gems:list task will list any gems being required for the application. The gems:install task will install all the gems being required for the application.
- Filters in controllers can now be inherited from parent controller classes.
- gem: mack_ruby_core_extensions 0.1.5
- gem: thing 0.7.1
$ sudo gem install mack

