Sha256: 596792b861b46901d1308f444c2e53a043c47012b1e308fb385066a28e4a1311

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

class Status
  class Line
    def initialize(text)
      text.strip!
      @modified = /^M/.match(text) ? true : false
      @external = /^X/.match(text) ? true : false
      @unversioned = /^\?/.match(text) ? true : false
      @modified_properties = /^.M/.match(text) ? true : false
      @path = text.gsub(/^...... /, '')
    end

    attr_reader :path

    def modified?
      @modified
    end
    def external?
      @external
    end
    def unversioned?
      @unversioned
    end
    def modified_properties?
      @modified_properties
    end
  end


  def initialize(text)
    @lines = text.split("\n").collect do |line|
      Status::Line.new(line)
    end
  end

  def modified
    @lines.select { |line| line.modified? }.collect {|line| line.path}
  end

  def externals
    @lines.select { |line| line.external? }.collect {|line| line.path}
  end

  def unversioned
    @lines.select { |line| line.unversioned? }.collect {|line| line.path}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sub-0.3.0 lib/sub/status.rb