Top Level Namespace
Defined Under Namespace
Modules: ApplicationHelper, Concept, ConceptsHelper, DashboardHelper, FormHelper, Iqvoc, NavigationHelper, RdfHelper, SearchExtension, SearchResultsHelper, WidgetHelper Classes: ApplicationController, CollectionsController, ConceptsController, ConfigurationSetting, DashboardController, FrontpageController, ImportController, InstanceConfigurationController, PagesController, RdfController, RdfStore, SearchResultsController, String, TripleStoreSyncsController, User, UserSession, UserSessionsController, UsersController
Constant Summary collapse
- CSV =
FCSV
Instance Method Summary collapse
-
#dbg(*args, &block) ⇒ Object
prints arguments to STDOUT or log depending on context optional block should return an array of values; the resulting output is then wrapped in separator lines the last argument may be an options hash with members :inspect and/or :tag.
Instance Method Details
#dbg(*args, &block) ⇒ Object
prints arguments to STDOUT or log depending on context optional block should return an array of values; the resulting output is then wrapped in separator lines the last argument may be an options hash with members :inspect and/or :tag
examples:
dbg("IMPORTANT", foo, )
dbg { [lipsum] }
dbg(foo, , :inspect => false, :tag => false) do |args|
args << lorem
args << ipsum
end
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/debug.rb', line 15 def dbg(*args, &block) defaults = { :inspect => true, :tag => true } = args.last.is_a?(Hash) && (defaults.keys & args.last.keys).any? = defaults.merge( ? args.pop : {}) tty = defined?(Rails::Console) || Rails.env.test? # STDOUT is usually available here meth = tty ? method(:puts) : Rails.logger.method(:debug) if block meth.call "=" * 80 block_args = yield [] # XXX: ideally we'd pass the `dbg` method itself here, but the need for `.call` makes for a weird API block_args << dbg(*block_args) meth.call "-" * 80 return unless args.length > 0 end prefix = "#{args.shift} " if [String, Symbol].include?(args.first.class) # XXX: undocumented and unexpected serializer = [:inspect] ? :inspect : :to_s msg = args.map(&serializer).join(" | ") msg = "#{prefix}#{msg}" msg = "[DEBUG] #{msg}" if [:tag] meth.call msg end |