Skip to content

Commit

Permalink
Added pom, pickone; added --sparky option to autovalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrady committed May 12, 2009
1 parent 3294fb1 commit b332593
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
30 changes: 28 additions & 2 deletions autovalidate
Expand Up @@ -7,10 +7,12 @@
require 'appscript'
require 'libxml'
require 'ruby-debug'
require 'sparky'
include Appscript

class XmlValidateWatcher
attr_reader :xml, :xsd, :errors, :xmlstat, :xsdstat
@@use_sparky = 0

def initialize(xml, xsd)
@xml, @xsd = xml, xsd
Expand All @@ -19,8 +21,21 @@ class XmlValidateWatcher

iterm = Appscript::app('iTerm')
@term = iterm.current_terminal.sessions.get.find {|sess| sess.get == iterm.current_terminal.current_session.get }
end

@sparky = Sparky.new if use_sparky?
end

def self.use_sparky!
@@use_sparky = true
end

def self.no_sparky!
@@use_sparky = false
end

def use_sparky?
@@use_sparky
end

def header
puts "\033[2J\033[H"
Expand All @@ -31,13 +46,16 @@ class XmlValidateWatcher

def red
@term.background_color.set [32768, 0, 0]
@sparky.reset && @sparky.failed if use_sparky?
end

def green
@term.background_color.set [0, 32768, 0]
@sparky.reset && @sparky.pass if use_sparky?
end

def validate
@sparky.reset && @sparky.run if use_sparky?
header
result = false
begin
Expand Down Expand Up @@ -66,7 +84,15 @@ class XmlValidateWatcher
end

if $0 == __FILE__
watcher = XmlValidateWatcher.new(ARGV[0], ARGV[1])
args = ARGV.dup
if args.include?("--sparky")
XmlValidateWatcher.use_sparky!
args.delete("--sparky")
else
XmlValidateWatcher.no_sparky!
end

watcher = XmlValidateWatcher.new(args[0], args[1])
watcher.run
end

11 changes: 11 additions & 0 deletions pickone
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

srand(Time.now.to_i)

choice = nil
num = 0
$stdin.each_line do |line|
num += 1
choice = line if rand(num) == 0
end
puts choice
6 changes: 6 additions & 0 deletions pom
@@ -0,0 +1,6 @@
#!/bin/sh

# Choose a pom- word at random from dictionary (for Pomodoro worksheet
# titles)
grep -Ei '^pom' /usr/share/dict/words | pickone

0 comments on commit b332593

Please sign in to comment.