Sha256: 305cbddfda62bb6b53553ebd44cb1feed89d7cb1461e6676a754a319f2778855

Contents?: true

Size: 970 Bytes

Versions: 6

Compression:

Stored size: 970 Bytes

Contents

require 'doc'

module Doc
  class Tasks
    include Rake::DSL

    attr_reader :documentor
    def initialize(*arguments, &block)
      @documentor = Documentor.new(*arguments, &block)
      define
    end

    def humanize_time(seconds)
      case seconds
      when 0...60
        '%.1fs' % seconds
      when 60...3600
        '%.1fm' % (seconds / 60)
      else
        '%.1fh' % (seconds / 3600)
      end
    end

    def count_time
      start = Time.now
      yield
      $stderr.puts "It took #{humanize_time(Time.now - start)}"
    end

  private

    def define
      task :default => :build

      task :config do
        count_time{ documentor.config }
      end

      desc 'build documentation'
      task :build do
        count_time{ documentor.build }
      end

      namespace :build do
        desc 'force update and build documentation'
        task :update do
          count_time{ documentor.build(true) }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doc-0.5.0 lib/doc/tasks.rb
doc-0.4.1 lib/doc/tasks.rb
doc-0.4.0 lib/doc/tasks.rb
doc-0.3.0 lib/doc/tasks.rb
doc-0.2.8 lib/doc/tasks.rb
doc-0.2.7 lib/doc/tasks.rb