public
Description: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
Homepage: http://github.com/fnando/test_notifier
Clone URL: git://github.com/fnando/test_notifier.git
Click here to lend your support to: test_notifier and make a donation at www.pledgie.com !
test_notifier / Rakefile
100644 74 lines (64 sloc) 2.577 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "rubygems"
require "rake"
 
PKG_FILES = %w(Rakefile test_notifier.gemspec History.txt License.txt README.markdown TODO.txt) +
  Dir["lib/**/*"]
 
spec = Gem::Specification.new do |s|
  s.name = "test_notifier"
  s.version = "0.1.0"
  s.summary = "Display system notifications (dbus, growl and snarl) after running tests."
  s.authors = ["Nando Vieira"]
  s.email = ["fnando.vieira@gmail.com"]
  s.homepage = "http://github.com/fnando/test_notifier"
  s.description = "Display system notifications (dbus, growl and snarl) after \
running tests. It works on Mac OS X, Linux and Windows. Powerful when used \
with Autotest ZenTest gem for Rails apps."
  s.has_rdoc = false
  s.files = PKG_FILES
 
  s.add_dependency "rubigen"
  s.requirements << "You'll need Growl (Mac OS X), Libnotify (Linux) or Snarl (Windows)"
end
 
namespace :gem do
  # Thanks to the Merb project for this code.
  desc "Update Github Gemspec"
  task :update_gemspec do
    skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
    
    result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
    result << "# RUN : 'rake gem:update_gemspec'\n\n"
    result << "Gem::Specification.new do |s|\n"
    
    spec.instance_variables.each do |ivar|
      value = spec.instance_variable_get(ivar)
      name = ivar.split("@").last
      next if name == "date"
      
      next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
      if name == "dependencies"
        value.each do |d|
          dep, *ver = d.to_s.split(" ")
          result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
        end
      else
        case value
        when Array
          value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
        when FalseClass
        when TrueClass
        when Fixnum
        when String
          value = value.inspect
        else
          value = value.to_s.inspect
        end
        result << " s.#{name} = #{value}\n"
      end
    end
    
    result << "end"
    File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
  end
  
  desc "Build gem"
  task :build => [:update_gemspec] do
    system "gem build #{spec.instance_variable_get('@name')}.gemspec"
  end
  
  desc "Install gem"
  task :install => [:update_gemspec, :build] do
    system "sudo gem install #{spec.instance_variable_get('@name')}"
  end
end