~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to lib/rake/loaders/makefile.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
  # Makefile loader to be used with the import file loader.
4
4
  class MakefileLoader
 
5
    include Rake::DSL
 
6
 
5
7
    SPACE_MARK = "\0"
6
8
 
7
9
    # Load the makefile dependencies in +fn+.
8
10
    def load(fn)
9
 
      lines = open(fn) {|mf| mf.read}
 
11
      lines = File.read fn
10
12
      lines.gsub!(/\\ /, SPACE_MARK)
11
13
      lines.gsub!(/#[^\n]*\n/m, "")
12
14
      lines.gsub!(/\\\n/, ' ')
21
23
    def process_line(line)
22
24
      file_tasks, args = line.split(':', 2)
23
25
      return if args.nil?
24
 
      dependents = args.split.map {|arg| respace(arg)}
 
26
      dependents = args.split.map { |d| respace(d) }
25
27
      file_tasks.scan(/\S+/) do |file_task|
26
28
        file_task = respace(file_task)
27
29
        file file_task => dependents
29
31
    end
30
32
 
31
33
    def respace(str)
32
 
      str.tr(SPACE_MARK, ' ')
 
34
      str.tr SPACE_MARK, ' '
33
35
    end
34
36
  end
35
37