Class: Jeweler

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler2.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/generator/options.rb,
lib/jeweler/commands/build_gem.rb,
lib/jeweler/commands/install_gem.rb,
lib/jeweler/generator/rdoc_mixin.rb,
lib/jeweler/generator/riot_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/github_mixin.rb,
lib/jeweler/generator/shindo_mixin.rb,
lib/jeweler/rubygems_dot_org_tasks.rb,
lib/jeweler/commands/release_common.rb,
lib/jeweler/commands/release_to_git.rb,
lib/jeweler/generator/shoulda_mixin.rb,
lib/jeweler/commands/release_gemspec.rb,
lib/jeweler/generator/minitest_mixin.rb,
lib/jeweler/generator/testspec_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_rubygems.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, NoGitHubRepoNameGiven, NoGitHubToken, 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:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jeweler2.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

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



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

def base_dir
  @base_dir
end

#commitObject

Returns the value of attribute commit.



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

def commit
  @commit
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



28
29
30
# File 'lib/jeweler2.rb', line 28

def gemspec
  @gemspec
end

#gemspec_helperObject (readonly)

Returns the value of attribute gemspec_helper.



28
29
30
# File 'lib/jeweler2.rb', line 28

def gemspec_helper
  @gemspec_helper
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#repoObject

Returns the value of attribute repo.



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

def repo
  @repo
end

#version_helperObject (readonly)

Returns the value of attribute version_helper.



28
29
30
# File 'lib/jeweler2.rb', line 28

def version_helper
  @version_helper
end

Instance Method Details

#build_gemObject

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



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

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

#bump_major_versionObject

Bumps the major version.

1.5.1 -> 2.0.0



112
113
114
# File 'lib/jeweler2.rb', line 112

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



105
106
107
# File 'lib/jeweler2.rb', line 105

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



98
99
100
# File 'lib/jeweler2.rb', line 98

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

#check_dependencies(type = nil) ⇒ Object



147
148
149
150
151
152
# File 'lib/jeweler2.rb', line 147

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

  command.run
end

#expects_version_file?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/jeweler2.rb', line 173

def expects_version_file?
  gemspec.version.nil?
end

#git_base_dir(base_dir = nil) ⇒ Object



154
155
156
157
158
159
160
161
162
163
# File 'lib/jeweler2.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?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/jeweler2.rb', line 165

def in_git_repo?
  git_base_dir
end

#install_gemObject

Install a previously built gem



91
92
93
# File 'lib/jeweler2.rb', line 91

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.



48
49
50
# File 'lib/jeweler2.rb', line 48

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.



54
55
56
# File 'lib/jeweler2.rb', line 54

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.



60
61
62
# File 'lib/jeweler2.rb', line 60

def patch_version
  @version_helper.patch
end

#release_gem_to_rubyforgeObject



139
140
141
# File 'lib/jeweler2.rb', line 139

def release_gem_to_rubyforge
  # no-op
end

#release_gem_to_rubygemsObject



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

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

#release_gemspecObject



127
128
129
# File 'lib/jeweler2.rb', line 127

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

#release_to_gitObject



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

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

#setup_rubyforgeObject



143
144
145
# File 'lib/jeweler2.rb', line 143

def setup_rubyforge
  # no-op
end

#valid_gemspec?Boolean

is the project’s gemspec from disk valid?

Returns:

  • (Boolean)


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

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



76
77
78
# File 'lib/jeweler2.rb', line 76

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

#versionObject

Human readable version, which is used in the gemspec.



65
66
67
# File 'lib/jeweler2.rb', line 65

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

#version_file_exists?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/jeweler2.rb', line 169

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

#write_gemspecObject

Writes out the gemspec



70
71
72
# File 'lib/jeweler2.rb', line 70

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.



117
118
119
120
121
122
123
124
125
# File 'lib/jeweler2.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