Class: Gem::Tasks::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Gem::Tasks::Task
- Includes:
- Printing
- Defined in:
- lib/rubygems/tasks/task.rb
Direct Known Subclasses
Build::Gem, Build::Tar, Build::Task, Build::Zip, Console, Install, Push, Release, SCM::Push, SCM::Status, SCM::Tag, Sign::PGP, Sign::Task
Constant Summary
Constants included from Printing
Printing::ANSI_BRIGHT, Printing::ANSI_CLEAR, Printing::ANSI_GREEN, Printing::ANSI_RED, Printing::ANSI_YELLOW, Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::STATUS_PREFIX
Instance Attribute Summary collapse
-
#project ⇒ Project
readonly
Project metadata.
Instance Method Summary collapse
-
#bundle(command, *arguments) ⇒ Boolean
protected
Runs a
bundlecommand. -
#gem(command, *arguments) ⇒ Boolean
protected
Runs a
gemcommand. -
#gemspec_tasks(prefix) ⇒ Object
protected
Defines a task that will execute tasks for each gemspec.
-
#initialize ⇒ Task
constructor
Initializes the task.
-
#invoke(name) ⇒ Object
protected
Explicitly invokes a task.
-
#namespaced_tasks(prefix, subtasks) ⇒ Object
protected
Defines a task that will invoke one or all of the specifies tasks within the namespace.
-
#run(command, *arguments) ⇒ Boolean
protected
Runs a command.
-
#task?(name) ⇒ Boolean
protected
Determines if a task was defined.
Methods included from Printing
Constructor Details
#initialize ⇒ Task
Initializes the task.
24 25 26 |
# File 'lib/rubygems/tasks/task.rb', line 24 def initialize @project = Project.directories[Dir.pwd] end |
Instance Attribute Details
#project ⇒ Project (readonly)
Project metadata.
19 20 21 |
# File 'lib/rubygems/tasks/task.rb', line 19 def project @project end |
Instance Method Details
#bundle(command, *arguments) ⇒ Boolean (protected)
Runs a bundle command.
95 96 97 |
# File 'lib/rubygems/tasks/task.rb', line 95 def bundle(command,*arguments) run 'bundler', command, *arguments end |
#gem(command, *arguments) ⇒ Boolean (protected)
Runs a gem command.
71 72 73 74 75 76 77 78 79 |
# File 'lib/rubygems/tasks/task.rb', line 71 def gem(command,*arguments) if defined?(Bundler) Bundler.with_original_env do run 'gem', command, *arguments end else run 'gem', command, *arguments end end |
#gemspec_tasks(prefix) ⇒ Object (protected)
Defines a task that will execute tasks for each gemspec.
155 156 157 |
# File 'lib/rubygems/tasks/task.rb', line 155 def gemspec_tasks(prefix) namespaced_tasks prefix, @project.gemspecs.keys end |
#invoke(name) ⇒ Object (protected)
Explicitly invokes a task.
124 125 126 |
# File 'lib/rubygems/tasks/task.rb', line 124 def invoke(name) Rake.application[name].invoke end |
#namespaced_tasks(prefix, subtasks) ⇒ Object (protected)
Defines a task that will invoke one or all of the specifies tasks within the namespace.
143 144 145 |
# File 'lib/rubygems/tasks/task.rb', line 143 def namespaced_tasks(prefix,subtasks) task prefix => subtasks.map { |subtask| "#{prefix}:#{subtask}" } end |
#run(command, *arguments) ⇒ Boolean (protected)
Runs a command.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubygems/tasks/task.rb', line 44 def run(command,*arguments) show_command = [command, *arguments].join(' ') debug show_command unless system(command,*arguments) error "Command failed: #{show_command}" abort end return true end |
#task?(name) ⇒ Boolean (protected)
Determines if a task was defined.
110 111 112 |
# File 'lib/rubygems/tasks/task.rb', line 110 def task?(name) Rake::Task.task_defined?(name) end |