Sha256: 14fb4ea42a73b2899a48ea396037fe1a4ea2757ac32545009e4893768474e65a
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'connie/connie' require 'connie/dictionary' require 'connie/parser' module Connie # class Railtie < Rails::Railtie # config.tabelle = ActiveSupport::OrderedOptions.new # # initializer "tabelle.tabelle" do |app| # ActiveSupport.on_load(:action_view) do # include Tabelle::Helper # end # # ActiveSupport.on_load(:action_controller) do # include Tabelle::Controller # append_view_path File.expand_path('views',File.dirname(__FILE__)) # end # end # # end @dictionaries_paths = [File.expand_path('dictionaries',File.dirname(__FILE__))] VERSION = File.exist?('VERSION') ? File.read('VERSION') : "" end # The shorthand method to use connie # Accepts three kinds of arguments: # # 1) String # Connie parses the string replacing the :dictionary.format bits of string with random # results from it's dictionaries # # 2) Symbols # Uses the symbol to pick the dictionary to return and eventually calls the format on # it. # # 3) Arrays # As a form of convenience Connie picks a random element out of the array passed # def Connie(argument, options={}) case argument when String Connie::Parser.process(argument) when Symbol argument = argument.to_s.split('.').map &:to_sym dictionary = Connie[argument.first] if argument[1] dictionary.send argument[1], options else dictionary end when Array argument[rand(argument.size)] else raise ArgumentError, 'Connie\'s shorthand expects a string to parse or a symbol or an array' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
connie-0.0.1 | lib/connie.rb |