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/generator/rdoc_mixin.rb,
lib/jeweler/generator/yard_mixin.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/check_dependencies.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:



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

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.



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

def base_dir
  @base_dir
end

#commitObject

Returns the value of attribute commit.



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

def commit
  @commit
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



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

def gemspec
  @gemspec
end

#gemspec_helperObject (readonly)

Returns the value of attribute gemspec_helper.



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

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#repoObject

Returns the value of attribute repo.



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

def repo
  @repo
end

#rubyforgeObject

Returns the value of attribute rubyforge.



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

def rubyforge
  @rubyforge
end

#version_helperObject (readonly)

Returns the value of attribute version_helper.



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

def version_helper
  @version_helper
end

Instance Method Details

#build_gemObject



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

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

#bump_major_versionObject

Bumps the major version.

1.5.1 -> 2.0.0



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

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



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

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



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

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

#check_dependencies(type = nil) ⇒ Object



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

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

  command.run
end

#in_git_repo?Boolean

Returns:

  • (Boolean)


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

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

#install_gemObject



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

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.



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

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.



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

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.



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

def patch_version
  @version_helper.patch
end

#releaseObject



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

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

#release_gem_to_gemcutterObject



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

def release_gem_to_gemcutter
  Jeweler::Commands::ReleaseToGemcutter.build_for(self).run
end

#release_gem_to_rubyforgeObject



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

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

#setup_rubyforgeObject



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

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

#valid_gemspec?Boolean

is the project’s gemspec from disk valid?

Returns:

  • (Boolean)


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

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



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

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

#versionObject

Human readable version, which is used in the gemspec.



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

def version
  @version_helper.to_s
end

#version_exists?Boolean

Returns:

  • (Boolean)


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

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

#write_gemspecObject

Writes out the gemspec



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

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

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

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



112
113
114
115
116
117
118
119
# File 'lib/jeweler.rb', line 112

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

  command.run
end