Sha256: a121f35070b911a7298450a5f4fddb11769cc76b01bd3df232e4d56a4e718b4f

Contents?: true

Size: 851 Bytes

Versions: 2

Compression:

Stored size: 851 Bytes

Contents

module Sourcerer
  class << self

    def raw_source obj

      # default values
      begin
        block = 0
        return_string = ProcSource.new
      end

      case RUBY_VERSION

        when "1.9.3"
          begin

            if obj.source_location.nil?
              puts "WARN: Native Ruby 1.9.3 can't return sourceless code sources"
              return "Proc.new { }"
            end

            SourceFile.open(File.expand_path(obj.source_location[0])
            ).each_line_from obj.source_location[1] do |line|
              line = SourceCode.new(line)
              block += line.source_formater_for_line_sub
              return_string.concat(line)
              break if block == 0
            end

            return return_string

          end

      end

      return nil
    end

    def cache
      Cache
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sourcerer-0.5.2 lib/sourcerer/helpers.rb
sourcerer-0.5.1 lib/sourcerer/helpers.rb