You are here: Browse Railsplugins Glossary
The Glossary DSL is a generalized way to define descriptions of items in an object graph. It supports globbing to reduce the need for duplicate entries, and also supports internationalization.
Let’s say you want to give descriptions to music genres, artists in those genres, and albums by those artists.
Glossary.support :genre, :artist, :album do
matching "Pop//*" do
en "A pop song, so it sucks."
arb "Ughnia min now'a al-Pop, hakitha hia sayiya"
end
matching "/The Beatles/The White Album" do
en 'The ninth official album by The Beatles, a double album released in 1968 (whose actual title is "The Beatles")'
end
matching "/*/The * Album" do
en "An album with a name derivative of The White Album by The Beatles"
end
matching "Indie/Bright Eyes/Road to Joy" do
en "A politically motivated song whose melody is based on Beethoven's 9th Symphony (Ode to Joy)"
mya "A Burmese translation"
jp "A Japanese translation"
end
end
By convention, this assumes you have objects with class names like Genre, Artist, and Album, those objects have an instance variable called ‘name’ and, from the bottom-up, can determine their structure (ie, Albums have an ‘artist,’ Artists have a ‘genre,’ etc).
Then, go get the definition for a specific item:
puts Glossary[some_pop_song_instance] #=> "A pop song, so it probably sucks."
puts Glossary[some_pop_song_instance].to_s(:arb) #=> "Ughnia min now'a al-Pop, hakitha hia sayiya"
You’ll also notice the most specific match wins, as in this White Album example:
puts Glossary[the_white_album] #=> "The ninth official album by The Beatles..."
Even though the “The * Album” pattern comes after the “The White Album” pattern in the DSL, because there’s a more specific match it’s ignored.
== For FiveRuns
A simple example of this in use for Subsystems/Categories/Metrics would be:
matching 'OSX//*' do
en "An OSX metric"
end
NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly