Class: Gem::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/tasks.rb,
lib/rubygems/tasks/push.rb,
lib/rubygems/tasks/task.rb,
lib/rubygems/tasks/console.rb,
lib/rubygems/tasks/install.rb,
lib/rubygems/tasks/project.rb,
lib/rubygems/tasks/release.rb,
lib/rubygems/tasks/scm/tag.rb,
lib/rubygems/tasks/printing.rb,
lib/rubygems/tasks/scm/push.rb,
lib/rubygems/tasks/sign/pgp.rb,
lib/rubygems/tasks/build/gem.rb,
lib/rubygems/tasks/build/tar.rb,
lib/rubygems/tasks/build/zip.rb,
lib/rubygems/tasks/sign/task.rb,
lib/rubygems/tasks/build/task.rb,
lib/rubygems/tasks/scm/status.rb,
lib/rubygems/tasks/sign/checksum.rb

Overview

Defines basic Rake tasks for managing and releasing projects:

Defined Under Namespace

Modules: Build, Printing, SCM, Sign Classes: Console, Install, Project, Push, Release, Task

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|tasks| ... } ⇒ Tasks

Initializes the project tasks.

Examples:

Enables building of .gem and .tar.gz packages:

Gem::Tasks.new(build: {gem: true, tar: true})

Disables pushing .gem packages to rubygems.org:

Gem::Tasks.new(push: false)

Configures the version tag format:

Gem::Tasks.new do |tasks|
  tasks.scm.tag.format = "release-%s"
end

Parameters:

  • options (Hash{Symbol => Hash}) (defaults to: {})

    Enables or disables individual tasks.

Options Hash (options):

  • :build (Hash{Symbol => Boolean})

    Enables or disables the build tasks.

  • :scm (Hash{Symbol => Boolean})

    Enables or disables the scm tasks.

  • :console (Boolean) — default: true

    Enables or disables the console task.

  • :install (Boolean) — default: true

    Enables or disables the install task.

  • :push (Boolean) — default: true

    Enables or disables the push task.

  • :release (Boolean) — default: true

    Enables or disables the release task.

  • :sign (Hash{Symbol => Boolean})

    Enables or disables the sign tasks.

Yields:

  • (tasks)

    If a block is given, it will be passed the newly created tasks, before they are fully defined.

Yield Parameters:

  • tasks (Tasks)

    The newly created tasks.



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/rubygems/tasks.rb', line 112

def initialize(options={})
  build_options = options.fetch(:build,{})
  scm_options   = options.fetch(:scm,{})
  sign_options  = options.fetch(:sign,{})

  @scm   = OpenStruct.new
  @build = OpenStruct.new
  @sign  = OpenStruct.new

  if build_options
    @build.gem = (Build::Gem.new if build_options.fetch(:gem,true))
    @build.tar = (Build::Tar.new if build_options[:tar])
    @build.zip = (Build::Zip.new if build_options[:zip])
  end

  if scm_options
    @scm.status = (SCM::Status.new if scm_options.fetch(:status,true))
    @scm.tag    = (SCM::Tag.new    if scm_options.fetch(:tag,true))
    @scm.push   = (SCM::Push.new   if scm_options.fetch(:push,true))
  end

  if sign_options
    @sign.checksum = (Sign::Checksum.new if sign_options[:checksum])
    @sign.pgp      = (Sign::PGP.new      if sign_options[:pgp])
  end

  @console = (Console.new if options.fetch(:console,true))
  @install = (Install.new if options.fetch(:install,true))
  @push    = (Push.new    if options.fetch(:push,true))
  @release = (Release.new if options.fetch(:release,true))

  yield self if block_given?
end

Instance Attribute Details

#buildOpenStruct (readonly)

The build tasks.

Returns:

  • (OpenStruct)

    The collection of build tasks.



37
38
39
# File 'lib/rubygems/tasks.rb', line 37

def build
  @build
end

#consoleObject (readonly)

The console task.



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

def console
  @console
end

#installObject (readonly)

The install task.



59
60
61
# File 'lib/rubygems/tasks.rb', line 59

def install
  @install
end

#pushObject (readonly)

The push task.



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

def push
  @push
end

#releaseObject (readonly)

The release task.



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

def release
  @release
end

#scmOpenStruct (readonly)

The scm tasks.

Returns:

  • (OpenStruct)

    The collection of scm tasks.



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

def scm
  @scm
end

#signOpenStruct (readonly)

The sign tasks.

Returns:

  • (OpenStruct)

    The collection of sign tasks.



53
54
55
# File 'lib/rubygems/tasks.rb', line 53

def sign
  @sign
end