Permalink
Browse files

Rakefile re-working.

  • Loading branch information...
Pete Elmore
Pete Elmore committed Feb 18, 2009
1 parent 82cde1e commit c500da1dc57af08e0a954899013ea210fa84f185
Showing with 89 additions and 63 deletions.
  1. +71 −39 Rakefile
  2. +1 −1 lib/live_console_config.rb
  3. +17 −23 live_console.gemspec
View
110 Rakefile
@@ -1,49 +1,81 @@
-require 'rake'
-require 'rake/testtask'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'lib/live_console_config'
-require 'fileutils'
+$: << "#{File.dirname(__FILE__)}/lib"
-require 'lib/live_console_config'
+spec = Gem::Specification.new { |s|
+ s.name = LiveConsoleConfig::PkgName
+ s.version = LiveConsoleConfig::Version
+ s.author = LiveConsoleConfig::Authors
+ s.email = LiveConsoleConfig::Email
+ s.homepage = LiveConsoleConfig::URL
+ s.rubyforge_project = LiveConsoleConfig::Project
+
+ s.platform = Gem::Platform::RUBY
+
+ s.files = Dir["{lib,doc,bin,ext}/**/*"].delete_if {|f|
+ /\/rdoc(\/|$)/i.match f
+ } + %w(Rakefile)
+ s.require_path = 'lib'
+ s.has_rdoc = true
+ s.extra_rdoc_files = Dir['doc/*'].select(&File.method(:file?))
+ s.extensions << 'ext/extconf.rb' if File.exist? 'ext/extconf.rb'
+ Dir['bin/*'].map(&File.method(:basename)).map(&s.executables.method(:<<))
+
+ s.summary = 'A library to support adding an irb console to your ' \
+ 'running application.'
+ %w().each &s.method(:add_dependency)
+}
-$distname = "#{LiveConsoleConfig::PkgName}-#{LiveConsoleConfig::Version}"
-$tgz = "#{$distname}.tar.gz"
-$tarbz2 = "#{$distname}.tar.bz2"
-$gem = "#{$distname}.gem"
-$exclude = %W(
- --exclude=#{$distname}/#{$distname}
- --exclude=distrib
- --exclude=tags
- --exclude='.*.swp'
- --exclude='.*.tar.*z*'
- --exclude=.svn
- --exclude=.config
- --exclude=_darcs
-).join(' ')
-
-task :default => :packages
-
-task(:packages) {
- FileUtils.mkdir_p 'distrib'
- system "ruby gemspec"
- system "mv #{$distname}.gem distrib"
-
- Dir.chdir 'distrib'
- system "ln -sf .. #{$distname}"
- system "tar czhf #{$tgz} #{$exclude} #{$distname}"
- system "tar cjhf #{$tarbz2} #{$exclude} #{$distname}"
- Dir.chdir '..'
-
- File.unlink "distrib/#{$distname}"
+Rake::RDocTask.new(:doc) { |t|
+ t.main = 'doc/README'
+ t.rdoc_files.include 'lib/**/*.rb', 'doc/*', 'bin/*', 'ext/**/*.c',
+ 'ext/**/*.rb'
+ t.options << '-S' << '-N'
+ t.rdoc_dir = 'doc/rdoc'
}
-task(:install => :packages) {
- system "gem install distrib/#{$gem}"
+Rake::GemPackageTask.new(spec) { |pkg|
+ pkg.need_tar_bz2 = true
}
-task(:clean) {
- system "rm -rf distrib"
+desc "Builds and installs the gem for #{spec.name}"
+task(:install => :package) {
+ g = "pkg/#{spec.name}-#{spec.version}.gem"
+ system "sudo gem install -l #{g}"
}
-task(:doc) {
- system "rdoc -N -S -U -o doc/rdoc -m doc/README -x _darcs -x setup.rb lib/* doc/*"
+desc "Runs IRB, automatically require()ing #{spec.name}."
+task(:irb) {
+ exec "irb -Ilib -r#{spec.name}"
+}
+
+desc "Generates a static gemspec file; useful for github."
+task(:static_gemspec) {
+ # This whole thing is hacky.
+ spec.validate
+ spec_attrs = %w(
+ platform author email files require_path has_rdoc extra_rdoc_files
+ extensions executables name summary homepage
+ ).map { |attr|
+ "\ts.#{attr} = #{spec.send(attr).inspect}\n"
+ }.join <<
+ "\ts.version = #{spec.version.to_s.inspect}\n" <<
+ spec.dependencies.map { |dep|
+ "\ts.add_dependency #{dep.inspect}\n"
+ }.join
+
+ File.open("#{spec.name}.gemspec", 'w') { |f|
+ f.print <<-EOGEMSPEC
+# This is a static gempsec automatically generated by rake. It's better to
+# edit the Rakefile than this file. It is kept in the repository for the
+# benefit of github.
+
+spec = Gem::Specification.new { |s|
+#{spec_attrs}}
+
+Gem::Builder.new(spec).build if __FILE__ == $0
+ EOGEMSPEC
+ }
}
@@ -3,7 +3,7 @@ module LiveConsoleConfig
Authors = 'Pete Elmore'
Email = 'pete.elmore@gmail.com'
PkgName = 'live_console'
- Version = '0.2.0'
+ Version = '0.2.1'
URL = 'http://debu.gs/live-console'
Project = 'live-console'
end
View
@@ -1,27 +1,21 @@
-require 'rubygems'
-require 'lib/live_console_config'
+# This is a static gempsec automatically generated by rake. It's better to
+# edit the Rakefile than this file. It is kept in the repository for the
+# benefit of github.
-SPEC = Gem::Specification.new { |s|
- s.name = LiveConsoleConfig::PkgName
- s.version = LiveConsoleConfig::Version
- s.author = LiveConsoleConfig::Authors
- s.email = LiveConsoleConfig::Email
- s.homepage = LiveConsoleConfig::URL
- s.rubyforge_project = LiveConsoleConfig::Project
- s.platform = Gem::Platform::RUBY
- s.summary =
- 'A library to support adding a console to your running application.'
- s.files = Dir.glob("{bin,doc,lib}/**/*").delete_if { |file|
- [ /\/rdoc\//i, # No rdoc
- ].find { |rx| rx.match file }
- }
- Dir['bin/*'].map(&File.method(:basename)
- ).map(&s.executables.method(:<<))
- s.require_path 'lib'
+spec = Gem::Specification.new { |s|
+ s.platform = "ruby"
+ s.author = "Pete Elmore"
+ s.email = "pete.elmore@gmail.com"
+ s.files = ["lib/live_console", "lib/live_console/io_methods", "lib/live_console/io_methods/socket_io.rb", "lib/live_console/io_methods/unix_socket_io.rb", "lib/live_console/io_methods.rb", "lib/live_console.rb", "lib/live_console_config.rb", "doc/LICENSE", "doc/README", "doc/lc_example.rb", "doc/lc_unix_example.rb", "bin/udscat", "Rakefile"]
+ s.require_path = "lib"
s.has_rdoc = true
- s.extra_rdoc_files = Dir['doc/*'].select(&File.method(:file?))
+ s.extra_rdoc_files = ["doc/LICENSE", "doc/README", "doc/lc_example.rb", "doc/lc_unix_example.rb"]
+ s.extensions = []
+ s.executables = ["udscat"]
+ s.name = "live_console"
+ s.summary = "A library to support adding an irb console to your running application."
+ s.homepage = "http://debu.gs/live-console"
+ s.version = "0.2.1"
}
-if __FILE__ == $0
- Gem::Builder.new(SPEC).build
-end
+Gem::Builder.new(spec).build if __FILE__ == $0

0 comments on commit c500da1

Please sign in to comment.