Class: Jeweler

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler.rb,
lib/jeweler/errors.rb,
lib/jeweler/version.rb,
lib/jeweler/commands.rb,
lib/jeweler/generator.rb,
lib/jeweler/specification.rb,
lib/jeweler/gemspec_helper.rb,
lib/jeweler/rubygems_tasks.rb,
lib/jeweler/version_helper.rb,
lib/jeweler/gemcutter_tasks.rb,
lib/jeweler/rubyforge_tasks.rb,
lib/jeweler/rubygems_dot_org_tasks.rb,
lib/jeweler/commands/build_gem.rb,
lib/jeweler/commands/install_gem.rb,
lib/jeweler/commands/write_gemspec.rb,
lib/jeweler/commands/release_to_git.rb,
lib/jeweler/commands/release_gemspec.rb,
lib/jeweler/commands/validate_gemspec.rb,
lib/jeweler/commands/check_dependencies.rb,
lib/jeweler/commands/release_to_rubygems.rb,
lib/jeweler/generator/options.rb,
lib/jeweler/generator/rdoc_mixin.rb,
lib/jeweler/generator/riot_mixin.rb,
lib/jeweler/generator/yard_mixin.rb,
lib/jeweler/generator/application.rb,
lib/jeweler/generator/bacon_mixin.rb,
lib/jeweler/generator/rspec_mixin.rb,
lib/jeweler/generator/github_mixin.rb,
lib/jeweler/generator/shindo_mixin.rb,
lib/jeweler/generator/shoulda_mixin.rb,
lib/jeweler/generator/minitest_mixin.rb,
lib/jeweler/generator/testspec_mixin.rb,
lib/jeweler/generator/testunit_mixin.rb,
lib/jeweler/generator/micronaut_mixin.rb,
lib/jeweler/commands/version/base.rb,
lib/jeweler/commands/version/write.rb,
lib/jeweler/commands/version/bump_major.rb,
lib/jeweler/commands/version/bump_minor.rb,
lib/jeweler/commands/version/bump_patch.rb,
lib/jeweler/tasks.rb

Overview

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:

Defined Under Namespace

Modules: Commands, Specification, Version Classes: FileInTheWay, GemSpecHelper, GemcutterTasks, GemspecError, Generator, GitInitFailed, GitRepoCreationFailed, NoGitHubRepoNameGiven, NoGitHubUser, NoGitUserEmail, NoGitUserName, RubyforgeTasks, RubygemsDotOrgTasks, Tasks, VersionHelper, VersionYmlError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemspec, base_dir = '.') ⇒ Jeweler

Returns a new instance of Jeweler.

Raises:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jeweler.rb', line 32

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

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



30
31
32
# File 'lib/jeweler.rb', line 30

def base_dir
  @base_dir
end

#commitObject

Returns the value of attribute commit.



30
31
32
# File 'lib/jeweler.rb', line 30

def commit
  @commit
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



29
30
31
# File 'lib/jeweler.rb', line 29

def gemspec
  @gemspec
end

#gemspec_helperObject (readonly)

Returns the value of attribute gemspec_helper.



29
30
31
# File 'lib/jeweler.rb', line 29

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



30
31
32
# File 'lib/jeweler.rb', line 30

def output
  @output
end

#repoObject

Returns the value of attribute repo.



30
31
32
# File 'lib/jeweler.rb', line 30

def repo
  @repo
end

#version_helperObject (readonly)

Returns the value of attribute version_helper.



29
30
31
# File 'lib/jeweler.rb', line 29

def version_helper
  @version_helper
end

Instance Method Details

#build_gemObject

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



87
88
89
# File 'lib/jeweler.rb', line 87

def build_gem
  Jeweler::Commands::BuildGem.build_for(self).run
end

#bump_major_versionObject

Bumps the major version.

1.5.1 -> 2.0.0



113
114
115
# File 'lib/jeweler.rb', line 113

def bump_major_version
  Jeweler::Commands::Version::BumpMajor.build_for(self).run
end

#bump_minor_versionObject

Bumps the minor version.

1.5.1 -> 1.6.0



106
107
108
# File 'lib/jeweler.rb', line 106

def bump_minor_version
  Jeweler::Commands::Version::BumpMinor.build_for(self).run
end

#bump_patch_versionObject

Bumps the patch version.

1.5.1 -> 1.5.2



99
100
101
# File 'lib/jeweler.rb', line 99

def bump_patch_version
  Jeweler::Commands::Version::BumpPatch.build_for(self).run
end

#check_dependencies(type = nil) ⇒ Object



148
149
150
151
152
153
# File 'lib/jeweler.rb', line 148

def check_dependencies(type = nil)
  command = Jeweler::Commands::CheckDependencies.build_for(self)
  command.type = type

  command.run
end

#expects_version_file?Boolean

Returns:

  • (Boolean)


174
175
176
# File 'lib/jeweler.rb', line 174

def expects_version_file?
  gemspec.version.nil?
end

#git_base_dir(base_dir = nil) ⇒ Object



155
156
157
158
159
160
161
162
163
164
# File 'lib/jeweler.rb', line 155

def git_base_dir(base_dir = nil)
  base_dir = if base_dir
               File.dirname(base_dir)
             else
               File.expand_path(self.base_dir || '.')
             end
  return nil if base_dir == File.dirname('/')
  return base_dir if File.exist?(File.join(base_dir, '.git'))
  git_base_dir(base_dir)
end

#in_git_repo?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/jeweler.rb', line 166

def in_git_repo?
  git_base_dir
end

#install_gemObject

Install a previously built gem



92
93
94
# File 'lib/jeweler.rb', line 92

def install_gem
  Jeweler::Commands::InstallGem.build_for(self).run
end

#major_versionObject

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



49
50
51
# File 'lib/jeweler.rb', line 49

def major_version
  @version_helper.major
end

#minor_versionObject

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



55
56
57
# File 'lib/jeweler.rb', line 55

def minor_version
  @version_helper.minor
end

#patch_versionObject

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



61
62
63
# File 'lib/jeweler.rb', line 61

def patch_version
  @version_helper.patch
end

#release_gem_to_rubyforgeObject



140
141
142
# File 'lib/jeweler.rb', line 140

def release_gem_to_rubyforge
  # no-op
end

#release_gem_to_rubygemsObject



136
137
138
# File 'lib/jeweler.rb', line 136

def release_gem_to_rubygems
  Jeweler::Commands::ReleaseToRubygems.build_for(self).run
end

#release_gemspec(args) ⇒ Object



128
129
130
# File 'lib/jeweler.rb', line 128

def release_gemspec(args)
  Jeweler::Commands::ReleaseGemspec.build_for(self).run(args)
end

#release_to_git(args) ⇒ Object



132
133
134
# File 'lib/jeweler.rb', line 132

def release_to_git(args)
  Jeweler::Commands::ReleaseToGit.build_for(self).run(args)
end

#setup_rubyforgeObject



144
145
146
# File 'lib/jeweler.rb', line 144

def setup_rubyforge
  # no-op
end

#valid_gemspec?Boolean

is the project’s gemspec from disk valid?

Returns:

  • (Boolean)


82
83
84
# File 'lib/jeweler.rb', line 82

def valid_gemspec?
  gemspec_helper.valid?
end

#validate_gemspecObject

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



77
78
79
# File 'lib/jeweler.rb', line 77

def validate_gemspec
  Jeweler::Commands::ValidateGemspec.build_for(self).run
end

#versionObject

Human readable version, which is used in the gemspec.



66
67
68
# File 'lib/jeweler.rb', line 66

def version
  @gemspec.version || @version_helper.to_s
end

#version_file_exist?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'lib/jeweler.rb', line 170

def version_file_exist?
  File.exist?(@version_helper.plaintext_path) || File.exist?(@version_helper.yaml_path)
end

#write_gemspecObject

Writes out the gemspec



71
72
73
# File 'lib/jeweler.rb', line 71

def write_gemspec
  Jeweler::Commands::WriteGemspec.build_for(self).run
end

#write_version(major, minor, patch, build, _options = {}) ⇒ Object

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



118
119
120
121
122
123
124
125
126
# File 'lib/jeweler.rb', line 118

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