Module: Jeka::Console

Defined in:
lib/jeka/console.rb

Class Method Summary collapse

Class Method Details

._show(p, t, o, s) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jeka/console.rb', line 25

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

.add_algorithms(dir) ⇒ Object



4
5
6
7
8
9
# File 'lib/jeka/console.rb', line 4

def self.add_algorithms(dir)
  Jeka::Algorithm.reset
  Dir.glob(dir).each do |d|
    load d
  end
end

.buildObject



18
19
20
21
22
23
# File 'lib/jeka/console.rb', line 18

def self.build
  error = false
  Jeka::Algorithm.build_all do |p, t, o|
    self._show(p, t, o, true)
  end
end

.run(n) ⇒ Object



11
12
13
14
15
16
# File 'lib/jeka/console.rb', line 11

def self.run(n)
  error = false
  Jeka::Algorithm.run_all(n) do |p, t, o|
    self._show(p, t, o, false)
  end
end