<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,24 +1,22 @@
 require &quot;ono/compiler&quot;
+require &quot;ono/model&quot;
 require &quot;pp&quot;
 
 module Ono
 
   class Builder
     attr_accessor :compiler_factory, :stdout
+    attr_reader :repository
 
     def initialize(out, opts)
       @stdout = out
-      if opts[:workspace]
-        @workspace = File.expand_path opts[:workspace]
-      else
-        @workspace = File.expand_path '.'
-      end
+      @repository = Repository.new(opts[:workspace] || '.')
       @compiler_factory = CompilerFactory.new(out)
-      @compiler_factory.workspace = @workspace
+      @compiler_factory.workspace = @repository.path
     end
 
     def build_target(target)
-      real_target = abs_path target
+      real_target = @repository.abs_path target
       if File.extname(real_target) == &quot;&quot;
         return build_executable(real_target)
       else
@@ -28,41 +26,37 @@ module Ono
         deps.each {|dep| build_target dep}
         compiler = @compiler_factory.get_compiler_for source
         args = []
-        args &lt;&lt; &quot;-I#{@workspace}&quot;
+        args &lt;&lt; &quot;-I#{@repository.path}&quot;
         return compiler.compile source, real_target, args
       end
     end
 
     private
 
-    def abs_path(target)
-      File.expand_path target, @workspace
-    end
-
     def build_executable(target)
       objname = target + &quot;.o&quot;
       return false unless build_target(objname)
       deps = find_deps target
       deps.each {|dep| build_target dep}
-      deps.map! {|dep| abs_path dep}
+      deps.map! {|dep| @repository.abs_path dep}
       compiler = @compiler_factory.get_compiler_for objname
       deps &lt;&lt; objname
       compiler.link deps, target
     end
 
     def find_deps(target)
-      abs_target = abs_path target
+      abs_target = @repository.abs_path target
       src = find_source_for target
       candidate_deps = []
       include_re = Regexp.new '^#include &quot;(.*)&quot;'
       File.open(src).each_line do |line|
         if include_re =~ line
-          header = abs_path Regexp.last_match(1)
+          header = @repository.abs_path Regexp.last_match(1)
           # TODO: Should compare absolute path here.
           basename = header.chomp(File.extname header)
           unless basename == abs_target.chomp(File.extname target)
             obj = basename + &quot;.o&quot;
-            candidate_deps &lt;&lt; obj if find_source_for(abs_path(obj))
+            candidate_deps &lt;&lt; obj if find_source_for(@repository.abs_path(obj))
           end
         end
       end</diff>
      <filename>lib/ono/builder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,11 @@ module Ono
         assert_equal File.expand_path(&quot;tmp&quot;, Dir.pwd), @repo.path
       end
 
+      should &quot;translate . to pwd&quot; do
+        @repo = Repository.new(&quot;.&quot;)
+        assert_equal Dir.pwd, @repo.path
+      end
+
       context &quot;when #file(..) is called&quot; do
         setup do
           @repo = Repository.new(File.join(TEST_DATA_DIR, &quot;ws1&quot;))</diff>
      <filename>test/test_model.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d960bab5d1c2040fe9462eb430e150f8c5d3b91d</id>
    </parent>
  </parents>
  <author>
    <name>Hong Jiang</name>
    <email>hong@hjiang.net</email>
  </author>
  <url>http://github.com/hjiang/ono/commit/02fe45ef1a45146be22f2680fdc574f7f29d1024</url>
  <id>02fe45ef1a45146be22f2680fdc574f7f29d1024</id>
  <committed-date>2009-10-16T00:10:03-07:00</committed-date>
  <authored-date>2009-10-16T00:10:03-07:00</authored-date>
  <message>refactor Builder to reuse model code</message>
  <tree>9c70ea4ee004cea2473c4ececda541643f63c651</tree>
  <committer>
    <name>Hong Jiang</name>
    <email>hong@hjiang.net</email>
  </committer>
</commit>
