Plugins - Codex

StarAdd to favorites

Codex is a set of modules that lets you get that text out of your code. Really, it’s a pain in the ass to keep your flash messages and other bits of text inside source files. Now you can store them in shiny clean yml.

Here’s the deal:

  1. Each class has its own unique hash, consisting of the contents of application.yml merged with those of class_name.yml. This means, you can set a default error message in application.yml and then override if for specific classes as the need arises.
  2. You can have as many codices as you want, and you can switch between them at will. So you could have one codex will all of your messages in spanish, one in english, and one in republican. You get the idea.
  3. We have some utility methods to automate (kind of) flash messages. From within a controller action, you can now do this:
     flash_state :success (or :failure, or :dreadful, or :whatever)
    

We also have some test helper methods to assert_flash_state :success, etc.

Installation

  1. create /app/codices/default
  2. create application.yml and a yml file for each class that will use Codex (class_name.yml)
  3. include Codex::Base & Codex::ControllerExtensions in application.rb (or other controllers). You can also use Codex::Base in models, or any other class
  4. include Codex::TestHelper in test_helper.rb

Usage

  • instance_of_a_class.codex — Returns the codex for that class.
  • flash_state :success — Within a controller action sets flash[:notice] = codex[action][:success]
  • assert_flash_state :success — In a functional test, asserts that flash[:notice] == codex[action][:success]
  • set_codex ‘spanish’ — change the current codex to the one found in app/codices/spanish

http://svn.thebootstrapnation.com/public/plugins/codex/

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Misc. Enhancements

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?