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
bundle
command. -
#gem(command, *arguments) ⇒ Boolean
protected
Runs a
gem
command. -
#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.
22 23 24 |
# File 'lib/rubygems/tasks/task.rb', line 22 def initialize @project = Project.directories[Dir.pwd] end |
Instance Attribute Details
#project ⇒ Project (readonly)
Project metadata.
17 18 19 |
# File 'lib/rubygems/tasks/task.rb', line 17 def project @project end |
Instance Method Details
#bundle(command, *arguments) ⇒ Boolean (protected)
Runs a bundle
command.
93 94 95 |
# File 'lib/rubygems/tasks/task.rb', line 93 def bundle(command,*arguments) run 'bundler', command, *arguments end |
#gem(command, *arguments) ⇒ Boolean (protected)
Runs a gem
command.
69 70 71 72 73 74 75 76 77 |
# File 'lib/rubygems/tasks/task.rb', line 69 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.
153 154 155 |
# File 'lib/rubygems/tasks/task.rb', line 153 def gemspec_tasks(prefix) namespaced_tasks prefix, @project.gemspecs.keys end |
#invoke(name) ⇒ Object (protected)
Explicitly invokes a task.
122 123 124 |
# File 'lib/rubygems/tasks/task.rb', line 122 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.
141 142 143 |
# File 'lib/rubygems/tasks/task.rb', line 141 def namespaced_tasks(prefix,subtasks) task prefix => subtasks.map { |subtask| "#{prefix}:#{subtask}" } end |
#run(command, *arguments) ⇒ Boolean (protected)
Runs a command.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubygems/tasks/task.rb', line 42 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.
108 109 110 |
# File 'lib/rubygems/tasks/task.rb', line 108 def task?(name) Rake::Task.task_defined?(name) end |