bin/ciwatch in matrixci-0.0.5 vs bin/ciwatch in matrixci-0.0.6
- old
+ new
@@ -1,7 +1,69 @@
#!/usr/bin/env ruby
+require 'json'
+require 'matrixci'
+require 'rbcurse/core/util/app'
+
+class CellRenderer
+ attr_accessor :display_length
+
+ def repaint g, r, c, crow, content, focus_type, selected
+ color = $datacolor
+ att = NORMAL
+ att = REVERSE if selected
+ build = JSON.parse(content)
+ color = get_color($datacolor, :yellow, :black) if build["color"] == "yellow"
+ color = get_color($datacolor, :red, :black) if build["color"] == "red"
+ color = get_color($datacolor, :green, :black) if build["color"] == "green"
+ g.wattron(Ncurses.COLOR_PAIR(color) | att)
+ g.mvwprintw(r, c, "%s", :string, build["str"]);
+ g.wattroff(Ncurses.COLOR_PAIR(color) | att)
+ rescue JSON::ParserError
+ end
+end
+
+def get_latest_runs
+ builds = []
+ MatrixCi::Project.all.each do |project|
+ project.all_recent_builds.each do |build|
+ builds << build.to_json
+ end
+ end
+
+ builds
+end
+
+x = App.new do
+ header = app_header "MatrixCI", :text_center => "YOLO", :text_right =>"MatrixCI",
+ :color => :black, :bgcolor => :white, :attr => :bold
+ message "You are in a crowded room. Lots of people are committing code. There is only one obvious exit, q."
+
+ lb = listbox :list => get_latest_runs, :title => "[ Latest Builds ]", :name => "tasklist", :row => 1, :height => Ncurses.LINES-4, :width => Ncurses.COLS-1
+ lb.truncation_required = false
+ lb.should_show_focus = false
+ lb.cell_renderer CellRenderer.new
+
+ @form.bind_key("q") { exit }
+ @form.bind_key("r") { lb.list get_latest_runs }
+ stack :margin_top => 1, :height => FFI::NCurses.LINES-3 do
+
+ end # stack
+ status_line :row => FFI::NCurses.LINES-1
+
+ while true
+ lb.list get_latest_runs
+ @form.repaint
+ @window.wrefresh
+ sleep(1)
+ end
+end # app
+
while true
- puts Time.now.utc
- system("ci all")
- sleep(30)
+ x.refresh
+ sleep(10)
end
+# while true
+# puts Time.now.utc
+# system("ci all")
+# sleep(30)
+# end