Class: Jeweler

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler.rb,
lib/jeweler/errors.rb,
lib/jeweler/generator.rb,
lib/jeweler/specification.rb,
lib/jeweler/gemspec_helper.rb,
lib/jeweler/version_helper.rb,
lib/jeweler/rubyforge_tasks.rb,
lib/jeweler/commands/release.rb,
lib/jeweler/generator/options.rb,
lib/jeweler/commands/build_gem.rb,
lib/jeweler/commands/install_gem.rb,
lib/jeweler/commands/version/base.rb,
lib/jeweler/generator/application.rb,
lib/jeweler/generator/bacon_mixin.rb,
lib/jeweler/generator/rspec_mixin.rb,
lib/jeweler/commands/version/write.rb,
lib/jeweler/commands/write_gemspec.rb,
lib/jeweler/generator/shoulda_mixin.rb,
lib/jeweler/commands/setup_rubyforge.rb,
lib/jeweler/generator/minitest_mixin.rb,
lib/jeweler/generator/testunit_mixin.rb,
lib/jeweler/commands/validate_gemspec.rb,
lib/jeweler/generator/micronaut_mixin.rb,
lib/jeweler/commands/version/bump_major.rb,
lib/jeweler/commands/version/bump_minor.rb,
lib/jeweler/commands/version/bump_patch.rb,
lib/jeweler/commands/release_to_rubyforge.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.

Defined Under Namespace

Modules: Commands, Specification Classes: FileInTheWay, GemSpecHelper, GemspecError, Generator, GitInitFailed, MissingRubyForgePackageError, NoGitHubRepoNameGiven, NoGitHubToken, NoGitHubUser, NoGitUserEmail, NoGitUserName, NoRubyForgeProjectInGemspecError, RubyForgeProjectNotConfiguredError, RubyforgeTasks, 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:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jeweler.rb', line 26

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)

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

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



24
25
26
# File 'lib/jeweler.rb', line 24

def base_dir
  @base_dir
end

#commitObject

Returns the value of attribute commit.



24
25
26
# File 'lib/jeweler.rb', line 24

def commit
  @commit
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



23
24
25
# File 'lib/jeweler.rb', line 23

def gemspec
  @gemspec
end

#gemspec_helperObject (readonly)

Returns the value of attribute gemspec_helper.



23
24
25
# File 'lib/jeweler.rb', line 23

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



24
25
26
# File 'lib/jeweler.rb', line 24

def output
  @output
end

#repoObject

Returns the value of attribute repo.



24
25
26
# File 'lib/jeweler.rb', line 24

def repo
  @repo
end

#rubyforgeObject

Returns the value of attribute rubyforge.



24
25
26
# File 'lib/jeweler.rb', line 24

def rubyforge
  @rubyforge
end

#version_helperObject (readonly)

Returns the value of attribute version_helper.



23
24
25
# File 'lib/jeweler.rb', line 23

def version_helper
  @version_helper
end

Instance Method Details

#build_gemObject



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

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

#bump_major_versionObject

Bumps the major version.

1.5.1 -> 2.0.0



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

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



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

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



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

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

#in_git_repo?Boolean

Returns:

  • (Boolean)


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

def in_git_repo?
  File.exists?(File.join(self.base_dir, '.git'))
end

#install_gemObject



85
86
87
# File 'lib/jeweler.rb', line 85

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.



44
45
46
# File 'lib/jeweler.rb', line 44

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.



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

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.



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

def patch_version
  @version_helper.patch
end

#releaseObject



118
119
120
# File 'lib/jeweler.rb', line 118

def release
  Jeweler::Commands::Release.build_for(self).run
end

#release_gem_to_rubyforgeObject



122
123
124
# File 'lib/jeweler.rb', line 122

def release_gem_to_rubyforge
  Jeweler::Commands::ReleaseToRubyforge.build_for(self).run
end

#setup_rubyforgeObject



126
127
128
# File 'lib/jeweler.rb', line 126

def setup_rubyforge
  Jeweler::Commands::SetupRubyforge.build_for(self).run
end

#valid_gemspec?Boolean

is the project’s gemspec from disk valid?

Returns:

  • (Boolean)


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

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



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

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

#versionObject

Human readable version, which is used in the gemspec.



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

def version
  @version_helper.to_s
end

#version_exists?Boolean

Returns:

  • (Boolean)


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

def version_exists?
  File.exists?(@version_helper.plaintext_path) || File.exists?(@version_helper.yaml_path)
end

#write_gemspecObject

Writes out the gemspec



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

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

#write_version(version, options = {}) ⇒ Object

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



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

def write_version(version, options = {})
  command = Jeweler::Commands::Version::Write.build_for(self)
  command.version = version

  command.run
end