bones 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +30 -0
- data/README.txt +157 -0
- data/Rakefile +26 -0
- data/bin/bones +7 -0
- data/data/History.txt.erb +4 -0
- data/data/Manifest.txt +0 -0
- data/data/README.txt.erb +48 -0
- data/data/Rakefile.erb +23 -0
- data/data/bin/NAME.erb +8 -0
- data/data/lib/NAME.rb.erb +7 -0
- data/data/spec/NAME_spec.rb +0 -0
- data/data/tasks/annotations.rake +29 -0
- data/data/tasks/doc.rake +47 -0
- data/data/tasks/gem.rake +87 -0
- data/data/tasks/manifest.rake +41 -0
- data/data/tasks/rubyforge.rake +57 -0
- data/data/tasks/setup.rb +129 -0
- data/data/tasks/spec.rake +37 -0
- data/data/tasks/test.rake +35 -0
- data/data/test/test_NAME.rb +0 -0
- data/lib/bones.rb +177 -0
- data/tasks/annotations.rake +29 -0
- data/tasks/doc.rake +47 -0
- data/tasks/gem.rake +87 -0
- data/tasks/manifest.rake +41 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +129 -0
- data/tasks/spec.rake +37 -0
- data/tasks/test.rake +35 -0
- metadata +85 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# $Id: annotations.rake 419 2007-12-29 04:39:36Z tim_pease $
|
2
|
+
|
3
|
+
if HAVE_SOURCE_ANNOTATION_EXTRACTOR
|
4
|
+
|
5
|
+
desc "Enumerate all annotations"
|
6
|
+
task :notes do
|
7
|
+
SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :notes do
|
11
|
+
desc "Enumerate all OPTIMIZE annotations"
|
12
|
+
task :optimize do
|
13
|
+
SourceAnnotationExtractor.enumerate "OPTIMIZE"
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Enumerate all FIXME annotations"
|
17
|
+
task :fixme do
|
18
|
+
SourceAnnotationExtractor.enumerate "FIXME"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Enumerate all TODO annotations"
|
22
|
+
task :todo do
|
23
|
+
SourceAnnotationExtractor.enumerate "TODO"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end # if HAVE_SOURCE_ANNOTATION_EXTRACTOR
|
28
|
+
|
29
|
+
# EOF
|
data/tasks/doc.rake
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# $Id: doc.rake 417 2007-12-29 03:21:48Z tim_pease $
|
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.options << '-d' if !WIN32 and `which dot` =~ %r/\/dot/
|
11
|
+
rd.rdoc_dir = PROJ.rdoc_dir
|
12
|
+
|
13
|
+
incl = Regexp.new(PROJ.rdoc_include.join('|'))
|
14
|
+
excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
|
15
|
+
files = PROJ.files.find_all do |fn|
|
16
|
+
case fn
|
17
|
+
when excl; false
|
18
|
+
when incl; true
|
19
|
+
else false end
|
20
|
+
end
|
21
|
+
rd.rdoc_files.push(*files)
|
22
|
+
|
23
|
+
title = "#{PROJ.name}-#{PROJ.version} Documentation"
|
24
|
+
title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
|
25
|
+
|
26
|
+
rd.options << "-t #{title}"
|
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
|
+
# EOF
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# $Id: gem.rake 417 2007-12-29 03:21:48Z tim_pease $
|
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
|
+
|
16
|
+
s.description = PROJ.description
|
17
|
+
|
18
|
+
PROJ.dependencies.each do |dep|
|
19
|
+
s.add_dependency(*dep)
|
20
|
+
end
|
21
|
+
|
22
|
+
s.files = PROJ.files
|
23
|
+
s.executables = PROJ.executables.map {|fn| File.basename(fn)}
|
24
|
+
s.extensions = PROJ.files.grep %r/extconf\.rb$/
|
25
|
+
|
26
|
+
s.bindir = 'bin'
|
27
|
+
dirs = Dir["{#{PROJ.libs.join(',')}}"]
|
28
|
+
s.require_paths = dirs unless dirs.empty?
|
29
|
+
|
30
|
+
incl = Regexp.new(PROJ.rdoc_include.join('|'))
|
31
|
+
excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
|
32
|
+
excl = Regexp.new(excl.join('|'))
|
33
|
+
rdoc_files = PROJ.files.find_all do |fn|
|
34
|
+
case fn
|
35
|
+
when excl; false
|
36
|
+
when incl; true
|
37
|
+
else false end
|
38
|
+
end
|
39
|
+
s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
|
40
|
+
s.extra_rdoc_files = rdoc_files
|
41
|
+
s.has_rdoc = true
|
42
|
+
|
43
|
+
if test ?f, PROJ.test_file
|
44
|
+
s.test_file = PROJ.test_file
|
45
|
+
else
|
46
|
+
s.test_files = PROJ.tests.to_a
|
47
|
+
end
|
48
|
+
|
49
|
+
# Do any extra stuff the user wants
|
50
|
+
# spec_extras.each do |msg, val|
|
51
|
+
# case val
|
52
|
+
# when Proc
|
53
|
+
# val.call(s.send(msg))
|
54
|
+
# else
|
55
|
+
# s.send "#{msg}=", val
|
56
|
+
# end
|
57
|
+
# end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Show information about the gem'
|
61
|
+
task :debug do
|
62
|
+
puts PROJ.spec.to_ruby
|
63
|
+
end
|
64
|
+
|
65
|
+
Rake::GemPackageTask.new(PROJ.spec) do |pkg|
|
66
|
+
pkg.need_tar = PROJ.need_tar
|
67
|
+
pkg.need_zip = PROJ.need_zip
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'Install the gem'
|
71
|
+
task :install => [:clobber, :package] do
|
72
|
+
sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.file_name}"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Uninstall the gem'
|
76
|
+
task :uninstall do
|
77
|
+
sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' #{PROJ.name}"
|
78
|
+
end
|
79
|
+
|
80
|
+
end # namespace :gem
|
81
|
+
|
82
|
+
desc 'Alias to gem:package'
|
83
|
+
task :gem => 'gem:package'
|
84
|
+
|
85
|
+
task :clobber => 'gem:clobber_package'
|
86
|
+
|
87
|
+
# EOF
|
data/tasks/manifest.rake
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# $Id: manifest.rake 419 2007-12-29 04:39:36Z tim_pease $
|
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 = []
|
11
|
+
exclude = Regexp.new(PROJ.exclude.join('|'))
|
12
|
+
Find.find '.' do |path|
|
13
|
+
path.sub! %r/^(\.\/|\/)/o, ''
|
14
|
+
next unless test ?f, path
|
15
|
+
next if path =~ exclude
|
16
|
+
files << path
|
17
|
+
end
|
18
|
+
|
19
|
+
File.open(fn, 'w') {|fp| fp.puts files.sort}
|
20
|
+
system "#{DIFF} -du Manifest.txt #{fn}"
|
21
|
+
rm fn rescue nil
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Create a new manifest'
|
25
|
+
task :create do
|
26
|
+
fn = 'Manifest.txt'
|
27
|
+
files = []
|
28
|
+
exclude = Regexp.new(PROJ.exclude.join('|'))
|
29
|
+
Find.find '.' do |path|
|
30
|
+
path.sub! %r/^(\.\/|\/)/o, ''
|
31
|
+
next unless test ?f, path
|
32
|
+
next if path =~ exclude
|
33
|
+
files << path
|
34
|
+
end
|
35
|
+
|
36
|
+
files << fn unless test ?f, fn
|
37
|
+
File.open(fn, 'w') {|fp| fp.puts files.sort}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# EOF
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# $Id: rubyforge.rake 417 2007-12-29 03:21:48Z tim_pease $
|
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 || PROJ.name
|
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
|
data/tasks/setup.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# $Id: setup.rb 419 2007-12-29 04:39:36Z tim_pease $
|
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)
|
20
|
+
|
21
|
+
# Rspec
|
22
|
+
PROJ.specs = FileList['spec/**/*_spec.rb']
|
23
|
+
PROJ.spec_opts = []
|
24
|
+
|
25
|
+
# Test::Unit
|
26
|
+
PROJ.tests = FileList['test/**/test_*.rb']
|
27
|
+
PROJ.test_file = 'test/all.rb'
|
28
|
+
PROJ.test_opts = []
|
29
|
+
|
30
|
+
# Rcov
|
31
|
+
PROJ.rcov_opts = ['--sort', 'coverage', '-T']
|
32
|
+
|
33
|
+
# Rdoc
|
34
|
+
PROJ.rdoc_opts = []
|
35
|
+
PROJ.rdoc_include = %w(^lib ^bin ^ext txt$)
|
36
|
+
PROJ.rdoc_exclude = %w(extconf\.rb$ ^Manifest\.txt$)
|
37
|
+
PROJ.rdoc_main = 'README.txt'
|
38
|
+
PROJ.rdoc_dir = 'doc'
|
39
|
+
PROJ.rdoc_remote_dir = nil
|
40
|
+
|
41
|
+
# Extensions
|
42
|
+
PROJ.extensions = FileList['ext/**/extconf.rb']
|
43
|
+
PROJ.ruby_opts = %w(-w)
|
44
|
+
PROJ.libs = []
|
45
|
+
%w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
|
46
|
+
|
47
|
+
# Gem Packaging
|
48
|
+
PROJ.files =
|
49
|
+
if test ?f, 'Manifest.txt'
|
50
|
+
files = File.readlines('Manifest.txt').map {|fn| fn.chomp.strip}
|
51
|
+
files.delete ''
|
52
|
+
files
|
53
|
+
else [] end
|
54
|
+
PROJ.executables = PROJ.files.find_all {|fn| fn =~ %r/^bin/}
|
55
|
+
PROJ.dependencies = []
|
56
|
+
PROJ.need_tar = true
|
57
|
+
PROJ.need_zip = false
|
58
|
+
|
59
|
+
# Load the other rake files in the tasks folder
|
60
|
+
Dir.glob('tasks/*.rake').sort.each {|fn| import fn}
|
61
|
+
|
62
|
+
# Setup some constants
|
63
|
+
WIN32 = %r/win32/ =~ RUBY_PLATFORM unless defined? WIN32
|
64
|
+
|
65
|
+
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
|
66
|
+
|
67
|
+
def quiet( &block )
|
68
|
+
io = [STDOUT.dup, STDERR.dup]
|
69
|
+
STDOUT.reopen DEV_NULL
|
70
|
+
STDERR.reopen DEV_NULL
|
71
|
+
block.call
|
72
|
+
ensure
|
73
|
+
STDOUT.reopen io.first
|
74
|
+
STDERR.reopen io.last
|
75
|
+
end
|
76
|
+
|
77
|
+
DIFF = if WIN32 then 'diff.exe'
|
78
|
+
else
|
79
|
+
if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
|
80
|
+
else 'diff' end
|
81
|
+
end unless defined? DIFF
|
82
|
+
|
83
|
+
SUDO = if WIN32 then ''
|
84
|
+
else
|
85
|
+
if quiet {system 'which sudo'} then 'sudo'
|
86
|
+
else '' end
|
87
|
+
end
|
88
|
+
|
89
|
+
RCOV = WIN32 ? 'rcov.cmd' : 'rcov'
|
90
|
+
GEM = WIN32 ? 'gem.cmd' : 'gem'
|
91
|
+
|
92
|
+
%w(rcov spec rubyforge source_annotation_extractor).each do |lib|
|
93
|
+
begin
|
94
|
+
require lib
|
95
|
+
Object.instance_eval {const_set "HAVE_#{lib.upcase}", true}
|
96
|
+
rescue LoadError
|
97
|
+
Object.instance_eval {const_set "HAVE_#{lib.upcase}", false}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Reads a file at +path+ and spits out an array of the +paragraphs+
|
102
|
+
# specified.
|
103
|
+
#
|
104
|
+
# changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
105
|
+
# summary, *description = paragraphs_of('README.txt', 3, 3..8)
|
106
|
+
#
|
107
|
+
def paragraphs_of(path, *paragraphs)
|
108
|
+
File.read(path).delete("\r").split(/\n\n+/).values_at(*paragraphs)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Adds the given gem _name_ to the current project's dependency list. An
|
112
|
+
# optional gem _version_ can be given. If omitted, the newest gem version
|
113
|
+
# will be used.
|
114
|
+
#
|
115
|
+
def depend_on( name, version = nil )
|
116
|
+
spec = Gem.source_index.find_name(name).last
|
117
|
+
version = spec.version.to_s if version.nil? and !spec.nil?
|
118
|
+
|
119
|
+
PROJ.dependencies << (version.nil? ? [name] : [name, ">= #{version}"])
|
120
|
+
end
|
121
|
+
|
122
|
+
# Adds the given _path_ to the include path if it is not already there
|
123
|
+
#
|
124
|
+
def ensure_in_path( path )
|
125
|
+
path = File.expand_path(path)
|
126
|
+
$:.unshift(path) if test(?d, path) and not $:.include?(path)
|
127
|
+
end
|
128
|
+
|
129
|
+
# EOF
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# $Id: spec.rake 417 2007-12-29 03:21:48Z tim_pease $
|
2
|
+
|
3
|
+
if HAVE_SPEC
|
4
|
+
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
|
9
|
+
desc 'Run all specs with basic output'
|
10
|
+
Spec::Rake::SpecTask.new(:run) do |t|
|
11
|
+
t.spec_opts = PROJ.spec_opts
|
12
|
+
t.spec_files = PROJ.specs
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run all specs with text output'
|
16
|
+
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
17
|
+
t.spec_opts = PROJ.spec_opts + ['--format', 'specdoc']
|
18
|
+
t.spec_files = PROJ.specs
|
19
|
+
end
|
20
|
+
|
21
|
+
if HAVE_RCOV
|
22
|
+
desc 'Run all specs with RCov'
|
23
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
24
|
+
t.spec_opts = PROJ.spec_opts
|
25
|
+
t.spec_files = PROJ.specs
|
26
|
+
t.rcov = true
|
27
|
+
t.rcov_opts = PROJ.rcov_opts + ['--exclude', 'spec']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end # namespace :spec
|
32
|
+
|
33
|
+
task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
|
34
|
+
|
35
|
+
end # if HAVE_SPEC
|
36
|
+
|
37
|
+
# EOF
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# $Id: test.rake 417 2007-12-29 03:21:48Z tim_pease $
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
|
7
|
+
Rake::TestTask.new(:run) do |t|
|
8
|
+
t.libs = PROJ.libs
|
9
|
+
t.test_files = if test ?f, PROJ.test_file then [PROJ.test_file]
|
10
|
+
else PROJ.tests end
|
11
|
+
t.ruby_opts += PROJ.ruby_opts
|
12
|
+
t.ruby_opts += PROJ.test_opts
|
13
|
+
end
|
14
|
+
|
15
|
+
if HAVE_RCOV
|
16
|
+
desc 'Run rcov on the unit tests'
|
17
|
+
task :rcov => :clobber_rcov do
|
18
|
+
opts = PROJ.rcov_opts.join(' ')
|
19
|
+
files = if test ?f, PROJ.test_file then [PROJ.test_file]
|
20
|
+
else PROJ.tests end
|
21
|
+
files = files.join(' ')
|
22
|
+
sh "#{RCOV} #{files} #{opts}"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Remove rcov products'
|
26
|
+
task :clobber_rcov do
|
27
|
+
rm_r 'coverage' rescue nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end # namespace :test
|
32
|
+
|
33
|
+
task :clobber => 'test:clobber_rcov' if HAVE_RCOV
|
34
|
+
|
35
|
+
# EOF
|