zorglub 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/tasks/git.rake ADDED
@@ -0,0 +1,38 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ if HAVE_GIT
4
+
5
+ namespace :git do
6
+
7
+ # A prerequisites task that all other tasks depend upon
8
+ task :prereqs
9
+
10
+ desc 'Show tags from the Git repository'
11
+ task :show_tags => 'git:prereqs' do |t|
12
+ puts %x/git tag/
13
+ end
14
+
15
+ desc 'Create a new tag in the Git repository'
16
+ task :create_tag => 'git:prereqs' do |t|
17
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
18
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
19
+ tag = "%s" % [ PROJ.version ]
20
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
21
+ puts "Creating Git tag '#{tag}'"
22
+ unless system "git tag -a -m '#{msg}' #{tag}"
23
+ abort "Tag creation failed"
24
+ end
25
+ # if %x/git remote/ =~ %r/^origin\s*$/
26
+ # unless system "git push origin #{tag}"
27
+ # abort "Could not push tag to remote Git repository"
28
+ # end
29
+ # end
30
+ end
31
+
32
+ end # namespace :git
33
+
34
+ #task 'gem:release' => 'git:create_tag'
35
+
36
+ end # if HAVE_GIT
37
+
38
+ # EOF
data/tasks/helpers.rb ADDED
@@ -0,0 +1,130 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ require 'fileutils'
4
+ require 'find'
5
+ require 'date'
6
+ #
7
+ # Reads a file at +path+ and spits out an array of the +paragraphs+
8
+ # specified.
9
+ #
10
+ # changes = paragraphs_of('History.txt', 0..1).join("\n\n")
11
+ # summary, *description = paragraphs_of('README.txt', 3, 3..8)
12
+ #
13
+ def paragraphs_of( path, *paragraphs )
14
+ title = String === paragraphs.first ? paragraphs.shift : nil
15
+ ary = File.read(path).delete("\r").split(/\n\n+/)
16
+
17
+ result = if title
18
+ tmp, matching = [], false
19
+ rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
20
+ paragraphs << (0..-1) if paragraphs.empty?
21
+
22
+ ary.each do |val|
23
+ if val =~ rgxp
24
+ break if matching
25
+ matching = true
26
+ rgxp = %r/^=+/i
27
+ elsif matching
28
+ tmp << val
29
+ end
30
+ end
31
+ tmp
32
+ else ary end
33
+
34
+ result.values_at(*paragraphs)
35
+ end
36
+
37
+ # Adds the given gem _name_ to the current project's dependency list. An
38
+ # optional gem _version_ can be given. If omitted, the newest gem version
39
+ # will be used.
40
+ #
41
+ def depend_on( name, version = nil )
42
+ spec = Gem::Specification.find_by_name(name)
43
+ version = spec.version.to_s if version.nil? and !spec.nil?
44
+
45
+ PROJ.gem.dependencies << case version
46
+ when nil; [name]
47
+ when %r/^\d/; [name, ">= #{version}"]
48
+ else [name, version] end
49
+ end
50
+
51
+ # Adds the given arguments to the include path if they are not already there
52
+ #
53
+ #def ensure_in_path( *args )
54
+ # args.each do |path|
55
+ # path = File.expand_path(path)
56
+ # $:.unshift(path) if test(?d, path) and not $:.include?(path)
57
+ # end
58
+ #end
59
+
60
+ # Find a rake task using the task name and remove any description text. This
61
+ # will prevent the task from being displayed in the list of available tasks.
62
+ #
63
+ def remove_desc_for_task( names )
64
+ Array(names).each do |task_name|
65
+ task = Rake.application.tasks.find {|t| t.name == task_name}
66
+ next if task.nil?
67
+ task.instance_variable_set :@comment, nil
68
+ end
69
+ end
70
+
71
+ # Change working directories to _dir_, call the _block_ of code, and then
72
+ # change back to the original working directory (the current directory when
73
+ # this method was called).
74
+ #
75
+ #def in_directory( dir, &block )
76
+ # curdir = pwd
77
+ # begin
78
+ # cd dir
79
+ # return block.call
80
+ # ensure
81
+ # cd curdir
82
+ # end
83
+ #end
84
+
85
+ # Scans the current working directory and creates a list of files that are
86
+ # candidates to be in the manifest.
87
+ #
88
+ #def manifest
89
+ # files = []
90
+ # exclude = PROJ.exclude.dup
91
+ # comment = %r/^\s*#/
92
+ #
93
+ # # process the ignore file and add the items there to the exclude list
94
+ # if test(?f, PROJ.ignore_file)
95
+ # ary = []
96
+ # File.readlines(PROJ.ignore_file).each do |line|
97
+ # next if line =~ comment
98
+ # line.chomp!
99
+ # line.strip!
100
+ # next if line.nil? or line.empty?
101
+ #
102
+ # glob = line =~ %r/\*\./ ? File.join('**', line) : line
103
+ # Dir.glob(glob).each {|fn| ary << "^#{Regexp.escape(fn)}"}
104
+ # end
105
+ # exclude.concat ary
106
+ # end
107
+ #
108
+ # # generate a regular expression from the exclude list
109
+ # exclude = Regexp.new(exclude.join('|'))
110
+ #
111
+ # Find.find '.' do |path|
112
+ # path.sub! %r/^(\.\/|\/)/o, ''
113
+ # next unless test ?f, path
114
+ # next if path =~ exclude
115
+ # files << path
116
+ # end
117
+ # files.sort!
118
+ #end
119
+
120
+ # We need a "valid" method that determines if a string is suitable for use
121
+ # in the gem specification.
122
+ #
123
+ class Object
124
+ def valid?
125
+ return !(self.empty? or self == "\000") if self.respond_to?(:to_str)
126
+ return false
127
+ end
128
+ end
129
+
130
+ # EOF
data/tasks/notes.rake ADDED
@@ -0,0 +1,27 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ if HAVE_BONES
4
+
5
+ desc "Enumerate all annotations"
6
+ task :notes do |t|
7
+ id = if t.application.top_level_tasks.length > 1
8
+ t.application.top_level_tasks.slice!(1..-1).join(' ')
9
+ end
10
+ Bones::AnnotationExtractor.enumerate(PROJ, PROJ.notes.tags.join('|'), id, :tag => true)
11
+ end
12
+
13
+ namespace :notes do
14
+ PROJ.notes.tags.each do |tag|
15
+ desc "Enumerate all #{tag} annotations"
16
+ task tag.downcase.to_sym do |t|
17
+ id = if t.application.top_level_tasks.length > 1
18
+ t.application.top_level_tasks.slice!(1..-1).join(' ')
19
+ end
20
+ Bones::AnnotationExtractor.enumerate(PROJ, tag, id)
21
+ end
22
+ end
23
+ end
24
+
25
+ end # if HAVE_BONES
26
+
27
+ # EOF
@@ -0,0 +1,35 @@
1
+ # -*- coding: UTF-8 -*-
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
+ PROJ.exclude << ["^#{Regexp.escape(PROJ.ann.file)}$",
7
+ "^#{Regexp.escape(PROJ.ignore_file)}$",
8
+ "^#{Regexp.escape(PROJ.rdoc.dir)}/",
9
+ "^#{Regexp.escape(PROJ.rcov.dir)}/"]
10
+
11
+ flatten_arrays = lambda do |this,os|
12
+ os.instance_variable_get(:@table).each do |key,val|
13
+ next if key == :dependencies \
14
+ or key == :development_dependencies
15
+ case val
16
+ when Array; val.flatten!
17
+ when OpenStruct; this.call(this,val)
18
+ end
19
+ end
20
+ end
21
+ flatten_arrays.call(flatten_arrays,PROJ)
22
+
23
+ PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
24
+
25
+ PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
26
+
27
+ PROJ.summary ||= PROJ.description.split('.').first
28
+
29
+ PROJ.gem.files ||= manifest
30
+
31
+ PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}
32
+
33
+ PROJ.rdoc.main ||= PROJ.readme_file
34
+
35
+ # EOF
data/tasks/rdoc.rake ADDED
@@ -0,0 +1,46 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ require 'rdoc/task'
4
+
5
+ namespace :doc do
6
+ desc 'Generate RDoc documentation'
7
+ Rake::RDocTask.new do |rd|
8
+ rdoc = PROJ.rdoc
9
+ rd.main = rdoc.main
10
+ rd.rdoc_dir = rdoc.dir
11
+
12
+ incl = Regexp.new(rdoc.include.join('|'))
13
+ excl = Regexp.new(rdoc.exclude.join('|'))
14
+ files = PROJ.gem.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
+ title = "#{PROJ.name}-#{PROJ.version} Documentation"
22
+ rf_name = PROJ.rubyforge.name
23
+ title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
24
+ rd.options << "-t #{title}"
25
+ rd.options.concat(rdoc.opts)
26
+ end
27
+
28
+ desc 'Generate ri locally for testing'
29
+ task :ri => :clobber_ri do
30
+ sh "#{RDOC} --ri -o ri ."
31
+ end
32
+
33
+ task :clobber_ri do
34
+ rm_r 'ri' rescue nil
35
+ end
36
+ end # namespace :doc
37
+
38
+ desc 'Alias to doc:rdoc'
39
+ task :doc => 'doc:rdoc'
40
+
41
+ desc 'Remove all build products'
42
+ task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
43
+
44
+ remove_desc_for_task %w(doc:clobber_rdoc)
45
+
46
+ # EOF
@@ -0,0 +1,54 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ if PROJ.rubyforge.name.valid? && 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, 'gem'] 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.gem._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
+ rf.configure rescue nil
22
+ puts 'Logging in'
23
+ rf.login
24
+
25
+ c = rf.userconfig
26
+ c['release_notes'] = PROJ.description if PROJ.description
27
+ c['release_changes'] = PROJ.changes if PROJ.changes
28
+ c['preformatted'] = true
29
+
30
+ files = Dir.glob("#{pkg}*.*")
31
+
32
+ puts "Releasing #{PROJ.name} v. #{PROJ.version}"
33
+ rf.add_release PROJ.rubyforge.name, PROJ.name, PROJ.version, *files
34
+ end
35
+ end # namespace :gem
36
+
37
+
38
+ namespace :doc do
39
+ desc "Publish RDoc to RubyForge"
40
+ task :release => %w(doc:clobber_rdoc doc:rdoc) do
41
+ config = YAML.load(File.read(File.expand_path('~/.rubyforge/user-config.yml')))
42
+
43
+ host = "#{config['username']}@rubyforge.org"
44
+ remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge.name}/"
45
+ remote_dir << PROJ.rdoc.remote_dir if PROJ.rdoc.remote_dir
46
+ local_dir = PROJ.rdoc.dir
47
+
48
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
49
+ end
50
+ end # namespace :doc
51
+
52
+ end # if HAVE_RUBYFORGE
53
+
54
+ # EOF
data/tasks/setup.rb ADDED
@@ -0,0 +1,129 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'rake/clean'
6
+ require 'ostruct'
7
+
8
+ class OpenStruct; undef :gem; end
9
+
10
+ # TODO: make my own openstruct type object that includes descriptions
11
+ # TODO: use the descriptions to output help on the available bones options
12
+
13
+ PROJ = OpenStruct.new(
14
+ # Project Defaults
15
+ :name => nil,
16
+ :summary => nil,
17
+ :description => nil,
18
+ :changes => nil,
19
+ :authors => nil,
20
+ :email => nil,
21
+ :url => "\000",
22
+ :version => ENV['VERSION'] || '0.0.0',
23
+ :exclude => %w(tmp$ bak$ ~$ CVS \.svn/ \.git/ ^pkg/),
24
+ :release_name => ENV['RELEASE'],
25
+
26
+ # System Defaults
27
+ :ruby_opts => %w(-w),
28
+ :libs => [],
29
+ :history_file => 'Changelog',
30
+ :readme_file => 'README.rdoc',
31
+ :ignore_file => '.bnsignore',
32
+
33
+ # Announce
34
+ :ann => OpenStruct.new(
35
+ :file => 'announcement.txt',
36
+ :text => nil,
37
+ :paragraphs => [],
38
+ :email => {
39
+ :from => nil,
40
+ :to => %w(ruby-talk@ruby-lang.org),
41
+ :server => 'localhost',
42
+ :port => 25,
43
+ :domain => ENV['HOSTNAME'],
44
+ :acct => nil,
45
+ :passwd => nil,
46
+ :authtype => :plain,
47
+ :tls => true,
48
+ }
49
+ ),
50
+
51
+ # Gem Packaging
52
+ :gem => OpenStruct.new(
53
+ :dependencies => [],
54
+ :development_dependencies => [],
55
+ :executables => nil,
56
+ :extensions => FileList['ext/**/extconf.rb'],
57
+ :files => nil,
58
+ :need_tar => true,
59
+ :need_zip => false,
60
+ :extras => {}
61
+ ),
62
+
63
+ # File Annotations
64
+ :notes => OpenStruct.new(
65
+ :exclude => %w(^tasks/setup\.rb$),
66
+ :extensions => %w(.txt .rb .erb .rdoc) << '',
67
+ :tags => %w(FIXME OPTIMIZE TODO)
68
+ ),
69
+
70
+ # Rcov
71
+ :rcov => OpenStruct.new(
72
+ :dir => 'coverage',
73
+ :opts => %w[--sort coverage -T -x lib/rcov],
74
+ :threshold => 90.0,
75
+ :threshold_exact => false
76
+ ),
77
+
78
+ # Rdoc
79
+ :rdoc => OpenStruct.new(
80
+ :opts => [],
81
+ :include => %w(^lib/ ^bin/ ^ext/ \.txt$ \.rdoc$),
82
+ :exclude => %w(extconf\.rb$),
83
+ :main => nil,
84
+ :dir => 'doc',
85
+ :remote_dir => nil
86
+ ),
87
+
88
+ # Rubyforge
89
+ :rubyforge => OpenStruct.new(
90
+ :name => "\000"
91
+ ),
92
+
93
+ # Rspec
94
+ :spec => OpenStruct.new(
95
+ :files => FileList['spec/**/*_spec.rb'],
96
+ :opts => []
97
+ ),
98
+
99
+ # Subversion Repository
100
+ :svn => OpenStruct.new(
101
+ :root => nil,
102
+ :path => '',
103
+ :trunk => 'trunk',
104
+ :tags => 'tags',
105
+ :branches => 'branches'
106
+ ),
107
+
108
+ # Test::Unit
109
+ :test => OpenStruct.new(
110
+ :files => FileList['test/**/test_*.rb'],
111
+ :file => 'test/all.rb',
112
+ :opts => []
113
+ )
114
+ )
115
+
116
+ # Load the other rake files in the tasks folder
117
+ tasks_dir = File.expand_path(File.dirname(__FILE__))
118
+ post_load_fn = File.join(tasks_dir, 'post_load.rake')
119
+ rakefiles = Dir.glob(File.join(tasks_dir, '*.rake')).sort
120
+ rakefiles.unshift(rakefiles.delete(post_load_fn)).compact!
121
+ import(*rakefiles)
122
+
123
+ # Setup the project libraries
124
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
125
+
126
+ load './tasks/constants.rb'
127
+ load './tasks/helpers.rb'
128
+
129
+ # EOF
data/tasks/spec.rake ADDED
@@ -0,0 +1,44 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ #if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
4
+ require 'rspec/core/rake_task'
5
+ #
6
+ namespace :spec do
7
+
8
+ desc 'Run all specs with basic output'
9
+ RSpec::Core::RakeTask.new(:run) do |t,args|
10
+ t.ruby_opts = PROJ.ruby_opts
11
+ t.rspec_opts = PROJ.spec.opts
12
+ t.pattern = ENV['pattern'] if ENV['pattern']
13
+ end
14
+
15
+ desc 'Run all specs with text output'
16
+ RSpec::Core::RakeTask.new(:doc) do |t|
17
+ t.ruby_opts = PROJ.ruby_opts
18
+ t.rspec_opts = PROJ.spec.opts + ['-fs' ]
19
+ t.pattern = ENV['pattern'] if ENV['pattern']
20
+ end
21
+
22
+ desc 'Run all specs with html output'
23
+ RSpec::Core::RakeTask.new(:html) do |t|
24
+ t.ruby_opts = PROJ.ruby_opts
25
+ t.rspec_opts = PROJ.spec.opts + ['-fh' ]
26
+ t.pattern = ENV['pattern'] if ENV['pattern']
27
+ end
28
+
29
+ if HAVE_RCOV
30
+ desc 'Run all specs with RCov'
31
+ RSpec::Core::RakeTask.new(:rcov) do |t|
32
+ t.ruby_opts = PROJ.ruby_opts
33
+ t.rspec_opts = PROJ.spec.opts
34
+ t.rcov = true
35
+ t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
36
+ end
37
+ end
38
+
39
+ end # namespace :spec
40
+
41
+ desc 'Alias to spec:run'
42
+ task :spec => 'spec:run'
43
+
44
+ # EOF
data/tasks/svn.rake ADDED
@@ -0,0 +1,48 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ if HAVE_SVN
4
+
5
+ unless PROJ.svn.root
6
+ info = %x/svn info ./
7
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
8
+ PROJ.svn.root = (m.nil? ? '' : m[1])
9
+ end
10
+ PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
11
+
12
+ namespace :svn do
13
+
14
+ # A prerequisites task that all other tasks depend upon
15
+ task :prereqs
16
+
17
+ desc 'Show tags from the SVN repository'
18
+ task :show_tags => 'svn:prereqs' do |t|
19
+ tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
20
+ tags.gsub!(%r/\/$/, '')
21
+ tags = tags.split("\n").sort {|a,b| b <=> a}
22
+ puts tags
23
+ end
24
+
25
+ desc 'Create a new tag in the SVN repository'
26
+ task :create_tag => 'svn:prereqs' do |t|
27
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
28
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
29
+
30
+ svn = PROJ.svn
31
+ trunk = File.join(svn.root, svn.trunk)
32
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
33
+ tag = File.join(svn.root, svn.tags, tag)
34
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
35
+
36
+ puts "Creating SVN tag '#{tag}'"
37
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
38
+ abort "Tag creation failed"
39
+ end
40
+ end
41
+
42
+ end # namespace :svn
43
+
44
+ task 'gem:release' => 'svn:create_tag'
45
+
46
+ end # if PROJ.svn.path
47
+
48
+ # EOF
data/tasks/test.rake ADDED
@@ -0,0 +1,41 @@
1
+ # -*- coding: UTF-8 -*-
2
+ #
3
+ if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
4
+ require 'rake/testtask'
5
+
6
+ namespace :test do
7
+
8
+ Rake::TestTask.new(:run) do |t|
9
+ t.libs = PROJ.libs
10
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
11
+ else PROJ.test.files end
12
+ t.ruby_opts += PROJ.ruby_opts
13
+ t.ruby_opts += PROJ.test.opts
14
+ end
15
+
16
+ if HAVE_RCOV
17
+ desc 'Run rcov on the unit tests'
18
+ task :rcov => :clobber_rcov do
19
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
20
+ opts = opts.join(' ')
21
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
22
+ else PROJ.test.files end
23
+ files = files.join(' ')
24
+ sh "#{RCOV} #{files} #{opts}"
25
+ end
26
+
27
+ task :clobber_rcov do
28
+ rm_r 'coverage' rescue nil
29
+ end
30
+ end
31
+
32
+ end # namespace :test
33
+
34
+ desc 'Alias to test:run'
35
+ task :test => 'test:run'
36
+
37
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
38
+
39
+ end
40
+
41
+ # EOF