dcrec1-autotest-notification 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/History.txt +58 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +59 -0
  4. data/PostInstall.txt +9 -0
  5. data/README.txt +138 -0
  6. data/Rakefile +4 -0
  7. data/autotest-notification.gemspec +49 -0
  8. data/bin/an-install +91 -0
  9. data/bin/an-uninstall +50 -0
  10. data/bin/playsound +0 -0
  11. data/config/hoe.rb +75 -0
  12. data/config/requirements.rb +15 -0
  13. data/images/buuf/fail.png +0 -0
  14. data/images/buuf/pass.png +0 -0
  15. data/images/buuf/pending.png +0 -0
  16. data/images/doom/doom_0.png +0 -0
  17. data/images/doom/doom_1.png +0 -0
  18. data/images/doom/doom_2.png +0 -0
  19. data/images/doom/doom_3.png +0 -0
  20. data/images/doom/doom_4.png +0 -0
  21. data/images/doom/doom_5.png +0 -0
  22. data/images/doom/doom_6.png +0 -0
  23. data/images/fail.png +0 -0
  24. data/images/pass.png +0 -0
  25. data/images/pending.png +0 -0
  26. data/lib/autotest_notification.rb +73 -0
  27. data/lib/autotest_notification/buuf.rb +9 -0
  28. data/lib/autotest_notification/cygwin.rb +14 -0
  29. data/lib/autotest_notification/doom.rb +25 -0
  30. data/lib/autotest_notification/linux.rb +55 -0
  31. data/lib/autotest_notification/mac.rb +25 -0
  32. data/lib/autotest_notification/version.rb +9 -0
  33. data/lib/autotest_notification/windows.rb +11 -0
  34. data/script/console +10 -0
  35. data/script/destroy +14 -0
  36. data/script/generate +14 -0
  37. data/script/txt2html +82 -0
  38. data/setup.rb +1585 -0
  39. data/sounds/doom/0.wav +0 -0
  40. data/sounds/doom/1.wav +0 -0
  41. data/sounds/doom/2.wav +0 -0
  42. data/sounds/doom/3.wav +0 -0
  43. data/sounds/doom/4.wav +0 -0
  44. data/sounds/doom/5.wav +0 -0
  45. data/sounds/doom/6.wav +0 -0
  46. data/tasks/deployment.rake +34 -0
  47. data/tasks/environment.rake +7 -0
  48. data/tasks/website.rake +17 -0
  49. data/test/autotest_notification/test_cygwin.rb +10 -0
  50. data/test/autotest_notification/test_linux.rb +91 -0
  51. data/test/autotest_notification/test_mac.rb +42 -0
  52. data/test/autotest_notification/test_windows.rb +12 -0
  53. data/test/test_autotest_notification.rb +44 -0
  54. data/test/test_helper.rb +25 -0
  55. data/website/index.html +86 -0
  56. data/website/index.txt +83 -0
  57. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  58. data/website/stylesheets/screen.css +138 -0
  59. data/website/template.html.erb +48 -0
  60. metadata +160 -0
data/bin/playsound ADDED
Binary file
data/config/hoe.rb ADDED
@@ -0,0 +1,75 @@
1
+ require 'autotest_notification/version'
2
+
3
+ AUTHOR = "Carlos Brando, Rodrigo Urubatan, Alexandre da Silva, Carlos Júnior, Davis Zanetti Cabral, Marcos Tapajós, Thiago Pradi, Ozéias Sant'ana, Samuel Flores, Diego Carrion"
4
+ EMAIL = "autotest-notification@carlosbrando.com"
5
+ DESCRIPTION = "This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results."
6
+ GEM_NAME = 'autotest-notification' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = nil # 'autotestnotific' # The unix name for your project
8
+ HOMEPATH = "http://github.com/carlosbrando/autotest-notification/"
9
+ DOWNLOAD_PATH = "http://github.com/carlosbrando/autotest-notification/tarball/master"
10
+
11
+ EXTRA_DEPENDENCIES = [
12
+ ['ZenTest', '>= 3.9.2']
13
+ # ['activesupport', '>= 1.3.1']
14
+ ] # An array of rubygem dependencies [name, version]
15
+
16
+ @config_file = "~/.rubyforge/user-config.yml"
17
+ @config = nil
18
+ RUBYFORGE_USERNAME = "carlosbrando"
19
+ def rubyforge_username
20
+ unless @config
21
+ begin
22
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
23
+ rescue
24
+ puts <<-EOS
25
+ ERROR: No rubyforge config file found: #{@config_file}
26
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
27
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
28
+ EOS
29
+ exit
30
+ end
31
+ end
32
+ RUBYFORGE_USERNAME.replace @config["username"]
33
+ end
34
+
35
+
36
+ REV = nil
37
+ # UNCOMMENT IF REQUIRED:
38
+ # REV = YAML.load(`svn info`)['Revision']
39
+ VERS = AutotestNotification::VERSION::STRING + (REV ? ".#{REV}" : "")
40
+ RDOC_OPTS = ['--quiet', '--title', 'autotest_notification documentation',
41
+ "--opname", "index.html",
42
+ "--line-numbers",
43
+ "--main", "README",
44
+ "--inline-source"]
45
+
46
+ class Hoe
47
+ def extra_deps
48
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
49
+ @extra_deps
50
+ end
51
+ end
52
+
53
+ # Generate all the Rake tasks
54
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
55
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
56
+ p.developer(AUTHOR, EMAIL)
57
+ p.description = DESCRIPTION
58
+ p.summary = DESCRIPTION
59
+ p.url = HOMEPATH
60
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
61
+ p.test_globs = ["test/**/test_*.rb"]
62
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
63
+
64
+ # == Optional
65
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
66
+ p.extra_deps = EXTRA_DEPENDENCIES
67
+
68
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
69
+ end
70
+
71
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
72
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
73
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
74
+ $hoe.rsync_args = '-av --delete --ignore-errors'
75
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen ZenTest].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/images/fail.png ADDED
Binary file
data/images/pass.png ADDED
Binary file
Binary file
@@ -0,0 +1,73 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ %w{ linux mac windows cygwin doom buuf }.each { |x| require "autotest_notification/#{x}" }
3
+
4
+ module AutotestNotification
5
+ IMAGES_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../images/")
6
+ SUCCESS_IMAGE = "#{IMAGES_DIRECTORY}/pass.png";
7
+ FAIL_IMAGE = "#{IMAGES_DIRECTORY}/fail.png";
8
+ PENDING_IMAGE = "#{IMAGES_DIRECTORY}/pending.png"
9
+
10
+ EXPIRATION_IN_SECONDS = 3
11
+
12
+ Autotest.add_hook :ran_command do |at|
13
+ result = at.results.is_a?(Array) ? at.results.last : at.results.split("\n").last
14
+
15
+ if result
16
+ %w{ test assertion error example pending failure }.each { |x| instance_variable_set "@#{x}s", result[/(\d+) #{x}/, 1].to_i }
17
+
18
+ case result
19
+ when /test/
20
+ code = 31 if @failures > 0 || @errors > 0
21
+ msg = unit_test_message(@tests, @assertions, @failures, @errors)
22
+ when /example/
23
+ code = (@failures > 0) ? 31 : (@pendings > 0) ? 33 : 32
24
+ msg = rspec_message(@examples, @failures, @pendings)
25
+ else
26
+ code = 31
27
+ msg = "1 exception occurred"
28
+ @failures = 1
29
+ end
30
+
31
+ if @failures > 0 || @errors > 0
32
+ notify "FAIL", msg, FAIL_IMAGE, @tests + @examples, @failures + @errors, 2
33
+ elsif PENDING && @pendings > 0
34
+ notify "Pending", msg, PENDING_IMAGE, @tests + @examples, @failures + @errors, 1
35
+ else
36
+ notify "Pass", msg, SUCCESS_IMAGE, @tests + @examples, 0, -2
37
+ end
38
+
39
+ puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
40
+ end
41
+ end
42
+
43
+ class << self
44
+ def notify(title, msg, img = SUCCESS_IMAGE, total = 1, failures = 0, priority = 0)
45
+
46
+ img = Doom.image(total, failures) if DOOM_EDITION
47
+ img = Buuf.image(title.downcase) if BUUF
48
+
49
+ case RUBY_PLATFORM
50
+ when /linux/
51
+ Linux.notify(title, msg, img, total, failures)
52
+ when /darwin/
53
+ Mac.notify(title, msg, img, total, failures, priority)
54
+ when /cygwin/
55
+ Cygwin.notify(title, msg, img)
56
+ when /mswin/
57
+ Windows.notify(title, msg, img)
58
+ end
59
+ end
60
+
61
+ def pluralize(text, number)
62
+ "#{number} #{text}#{'s' if number != 1}"
63
+ end
64
+
65
+ def unit_test_message(tests, assertions, failures, errors)
66
+ "#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}"
67
+ end
68
+
69
+ def rspec_message(examples, failures, pendings)
70
+ "#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending"
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,9 @@
1
+ module AutotestNotification
2
+ class Buuf
3
+ class << self
4
+ def image(notification)
5
+ "#{IMAGES_DIRECTORY}/buuf/#{notification}.png"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module AutotestNotification
2
+ class Cygwin
3
+ class << self
4
+ def notify(title, msg, img)
5
+ img = get_image_path(img).strip
6
+ system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{EXPIRATION_IN_SECONDS}"
7
+ end
8
+
9
+ def get_image_path(img)
10
+ `cygpath -m #{img}`
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ module AutotestNotification
2
+ class Doom
3
+ class << self
4
+ def image(total, failures)
5
+ "#{IMAGES_DIRECTORY}/doom/doom_#{percent(total, failures)}.png"
6
+ end
7
+
8
+ def play_sound(total, failures)
9
+ sound_file = "#{File.expand_path(File.dirname(__FILE__) + "/../../sounds/doom/")}/#{percent(total, failures)}.wav"
10
+
11
+ case RUBY_PLATFORM
12
+ when /darwin/
13
+ `#{File.expand_path(File.dirname(__FILE__) + "/../../bin/")}/playsound #{sound_file}`
14
+ when /linux/
15
+ system("/usr/bin/mplayer #{sound_file} > /dev/null 2> /dev/null")
16
+ end
17
+ end
18
+
19
+ private
20
+ def percent(total, failures)
21
+ percent = failures.zero? ? 0 : ((5 * failures) / total) + 1
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ module AutotestNotification
2
+ class Linux
3
+ class << self
4
+
5
+ def notify(title, msg, img, total = 1, failures = 0)
6
+ if has_notify?
7
+ notify_send(title, msg, img)
8
+ elsif has_zenity?
9
+ zenity(title, msg, img)
10
+ elsif has_kdialog?
11
+ kdialog(title, msg, img)
12
+ end
13
+
14
+ say(total, failures) if SPEAKING
15
+ end
16
+
17
+ protected
18
+
19
+ def has_notify?
20
+ system "which notify-send 2> /dev/null"
21
+ end
22
+
23
+ def has_kdialog?
24
+ system "which kdialog 2> /dev/null"
25
+ end
26
+
27
+ def has_zenity?
28
+ system "which zenity 2> /dev/null"
29
+ end
30
+
31
+ def notify_send(title, msg, img)
32
+ system "notify-send -t #{EXPIRATION_IN_SECONDS * 1000} -i #{img} '#{title}' '#{msg}'"
33
+ end
34
+
35
+ def kdialog(title, msg, img)
36
+ system "kdialog --title '#{title}' --passivepopup '#{msg}' #{EXPIRATION_IN_SECONDS}"
37
+ end
38
+
39
+ def zenity(title, msg, img)
40
+ system "zenity --info --text='#{msg}' --title='#{title}'"
41
+ end
42
+
43
+ def say(total, failures)
44
+ if failures > 0
45
+ DOOM_EDITION ? Doom.play_sound(total, failures) : system("/usr/bin/espeak '#{failures} test#{'s' unless failures == 1} failed'")
46
+ else
47
+ DOOM_EDITION ? Doom.play_sound(total, failures) : system("/usr/bin/espeak 'All tests passed successfully'")
48
+ end
49
+ rescue
50
+ puts "You need the #{DOOM_EDITION ? 'mplayer' : 'espeak'} installed to hear the sounds."
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,25 @@
1
+ module AutotestNotification
2
+ class Mac
3
+ @last_test_failed = false
4
+
5
+ class << self
6
+
7
+ def notify(title, msg, img, total = 1, failures = 0, priority = 0)
8
+ system "growlnotify -n autotest --image #{img} #{'-s ' if ((failures > 0) and STICKY)}-p #{priority} -m '#{msg}' -t #{title}"
9
+ say(total, failures) if SPEAKING
10
+ end
11
+
12
+ def say(total, failures)
13
+
14
+ if failures > 0
15
+ DOOM_EDITION ? Doom.play_sound(total, failures) : system("say #{failures} test#{'s' unless failures == 1} failed.")
16
+ @last_test_failed = true
17
+ elsif @last_test_failed
18
+ DOOM_EDITION ? Doom.play_sound(total, failures) : system("say All tests passed successfully.")
19
+ @last_test_failed = false
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module AutotestNotification #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 1
4
+ MINOR = 7
5
+ TINY = 3
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ require 'snarl' if RUBY_PLATFORM =~ /mswin/
2
+
3
+ module AutotestNotification
4
+ class Windows
5
+ class << self
6
+ def notify(title, msg, img)
7
+ Snarl.show_message(title, msg, img)
8
+ end
9
+ end
10
+ end
11
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/autotest_notification.rb'}"
9
+ puts "Loading autotest_notification gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ GEM_NAME = 'autotest_notification' # what ppl will type to install your gem
4
+ RUBYFORGE_PROJECT = 'autotest_notification'
5
+
6
+ require 'rubygems'
7
+ begin
8
+ require 'newgem'
9
+ require 'rubyforge'
10
+ rescue LoadError
11
+ puts "\n\nGenerating the website requires the newgem RubyGem"
12
+ puts "Install: gem install newgem\n\n"
13
+ exit(1)
14
+ end
15
+ require 'redcloth'
16
+ require 'syntax/convertors/html'
17
+ require 'erb'
18
+ require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
+
20
+ version = AutotestNotification::VERSION::STRING
21
+ download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
+
23
+ def rubyforge_project_id
24
+ RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
+ end
26
+
27
+ class Fixnum
28
+ def ordinal
29
+ # teens
30
+ return 'th' if (10..19).include?(self % 100)
31
+ # others
32
+ case self % 10
33
+ when 1: return 'st'
34
+ when 2: return 'nd'
35
+ when 3: return 'rd'
36
+ else return 'th'
37
+ end
38
+ end
39
+ end
40
+
41
+ class Time
42
+ def pretty
43
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
+ end
45
+ end
46
+
47
+ def convert_syntax(syntax, source)
48
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
+ end
50
+
51
+ if ARGV.length >= 1
52
+ src, template = ARGV
53
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
+ else
55
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
+ exit!
57
+ end
58
+
59
+ template = ERB.new(File.open(template).read)
60
+
61
+ title = nil
62
+ body = nil
63
+ File.open(src) do |fsrc|
64
+ title_text = fsrc.readline
65
+ body_text_template = fsrc.read
66
+ body_text = ERB.new(body_text_template).result(binding)
67
+ syntax_items = []
68
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
+ ident = syntax_items.length
70
+ element, syntax, source = $1, $2, $3
71
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
+ "syntax-temp-#{ident}"
73
+ }
74
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
+ body = RedCloth.new(body_text).to_html
76
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
+ end
78
+ stat = File.stat(src)
79
+ created = stat.ctime
80
+ modified = stat.mtime
81
+
82
+ $stdout << template.result(binding)