Release 0.7.0

I know that with every release I say something like, “This is a big release”, but the fact of the matter is this is a big release. Amongst the 49 tickets that make up release 0.7.0, there are two in particular that are at the core of Mack’s very existence, they are Distributed Objects and Distributed Views/Layouts.

Back on March 26th Mack 0.4.0 was released. This release brought the first of three large distributed features, Distributed Routes. With 0.7.0 Mack fully realizes it’s goal of making it easy to write fully distributed web applications. There is a very nice wiki page, on our new wiki, that shows in detail how to use the new distributed features. That page can found here. Also, don’t forget to watch the screencast of the new distributed features that can be found here.

Distributed Objects

Distributed objects allow you to easily distribute access to your library and model code amongst any of your other Mack applications. Allowing this access is as simple as requiring the mack-distributed gem, adding a few lines to your configuration, and starting the mack_ring_server binary. ‘Client’ applications just need to require the mack-distributed gem.

Distributed Views/Layouts

With distributed views and layouts you can now share the look and feel from one application with all of your applications. Configuration and use is just as easy using distributed objects.

Form and HTML Helpers

People have been requesting more HTML and form helper methods, and we’re more than happy to comply. There are whole bunch of these new methods now to help you more easily build your applications. The generators have been updated to use these new methods, to make your job even easier. There is also now support for doing Date/Time drop downs, similar to Rails and Merb.

‘Tell’ Messaging

Rails folks know ‘tell’ messaging as ‘flash’ messaging and Merb folks know it as ‘message’ messaging. We went with ‘tell’. Tell messages are cleared after any non-redirect request. They’re a great way to send a simple message down to the client.

New Wiki

With this release there is also a new wiki at, http://www.mackwiki.com. This new wiki, incidentally built using Mack 0.7.0, will house all the tutorials and how-to’s for Mack. There are a few entries from the old wiki that still need to brought over during the next day or two.

Changelog:

  • [#114] Javascript link_helper
  • [#112] Error generating mack application
  • [#109] DataMapper 0.9.4
  • [#103] Log colors for the console are now configurable per log level.
  • [#102] New association method in data_factory
  • [#101] Update to file upload testing (build_file -> file_for_upload, and multipart support in put)
  • [#100] Inline routing parameters are being mutated
  • [#99] Upgraded to facets 2.4.3
  • [#98] Fixed mack-facets not being loaded before app_config files.
  • [#97] Fixed sessions only working with ‘local_memory’ mode
  • [#96] Distributed Views module now uses file cache
  • [#92] Removed deprecated app_config.orm code.
  • [#91] Fixed Mack blowing up if there is no config/initializers/gems.rb file.
  • [#90] Added deprecation system.
  • [#89] rake gems:* will now only display warning if any gem required is not installed (and not break)
  • [#88] Implemented pending SQLite3 tests in mack-activerecord
  • [#87] Refactored out common ORM code from mack-active_record and mack-data_mapper into mack-orm
  • [#86] stylesheet link helper
  • [#85] Refactored out Mack::ViewHelpers::HtmlHelpers into Mack::ViewHelpers::HtmlHelpers, Mack::ViewHelpers::FormHelpers and Mack::ViewHelpers::linkHelpers
  • [#84] Added Mack::Distributed.lookup(url) to retrieve specific distributed services.
  • [#83] Added mail_to HTML helper.
  • [#82] Added ACL support to mack-distributed
  • [#81] Fixed sessions working with redirects in testing
  • [#80] Distributed objects present both the DRb::DRbObject inspect and the original object’s inspect when asked.
  • [#79] Renamed app_config.mack.use_distributed_routes to app_config.mack.share_routes
  • [#76] Move mack_ring_server to mack-distributed
  • [#75] Left over mack-distributed rake tasks
  • [#74] Added optional feature to disable initialization logging.
  • [#73] Tests no longer use the functional/unit directories
  • [#69] Added ViewHelperGenerator and ControllerHelperGenerator
  • [#68] Transactional support in mack-AR
  • [#67] Added test:setup tasks for active_record and data_mapper
  • [#62] Removed const redefined warnings if mack-l10n is used along with mack-activerecord
  • [#39] HAML 2.0.2 support
  • [#28] Refactored out encryption into the mack-encryption gem.
  • [#25] Added ControllerGenerator
  • [#19] Added HTML form helpers
  • [#15] File upload testing support (ability to do multipart form post in testing)
  • [#11] Distributed Layout/Views
  • [#10] Added distributed objects to mack-distributed.
  • [#8] Move distributed code from mack-core to mack-more
  • [#5] Added tell messaging
  • gem: genosaurus 1.2.2
  • gem: haml 2.0.2
  • gem: addressable 1.0.4
  • gem: facets 2.4.3
  • gem: data_mapper 0.9.4

Ruby Opals

At RubyConf a bunch of us sat around a few glasses of beer and had a ‘bitch’ session about the state of Ruby Gems, a system we all consider be rather sub-par. At that session Tracy Flynn, friend and colleague of yours truly, said we should do something about it. He suggested we write RubyOpals. Well, Tracy is putting his money where his mouth is, http://github.com/tflynn/rubyopals/tree/master. I can tell you that I for one, can’t wait for Ruby Opals! I’ve already forked the project and started contributing! As soon as the first version is ready for release, I can tell you that Mack, Cachetastic, Genosaurus, etc… will all be the first available as opals.

I highly encourage all of you out there to add this project to your ‘watch’ list on GitHub. And if you have the time, and want to help write something special, I highly encourage you to fork it and start contributing! Time to get out there and start making the Ruby world a much, much, much better place.

Release 0.5.0

I know I’ve been talking about this release for a while now, and here it finally is. There’s some good bug fixes in here, a few new rake tasks, and some other little things like that.

The biggest thing, however, is what’s been causing a stir online now for the past few days, I’ve split out the ORM support into separate gems. I’m not going to go over it again, you can find all the details here: http://www.mackframework.com/2008/05/04/orms-and-mack/

Needless to say this is a good release to get, if not for the bug fixes alone, but for the great db:create rake tasks that are now in there. Thanks, again, to Darsono Sutedja for his great contributions.

Changelog

  • Added rake db:create and db:create:all rake tasks.
  • Refactored out constants, such as MACK_ROOT and MACK_ENV and made them into Mack::Configuration.env, Mack::Configuration.root, etc…
  • Added test:stats and test:coverage Rake tasks.
  • Removed support for ActiveRecord and DataMapper and moved them into their own gems.
  • Fixed a bug where yields in ERB weren’t giving the desired results.
  • DataMapper database.yml file can now be nested, and is generated as such.
  • Cleaned up some tests, and refactored the HTML generation stuff.
  • Fixed a bug with the scaffold generating ‘bad’ methods instead of ‘post’
  • Made error_messages_for more compatible with DataMapper.
  • Fixed a bug loading url.rb and uploaded_file.rb found by Phil Darnowsky
  • [dsutedja] Render method (in controller_base) now accepts response status code.
  • gem: mack_ruby_core_extensions 0.1.23
  • gem: genosaurus 1.1.4
  • gem: datamapper 0.3.2
  • gem: rcov 0.8.1.2.0
  • gem: mack-data_mapper 0.5.0
  • gem: erubis 2.6.0

Release 0.4.7

0.4.7 is a MUST have release. It fixes a few good bugs, like the ability to upload files now works! Plus it introduces a few nice little goodies.

File uploads are now pretty easy to do. There’s a new Mack::Request::UploadedFile that helps to wrap the Hash that Rack gives you when you upload a file. Here’s a simple example of it being used:

class UploadsController < Mack::Controller::Base
  def create
    @my_new_file = request.file(:my_new_file)
    @my_new_file.save_to([MACK_PUBLIC, "uploaded_files", @my_new_file.file_name])
  end
end

That’s it! That’s all you need to upload a file! I’m going to add file uploads to the blog demo over the next few days.

You can now do ‘namespaced’ routes, such as Admin::UserController. You can very simply map them in your routes.rb as:

r.resource "admin/users"

There’s now a new rake task, generator:list, that shows all the generators available to your app.

Darsono Sutedja gets the prize for being the first person, other than myself, to contribute to Mack. Thanks a ton Darsono! It’s much appreciated.

All of the generators now use the Genosaurus generator system. Not really that exciting, but it makes for a nice, cleaner code base.

There’s a few other things in there as well. The changelog below has a few more things. Enjoy!

Changelog:

  • Added Mack::Request::UploadFile class to make dealing with file uploads easy.
  • Fixed bug where if a controller didn’t exist it wasn’t checking the public directory.
  • Generated DataMapper models no longer extend DataMapper::Base, but rather ‘include DataMapper::Persistence’. This corresponds to the 0.9.0 upcoming release of DataMapper.
  • Fixed a bug in request.params that was making file uploads into strings.
  • Namespaced resourced routes, such as Admin::UserController, now work.
  • Added rake generator:list task to list all the available generators.
  • scaffold generator now creates a stub functional test.
  • model generator now creates a stub unit test.
  • Rake tasks in plugins now show up in the Rake tasks list.
  • All generators, including the ‘mack’ binary are now using Genosaurus.
  • [dsutedja] initializer will load MACK_APP/controllers/default_controller.rb if it exists
  • [dsutedja] added link_image_to and image_tag to html helper.
  • gem: thin 0.8.1
  • gem: genosaurus 1.1.1

Genosaurus 1.1.1

So this week I took a small break away from Mack to build another library, Genosaurus. I found that in Mack I had basically written a generator system, so I extracted it out into a stand alone library that anybody can use, and I called it Genosaurus. Genosaurus is, in my opinion, an incredibly easy to use generator framework. Let’s be honest, we’ve all basically built a generator system at one point or another, so I’ve just wrapped it up nicely. The next release of Mack, due out the end of this week, will have all it’s generators converted to use Genosaurus. Let’s take a look at a section of the README for Genosaurus:

Implied Manifests

The easiest way to use Genosaurus is to let it do the work for you. Let‘s looked at what‘s called an ‘implied’ manifest:

  dir:
    simple_generator.rb
    templates:
      hello_world.txt.template

That‘s our folder structure. Now let‘s look at simple_generator.rb:

  require 'rubygems'
  require 'genosaurus'

  class SimpleGenerator < Genosaurus
  end

Now if we run that generator:

  $irb: SimpleGenerator.run

We should get a file called hello_world.txt generated in the current directory. Yes, it truly is that simple! With implied manifests our directory structure under ‘templates’ tells the whole story, and Genosaurus is smart enough to figure it out. All the file names, and the same goes for folders, need to end in .template, and Genosaurus will do the rest. All the files will go through ERB before they generated, so you can put all your lovely little dynamic goodies in there. File, and folder, names also get run through ERB so you can even make the file name dynamic too! Let‘s look at a more complex example:

  dir:
    complex_generator.rb
    templates:
      app:
        views:
          <%=param(:name).plural%>.template:
            hello_world.html.erb
        models:
          <%=param(:name)%>.rb.template

Let‘s run our complex_generator.rb file:

  require 'rubygems'
  require 'genosaurus'

  class ComplexGenerator < Genosaurus
    require_param: name
  end

Now if we run that generator:

  $irb: ComplexGenerator.run("name" => "user")

Now you should end up with the following:

  app:
    views:
      users:
        hello_world.html.erb
    models:
      user.rb.template

In the ComplexGenerator we told Genosaurus that we are requiring that the parameter, name, be passed into it. We are then using that parameter to generate the names of some files and folders. Pretty cool, eh? See how simple that is.

Explicit Manifests

Explicit manifests are used when there is a manifest.yml supplied at the same level as the generator. If there is a manifest.yml file then implied manifests are not used. This means you have to define the entire generation process. This is great if you have a pretty complicated generator, as the manifest.yml is also sent through ERB before being loaded. Let‘s look at the manifest.yml file for our simple_generator example:

  template_1:
    type: file
    template_path: <%= File.join(templates_directory_path, "templates", "hello_world.txt.template")
    output_path: hello_world.txt

Pretty simple. We give the template a name, template_1, it really doesn‘t matter what it is, but Hash objects need keys. The ‘type’ parameter is either file or directory. The template_path is the path to the template. Finally, the output_path is the where you want the file to be generated. Let‘s look at our more complex example. We can change the directory structure a bit, since we really don‘t need ERB in the file names now:

  dir:
    complex_generator.rb
    templates:
      hello_world.html.erb.template
      model.rb.template

Our manifest.yml file would look like this:

  hello_world_template:
    type: file
    template_path: <%= File.join(templates_directory_path, "templates", "hello_world.html.erb")
    output_path: <%= File.join("app", "views", param(:name).plural, "hello_world.html.erb") %>
  model_template:
    type: file
    template_path: <%= File.join(templates_directory_path, "templates", "model.html.erb")
    output_path: <%= File.join("app", "models", "#{param(:name)}.rb") %>

This will generate the exact same thing as our implied manifest.