class Jeweler

A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.

See Jeweler::Tasks for examples of how to get started. Additionally, resources are available on the wiki:

Attributes

base_dir[RW]
commit[RW]
gemspec[R]
gemspec_helper[R]
output[RW]
repo[RW]
version_helper[R]

Public Instance Methods

build_gem() click to toggle source

Build a gem using the project’s latest Gem::Specification

# File lib/jeweler.rb, line 86
def build_gem
  Jeweler::Commands::BuildGem.build_for(self).run
end
bump_major_version() click to toggle source

Bumps the major version.

1.5.1 -> 2.0.0

# File lib/jeweler.rb, line 112
def bump_major_version()
  Jeweler::Commands::Version::BumpMajor.build_for(self).run
end
bump_minor_version() click to toggle source

Bumps the minor version.

1.5.1 -> 1.6.0

# File lib/jeweler.rb, line 105
def bump_minor_version()
  Jeweler::Commands::Version::BumpMinor.build_for(self).run
end
bump_patch_version() click to toggle source

Bumps the patch version.

1.5.1 -> 1.5.2

# File lib/jeweler.rb, line 98
def bump_patch_version()
  Jeweler::Commands::Version::BumpPatch.build_for(self).run
end
check_dependencies(type = nil) click to toggle source
# File lib/jeweler.rb, line 147
def check_dependencies(type = nil)
  command = Jeweler::Commands::CheckDependencies.build_for(self)
  command.type = type

  command.run
end
expects_version_file?() click to toggle source
# File lib/jeweler.rb, line 173
def expects_version_file?
  gemspec.version.nil?
end
git_base_dir(base_dir = nil) click to toggle source
# File lib/jeweler.rb, line 154
def git_base_dir(base_dir = nil)
  if base_dir
    base_dir = File.dirname(base_dir)
  else
    base_dir = File.expand_path(self.base_dir || ".")
  end
  return nil if base_dir==File.dirname("/")
  return base_dir if File.exists?(File.join(base_dir, '.git'))
  return git_base_dir(base_dir)
end
in_git_repo?() click to toggle source
# File lib/jeweler.rb, line 165
def in_git_repo?
  git_base_dir
end
install_gem() click to toggle source

Install a previously built gem

# File lib/jeweler.rb, line 91
def install_gem
  Jeweler::Commands::InstallGem.build_for(self).run
end
major_version() click to toggle source

Major version, as defined by the gemspec’s Version module. For 1.5.3, this would return 1.

# File lib/jeweler.rb, line 48
def major_version
  @version_helper.major
end
minor_version() click to toggle source

Minor version, as defined by the gemspec’s Version module. For 1.5.3, this would return 5.

# File lib/jeweler.rb, line 54
def minor_version
  @version_helper.minor
end
patch_version() click to toggle source

Patch version, as defined by the gemspec’s Version module. For 1.5.3, this would return 5.

# File lib/jeweler.rb, line 60
def patch_version
  @version_helper.patch
end
release_gem_to_rubyforge() click to toggle source
# File lib/jeweler.rb, line 139
def release_gem_to_rubyforge
  # no-op
end
release_gem_to_rubygems() click to toggle source
# File lib/jeweler.rb, line 135
def release_gem_to_rubygems
  Jeweler::Commands::ReleaseToRubygems.build_for(self).run
end
release_gemspec() click to toggle source
# File lib/jeweler.rb, line 127
def release_gemspec
  Jeweler::Commands::ReleaseGemspec.build_for(self).run
end
release_to_git() click to toggle source
# File lib/jeweler.rb, line 131
def release_to_git
  Jeweler::Commands::ReleaseToGit.build_for(self).run
end
setup_rubyforge() click to toggle source
# File lib/jeweler.rb, line 143
def setup_rubyforge
  # no-op
end
valid_gemspec?() click to toggle source

is the project’s gemspec from disk valid?

# File lib/jeweler.rb, line 81
def valid_gemspec?
  gemspec_helper.valid?
end
validate_gemspec() click to toggle source

Validates the project’s gemspec from disk in an environment similar to how GitHub would build from it. See gist.github.com/16215

# File lib/jeweler.rb, line 76
def validate_gemspec
  Jeweler::Commands::ValidateGemspec.build_for(self).run
end
version() click to toggle source

Human readable version, which is used in the gemspec.

# File lib/jeweler.rb, line 65
def version
  @gemspec.version || @version_helper.to_s
end
version_file_exists?() click to toggle source
# File lib/jeweler.rb, line 169
def version_file_exists?
  File.exists?(@version_helper.plaintext_path) || File.exists?(@version_helper.yaml_path)
end
write_gemspec() click to toggle source

Writes out the gemspec

# File lib/jeweler.rb, line 70
def write_gemspec
  Jeweler::Commands::WriteGemspec.build_for(self).run
end
write_version(major, minor, patch, build, options = {}) click to toggle source

Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.

# File lib/jeweler.rb, line 117
def write_version(major, minor, patch, build, options = {})
  command = Jeweler::Commands::Version::Write.build_for(self)
  command.major = major
  command.minor = minor
  command.patch = patch
  command.build = build

  command.run
end

Public Class Methods

new(gemspec, base_dir = '.') click to toggle source
# File lib/jeweler.rb, line 31
def initialize(gemspec, base_dir = '.')
  raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?

  @gemspec = gemspec
  @gemspec.extend(Specification)
  @gemspec.set_jeweler_defaults(base_dir, git_base_dir)

  @base_dir       = base_dir
  @repo           = Git.open(git_base_dir) if in_git_repo?
  @version_helper = Jeweler::VersionHelper.new(base_dir)
  @output         = $stdout
  @commit         = true
  @gemspec_helper = GemSpecHelper.new(gemspec, base_dir)
end