|
1 | 1 | require "rubygems" |
| 2 | +require 'hanna/rdoctask' |
| 3 | +require 'hoe' |
| 4 | + |
| 5 | +$LOAD_PATH.unshift('lib') |
| 6 | + |
| 7 | +require 'net/ldap' |
| 8 | + |
2 | 9 | require "rake/gempackagetask" |
3 | 10 | require "rake/rdoctask" |
4 | 11 |
|
5 | | -require "rake/testtask" |
6 | | -Rake::TestTask.new do |t| |
7 | | - t.libs << "test" |
8 | | - t.test_files = FileList["test/test_*.rb"] |
9 | | - t.verbose = true |
10 | | -end |
| 12 | +PKG_NAME = 'net-ldap' |
| 13 | +PKG_VERSION = Net::LDAP::VERSION |
| 14 | +PKG_DIST = "#{PKG_NAME}-#{PKG_VERSION}" |
| 15 | +PKG_TAR = "pkg/#{PKG_DIST}.tar.gz" |
| 16 | +MANIFEST = File.read("Manifest.txt").split |
11 | 17 |
|
12 | | -require 'spec/rake/spectask' |
13 | | -Spec::Rake::SpecTask.new |
14 | | - |
15 | | -task :default => ["test", 'spec'] |
16 | | - |
17 | | -# This builds the actual gem. For details of what all these options |
18 | | -# mean, and other ones you can add, check the documentation here: |
19 | | -# |
20 | | -# http://rubygems.org/read/chapter/20 |
21 | | -# |
22 | | -spec = Gem::Specification.new do |s| |
23 | | - |
24 | | - # Change these as appropriate |
25 | | - s.name = "net-ldap" |
26 | | - s.version = "0.1.0" |
27 | | - s.summary = "Net::LDAP is an LDAP support library written in pure Ruby. It supports most LDAP client features and a subset of server features as well." |
28 | | - s.authors = [ |
29 | | - "Francis Cianfrocca", |
30 | | - "Austin Ziegler", |
31 | | - "Emiel van de Laar", |
32 | | - "Rory O\'Connell", |
33 | | - "Kaspar Schiess"] |
34 | | - |
35 | | - s.description = "Pure Ruby LDAP library" |
36 | | - |
37 | | - # Add any extra files to include in the gem |
38 | | - s.files = %w(COPYING History.txt LICENSE Rakefile README.txt) + Dir.glob("{spec,test,lib/**/*}") |
39 | | - s.require_paths = ["lib"] |
40 | | -end |
| 18 | +Hoe.spec PKG_NAME do |
| 19 | + self.readme_file = "README.markdown" |
| 20 | + self.version = PKG_VERSION |
| 21 | + self.rubyforge_name = PKG_NAME |
41 | 22 |
|
42 | | -# This task actually builds the gem. We also regenerate a static |
43 | | -# .gemspec file, which is useful if something (i.e. GitHub) will |
44 | | -# be automatically building a gem for this project. If you're not |
45 | | -# using GitHub, edit as appropriate. |
46 | | -# |
47 | | -# To publish your gem online, install the 'gemcutter' gem; Read more |
48 | | -# about that here: http://gemcutter.org/pages/gem_docs |
49 | | -Rake::GemPackageTask.new(spec) do |pkg| |
50 | | - pkg.gem_spec = spec |
51 | | - |
52 | | - # Generate the gemspec file for github. |
53 | | - file = File.dirname(__FILE__) + "/#{spec.name}.gemspec" |
54 | | - File.open(file, "w") {|f| f << spec.to_ruby } |
| 23 | + developer "Francis Cianfrocca", "blackhedd@rubyforge.org" |
| 24 | + developer "Emiel van de Laar", "gemiel@gmail.com" |
| 25 | + developer "Rory O'Connell", "rory.ocon@gmail.com" |
| 26 | + developer "Kaspar Schiess", "kaspar.schiess@absurd.li" |
| 27 | + developer "Austin Ziegler", "austin@rubyforge.org" |
| 28 | + |
| 29 | + self.url = %W(http://net-ldap.rubyforge.org/ http://github.com/RoryO/ruby-net-ldap) |
| 30 | + |
| 31 | + self.summary = "Pure Ruby LDAP support library with most client features and some server features." |
| 32 | + self.changes = paragraphs_of(self.history_file, 0..1).join("\n\n") |
| 33 | + self.description = paragraphs_of(self.readme_file, 2..2).join("\n\n") |
| 34 | + |
| 35 | + extra_dev_deps << [ "archive-tar-minitar", "~>0.5.1" ] |
| 36 | + extra_dev_deps << [ "hanna", "~>0.1.2" ] |
| 37 | + clean_globs << "coverage" |
| 38 | + |
| 39 | + # This is a lie because I will continue to use Archive::Tar::Minitar. |
| 40 | + self.need_tar = false |
55 | 41 | end |
56 | 42 |
|
57 | | -# Generate documentation |
58 | | -Rake::RDocTask.new do |rd| |
59 | | - rd.main = "README.txt" |
60 | | - rd.rdoc_files.include("README.txt", "lib/**/*.rb") |
61 | | - rd.rdoc_dir = "rdoc" |
| 43 | +desc "Build a Net-LDAP .tar.gz distribution." |
| 44 | +task :tar => [ PKG_TAR ] |
| 45 | +file PKG_TAR => [ :test ] do |t| |
| 46 | + require 'archive/tar/minitar' |
| 47 | + require 'zlib' |
| 48 | + files = MANIFEST.map { |f| |
| 49 | + fn = File.join(PKG_DIST, f) |
| 50 | + tm = File.stat(f).mtime |
| 51 | + |
| 52 | + if File.directory?(f) |
| 53 | + { :name => fn, :mode => 0755, :dir => true, :mtime => tm } |
| 54 | + else |
| 55 | + mode = if f =~ %r{^bin} |
| 56 | + 0755 |
| 57 | + else |
| 58 | + 0644 |
| 59 | + end |
| 60 | + data = File.read(f) |
| 61 | + { :name => fn, :mode => mode, :data => data, :size => data.size, |
| 62 | + :mtime => tm } |
| 63 | + end |
| 64 | + } |
| 65 | + |
| 66 | + begin |
| 67 | + unless File.directory?(File.dirname(t.name)) |
| 68 | + require 'fileutils' |
| 69 | + File.mkdir_p File.dirname(t.name) |
| 70 | + end |
| 71 | + tf = File.open(t.name, 'wb') |
| 72 | + gz = Zlib::GzipWriter.new(tf) |
| 73 | + tw = Archive::Tar::Minitar::Writer.new(gz) |
| 74 | + |
| 75 | + files.each do |entry| |
| 76 | + if entry[:dir] |
| 77 | + tw.mkdir(entry[:name], entry) |
| 78 | + else |
| 79 | + tw.add_file_simple(entry[:name], entry) { |os| |
| 80 | + os.write(entry[:data]) |
| 81 | + } |
| 82 | + end |
| 83 | + end |
| 84 | + ensure |
| 85 | + tw.close if tw |
| 86 | + gz.close if gz |
| 87 | + end |
62 | 88 | end |
| 89 | +task :package => [ PKG_TAR ] |
| 90 | + |
| 91 | +desc "Build the manifest file from the current set of files." |
| 92 | +task :build_manifest do |t| |
| 93 | + require 'find' |
| 94 | + |
| 95 | + paths = [] |
| 96 | + Find.find(".") do |path| |
| 97 | + next if File.directory?(path) |
| 98 | + next if path =~ /\.svn/ |
| 99 | + next if path =~ /\.git/ |
| 100 | + next if path =~ /\.hoerc/ |
| 101 | + next if path =~ /\.swp$/ |
| 102 | + next if path =~ %r{coverage/} |
| 103 | + next if path =~ /~$/ |
| 104 | + paths << path.sub(%r{^\./}, '') |
| 105 | + end |
| 106 | + |
| 107 | + File.open("Manifest.txt", "w") do |f| |
| 108 | + f.puts paths.sort.join("\n") |
| 109 | + end |
63 | 110 |
|
64 | | -desc 'Clear out RDoc and generated packages' |
65 | | -task :clean => [:clobber_rdoc, :clobber_package] do |
66 | | - rm "#{spec.name}.gemspec" |
| 111 | + puts paths.sort.join("\n") |
67 | 112 | end |
| 113 | + |
| 114 | +# require "rake/testtask" |
| 115 | +# Rake::TestTask.new do |t| |
| 116 | +# t.libs << "test" |
| 117 | +# t.test_files = FileList["test/test_*.rb"] |
| 118 | +# t.verbose = true |
| 119 | +# end |
| 120 | + |
| 121 | +# require 'spec/rake/spectask' |
| 122 | +# Spec::Rake::SpecTask.new |
| 123 | + |
| 124 | +# task :default => ["test", 'spec'] |
| 125 | + |
0 commit comments