Sha256: e80955f9367e84e0b3862473fb14154a63ea2d039917bdc720e496fd207f7ba8

Contents?: true

Size: 964 Bytes

Versions: 3

Compression:

Stored size: 964 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

3 entries across 3 versions & 1 rubygems

Version Path
sub-0.4.0 lib/sub/status.rb
sub-0.4.1 lib/sub/status.rb
sub-0.4.2 lib/sub/status.rb