root/lang/ruby/rubywgem/trunk/tasks/basic_tasks.rake @ 5316

Revision 5316, 3.6 kB (checked in by walf443, 5 years ago)

lang/ruby/rubywgem: start new project rubywgem - just a wrapper of ruby command that can use gem library with -r option.

Line 
1
2REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
3CLEAN.include ['**/.*.sw?', '*.gem', '.config']
4
5Rake::GemPackageTask.new(SPEC) do |p|
6        p.need_tar = true
7        p.gem_spec = SPEC
8end
9
10task :default => [:spec]
11task :test    => [:spec]
12task :package => [:clean]
13
14require 'spec/rake/spectask'
15Spec::Rake::SpecTask.new(:spec) do |t|
16  t.spec_files = FileList['spec/**/*_spec.rb']
17  t.spec_opts = ['--options', 'spec/spec.opts']
18  t.warning = true
19  t.rcov = true
20  t.rcov_dir = 'doc/output/coverage'
21  t.rcov_opts = ['--exclude', 'spec,\.autotest']
22end
23
24desc "Heckle each module and class in turn"
25task :heckle => :spec do
26  root_modules = HECKLE_ROOT_MODULES
27  spec_files = FileList['spec/**/*_spec.rb']
28 
29  current_module, current_method = nil, nil
30  heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
31  unhandled_mutations = 0
32 
33  root_modules.each do |root_module|
34    IO.popen("heckle #{root_module} -t #{spec_files}") do |pipe|
35      while line = pipe.gets
36        line = line.chomp
37       
38        if line =~ /^\*\*\*  ((?:\w+(?:::)?)+)#(\w+)/
39          current_module, current_method = $1, $2
40        elsif line == "The following mutations didn't cause test failures:"
41          heckle_caught_modules[current_module] << current_method
42        elsif line == "+++ mutation"
43          unhandled_mutations += 1
44        end
45             
46        puts line
47      end
48    end
49  end
50 
51  if unhandled_mutations > 0
52    error_message_lines = ["*************\n"]
53   
54    error_message_lines <<
55      "Heckle found #{unhandled_mutations} " +
56      "mutation#{"s" unless unhandled_mutations == 1} " +
57      "that didn't cause spec violations\n"
58
59    heckle_caught_modules.each do |mod, methods|
60      error_message_lines <<
61        "#{mod} contains the following poorly-specified methods:"
62      methods.each do |m|
63        error_message_lines << " - #{m}"
64      end
65      error_message_lines << ""
66    end
67   
68    error_message_lines <<
69      "Get your act together and come back " +
70      "when your specs are doing their job!"
71   
72    puts "*************"
73    raise error_message_lines.join("\n")
74  else
75    puts "Well done! Your code withstood a heckling."
76  end
77end
78
79require 'spec/rake/verify_rcov'
80RCov::VerifyTask.new(:rcov => :spec) do |t|
81  t.index_html = "doc/output/coverage/index.html"
82  t.threshold = 100
83end
84
85task :install do
86        name = "#{NAME}-#{VERS}.gem"
87        sh %{rake package}
88        sh %{sudo gem install pkg/#{name}}
89end
90
91task :uninstall => [:clean] do
92        sh %{sudo gem uninstall #{NAME}}
93end
94
95
96Rake::RDocTask.new do |rdoc|
97        rdoc.rdoc_dir = 'html'
98        rdoc.options += RDOC_OPTS
99        rdoc.template = "resh"
100        #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
101        if ENV['DOC_FILES']
102                rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
103        else
104                rdoc.rdoc_files.include('README', 'ChangeLog')
105                rdoc.rdoc_files.include('lib/**/*.rb')
106                rdoc.rdoc_files.include('ext/**/*.c')
107        end
108end
109
110desc "Publish to RubyForge"
111task :rubyforge => [:rdoc, :package] do
112        require 'rubyforge'
113        Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'yoshimi').upload
114end
115
116desc 'Package and upload the release to rubyforge.'
117task :release => [:clean, :package] do |t|
118        require 'rubyforge'
119        v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
120        abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
121        pkg = "pkg/#{NAME}-#{VERS}"
122
123        rf = RubyForge.new
124        puts "Logging in"
125        rf.login
126
127        c = rf.userconfig
128#       c["release_notes"] = description if description
129#       c["release_changes"] = changes if changes
130        c["preformatted"] = true
131
132        files = [
133                "#{pkg}.tgz",
134                "#{pkg}.gem"
135        ].compact
136
137        puts "Releasing #{NAME} v. #{VERS}"
138        rf.add_release RUBYFORGE_PROJECT_ID, RUBYFORGE_PACKAGE_ID, VERS, *files
139end
Note: See TracBrowser for help on using the browser.