module Ore::RubyGems

Public Instance Methods

to_gem() click to toggle source

Builds a gem for the project.

@return [Pathname]

The path to the built gem file within the `pkg/` directory.

@since 0.1.5

# File lib/ore/rubygems.rb, line 121
def to_gem
  pkg_dir = @root.join(@@pkg_dir)
  FileUtils.mkdir_p(pkg_dir)

  gem_file = Gem::Builder.new(self.to_gemspec).build
  pkg_path = @root.join(pkg_file)

  FileUtils.mv(gem_file,pkg_path)
  return pkg_path
end
to_gemspec() { |gemspec| ... } click to toggle source

Populates a Gem Specification using the metadata of the project.

@yield [gemspec]

The given block will be passed the populated Gem Specification
object.

@yieldparam [Gem::Specification] gemspec

The newly created Gem Specification.

@return [Gem::Specification]

The Gem Specification.

@see rubygems.rubyforge.org/rdoc/Gem/Specification.html

@since 0.1.5

# File lib/ore/rubygems.rb, line 26
def to_gemspec
  Gem::Specification.new do |gemspec|
    gemspec.name = @name.to_s
    gemspec.version = @version.to_s
    gemspec.summary = @summary.to_s
    gemspec.description = @description.to_s
    gemspec.licenses = @licenses
    gemspec.authors = @authors
    gemspec.homepage = @homepage
    gemspec.email = @emails
    gemspec.date = @date

    @require_paths.each do |path|
      unless gemspec.require_paths.include?(path)
        gemspec.require_paths << path
      end
    end

    gemspec.executables = @executables

    # default_executable is deprecated in RubyGems 1.7.0 and will be
    # removed after 2011-10-01.
    if Gem::VERSION < '1.7.'
      gemspec.default_executable = @default_executable
    end

    # forcibly set the @has_rdoc ivar, as RubyGems 1.5.x disables the
    # #has_rdoc= writer method.
    if gemspec.instance_variable_defined?('@has_rdoc')
      case @documentation
      when :yard
        gemspec.instance_variable_set('@has_rdoc','yard')
      when :rdoc
        gemspec.instance_variable_set('@has_rdoc',true)
      when nil
        gemspec.instance_variable_set('@has_rdoc',false)
      end
    end

    gemspec.extra_rdoc_files = @extra_doc_files
    gemspec.files = @files
    gemspec.test_files = @test_files
    gemspec.post_install_message = @post_install_message

    gemspec.requirements = @requirements

    if gemspec.respond_to?(:required_ruby_version=)
      gemspec.required_ruby_version = @required_ruby_version
    end

    if gemspec.respond_to?(:required_rubygems_version=)
      gemspec.required_rubygems_version = @required_rubygems_version
    end

    @dependencies.each do |dep|
      gemspec.add_dependency(dep.name,*dep.versions)
    end

    if gemspec.respond_to?(:add_runtime_dependency)
      @runtime_dependencies.each do |dep|
        gemspec.add_runtime_dependency(dep.name,*dep.versions)
      end
    else
      @runtime_dependencies.each do |dep|
        gemspec.add_dependency(dep.name,*dep.versions)
      end
    end

    if gemspec.respond_to?(:add_development_dependency)
      @development_dependencies.each do |dep|
        gemspec.add_development_dependency(dep.name,*dep.versions)
      end
    else
      @development_dependencies.each do |dep|
        gemspec.add_dependency(dep.name,*dep.versions)
      end
    end

    # legacy information
    if gemspec.respond_to?(:rubyforge_project=)
      gemspec.rubyforge_project = gemspec.name
    end

    yield gemspec if block_given?
  end
end