Sha256: 040674ddc1e15054034767519c5359f534f2439a421b5a558552f0230103f63a

Contents?: true

Size: 1.06 KB

Versions: 46

Compression:

Stored size: 1.06 KB

Contents

module Git
  
  # object that holds all the available stashes
  class Stashes
    include Enumerable
    
    def initialize(base)
      @stashes = []
      
      @base = base
            
      @base.lib.stashes_all.each do |id, message|
        @stashes.unshift(Git::Stash.new(@base, message, true))
      end
    end

    #
    # Returns an multi-dimensional Array of elements that have been stash saved.
    # Array is based on position and name. See Example
    #
    # @example Returns Array of items that have been stashed
    #     .all - [0, "testing-stash-all"]]
    # @return [Array]
    def all
      @base.lib.stashes_all
    end
    
    def save(message)
      s = Git::Stash.new(@base, message)
      @stashes.unshift(s) if s.saved?
    end
    
    def apply(index=nil)
      @base.lib.stash_apply(index)
    end
    
    def clear
      @base.lib.stash_clear
      @stashes = []
    end

    def size
      @stashes.size
    end
    
    def each(&block)
      @stashes.each(&block)
    end
    
    def [](index)
      @stashes[index.to_i]
    end
    
  end
end

Version data entries

46 entries across 46 versions & 7 rubygems

Version Path
git-2.3.3 lib/git/stashes.rb
git-2.3.2 lib/git/stashes.rb
git-2.3.1 lib/git/stashes.rb
git-2.3.0 lib/git/stashes.rb
git-2.2.0 lib/git/stashes.rb
git-2.1.1 lib/git/stashes.rb
git-2.1.0 lib/git/stashes.rb
git-2.0.0.pre3 lib/git/stashes.rb
git-2.0.0.pre2 lib/git/stashes.rb
git-2.0.0.pre1 lib/git/stashes.rb
git-1.19.1 lib/git/stashes.rb
git-1.19.0 lib/git/stashes.rb
git-1.18.0 lib/git/stashes.rb
git-1.17.2 lib/git/stashes.rb
git-1.17.1 lib/git/stashes.rb
git-1.17.0 lib/git/stashes.rb
git-1.16.0 lib/git/stashes.rb
git-1.15.0 lib/git/stashes.rb
git-1.14.0 lib/git/stashes.rb
git-1.13.2 lib/git/stashes.rb