Module: Sourcerer

Defined in:
lib/source.rb,
lib/sourcerer.rb,
lib/sourcerer/cache.rb,
lib/sourcerer/method.rb,
lib/sourcerer/helpers.rb,
lib/sourcerer/proc_source.rb,
lib/sourcerer/source_code.rb,
lib/sourcerer/proc_source_body.rb,
lib/sourcerer/proc_source_params.rb

Defined Under Namespace

Modules: MethodDSL Classes: Cache, ProcSource, ProcSourceBody, ProcSourceParams, SourceCode

Class Method Summary collapse

Class Method Details

.cacheObject



39
40
41
# File 'lib/sourcerer/helpers.rb', line 39

def cache
  Cache
end

.raw_source(obj) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sourcerer/helpers.rb', line 4

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