root/linen/trunk/Rakefile

Revision 567, 3.4 kB (checked in by bbleything, 3 months ago)

source:linen/trunk/Rakefile

  • Only generate coverage if you run the rcov task

source:linen/trunk/spec/spec_helper.rb
source:linen/trunk/lib/linen/spec_matchers.rb

  • put the ArgumentMatchers? custom rspec matcher module in lib. This gives users of Linen access to these matchers when testing their own applications
  • add a note describing why the CompletionMatchers? module is not also being moved

source:linen/trunk/spec/argument_spec.rb

  • require spec_matchers
  • Property svn:keywords set to Date Rev Author URL Id
Line 
1 #!/usr/bin/env ruby
2 #
3 # Based heavily on Ben Bleything's Rakefile for plist, which
4 # is in turn based on Geoffrey Grosenbach's Rakefile for
5 # gruff.
6 #
7 # Includes whitespace-fixing task based on code from Typo.
8 #
9 # == Authors
10 #
11 # * Ben Bleything <bbleything@laika.com>
12 #
13 # == Copyright
14 #
15 # Copyright (c) 2008 LAIKA, Inc.
16 #
17 # This code released under the terms of the BSD license.
18 #
19 # == Version
20 #
21 #  $Id$
22 #
23
24 require 'fileutils'
25 require 'rubygems'
26 require 'rake'
27 require 'spec/rake/spectask'
28 require 'rake/rdoctask'
29 require 'rake/packagetask'
30 require 'rake/gempackagetask'
31
32 $:.unshift(File.dirname(__FILE__) + "/lib")
33 require 'linen'
34
35 PKG_NAME      = 'linen'
36 PKG_VERSION   = Linen::VERSION
37
38 TEXT_FILES    = %w( Rakefile README LICENSE )
39 LIB_FILES     = Dir.glob('lib/**/*').delete_if { |item| item.include?( "\.svn" ) }
40 SPEC_FILES    = Dir.glob('spec/*_spec.rb')
41 EXAMPLE_FILES = Dir.glob('examples/*.rb')
42 RELEASE_FILES = TEXT_FILES + LIB_FILES + SPEC_FILES + EXAMPLE_FILES
43
44 task :default => :spec
45
46 ### Run the specifications
47 Spec::Rake::SpecTask.new do |r|
48     r.libs      = SPEC_FILES
49     r.spec_opts = %w(--format specdoc --color)
50 end
51
52 ### Run the specifications and generate coverage information
53 Spec::Rake::SpecTask.new( :rcov ) do |r|
54     r.rcov      = true
55     r.rcov_dir  = 'coverage'
56     r.libs      = SPEC_FILES
57 end
58
59 desc "Clean pkg, coverage, and rdoc; remove .bak files"
60 task :clean => [ :clobber_rdoc, :clobber_package, :clobber_spec ] do
61     puts cmd = "find . -type f -name *.bak -delete"
62     `#{cmd}`
63 end
64
65 desc "Strip trailing whitespace and fix newlines for all release files"
66 task :fix_whitespace => [ :clean ] do
67     RELEASE_FILES.each do |filename|
68         next if File.directory? filename
69
70         File.open(filename) do |file|
71             newfile = ''
72             needs_love = false
73
74             file.readlines.each_with_index do |line, lineno|
75                 if line =~ /[ \t]+$/
76                     needs_love = true
77                     puts "#{filename}: trailing whitespace on line #{lineno}"
78                     line.gsub!(/[ \t]*$/, '')
79                 end
80
81                 if line.chomp == line
82                     needs_love = true
83                     puts "#{filename}: no newline on line #{lineno}"
84                     line << "\n"
85                 end
86
87                 newfile << line
88             end
89
90             if needs_love
91                 tempname = "#{filename}.new"
92
93                 File.open(tempname, 'w').write(newfile)
94                 File.chmod(File.stat(filename).mode, tempname)
95
96                 FileUtils.ln filename, "#{filename}.bak"
97                 FileUtils.ln tempname, filename, :force => true
98                 File.unlink(tempname)
99             end
100         end
101     end
102 end
103
104
105 ### Genereate the RDoc documentation
106 Rake::RDocTask.new { |rdoc|
107     rdoc.rdoc_dir = 'rdoc'
108     rdoc.title    = "Linen - A pluggable command-line interface library"
109     rdoc.options << '-SNmREADME'
110
111     rdoc.rdoc_files.include TEXT_FILES
112     rdoc.rdoc_files.include LIB_FILES
113     rdoc.rdoc_files.include Dir.glob('docs/**').delete_if {|f| f.include? 'jamis' }
114 }
115
116
117 ### Create compressed packages
118 spec = Gem::Specification.new do |s|
119     s.name    = PKG_NAME
120     s.version = PKG_VERSION
121
122     s.summary     = "Linen - A pluggable command-line interface library"
123     s.description = <<-EOD
124     Linen is a library which can be used to build a command-line interface for any purpose.  It features a plugin architecture to specify new tasks, Readline support, history, and more.
125     EOD
126
127     s.authors  = "LAIKA, Inc."
128     s.homepage = "http://opensource.laika.com"
129
130     s.has_rdoc = true
131
132     s.files      = RELEASE_FILES
133     s.test_files = SPEC_FILES
134
135     s.autorequire = 'linen'
136 end
137
138
139 Rake::GemPackageTask.new(spec) do |p|
140     p.gem_spec = spec
141     p.need_tar = true
142     p.need_zip = true
143 end
Note: See TracBrowser for help on using the browser.