topfunky-castanaut 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ # $Id$
2
+
3
+ require File.join(File.dirname(__FILE__), %w[spec_helper])
4
+
5
+ describe Castanaut do
6
+ # Feel free to contribute specs if this void leaves you feeling vertiginous.
7
+ end
8
+
9
+ # EOF
@@ -0,0 +1,18 @@
1
+ # $Id$
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib castanaut])
5
+ )
6
+
7
+ Spec::Runner.configure do |config|
8
+ # == Mock Framework
9
+ #
10
+ # RSpec uses it's own mocking framework by default. If you prefer to
11
+ # use mocha, flexmock or RR, uncomment the appropriate line:
12
+ #
13
+ # config.mock_with :mocha
14
+ # config.mock_with :flexmock
15
+ # config.mock_with :rr
16
+ end
17
+
18
+ # EOF
@@ -0,0 +1,77 @@
1
+ # $Id$
2
+
3
+ begin
4
+ require 'bones/smtp_tls'
5
+ rescue LoadError
6
+ require 'net/smtp'
7
+ end
8
+ require 'time'
9
+
10
+ namespace :ann do
11
+
12
+ desc "Create an announcement file"
13
+ task :announcement do
14
+ File.open('announcement.txt','w') do |fd|
15
+ fd.puts("#{PROJ.name} version #{PROJ.version}")
16
+ fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
17
+ fd.puts(" #{PROJ.url}") if PROJ.url
18
+ fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
19
+ fd.puts
20
+ fd.puts("== DESCRIPTION")
21
+ fd.puts
22
+ fd.puts(PROJ.description)
23
+ fd.puts
24
+ fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
25
+ fd.puts
26
+ PROJ.ann_paragraphs.each do |p|
27
+ fd.puts "== #{p.upcase}"
28
+ fd.puts
29
+ fd.puts paragraphs_of('README.txt', p).join("\n\n")
30
+ fd.puts
31
+ end
32
+ fd.puts PROJ.ann_text if PROJ.ann_text
33
+ end
34
+ end
35
+
36
+ desc "Send email announcement"
37
+ task :email => :announcement do
38
+ from = PROJ.ann_email[:from] || PROJ.email
39
+ to = Array(PROJ.ann_email[:to])
40
+
41
+ ### build a mail header for RFC 822
42
+ rfc822msg = "From: #{from}\n"
43
+ rfc822msg << "To: #{to.join(',')}\n"
44
+ rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
45
+ rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
46
+ rfc822msg << "\n"
47
+ rfc822msg << "Date: #{Time.new.rfc822}\n"
48
+ rfc822msg << "Message-Id: "
49
+ rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
50
+ rfc822msg << File.read('announcement.txt')
51
+
52
+ params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
53
+ PROJ.ann_email[key]
54
+ end
55
+
56
+ params[3] = PROJ.email if params[3].nil?
57
+
58
+ if params[4].nil?
59
+ STDOUT.write "Please enter your e-mail password (#{params[3]}): "
60
+ params[4] = STDIN.gets.chomp
61
+ end
62
+
63
+ ### send email
64
+ Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
65
+ end
66
+
67
+ task :clobber_announcement do
68
+ rm 'announcement.txt' rescue nil
69
+ end
70
+ end # namespace :ann
71
+
72
+ desc 'Alias to ann:announcement'
73
+ task :ann => 'ann:announcement'
74
+
75
+ task :clobber => %w(ann:clobber_announcement)
76
+
77
+ # EOF
@@ -0,0 +1,22 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ desc "Enumerate all annotations"
6
+ task :notes do
7
+ Bones::AnnotationExtractor.enumerate(
8
+ PROJ, PROJ.annotation_tags.join('|'), :tag => true)
9
+ end
10
+
11
+ namespace :notes do
12
+ PROJ.annotation_tags.each do |tag|
13
+ desc "Enumerate all #{tag} annotations"
14
+ task tag.downcase.to_sym do
15
+ Bones::AnnotationExtractor.enumerate(PROJ, tag)
16
+ end
17
+ end
18
+ end
19
+
20
+ end # if HAVE_BONES
21
+
22
+ # EOF
@@ -0,0 +1,49 @@
1
+ # $Id$
2
+
3
+ require 'rake/rdoctask'
4
+
5
+ namespace :doc do
6
+
7
+ desc 'Generate RDoc documentation'
8
+ Rake::RDocTask.new do |rd|
9
+ rd.main = PROJ.rdoc_main
10
+ rd.rdoc_dir = PROJ.rdoc_dir
11
+
12
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
13
+ excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
14
+ files = PROJ.files.find_all do |fn|
15
+ case fn
16
+ when excl; false
17
+ when incl; true
18
+ else false end
19
+ end
20
+ rd.rdoc_files.push(*files)
21
+
22
+ title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
+ title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
24
+
25
+ rd.options << "-t #{title}"
26
+ rd.options.concat(PROJ.rdoc_opts)
27
+ end
28
+
29
+ desc 'Generate ri locally for testing'
30
+ task :ri => :clobber_ri do
31
+ sh "#{RDOC} --ri -o ri ."
32
+ end
33
+
34
+ desc 'Remove ri products'
35
+ task :clobber_ri do
36
+ rm_r 'ri' rescue nil
37
+ end
38
+
39
+ end # namespace :doc
40
+
41
+ desc 'Alias to doc:rdoc'
42
+ task :doc => 'doc:rdoc'
43
+
44
+ desc 'Remove all build products'
45
+ task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
46
+
47
+ remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
48
+
49
+ # EOF
@@ -0,0 +1,110 @@
1
+ # $Id$
2
+
3
+ require 'rake/gempackagetask'
4
+
5
+ namespace :gem do
6
+
7
+ PROJ.spec = Gem::Specification.new do |s|
8
+ s.name = PROJ.name
9
+ s.version = PROJ.version
10
+ s.summary = PROJ.summary
11
+ s.authors = Array(PROJ.authors)
12
+ s.email = PROJ.email
13
+ s.homepage = Array(PROJ.url).first
14
+ s.rubyforge_project = PROJ.rubyforge_name
15
+ s.post_install_message = PROJ.post_install_message
16
+
17
+ s.description = PROJ.description
18
+
19
+ PROJ.dependencies.each do |dep|
20
+ s.add_dependency(*dep)
21
+ end
22
+
23
+ s.files = PROJ.files
24
+ s.executables = PROJ.executables.map {|fn| File.basename(fn)}
25
+ s.extensions = PROJ.files.grep %r/extconf\.rb$/
26
+
27
+ s.bindir = 'bin'
28
+ dirs = Dir["{#{PROJ.libs.join(',')}}"]
29
+ s.require_paths = dirs unless dirs.empty?
30
+
31
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
32
+ excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
33
+ excl = Regexp.new(excl.join('|'))
34
+ rdoc_files = PROJ.files.find_all do |fn|
35
+ case fn
36
+ when excl; false
37
+ when incl; true
38
+ else false end
39
+ end
40
+ s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
41
+ s.extra_rdoc_files = rdoc_files
42
+ s.has_rdoc = true
43
+
44
+ if test ?f, PROJ.test_file
45
+ s.test_file = PROJ.test_file
46
+ else
47
+ s.test_files = PROJ.tests.to_a
48
+ end
49
+
50
+ # Do any extra stuff the user wants
51
+ # spec_extras.each do |msg, val|
52
+ # case val
53
+ # when Proc
54
+ # val.call(s.send(msg))
55
+ # else
56
+ # s.send "#{msg}=", val
57
+ # end
58
+ # end
59
+ end
60
+
61
+ desc 'Show information about the gem'
62
+ task :debug do
63
+ puts PROJ.spec.to_ruby
64
+ end
65
+
66
+ pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
67
+ pkg.need_tar = PROJ.need_tar
68
+ pkg.need_zip = PROJ.need_zip
69
+ pkg.package_files += PROJ.spec.files
70
+ end
71
+ Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
72
+
73
+ gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
74
+ "#{pkg.package_name}.gem"
75
+ else
76
+ "#{pkg.package_name}-#{PROJ.spec.platform}.gem"
77
+ end
78
+
79
+ desc "Build the gem file #{gem_file}"
80
+ task :package => "#{pkg.package_dir}/#{gem_file}"
81
+
82
+ file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
83
+ when_writing("Creating GEM") {
84
+ Gem::Builder.new(PROJ.spec).build
85
+ verbose(true) {
86
+ mv gem_file, "#{pkg.package_dir}/#{gem_file}"
87
+ }
88
+ }
89
+ end
90
+
91
+ desc 'Install the gem'
92
+ task :install => [:clobber, :package] do
93
+ sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
94
+ end
95
+
96
+ desc 'Uninstall the gem'
97
+ task :uninstall do
98
+ sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
99
+ end
100
+
101
+ end # namespace :gem
102
+
103
+ desc 'Alias to gem:package'
104
+ task :gem => 'gem:package'
105
+
106
+ task :clobber => 'gem:clobber_package'
107
+
108
+ remove_desc_for_task %w(gem:clobber_package)
109
+
110
+ # EOF
@@ -0,0 +1,50 @@
1
+ # $Id$
2
+
3
+ require 'find'
4
+
5
+ namespace :manifest do
6
+
7
+ desc 'Verify the manifest'
8
+ task :check do
9
+ fn = 'Manifest.tmp'
10
+ files = manifest_files
11
+
12
+ File.open(fn, 'w') {|fp| fp.puts files}
13
+ lines = %x(#{DIFF} -du Manifest.txt #{fn}).split("\n")
14
+ if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
15
+ lines.map! do |line|
16
+ case line
17
+ when %r/^(-{3}|\+{3})/; nil
18
+ when %r/^@/; Console::ANSICode.blue line
19
+ when %r/^\+/; Console::ANSICode.green line
20
+ when %r/^\-/; Console::ANSICode.red line
21
+ else line end
22
+ end
23
+ end
24
+ puts lines.compact
25
+ rm fn rescue nil
26
+ end
27
+
28
+ desc 'Create a new manifest'
29
+ task :create do
30
+ fn = 'Manifest.txt'
31
+ files = manifest_files
32
+ unless test(?f, fn)
33
+ files << fn
34
+ files.sort!
35
+ end
36
+ File.open(fn, 'w') {|fp| fp.puts files}
37
+ end
38
+
39
+ task :assert do
40
+ files = manifest_files
41
+ manifest = File.read('Manifest.txt').split($/)
42
+ raise RuntimeError, "Manifest.txt is out of date" unless files == manifest
43
+ end
44
+
45
+ end # namespace :manifest
46
+
47
+ desc 'Alias to manifest:check'
48
+ task :manifest => 'manifest:check'
49
+
50
+ # EOF
@@ -0,0 +1,18 @@
1
+ # $Id$
2
+
3
+ # This file does not define any rake tasks. It is used to load some project
4
+ # settings if they are not defined by the user.
5
+
6
+ unless PROJ.changes
7
+ PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
8
+ end
9
+
10
+ unless PROJ.description
11
+ PROJ.description = paragraphs_of('README.txt', 'description').join("\n\n")
12
+ end
13
+
14
+ unless PROJ.summary
15
+ PROJ.summary = PROJ.description.split('.').first
16
+ end
17
+
18
+ # EOF
@@ -0,0 +1,57 @@
1
+ # $Id$
2
+
3
+ if PROJ.rubyforge_name && HAVE_RUBYFORGE
4
+
5
+ require 'rubyforge'
6
+ require 'rake/contrib/sshpublisher'
7
+
8
+ namespace :gem do
9
+ desc 'Package and upload to RubyForge'
10
+ task :release => [:clobber, :package] do |t|
11
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
+ pkg = "pkg/#{PROJ.spec.full_name}"
14
+
15
+ if $DEBUG then
16
+ puts "release_id = rf.add_release #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
17
+ puts "rf.add_file #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
18
+ end
19
+
20
+ rf = RubyForge.new
21
+ puts 'Logging in'
22
+ rf.login
23
+
24
+ c = rf.userconfig
25
+ c['release_notes'] = PROJ.description if PROJ.description
26
+ c['release_changes'] = PROJ.changes if PROJ.changes
27
+ c['preformatted'] = true
28
+
29
+ files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
+ (PROJ.need_zip ? "#{pkg}.zip" : nil),
31
+ "#{pkg}.gem"].compact
32
+
33
+ puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
+ rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
35
+ end
36
+ end # namespace :gem
37
+
38
+
39
+ namespace :doc do
40
+ desc "Publish RDoc to RubyForge"
41
+ task :release => %w(doc:clobber_rdoc doc:rdoc) do
42
+ config = YAML.load(
43
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
44
+ )
45
+
46
+ host = "#{config['username']}@rubyforge.org"
47
+ remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge_name}/"
48
+ remote_dir << PROJ.rdoc_remote_dir if PROJ.rdoc_remote_dir
49
+ local_dir = PROJ.rdoc_dir
50
+
51
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
+ end
53
+ end # namespace :doc
54
+
55
+ end # if HAVE_RUBYFORGE
56
+
57
+ # EOF
@@ -0,0 +1,221 @@
1
+ # $Id$
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'fileutils'
6
+ require 'ostruct'
7
+
8
+ PROJ = OpenStruct.new
9
+
10
+ PROJ.name = nil
11
+ PROJ.summary = nil
12
+ PROJ.description = nil
13
+ PROJ.changes = nil
14
+ PROJ.authors = nil
15
+ PROJ.email = nil
16
+ PROJ.url = nil
17
+ PROJ.version = ENV['VERSION'] || '0.0.0'
18
+ PROJ.rubyforge_name = nil
19
+ PROJ.exclude = %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/ announcement.txt)
20
+ PROJ.release_name = ENV['RELEASE']
21
+
22
+ # Rspec
23
+ PROJ.specs = FileList['spec/**/*_spec.rb']
24
+ PROJ.spec_opts = []
25
+
26
+ # Test::Unit
27
+ PROJ.tests = FileList['test/**/test_*.rb']
28
+ PROJ.test_file = 'test/all.rb'
29
+ PROJ.test_opts = []
30
+
31
+ # Rcov
32
+ PROJ.rcov_opts = ['--sort', 'coverage', '-T']
33
+
34
+ # Rdoc
35
+ PROJ.rdoc_opts = []
36
+ PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
37
+ PROJ.rdoc_exclude = %w(extconf.rb$ ^Manifest.txt$)
38
+ PROJ.rdoc_main = 'README.txt'
39
+ PROJ.rdoc_dir = 'doc'
40
+ PROJ.rdoc_remote_dir = nil
41
+
42
+ # Extensions
43
+ PROJ.extensions = FileList['ext/**/extconf.rb']
44
+ PROJ.ruby_opts = %w(-w)
45
+ PROJ.libs = []
46
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
47
+
48
+ # Gem Packaging
49
+ PROJ.files =
50
+ if test ?f, 'Manifest.txt'
51
+ files = File.readlines('Manifest.txt').map {|fn| fn.chomp.strip}
52
+ files.delete ''
53
+ files
54
+ else [] end
55
+ PROJ.executables = PROJ.files.find_all {|fn| fn =~ %r/^bin/}
56
+ PROJ.dependencies = []
57
+ PROJ.need_tar = true
58
+ PROJ.need_zip = false
59
+ PROJ.post_install_message = nil
60
+
61
+ # File Annotations
62
+ PROJ.annotation_exclude = %w(^tasks/setup.rb$)
63
+ PROJ.annotation_extensions = %w(.txt .rb .erb) << ''
64
+ PROJ.annotation_tags = %w(FIXME OPTIMIZE TODO)
65
+
66
+ # Subversion Repository
67
+ PROJ.svn = false
68
+ PROJ.svn_root = nil
69
+ PROJ.svn_trunk = 'trunk'
70
+ PROJ.svn_tags = 'tags'
71
+ PROJ.svn_branches = 'branches'
72
+
73
+ # Announce
74
+ PROJ.ann_text = nil
75
+ PROJ.ann_paragraphs = []
76
+ PROJ.ann_email = {
77
+ :from => nil,
78
+ :to => %w(ruby-talk@ruby-lang.org),
79
+ :server => 'localhost',
80
+ :port => 25,
81
+ :domain => ENV['HOSTNAME'],
82
+ :acct => nil,
83
+ :passwd => nil,
84
+ :authtype => :plain
85
+ }
86
+
87
+ # Load the other rake files in the tasks folder
88
+ rakefiles = Dir.glob('tasks/*.rake').sort
89
+ rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
90
+ import(*rakefiles)
91
+
92
+ # Setup some constants
93
+ WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
94
+
95
+ DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
96
+
97
+ def quiet( &block )
98
+ io = [STDOUT.dup, STDERR.dup]
99
+ STDOUT.reopen DEV_NULL
100
+ STDERR.reopen DEV_NULL
101
+ block.call
102
+ ensure
103
+ STDOUT.reopen io.first
104
+ STDERR.reopen io.last
105
+ end
106
+
107
+ DIFF = if WIN32 then 'diff.exe'
108
+ else
109
+ if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
110
+ else 'diff' end
111
+ end unless defined? DIFF
112
+
113
+ SUDO = if WIN32 then ''
114
+ else
115
+ if quiet {system 'which sudo'} then 'sudo'
116
+ else '' end
117
+ end
118
+
119
+ RCOV = WIN32 ? 'rcov.bat' : 'rcov'
120
+ GEM = WIN32 ? 'gem.bat' : 'gem'
121
+
122
+ %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
123
+ begin
124
+ require lib
125
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
126
+ rescue LoadError
127
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
128
+ end
129
+ end
130
+
131
+ # Reads a file at +path+ and spits out an array of the +paragraphs+
132
+ # specified.
133
+ #
134
+ # changes = paragraphs_of('History.txt', 0..1).join("\n\n")
135
+ # summary, *description = paragraphs_of('README.txt', 3, 3..8)
136
+ #
137
+ def paragraphs_of( path, *paragraphs )
138
+ title = String === paragraphs.first ? paragraphs.shift : nil
139
+ ary = File.read(path).delete("\r").split(/\n\n+/)
140
+
141
+ result = if title
142
+ tmp, matching = [], false
143
+ rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
144
+ paragraphs << (0..-1) if paragraphs.empty?
145
+
146
+ ary.each do |val|
147
+ if val =~ rgxp
148
+ break if matching
149
+ matching = true
150
+ rgxp = %r/^=+/i
151
+ elsif matching
152
+ tmp << val
153
+ end
154
+ end
155
+ tmp
156
+ else ary end
157
+
158
+ result.values_at(*paragraphs)
159
+ end
160
+
161
+ # Adds the given gem _name_ to the current project's dependency list. An
162
+ # optional gem _version_ can be given. If omitted, the newest gem version
163
+ # will be used.
164
+ #
165
+ def depend_on( name, version = nil )
166
+ spec = Gem.source_index.find_name(name).last
167
+ version = spec.version.to_s if version.nil? and !spec.nil?
168
+
169
+ PROJ.dependencies << (version.nil? ? [name] : [name, ">= #{version}"])
170
+ end
171
+
172
+ # Adds the given arguments to the include path if they are not already there
173
+ #
174
+ def ensure_in_path( *args )
175
+ args.each do |path|
176
+ path = File.expand_path(path)
177
+ $:.unshift(path) if test(?d, path) and not $:.include?(path)
178
+ end
179
+ end
180
+
181
+ # Find a rake task using the task name and remove any description text. This
182
+ # will prevent the task from being displayed in the list of available tasks.
183
+ #
184
+ def remove_desc_for_task( names )
185
+ Array(names).each do |task_name|
186
+ task = Rake.application.tasks.find {|t| t.name == task_name}
187
+ next if task.nil?
188
+ task.instance_variable_set :@comment, nil
189
+ end
190
+ end
191
+
192
+ # Change working directories to _dir_, call the _block_ of code, and then
193
+ # change back to the original working directory (the current directory when
194
+ # this method was called).
195
+ #
196
+ def in_directory( dir, &block )
197
+ curdir = pwd
198
+ begin
199
+ cd dir
200
+ return block.call
201
+ ensure
202
+ cd curdir
203
+ end
204
+ end
205
+
206
+ # Scans the current working directory and creates a list of files that are
207
+ # candidates to be in the manifest.
208
+ #
209
+ def manifest_files
210
+ files = []
211
+ exclude = Regexp.new(PROJ.exclude.join('|'))
212
+ Find.find '.' do |path|
213
+ path.sub! %r/^(\.\/|\/)/o, ''
214
+ next unless test ?f, path
215
+ next if path =~ exclude
216
+ files << path
217
+ end
218
+ files.sort!
219
+ end
220
+
221
+ # EOF