Sha256: 61f2897814709237efd3ee2f35e56227fd5c6ba6f6e5805d943cdd72810b4644

Contents?: true

Size: 962 Bytes

Versions: 9

Compression:

Stored size: 962 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
      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

9 entries across 9 versions & 1 rubygems

Version Path
doc-0.2.6 lib/doc/tasks.rb
doc-0.2.5 lib/doc/tasks.rb
doc-0.2.4 lib/doc/tasks.rb
doc-0.2.3 lib/doc/tasks.rb
doc-0.2.2 lib/doc/tasks.rb
doc-0.2.1 lib/doc/tasks.rb
doc-0.2.0 lib/doc/tasks.rb
doc-0.1.0 lib/doc/tasks.rb
doc-0.0.1 lib/doc/tasks.rb