<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/jake/application.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -28,7 +28,8 @@ var FILE = require(&quot;file&quot;),
     Task = require(&quot;jake/task&quot;).Task,
     FileTask = require(&quot;jake/filetask&quot;).FileTask,
     FileCreationTask = require(&quot;jake/filecreationtask&quot;).FileCreationTask,
-    TaskManager = require(&quot;jake/taskmanager&quot;).TaskManager;
+    TaskManager = require(&quot;jake/taskmanager&quot;).TaskManager,
+    Application = require(&quot;jake/application&quot;).Application;
 
 // FIXME: MAJOR hack to get globs working.
 FILE.glob = function(aPattern)
@@ -40,560 +41,6 @@ FILE.glob = function(aPattern)
     return FILE.read(&quot;/tmp/glob_fixme.txt&quot;, {charsert:&quot;UTF-8&quot;}).split('\n').slice(0, -1);
 }
 
-var DEFAULT_JAKEFILES = [&quot;jakefile&quot;, &quot;Jakefile&quot;, &quot;jakefile.js&quot;, &quot;Jakefile.js&quot;, &quot;jakefile.j&quot;, &quot;Jakefile.j&quot;];
-
-var Application = function()
-{
-    TaskManager.call(this);
-
-    this._name = &quot;jake&quot;;
-    this._jakefiles = DEFAULT_JAKEFILES.slice();
-    this._jakefile = null;
-    this._options = { };
-//    this._pendingImports = [];
-//    this._imported = [];
-//    this.loaders = { };
-//    this.defaultLoader = Rake::DefaultLoader.new
-    this._originalDirectory = FILE.cwd();
-    this._topLevelTasks = [];
-/*
-      add_loader('rb', DefaultLoader.new)
-      add_loader('rf', DefaultLoader.new)
-      add_loader('rake', DefaultLoader.new)
-      @tty_output = STDOUT.tty?*/
-}
-
-Application.__proto__ = TaskManager;
-Application.prototype.__proto__ = TaskManager.prototype;
-
-// Run the Rake application.  The run method performs the following three steps:
-//
-// * Initialize the command line options (+init+).
-// * Define the tasks (+loadRakefile+).
-// * Run the top level tasks (+runTasks+).
-//
-// If you wish to build a custom rake command, you should call +init+ on your
-// application.  The define any tasks.  Finally, call +topLevel+ to run your top
-// level tasks.
-Application.prototype.run = function()
-{
-    this.init();
-    this.loadJakefile();
-    this.topLevel();
-}
-
-// Initialize the command line parameters and app name.
-Application.prototype.init = function(/*String*/ anApplicationName)
-{
-    this._name = anApplicationName || &quot;jake&quot;;
-//    this.handleOptions();
-//FIXME: options
-    this.collectTasks();
-}
-
-// Find the rakefile and then load it and any pending imports.
-Application.prototype.loadJakefile = function()
-{
-    this.rawLoadJakefile();
-}
-
-// Run the top level tasks of a Rake application.
-Application.prototype.topLevel = function()
-{/*
-    if (options.showTasks())
-        this.displayTasksAndComments();
-    
-    else if (options.showPrereqs)
-        this.displayPreq;
-    else
-*/
-    this._topLevelTasks.forEach(function(/*String*/ aTaskName)
-    {
-        this.invokeTask(aTaskName);
-    }, this);
-}
-
-/*
-    # Add a loader to handle imported files ending in the extension
-    # +ext+.
-Application.prototype.
-
-    def add_loader(ext, loader)
-      ext = &quot;.#{ext}&quot; unless ext =~ /^\./
-      @loaders[ext] = loader
-    end
-
-    # Application options from the command line
-    def options
-      @options ||= OpenStruct.new
-    end
-
-    # private ----------------------------------------------------------------
-*/
-
-Application.prototype.invokeTask = function(/*String*/ aTaskString)
-{
-    var result = this.parseTaskString(aTaskString),
-        task = this.lookupTask(result[0]);
-
-    task.invoke.apply(task, result[1]);
-}
-
-Application.prototype.parseTaskString = function(/*String*/ aString)
-{
-    var matches = aString.match(/^([^\[]+)(\[(.*)\])$/);
-
-    if (matches)
-        return [matches[0], matches[3].split(/\s*,\s*/)];
-
-    return [aString, []];
-}
-/*
-    # Provide standard execption handling for the given block.
-    def standard_exception_handling
-      begin
-        yield
-      rescue SystemExit =&gt; ex
-        # Exit silently with current status
-        exit(ex.status)
-      rescue SystemExit, OptionParser::InvalidOption =&gt; ex
-        # Exit silently
-        exit(1)
-      rescue Exception =&gt; ex
-        # Exit with error message
-        $stderr.puts &quot;#{name} aborted!&quot;
-        $stderr.puts ex.message
-        if options.trace
-          $stderr.puts ex.backtrace.join(&quot;\n&quot;)
-        else
-          $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || &quot;&quot;
-          $stderr.puts &quot;(See full trace by running task with --trace)&quot;
-        end
-        exit(1)
-      end
-    end
-*/
-
-// True if one of the files in RAKEFILES is in the current directory.
-// If a match is found, it is copied into @rakefile.
-Application.prototype.hasJakefile = function(/*String*/ aDirectory)
-{
-    var jakefiles = this._jakefiles,
-        index = 0,
-        count = jakefiles.length;
-
-    for (; index &lt; count; ++index)
-    {
-        var jakefile = jakefiles[index];
-
-        if (FILE.exists(FILE.join(aDirectory, jakefile)))
-            return jakefile;
-
-        else if (jakefile === &quot;&quot;)
-            return null;
-    }
-    
-    return null;
-}
-/*
-    # True if we are outputting to TTY, false otherwise
-    def tty_output?
-      @tty_output
-    end
-
-    # Override the detected TTY output state (mostly for testing)
-    def tty_output=( tty_output_state )
-      @tty_output = tty_output_state
-    end
-
-    # We will truncate output if we are outputting to a TTY or if we've been
-    # given an explicit column width to honor
-    def truncate_output?
-      tty_output? || ENV['RAKE_COLUMNS']
-    end
-
-    # Display the tasks and comments.
-    def display_tasks_and_comments
-      displayable_tasks = tasks.select { |t|
-        t.comment &amp;&amp; t.name =~ options.show_task_pattern
-      }
-      if options.full_description
-        displayable_tasks.each do |t|
-          puts &quot;#{name} #{t.name_with_args}&quot;
-          t.full_comment.split(&quot;\n&quot;).each do |line|
-            puts &quot;    #{line}&quot;
-          end
-          puts
-        end
-      else
-        width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
-        max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
-        displayable_tasks.each do |t|
-          printf &quot;#{name} %-#{width}s  # %s\n&quot;,
-            t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
-        end
-      end
-    end
-
-    def terminal_width
-      if ENV['RAKE_COLUMNS']
-        result = ENV['RAKE_COLUMNS'].to_i
-      else
-        result = unix? ? dynamic_width : 80
-      end
-      (result &lt; 10) ? 80 : result
-    rescue
-      80
-    end
-
-    # Calculate the dynamic width of the 
-    def dynamic_width
-      @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
-    end
-
-    def dynamic_width_stty
-      %x{stty size 2&gt;/dev/null}.split[1].to_i
-    end
-
-    def dynamic_width_tput
-      %x{tput cols 2&gt;/dev/null}.to_i
-    end
-
-    def unix?
-      RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
-    end
-    
-    def windows?
-      Win32.windows?
-    end
-
-    def truncate(string, width)
-      if string.length &lt;= width
-        string
-      else
-        ( string[0, width-3] || &quot;&quot; ) + &quot;...&quot;
-      end
-    end
-
-    # Display the tasks and prerequisites
-    def display_prerequisites
-      tasks.each do |t|
-        puts &quot;#{name} #{t.name}&quot;
-        t.prerequisites.each { |pre| puts &quot;    #{pre}&quot; }
-      end
-    end
-
-    # A list of all the standard options used in rake, suitable for
-    # passing to OptionParser.
-    def standard_rake_options
-      [
-        ['--classic-namespace', '-C', &quot;Put Task and FileTask in the top level namespace&quot;,
-          lambda { |value|
-            require 'rake/classic_namespace'
-            options.classic_namespace = true
-          }
-        ],
-        ['--describe', '-D [PATTERN]', &quot;Describe the tasks (matching optional PATTERN), then exit.&quot;,
-          lambda { |value|
-            options.show_tasks = true
-            options.full_description = true
-            options.show_task_pattern = Regexp.new(value || '')
-          }
-        ],
-        ['--dry-run', '-n', &quot;Do a dry run without executing actions.&quot;,
-          lambda { |value|
-            verbose(true)
-            nowrite(true)
-            options.dryrun = true
-            options.trace = true
-          }
-        ],
-        ['--execute',  '-e CODE', &quot;Execute some Ruby code and exit.&quot;,
-          lambda { |value|
-            eval(value)
-            exit
-          }
-        ],
-        ['--execute-print',  '-p CODE', &quot;Execute some Ruby code, print the result, then exit.&quot;,
-          lambda { |value|
-            puts eval(value)
-            exit
-          }
-        ],
-        ['--execute-continue',  '-E CODE',
-          &quot;Execute some Ruby code, then continue with normal task processing.&quot;,
-          lambda { |value| eval(value) }            
-        ],
-        ['--libdir', '-I LIBDIR', &quot;Include LIBDIR in the search path for required modules.&quot;,
-          lambda { |value| $:.push(value) }
-        ],
-        ['--prereqs', '-P', &quot;Display the tasks and dependencies, then exit.&quot;,
-          lambda { |value| options.show_prereqs = true }
-        ],
-        ['--quiet', '-q', &quot;Do not log messages to standard output.&quot;,
-          lambda { |value| verbose(false) }
-        ],
-        ['--rakefile', '-f [FILE]', &quot;Use FILE as the rakefile.&quot;,
-          lambda { |value| 
-            value ||= ''
-            @rakefiles.clear 
-            @rakefiles &lt;&lt; value
-          }
-        ],
-        ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
-          &quot;Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')&quot;,
-          lambda { |value| options.rakelib = value.split(':') }
-        ],
-        ['--require', '-r MODULE', &quot;Require MODULE before executing rakefile.&quot;,
-          lambda { |value|
-            begin
-              require value
-            rescue LoadError =&gt; ex
-              begin
-                rake_require value
-              rescue LoadError =&gt; ex2
-                raise ex
-              end
-            end
-          }
-        ],
-        ['--rules', &quot;Trace the rules resolution.&quot;,
-          lambda { |value| options.trace_rules = true }
-        ],
-        ['--no-search', '--nosearch', '-N', &quot;Do not search parent directories for the Rakefile.&quot;,
-          lambda { |value| options.nosearch = true }
-        ],
-        ['--silent', '-s', &quot;Like --quiet, but also suppresses the 'in directory' announcement.&quot;,
-          lambda { |value|
-            verbose(false)
-            options.silent = true
-          }
-        ],
-        ['--system',  '-g',
-          &quot;Using system wide (global) rakefiles (usually '~/.rake/*.rake').&quot;,
-          lambda { |value| options.load_system = true }
-        ],
-        ['--no-system', '--nosystem', '-G',
-          &quot;Use standard project Rakefile search paths, ignore system wide rakefiles.&quot;,
-          lambda { |value| options.ignore_system = true }
-        ],
-        ['--tasks', '-T [PATTERN]', &quot;Display the tasks (matching optional PATTERN) with descriptions, then exit.&quot;,
-          lambda { |value|
-            options.show_tasks = true
-            options.show_task_pattern = Regexp.new(value || '')
-            options.full_description = false
-          }
-        ],
-        ['--trace', '-t', &quot;Turn on invoke/execute tracing, enable full backtrace.&quot;,
-          lambda { |value|
-            options.trace = true
-            verbose(true)
-          }
-        ],
-        ['--verbose', '-v', &quot;Log message to standard output.&quot;,
-          lambda { |value| verbose(true) }
-        ],
-        ['--version', '-V', &quot;Display the program version.&quot;,
-          lambda { |value|
-            puts &quot;rake, version #{RAKEVERSION}&quot;
-            exit
-          }
-        ]
-      ]
-    end
-
-    # Read and handle the command line options.
-    def handle_options
-      options.rakelib = ['rakelib']
-
-      OptionParser.new do |opts|
-        opts.banner = &quot;rake [-f rakefile] {options} targets...&quot;
-        opts.separator &quot;&quot;
-        opts.separator &quot;Options are ...&quot;
-
-        opts.on_tail(&quot;-h&quot;, &quot;--help&quot;, &quot;-H&quot;, &quot;Display this help message.&quot;) do
-          puts opts
-          exit
-        end
-
-        standard_rake_options.each { |args| opts.on(*args) }
-      end.parse!
-
-      # If class namespaces are requested, set the global options
-      # according to the values in the options structure.
-      if options.classic_namespace
-        $show_tasks = options.show_tasks
-        $show_prereqs = options.show_prereqs
-        $trace = options.trace
-        $dryrun = options.dryrun
-        $silent = options.silent
-      end
-    end
-
-    # Similar to the regular Ruby +require+ command, but will check
-    # for *.rake files in addition to *.rb files.
-    def rake_require(file_name, paths=$LOAD_PATH, loaded=$&quot;)
-      return false if loaded.include?(file_name)
-      paths.each do |path|
-        fn = file_name + &quot;.rake&quot;
-        full_path = File.join(path, fn)
-        if File.exist?(full_path)
-          load full_path
-          loaded &lt;&lt; fn
-          return true
-        end
-      end
-      fail LoadError, &quot;Can't find #{file_name}&quot;
-    end
-*/
-
-Application.prototype.findJakefileLocation = function()
-{
-    var directory = FILE.cwd(),
-        filename = null;
-
-    while (!(filename = this.hasJakefile(directory)))// &amp;&amp; !this._options.nosearch)
-        directory = FILE.join(directory, &quot;..&quot;);
-
-    if (!filename)
-        return null;
-
-    return [filename, directory];
-}
-
-Application.prototype.rawLoadJakefile = function()
-{
-    var result = this.findJakefileLocation(),
-        jakefile = result ? result[0] : null,
-        location = result ? result[1] : null,
-        options = this._options;
-/*
-    if (!options.ignore_system &amp;&amp; (options.load_system || !rakefile) &amp;&amp; system_dir &amp;&amp; FILE.directory?(system_dir)
-        if (options[&quot;silent&quot;])
-            print(&quot;(in &quot;);
-        puts &quot;(in #{Dir.pwd})&quot; unless options.silent
-        glob(&quot;#{system_dir}/*.rake&quot;) do |name|
-          add_import name
-        end
-    }
-    else*/
-    {
-        if (!jakefile)
-            throw &quot;No Jakefile found (looking for: &quot; + this._jakefiles.join(', ') + &quot;)&quot;;
-
-        this._jakefile = jakefile;
-
-//        file.chdir(location);
-
-        if (!options[&quot;silent&quot;])
-            print(&quot;(in &quot; + FILE.cwd() + &quot;)&quot;);
-
-//        $rakefile = @rakefile if options.classic_namespace
-
-        if (jakefile &amp;&amp; jakefile.length)//expand_path?
-            require(FILE.absolute(FILE.join(location, jakefile)));
-
-/*        options.rakelib.each do |rlib|
-          glob(&quot;#{rlib}/*.rake&quot;) do |name|
-            add_import name
-          end
-          */
-      }
-      //load_imports
-}
-
-/*
-    def glob(path, &amp;block)
-      Dir[path.gsub(&quot;\\&quot;, '/')].each(&amp;block)
-    end
-    private :glob
-*/
-/*
-    # The directory path containing the system wide rakefiles.
-    def system_dir
-      @system_dir ||=
-        begin
-          if ENV['RAKE_SYSTEM']
-            ENV['RAKE_SYSTEM']
-          elsif Win32.windows?
-            Win32.win32_system_dir
-          else
-            standard_system_dir
-          end
-        end
-    end
-    
-    # The standard directory containing system wide rake files.
-    def standard_system_dir #:nodoc:
-      File.join(File.expand_path('~'), '.rake')
-    end
-    private :standard_system_dir
-*/
-
-// Collect the list of tasks on the command line.  If no tasks are
-// given, return a list containing only the default task.
-// Environmental assignments are processed at this time as well.
-Application.prototype.collectTasks = function()
-{
-    this._topLevelTasks = [];
-
-    var topLevelTasks = this._topLevelTasks;
-
-    SYSTEM.args.slice(1).forEach(function(/*String*/ anArgument)
-    {
-        var matches = anArgument.match(/^(\w+)=(.*)$/);
-
-        if (matches)
-            SYSTEM.env[matches[1]] = matches[2];
-
-        else if (!anArgument.match(/^-/))
-            topLevelTasks.push(anArgument);
-    });
-
-    if (topLevelTasks.length &lt;= 0)
-        topLevelTasks.push(&quot;default&quot;);
-}
-/*
-    # Add a file to the list of files to be imported.
-    def add_import(fn)
-      @pending_imports &lt;&lt; fn
-    end
-
-    # Load the pending list of imported files.
-    def load_imports
-      while fn = @pending_imports.shift
-        next if @imported.member?(fn)
-        if fn_task = lookup(fn)
-          fn_task.invoke
-        end
-        ext = File.extname(fn)
-        loader = @loaders[ext] || @default_loader
-        loader.load(fn)
-        @imported &lt;&lt; fn
-      end
-    end
-
-    # Warn about deprecated use of top level constant names.
-    def const_warning(const_name)
-      @const_warning ||= false
-      if ! @const_warning
-        $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } +
-          %{found at: #{rakefile_location}} # '
-        $stderr.puts %{    Use --classic-namespace on rake command}
-        $stderr.puts %{    or 'require &quot;rake/classic_namespace&quot;' in Rakefile}
-      end
-      @const_warning = true
-    end
-
-    def rakefile_location
-      begin
-        fail
-      rescue RuntimeError =&gt; ex
-        ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || &quot;&quot;
-      end
-    end
-  */
-
 // Exports
 exports.Task = Task;
 exports.FileTask = FileTask;</diff>
      <filename>lib/jake.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c3e449073ae8686fee0785431f2a8de6baff7025</id>
    </parent>
  </parents>
  <author>
    <name>Francisco Tolmasky</name>
    <email>francisco@280north.com</email>
  </author>
  <url>http://github.com/280north/jake/commit/9999a05e7db4978a9e105d3b9144344506d63b88</url>
  <id>9999a05e7db4978a9e105d3b9144344506d63b88</id>
  <committed-date>2009-10-26T12:15:14-07:00</committed-date>
  <authored-date>2009-10-26T12:15:14-07:00</authored-date>
  <message>Split application out into its own file and added build times reporting.

Reviewed by me.</message>
  <tree>0089bf48f5bafc0e03ad790a3f2b5938bc720f4c</tree>
  <committer>
    <name>Francisco Tolmasky</name>
    <email>francisco@280north.com</email>
  </committer>
</commit>
