Sha256: bea0c10e9f07896a794bed4522da5a4869027fa29ededea3ad356ecfce3debae

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Jeka
  module Console
    
    def self.add_algorithms(dir)
      Jeka::Algorithm.reset
      ok = false
      Dir.glob(dir).each do |d|
        ok = true
        load d
      end
      ok
    end
    
    def self.run(n=1)
      error = false
      Jeka::Algorithm.run_all(n) do |p, t, o|
        self._show(p, t, o, false)
      end
    end
    
    def self.build
      error = false
      Jeka::Algorithm.build_all do |p, t, o|
        self._show(p, t, o, true)
      end
    end
    
    def self._show(p, t, o, s)
      case t
        when :step
          p = p.to_s
          while p.length < 3
            p = " " + p
          end
          puts "[#{p}%] #{o}"
        when :output
          if s
            o = o.join
            if o.length > 0
              puts o
            end
          end
        when :error
          o = o.join
          if o.length > 0
            puts o
          end
          error = true
        when :done
          if error
            puts "[100%] Some error occurs..."
          else
            puts "[100%] Done!"
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jeka-0.2.1 lib/jeka/console.rb