lib/reap/project/gem.rb in reap-9.3.5 vs lib/reap/project/gem.rb in reap-9.4.0

- old
+ new

@@ -1,5 +1,7 @@ +#require 'facets/project/package' + module Reap class Project # Remove gem package products. @@ -17,63 +19,11 @@ # Create a Gem package. # # TODO: Should this use staging too, like zip/tgz? def gem_package(options=nil) - begin - require 'rubygems/specification' - Gem::manage_gems - rescue LoadError - #raise LoadError, "RubyGems is not installed?" - end - - options = configure_options(options, 'package-gem', 'package') - - prepare(options) - - package = metadata.clone - package.update(options) - - abort "No name" unless package.name - abort "No version" unless package.version - - store = 'pkg' #package.package_directory - fname = package.stage_name - files = package.filelist - - stage = File.join(store, fname) - pfile = stage + ".gem" - - unless out_of_date?(pfile, *files) or force? - report_package_already_built(pfile) - return - end - - rm_r(stage) if File.exist?(stage) # remove old stage - stage(stage, files) # make new stage - package_manifest(stage) # generate manifest - - if dryrun? - status "gem build #{stage}" - else - file = nil - cd(stage) do - #status "vi #{metadata.name}.gemspec" - builder = ::Gem::Builder.new(gemspec(package)) - status "gem build #{stage}" - unless dryrun? - file = builder.build - file = File.expand_path(file) - end - end - # transfer gem package to package store - mkdir_p(store) - destination = File.join(store, File.basename(file)) - mv(file, store) unless File.expand_path(file) == File.expand_path(destination) - end - - return destination + return package_gem(options=nil) end # Install gem package, creating the package if not already created. # # TODO: Endure that we even need a gem package using #out_of_date? @@ -118,12 +68,11 @@ spec.author = package.contact spec.email = package.email spec.rubyforge_project = rubyforge_project spec.homepage = package.homepage - # Platform: ruby, mswin32, i586-linux, powerpc-darwin, current - spec.platform = 'ruby' # TODO current support! + spec.platform = package.platform #'ruby' spec.require_paths = [package.loadpath].flatten #if package.platform != 'ruby' # spec.require_paths.concat(spec.require_paths.collect{ |d| File.join(d, platform) }) @@ -131,37 +80,52 @@ spec.bindir = "bin" spec.executables = package.executables spec.requirements = package.requirements - # TODO: Looks like there is no choice but to auto-rdoc gem install. - spec.has_rdoc = !(FalseClass===package.document) - if package.dependencies package.dependencies.each do |d,v| spec.add_dependency(*[d,v].compact) end end - spec.extensions = package.compile + spec.extensions = [package.extensions].flatten.compact + # rdocs (argh!) + + readme = Dir.glob('README{,.txt}', File::FNM_CASEFOLD).first + + spec.has_rdoc = package.autodoc # Make true always? + + rdocfiles = [] + rdocfiles << readme if readme + rdocfiles.concat(Dir['[A-Z]*'] || []) # package.document + rdocfiles.uniq! + spec.extra_rdoc_files = rdocfiles + + rdoc_options = ['--inline-source'] + rdoc_options.concat ["--title", package.title] if package.title + rdoc_options.concat ["--main", readme] if readme + spec.rdoc_options = rdoc_options + spec.files = distribute - spec.test_files = distribute.select{ |f| f =~ /^test\// } # TODO make test_files configurable + # TODO make test_files configurable (?) + spec.test_files = distribute.select{ |f| f =~ /^test\// } end end # Report that a package has been built. # FIXME - def report_package_built(type, file) - r = '' - r << "\n Successfully built #{type}" - r << "\n Name: #{package.name}" - r << "\n Version: #{package.version}" - r << "\n File: #{File.basename(file)}" - say r - end + #def report_package_built(type, file) + # r = '' + # r << "\n Successfully built #{type}" + # r << "\n Name: #{package.name}" + # r << "\n Version: #{package.version}" + # r << "\n File: #{File.basename(file)}" + # say r + #end end end # # Build packages.