urubatan-autotest-notification 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,14 @@
1
+ == 0.1.0 2008-05-13
2
+ * Separated each operating system into a different file to facilitate maintenance. It's necessary to conduct more tests in each scene.
3
+
4
+ * 0.0.9:
5
+ * Adding KDE (kdialog) support.
6
+
7
+ * 0.0.7:
8
+ * Added support to Windows.
9
+
10
+ * 0.0.4:
11
+ * Added an-uninstall to remove the autotest hook.
12
+
13
+ * 1 major enhancement:
14
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Carlos Brando
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,33 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.txt
6
+ Rakefile
7
+ config/hoe.rb
8
+ config/requirements.rb
9
+ lib/autotest_notification.rb
10
+ lib/autotest_notification/version.rb
11
+ lib/autotest_notification/linux.rb
12
+ lib/autotest_notification/mac.rb
13
+ lib/autotest_notification/windows.rb
14
+ script/console
15
+ script/destroy
16
+ script/generate
17
+ script/txt2html
18
+ setup.rb
19
+ tasks/deployment.rake
20
+ tasks/environment.rake
21
+ tasks/website.rake
22
+ test/test_autotest_notification.rb
23
+ test/test_helper.rb
24
+ website/index.html
25
+ website/index.txt
26
+ website/javascripts/rounded_corners_lite.inc.js
27
+ website/stylesheets/screen.css
28
+ website/template.html.erb
29
+ bin/an-install
30
+ bin/an-uninstall
31
+ images/pass.png
32
+ images/fail.png
33
+ autotest-notification.gemspec
data/PostInstall.txt ADDED
@@ -0,0 +1,9 @@
1
+
2
+ For more information on autotest_notification, see http://github.com/carlosbrando/autotest-notification/
3
+
4
+ To turn on the notifier you need to run the following command:
5
+ an-install
6
+
7
+ To turn off:
8
+ an-uninstall
9
+
data/README.txt ADDED
@@ -0,0 +1,79 @@
1
+ = The Autotest Notification Gem
2
+
3
+ * http://github.com/carlosbrando/autotest-notification/
4
+
5
+ == DESCRIPTION:
6
+
7
+ This gem set the autotest (ZenTest) to send messages to software as Growl, LibNotify, and Snarl, displaying a window with the results.
8
+
9
+ == REQUIREMENTS:
10
+
11
+ * If you're using a Mac:
12
+ You need to have Growl and growlnotify installed on your machine.
13
+
14
+ Download the Growl [http://growl.info/index.php] and install it like any other application on your Mac
15
+
16
+ Then you must install the growlnotify.
17
+
18
+ In your shell, cd to the directory on the Growl disk image containing growlnotify, and type ./install.sh.
19
+ That script will install growlnotify to /usr/local/bin and the manpage to /usr/local/man.
20
+
21
+ * If yo're using a Windows:
22
+ You need to have Snarl and sncmd installed on your machine.
23
+
24
+ Download Snarl [http://www.fullphat.net/] and install it like any other application on your machine.
25
+
26
+ Then download sncmd [http://www.k23productions.com/download.php?view.105] open the zip file and place the executable from the zip in any directory in windows PATH (for example c:\windows)
27
+
28
+ * If you're using a Linux:
29
+ You need to have libnotify binaries installed.
30
+
31
+ For ubuntu this means: sudo apt-get install libnotify-bin
32
+
33
+ Other distributions may package it with other names, do a search for libnotify using your distribution package manager.
34
+
35
+ If you use KDE and do not have libnotify-bin installed, it will try to use kdialog wich is part of KDE.
36
+
37
+ == INSTALL:
38
+
39
+ $ sudo gem install carlosbrando-autotest-notification --source=http://gems.github.com
40
+
41
+ Run it to let the notifier in automatic mode:
42
+
43
+ $ an-install
44
+
45
+ To turn off the notifier:
46
+
47
+ $ an-uninstall
48
+
49
+ == Contributors
50
+
51
+ * carlosbrando [http://www.nomedojogo.com/]
52
+ * simpsomboy [http://alexandredasilva.wordpress.com/]
53
+ * urubatan [http://www.urubatan.info/]
54
+ * chjunior [http://tas.milk-it.net/]
55
+
56
+ == LICENSE:
57
+
58
+ (The MIT License)
59
+
60
+ Copyright (c) 2008
61
+
62
+ Permission is hereby granted, free of charge, to any person obtaining
63
+ a copy of this software and associated documentation files (the
64
+ 'Software'), to deal in the Software without restriction, including
65
+ without limitation the rights to use, copy, modify, merge, publish,
66
+ distribute, sublicense, and/or sell copies of the Software, and to
67
+ permit persons to whom the Software is furnished to do so, subject to
68
+ the following conditions:
69
+
70
+ The above copyright notice and this permission notice shall be
71
+ included in all copies or substantial portions of the Software.
72
+
73
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
74
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
75
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
76
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
77
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
78
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
79
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,33 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{autotest-notification}
3
+ s.version = "0.1.0"
4
+
5
+ s.specification_version = 2 if s.respond_to? :specification_version=
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Carlos Brando", "Rodrigo Urubatan", "Alexandre da Silva", "Carlos J\303\272nior"]
9
+ s.date = %q{2008-05-13}
10
+ s.description = %q{Set the autotest to display messages on the operating system using software such as Growl and LibNotify.}
11
+ s.email = ["eduardobrando@gmail.com"]
12
+ s.executables = ["an-install", "an-uninstall"]
13
+ s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "website/index.txt"]
14
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe.rb", "config/requirements.rb", "lib/autotest_notification.rb", "lib/autotest_notification/version.rb", "lib/autotest_notification/linux.rb", "lib/autotest_notification/mac.rb", "lib/autotest_notification/windows.rb", "script/console", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "test/test_autotest_notification.rb", "test/test_helper.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "website/stylesheets/screen.css", "website/template.html.erb", "bin/an-install", "bin/an-uninstall", "images/pass.png", "images/fail.png", "autotest-notification.gemspec"]
15
+ s.has_rdoc = true
16
+ s.homepage = %q{http://github.com/carlosbrando/autotest-notification/}
17
+ s.post_install_message = %q{
18
+ For more information on autotest_notification, see http://github.com/carlosbrando/autotest-notification/
19
+
20
+ To turn on the notifier you need to run the following command:
21
+ an-install
22
+
23
+ To turn off:
24
+ an-uninstall
25
+
26
+ }
27
+ s.rdoc_options = ["--main", "README.txt"]
28
+ s.require_paths = ["lib"]
29
+ s.rubyforge_project = %q{}
30
+ s.rubygems_version = %q{1.1.1}
31
+ s.summary = %q{Set the autotest to display messages on the operating system using software such as Growl and LibNotify.}
32
+ s.test_files = ["test/test_autotest_notification.rb", "test/test_helper.rb"]
33
+ end
data/bin/an-install ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2008-5-11.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ begin
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ # no rubygems to load, so we fail silently
10
+ end
11
+
12
+ require 'optparse'
13
+ require 'ftools'
14
+
15
+ # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
16
+
17
+ OPTIONS = {
18
+ :path => '~'
19
+ }
20
+ MANDATORY_OPTIONS = %w( )
21
+
22
+ parser = OptionParser.new do |opts|
23
+ opts.banner = <<BANNER
24
+ This application is wonderful because...
25
+
26
+ Usage: #{File.basename($0)} [options]
27
+
28
+ Options are:
29
+ BANNER
30
+ opts.separator ""
31
+ opts.on("-p", "--path=PATH", String,
32
+ "The root path for selecting files",
33
+ "Default: ~") { |OPTIONS[:path]| }
34
+ opts.on("-h", "--help",
35
+ "Show this help message.") { puts opts; exit }
36
+ opts.parse!(ARGV)
37
+
38
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
39
+ puts opts; exit
40
+ end
41
+ end
42
+
43
+ path = OPTIONS[:path]
44
+
45
+ f = File.new(File.expand_path(path) + "/.autotest", "w")
46
+ f.write "# ~.autotest\n"
47
+ f.write "require 'autotest_notification'"
48
+ f.close
49
+ puts "\nAs from now all tests will be notified automatically."
50
+ puts "" # a blank line
data/bin/an-uninstall ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2008-5-11.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ begin
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ # no rubygems to load, so we fail silently
10
+ end
11
+
12
+ require 'optparse'
13
+ require 'ftools'
14
+
15
+ # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
16
+
17
+ OPTIONS = {
18
+ :path => '~'
19
+ }
20
+ MANDATORY_OPTIONS = %w( )
21
+
22
+ parser = OptionParser.new do |opts|
23
+ opts.banner = <<BANNER
24
+ This application is wonderful because...
25
+
26
+ Usage: #{File.basename($0)} [options]
27
+
28
+ Options are:
29
+ BANNER
30
+ opts.separator ""
31
+ opts.on("-p", "--path=PATH", String,
32
+ "The root path for selecting files",
33
+ "Default: ~") { |OPTIONS[:path]| }
34
+ opts.on("-h", "--help",
35
+ "Show this help message.") { puts opts; exit }
36
+ opts.parse!(ARGV)
37
+
38
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
39
+ puts opts; exit
40
+ end
41
+ end
42
+
43
+ path = OPTIONS[:path]
44
+
45
+ autotest_file = File.expand_path(path) + "/.autotest"
46
+ if File.exist?(autotest_file)
47
+ File.delete(autotest_file)
48
+ puts "\nYou no longer receive notifications of your tests."
49
+ puts "" # a blank line
50
+ end
data/config/hoe.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'autotest_notification/version'
2
+
3
+ AUTHOR = "Carlos Brando, Rodrigo Urubatan, Alexandre da Silva, Carlos Júnior"
4
+ EMAIL = "eduardobrando@gmail.com"
5
+ DESCRIPTION = "Set the autotest to display messages on the operating system using software such as Growl and LibNotify."
6
+ GEM_NAME = 'autotest-notification' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = '' # 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
+ EXTRA_DEPENDENCIES = [
11
+ # ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "carlosbrando"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = AutotestNotification::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'autotest_notification documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--inline-source"]
43
+
44
+ class Hoe
45
+ def extra_deps
46
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
47
+ @extra_deps
48
+ end
49
+ end
50
+
51
+ # Generate all the Rake tasks
52
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
53
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
54
+ p.developer(AUTHOR, EMAIL)
55
+ p.description = DESCRIPTION
56
+ p.summary = DESCRIPTION
57
+ p.url = HOMEPATH
58
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
59
+ p.test_globs = ["test/**/test_*.rb"]
60
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
61
+
62
+ # == Optional
63
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
+ #p.extra_deps = EXTRA_DEPENDENCIES
65
+
66
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
67
+ end
68
+
69
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
70
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
71
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
72
+ $hoe.rsync_args = '-av --delete --ignore-errors'
73
+ $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].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]))
data/images/fail.png ADDED
Binary file
data/images/pass.png ADDED
Binary file
@@ -0,0 +1,26 @@
1
+ module AutotestNotification
2
+ class Linux
3
+ class << self
4
+ def notify(title, msg, img)
5
+ if has_notify?
6
+ notify_send(title, msg, img)
7
+ else
8
+ kdialog(title, msg, img)
9
+ end
10
+ end
11
+
12
+ protected
13
+ def notify_send(title, msg, img)
14
+ system "notify-send -t #{EXPIRATION_IN_SECONDS * 1000} -i #{img} '#{title}' '#{msg}'"
15
+ end
16
+
17
+ def kdialog(title, msg, img)
18
+ system "kdialog --title '#{title}' --passivepopup '#{msg}' #{EXPIRATION_IN_SECONDS}"
19
+ end
20
+
21
+ def has_notify?
22
+ system "which notify-send 2> /dev/null"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ module AutotestNotification
2
+ class Mac
3
+ class << self
4
+ def notify(title, msg, img, pri = 0)
5
+ system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module AutotestNotification #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module AutotestNotification
2
+ class Windows
3
+ class << self
4
+ def notify(title, msg, img)
5
+ img = `cygpath -m #{img}` if RUBY_PLATFORM =~ /cygwin/
6
+ img.strip!
7
+
8
+ system "sncmd /m '#{title}' '#{msg}' '#{img}' /t #{EXPIRATION_IN_SECONDS}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,70 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'autotest_notification/linux'
3
+ require 'autotest_notification/mac'
4
+ require 'autotest_notification/windows'
5
+
6
+ module AutotestNotification
7
+ FAIL = -1
8
+ PENDING = 0
9
+ SUCCESS = 1
10
+
11
+ EXPIRATION_IN_SECONDS = 3
12
+
13
+ IMAGES_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../images/")
14
+ SUCCESS_IMAGE = "#{IMAGES_DIRECTORY}/pass.png"
15
+ FAIL_IMAGE = "#{IMAGES_DIRECTORY}/fail.png"
16
+
17
+ Autotest.add_hook :ran_command do |at|
18
+
19
+ result = at.results.is_a?(Array) ? at.results.last : at.results.split("\n").last
20
+
21
+ if result
22
+
23
+ # Test::Unit
24
+ tests = result =~ /(\d+) test/ ? $1.to_i : 0
25
+ assertions = result =~ /(\d+) assertion/ ? $1.to_i : 0
26
+ errors = result =~ /(\d+) error/ ? $1.to_i : 0
27
+
28
+ # RSpec
29
+ examples = result =~ /(\d+) example/ ? $1.to_i : 0
30
+ pendings = result =~ /(\d+) pending/ ? $1.to_i : 0
31
+
32
+ # Shared
33
+ failures = result =~ /(\d+) failure/ ? $1.to_i : 0
34
+
35
+ code = 32
36
+ msg = if result =~ /test/
37
+ code = 31 if failures > 0 || errors > 0
38
+ "#{pluralize('test', tests)}, #{pluralize('assertion', assertions)}, #{pluralize('failure', failures)}, #{pluralize('error', errors)}"
39
+ else
40
+ code = (failures > 0) ? 31 : (pendings > 0) ? 33 : 32
41
+ "#{pluralize('example', examples)}, #{pluralize('failure', failures)}, #{pendings} pending"
42
+ end
43
+
44
+ if failures > 0 || errors > 0
45
+ notify "FAIL", msg, FAIL_IMAGE, 2
46
+ else
47
+ notify "Pass", msg, SUCCESS_IMAGE
48
+ end
49
+
50
+ puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
51
+ end
52
+ end
53
+
54
+ class << self
55
+ def notify(title, msg, img = SUCCESS_IMAGE, pri = 0)
56
+ case RUBY_PLATFORM
57
+ when /linux/
58
+ Linux.notify(title, msg, img)
59
+ when /darwin/
60
+ Mac.notify(title, msg, img, pri)
61
+ when /mswin|cygwin/
62
+ Windows.notify(title, msg, img)
63
+ end
64
+ end
65
+
66
+ def pluralize(text, number)
67
+ "#{number} #{text}#{'s' if number != 1}"
68
+ end
69
+ end
70
+ 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)