Sha256: 0a9cfddd76cc6befddc8256cc171094eacae6554b9af678ffee7c263861b6f2e

Contents?: true

Size: 865 Bytes

Versions: 19

Compression:

Stored size: 865 Bytes

Contents

require 'librarian/support/abstract_method'

module Librarian
  module Helpers
    module Debug

      include Support::AbstractMethod

      LIBRARIAN_PATH = Pathname.new('../../../../').expand_path(__FILE__)

      abstract_method :environment

    private

      def relative_path_to(path)
        environment.project_relative_path_to(path)
      end

      def debug
        if ui = environment.ui
          if ui.respond_to? :debug_line_numbers and ui.debug_line_numbers
            loc = caller.find{|l| !(l =~ /in `debug'$/)}
            if loc =~ /^(.+):(\d+):in `(.+)'$/
              loc = "#{Pathname.new($1).relative_path_from(LIBRARIAN_PATH)}:#{$2}:in `#{$3}'"
            end
            ui.debug { "[Librarian] #{yield} [#{loc}]" }
          else
            ui.debug { "[Librarian] #{yield}" }
          end
        end
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
librarian-0.0.24 lib/librarian/helpers/debug.rb
librarian-puppet-0.9.1 vendor/librarian/lib/librarian/helpers/debug.rb
librarian-puppet-0.9.0 vendor/librarian/lib/librarian/helpers/debug.rb
librarian-puppet-0.0.1.pre2 vendor/librarian/lib/librarian/helpers/debug.rb
librarian-puppet-0.0.1.pre vendor/librarian/lib/librarian/helpers/debug.rb
librarian-0.0.23 lib/librarian/helpers/debug.rb
librarian-0.0.22 lib/librarian/helpers/debug.rb
librarian-0.0.21 lib/librarian/helpers/debug.rb
librarian-0.0.20 lib/librarian/helpers/debug.rb
librarian-0.0.19 lib/librarian/helpers/debug.rb
librarian-0.0.18 lib/librarian/helpers/debug.rb
librarian-0.0.17 lib/librarian/helpers/debug.rb
librarian-0.0.16 lib/librarian/helpers/debug.rb
librarian-0.0.15 lib/librarian/helpers/debug.rb
librarian-0.0.14 lib/librarian/helpers/debug.rb
librarian-0.0.13 lib/librarian/helpers/debug.rb
librarian-0.0.12 lib/librarian/helpers/debug.rb
librarian-0.0.11 lib/librarian/helpers/debug.rb
librarian-0.0.10 lib/librarian/helpers/debug.rb