class Gem::Tasks::SCM::Status

The `scm:status` task.

Public Class Methods

new(options={}) { |self| ... } click to toggle source

Initializes the `status` task.

@param [Hash] options

Additional options.
Calls superclass method
# File lib/rubygems/tasks/scm/status.rb, line 17
def initialize(options={})
  super()

  yield self if block_given?
  define
end

Public Instance Methods

define() click to toggle source

Defines the `status` task.

# File lib/rubygems/tasks/scm/status.rb, line 27
def define
  namespace :scm do
    task :status do
      if dirty?
        error "Project has uncommitted changes!"

        status
        abort
      end
    end
  end

  # alias the `validate` task to scm:status
  task :validate => 'scm:status'
end
dirty?() click to toggle source

Checks the status of the project repository.

@return [Boolean]

Specifies whether the repository is dirty.

@api semipublic

@since 0.2.1

# File lib/rubygems/tasks/scm/status.rb, line 53
def dirty?
  status = case @project.scm
           when :git then %x`git status --porcelain --untracked-files=no`
           when :hg  then %x`hg status --quiet`
           when :svn then %x`svn status --quiet`
           else            ''
           end

  return !status.chomp.empty?
end
status() click to toggle source

Displays the status of the project repository.

@api semipublic

# File lib/rubygems/tasks/scm/status.rb, line 69
def status
  case @project.scm
  when :git then run 'git', 'status', '--untracked-files=no'
  when :hg  then run 'hg', 'status', '--quiet'
  when :svn then run 'svn', 'status', '--quiet'
  end
end