bones 1.3.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ desc "Enumerate all annotations"
6
+ task :notes do |t|
7
+ id = if ARGV.length > 1
8
+ t.application.top_level_tasks.slice!(1..-1).join(' ')
9
+ end
10
+ Bones::AnnotationExtractor.enumerate(
11
+ PROJ, PROJ.notes.tags.join('|'), id, :tag => true)
12
+ end
13
+
14
+ namespace :notes do
15
+ PROJ.notes.tags.each do |tag|
16
+ desc "Enumerate all #{tag} annotations"
17
+ task tag.downcase.to_sym do |t|
18
+ id = if ARGV.length > 1
19
+ t.application.top_level_tasks.slice!(1..-1).join(' ')
20
+ end
21
+ Bones::AnnotationExtractor.enumerate(PROJ, tag, id)
22
+ end
23
+ end
24
+ end
25
+
26
+ end # if HAVE_BONES
27
+
28
+ # EOF
@@ -3,14 +3,19 @@
3
3
  # This file does not define any rake tasks. It is used to load some project
4
4
  # settings if they are not defined by the user.
5
5
 
6
- PROJ.rdoc_exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
- PROJ.exclude << "^#{Regexp.escape(PROJ.ann_file)}$"
8
-
9
- PROJ.instance_variable_get(:@table).each do |key,val|
10
- next unless val.instance_of? Array
11
- next if key == :dependencies
12
- val.flatten!
13
- end
6
+ PROJ.rdoc.exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
7
+ PROJ.exclude << "^#{Regexp.escape(PROJ.ann.file)}$"
8
+
9
+ flatten_arrays = lambda do |this,os|
10
+ os.instance_variable_get(:@table).each do |key,val|
11
+ next if key == :dependencies
12
+ case val
13
+ when Array; val.flatten!
14
+ when OpenStruct; this.call(this,val)
15
+ end
16
+ end
17
+ end
18
+ flatten_arrays.call(flatten_arrays,PROJ)
14
19
 
15
20
  PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
16
21
 
@@ -18,15 +23,15 @@ PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
18
23
 
19
24
  PROJ.summary ||= PROJ.description.split('.').first
20
25
 
21
- PROJ.files ||=
26
+ PROJ.gem.files ||=
22
27
  if test(?f, PROJ.manifest_file)
23
28
  files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
24
29
  files.delete ''
25
30
  files
26
31
  else [] end
27
32
 
28
- PROJ.executables ||= PROJ.files.find_all {|fn| fn =~ %r/^bin/}
33
+ PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}
29
34
 
30
- PROJ.rdoc_main ||= PROJ.readme_file
35
+ PROJ.rdoc.main ||= PROJ.readme_file
31
36
 
32
37
  # EOF
@@ -6,12 +6,13 @@ namespace :doc do
6
6
 
7
7
  desc 'Generate RDoc documentation'
8
8
  Rake::RDocTask.new do |rd|
9
- rd.main = PROJ.rdoc_main
10
- rd.rdoc_dir = PROJ.rdoc_dir
9
+ rdoc = PROJ.rdoc
10
+ rd.main = rdoc.main
11
+ rd.rdoc_dir = rdoc.dir
11
12
 
12
- incl = Regexp.new(PROJ.rdoc_include.join('|'))
13
- excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
14
- files = PROJ.files.find_all do |fn|
13
+ incl = Regexp.new(rdoc.include.join('|'))
14
+ excl = Regexp.new(rdoc.exclude.join('|'))
15
+ files = PROJ.gem.files.find_all do |fn|
15
16
  case fn
16
17
  when excl; false
17
18
  when incl; true
@@ -20,10 +21,12 @@ namespace :doc do
20
21
  rd.rdoc_files.push(*files)
21
22
 
22
23
  title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
- title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
24
+
25
+ rf_name = PROJ.rubyforge.name
26
+ title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
24
27
 
25
28
  rd.options << "-t #{title}"
26
- rd.options.concat(PROJ.rdoc_opts)
29
+ rd.options.concat(rdoc.opts)
27
30
  end
28
31
 
29
32
  desc 'Generate ri locally for testing'
@@ -1,6 +1,6 @@
1
1
  # $Id$
2
2
 
3
- if PROJ.rubyforge_name && HAVE_RUBYFORGE
3
+ if PROJ.rubyforge.name.valid? && HAVE_RUBYFORGE
4
4
 
5
5
  require 'rubyforge'
6
6
  require 'rake/contrib/sshpublisher'
@@ -10,11 +10,11 @@ namespace :gem do
10
10
  task :release => [:clobber, :package] do |t|
11
11
  v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
12
  abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
- pkg = "pkg/#{PROJ.spec.full_name}"
13
+ pkg = "pkg/#{PROJ.gem._spec.full_name}"
14
14
 
15
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\""
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
18
  end
19
19
 
20
20
  rf = RubyForge.new
@@ -26,12 +26,12 @@ namespace :gem do
26
26
  c['release_changes'] = PROJ.changes if PROJ.changes
27
27
  c['preformatted'] = true
28
28
 
29
- files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
- (PROJ.need_zip ? "#{pkg}.zip" : nil),
29
+ files = [(PROJ.gem.need_tar ? "#{pkg}.tgz" : nil),
30
+ (PROJ.gem.need_zip ? "#{pkg}.zip" : nil),
31
31
  "#{pkg}.gem"].compact
32
32
 
33
33
  puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
- rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
34
+ rf.add_release PROJ.rubyforge.name, PROJ.name, PROJ.version, *files
35
35
  end
36
36
  end # namespace :gem
37
37
 
@@ -44,9 +44,9 @@ namespace :doc do
44
44
  )
45
45
 
46
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
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
50
 
51
51
  Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
52
  end
@@ -6,92 +6,117 @@ require 'rake/clean'
6
6
  require 'fileutils'
7
7
  require 'ostruct'
8
8
 
9
- PROJ = OpenStruct.new
10
-
11
- PROJ.name = nil
12
- PROJ.summary = nil
13
- PROJ.description = nil
14
- PROJ.changes = nil
15
- PROJ.authors = nil
16
- PROJ.email = nil
17
- PROJ.url = nil
18
- PROJ.version = ENV['VERSION'] || '0.0.0'
19
- PROJ.rubyforge_name = nil
20
- PROJ.exclude = %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/)
21
- PROJ.release_name = ENV['RELEASE']
22
- PROJ.history_file = 'History.txt'
23
- PROJ.manifest_file = 'Manifest.txt'
24
- PROJ.readme_file = 'README.txt'
25
-
26
- # Rspec
27
- PROJ.specs = FileList['spec/**/*_spec.rb']
28
- PROJ.spec_opts = []
29
-
30
- # Test::Unit
31
- PROJ.tests = FileList['test/**/test_*.rb']
32
- PROJ.test_file = 'test/all.rb'
33
- PROJ.test_opts = []
34
-
35
- # Rcov
36
- PROJ.rcov_dir = 'coverage'
37
- PROJ.rcov_opts = %w[--sort coverage -T]
38
- PROJ.rcov_threshold = 90.0
39
- PROJ.rcov_threshold_exact = false
40
-
41
- # Rdoc
42
- PROJ.rdoc_opts = []
43
- PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
44
- PROJ.rdoc_exclude = %w(extconf.rb$)
45
- PROJ.rdoc_main = nil
46
- PROJ.rdoc_dir = 'doc'
47
- PROJ.rdoc_remote_dir = nil
48
-
49
- # Extensions
50
- PROJ.extensions = FileList['ext/**/extconf.rb']
51
- PROJ.ruby_opts = %w(-w)
52
- PROJ.libs = []
53
- %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
9
+ class OpenStruct; undef :gem; end
10
+
11
+ PROJ = OpenStruct.new(
12
+ # Project Defaults
13
+ :name => nil,
14
+ :summary => nil,
15
+ :description => nil,
16
+ :changes => nil,
17
+ :authors => nil,
18
+ :email => nil,
19
+ :url => "\000",
20
+ :version => ENV['VERSION'] || '0.0.0',
21
+ :exclude => %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/),
22
+ :release_name => ENV['RELEASE'],
23
+
24
+ # System Defaults
25
+ :ruby_opts => %w(-w),
26
+ :libs => [],
27
+ :history_file => 'History.txt',
28
+ :manifest_file => 'Manifest.txt',
29
+ :readme_file => 'README.txt',
30
+
31
+ # Announce
32
+ :ann => OpenStruct.new(
33
+ :file => 'announcement.txt',
34
+ :text => nil,
35
+ :paragraphs => [],
36
+ :email => {
37
+ :from => nil,
38
+ :to => %w(ruby-talk@ruby-lang.org),
39
+ :server => 'localhost',
40
+ :port => 25,
41
+ :domain => ENV['HOSTNAME'],
42
+ :acct => nil,
43
+ :passwd => nil,
44
+ :authtype => :plain
45
+ }
46
+ ),
47
+
48
+ # Gem Packaging
49
+ :gem => OpenStruct.new(
50
+ :dependencies => [],
51
+ :executables => nil,
52
+ :extensions => FileList['ext/**/extconf.rb'],
53
+ :files => nil,
54
+ :need_tar => true,
55
+ :need_zip => false,
56
+ :extras => {}
57
+ ),
58
+
59
+ # File Annotations
60
+ :notes => OpenStruct.new(
61
+ :exclude => %w(^tasks/setup.rb$),
62
+ :extensions => %w(.txt .rb .erb) << '',
63
+ :tags => %w(FIXME OPTIMIZE TODO)
64
+ ),
65
+
66
+ # Rcov
67
+ :rcov => OpenStruct.new(
68
+ :dir => 'coverage',
69
+ :opts => %w[--sort coverage -T],
70
+ :threshold => 90.0,
71
+ :threshold_exact => false
72
+ ),
73
+
74
+ # Rdoc
75
+ :rdoc => OpenStruct.new(
76
+ :opts => [],
77
+ :include => %w(^lib/ ^bin/ ^ext/ .txt$),
78
+ :exclude => %w(extconf.rb$),
79
+ :main => nil,
80
+ :dir => 'doc',
81
+ :remote_dir => nil
82
+ ),
83
+
84
+ # Rubyforge
85
+ :rubyforge => OpenStruct.new(
86
+ :name => "\000"
87
+ ),
54
88
 
55
- # Gem Packaging
56
- PROJ.files = nil
57
- PROJ.executables = nil
58
- PROJ.dependencies = []
59
- PROJ.need_tar = true
60
- PROJ.need_zip = false
61
- PROJ.post_install_message = nil
62
-
63
- # File Annotations
64
- PROJ.annotation_exclude = %w(^tasks/setup.rb$)
65
- PROJ.annotation_extensions = %w(.txt .rb .erb) << ''
66
- PROJ.annotation_tags = %w(FIXME OPTIMIZE TODO)
67
-
68
- # Subversion Repository
69
- PROJ.svn = false
70
- PROJ.svn_root = nil
71
- PROJ.svn_trunk = 'trunk'
72
- PROJ.svn_tags = 'tags'
73
- PROJ.svn_branches = 'branches'
74
-
75
- # Announce
76
- PROJ.ann_file = 'announcement.txt'
77
- PROJ.ann_text = nil
78
- PROJ.ann_paragraphs = []
79
- PROJ.ann_email = {
80
- :from => nil,
81
- :to => %w(ruby-talk@ruby-lang.org),
82
- :server => 'localhost',
83
- :port => 25,
84
- :domain => ENV['HOSTNAME'],
85
- :acct => nil,
86
- :passwd => nil,
87
- :authtype => :plain
88
- }
89
+ # Rspec
90
+ :spec => OpenStruct.new(
91
+ :files => FileList['spec/**/*_spec.rb'],
92
+ :opts => []
93
+ ),
94
+
95
+ # Subversion Repository
96
+ :svn => OpenStruct.new(
97
+ :root => nil,
98
+ :path => '',
99
+ :trunk => 'trunk',
100
+ :tags => 'tags',
101
+ :branches => 'branches'
102
+ ),
103
+
104
+ # Test::Unit
105
+ :test => OpenStruct.new(
106
+ :files => FileList['test/**/test_*.rb'],
107
+ :file => 'test/all.rb',
108
+ :opts => []
109
+ )
110
+ )
89
111
 
90
112
  # Load the other rake files in the tasks folder
91
113
  rakefiles = Dir.glob('tasks/*.rake').sort
92
114
  rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
93
115
  import(*rakefiles)
94
116
 
117
+ # Setup the project libraries
118
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
119
+
95
120
  # Setup some constants
96
121
  WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
97
122
 
@@ -105,6 +130,7 @@ def quiet( &block )
105
130
  ensure
106
131
  STDOUT.reopen io.first
107
132
  STDERR.reopen io.last
133
+ $stdout, $stderr = STDOUT, STDERR
108
134
  end
109
135
 
110
136
  DIFF = if WIN32 then 'diff.exe'
@@ -120,6 +146,7 @@ SUDO = if WIN32 then ''
120
146
  end
121
147
 
122
148
  RCOV = WIN32 ? 'rcov.bat' : 'rcov'
149
+ RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
123
150
  GEM = WIN32 ? 'gem.bat' : 'gem'
124
151
 
125
152
  %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
@@ -130,6 +157,8 @@ GEM = WIN32 ? 'gem.bat' : 'gem'
130
157
  Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
131
158
  end
132
159
  end
160
+ HAVE_SVN = (Dir.entries(Dir.pwd).include?('.svn') and
161
+ system("svn --version 2>&1 > #{DEV_NULL}"))
133
162
 
134
163
  # Reads a file at +path+ and spits out an array of the +paragraphs+
135
164
  # specified.
@@ -169,7 +198,7 @@ def depend_on( name, version = nil )
169
198
  spec = Gem.source_index.find_name(name).last
170
199
  version = spec.version.to_s if version.nil? and !spec.nil?
171
200
 
172
- PROJ.dependencies << case version
201
+ PROJ.gem.dependencies << case version
173
202
  when nil; [name]
174
203
  when %r/^\d/; [name, ">= #{version}"]
175
204
  else [name, version] end
@@ -224,4 +253,14 @@ def manifest_files
224
253
  files.sort!
225
254
  end
226
255
 
256
+ # We need a "valid" method thtat determines if a string is suitable for use
257
+ # in the gem specification.
258
+ #
259
+ class Object
260
+ def valid?
261
+ return !(self.empty? or self == "\000") if self.respond_to?(:to_str)
262
+ return false
263
+ end
264
+ end
265
+
227
266
  # EOF
@@ -8,16 +8,16 @@ namespace :spec do
8
8
  desc 'Run all specs with basic output'
9
9
  Spec::Rake::SpecTask.new(:run) do |t|
10
10
  t.ruby_opts = PROJ.ruby_opts
11
- t.spec_opts = PROJ.spec_opts
12
- t.spec_files = PROJ.specs
11
+ t.spec_opts = PROJ.spec.opts
12
+ t.spec_files = PROJ.spec.files
13
13
  t.libs += PROJ.libs
14
14
  end
15
15
 
16
16
  desc 'Run all specs with text output'
17
17
  Spec::Rake::SpecTask.new(:specdoc) do |t|
18
18
  t.ruby_opts = PROJ.ruby_opts
19
- t.spec_opts = PROJ.spec_opts + ['--format', 'specdoc']
20
- t.spec_files = PROJ.specs
19
+ t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
20
+ t.spec_files = PROJ.spec.files
21
21
  t.libs += PROJ.libs
22
22
  end
23
23
 
@@ -25,21 +25,22 @@ namespace :spec do
25
25
  desc 'Run all specs with RCov'
26
26
  Spec::Rake::SpecTask.new(:rcov) do |t|
27
27
  t.ruby_opts = PROJ.ruby_opts
28
- t.spec_opts = PROJ.spec_opts
29
- t.spec_files = PROJ.specs
28
+ t.spec_opts = PROJ.spec.opts
29
+ t.spec_files = PROJ.spec.files
30
30
  t.libs += PROJ.libs
31
31
  t.rcov = true
32
- t.rcov_dir = PROJ.rcov_dir
33
- t.rcov_opts = PROJ.rcov_opts + ['--exclude', 'spec']
32
+ t.rcov_dir = PROJ.rcov.dir
33
+ t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
34
34
  end
35
35
 
36
36
  RCov::VerifyTask.new(:verify) do |t|
37
- t.threshold = PROJ.rcov_threshold
38
- t.index_html = File.join(PROJ.rcov_dir, 'index.html')
39
- t.require_exact_threshold = PROJ.rcov_threshold_exact
37
+ t.threshold = PROJ.rcov.threshold
38
+ t.index_html = File.join(PROJ.rcov.dir, 'index.html')
39
+ t.require_exact_threshold = PROJ.rcov.threshold_exact
40
40
  end
41
41
 
42
42
  task :verify => :rcov
43
+ remove_desc_for_task %w(spec:clobber_rcov)
43
44
  end
44
45
 
45
46
  end # namespace :spec
@@ -49,8 +50,6 @@ task :spec => 'spec:run'
49
50
 
50
51
  task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
51
52
 
52
- remove_desc_for_task %w(spec:clobber_rcov)
53
-
54
53
  end # if HAVE_SPEC_RAKE_SPECTASK
55
54
 
56
55
  # EOF