Sha256: 09a753ad9787d350c7d276e76855836676fb595a855f00bce27889d526162fa3

Contents?: true

Size: 576 Bytes

Versions: 39

Compression:

Stored size: 576 Bytes

Contents

module Awsborn
  class GitBranch

    attr_reader :branch

    def initialize (branch)
      require 'git'
      @branch = branch
    end
    
    def file (path)
      path, file = File.split(path)

      repo = Git.open(root)
      tree = repo.branches[branch].gcommit.gtree
      path.each { |dir| tree = tree.subtrees[dir] }
      tree.blobs[file].contents
    end

    protected

    def root
      dir = File.expand_path('.')
      while dir != '/'
        return dir if File.directory?(File.join(dir, '.git'))
        dir = File.dirname(dir)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
awsborn-0.9.11 lib/awsborn/git_branch.rb
awsborn-0.9.10 lib/awsborn/git_branch.rb
awsborn-0.9.9 lib/awsborn/git_branch.rb
awsborn-0.9.8 lib/awsborn/git_branch.rb
awsborn-0.9.7 lib/awsborn/git_branch.rb
awsborn-0.9.6 lib/awsborn/git_branch.rb
awsborn-0.9.5 lib/awsborn/git_branch.rb
awsborn-0.9.4 lib/awsborn/git_branch.rb
awsborn-0.9.3 lib/awsborn/git_branch.rb
awsborn-0.9.2 lib/awsborn/git_branch.rb
awsborn-0.9.1 lib/awsborn/git_branch.rb
awsborn-0.9.0 lib/awsborn/git_branch.rb
awsborn-0.8.7 lib/awsborn/git_branch.rb
awsborn-0.8.6 lib/awsborn/git_branch.rb
awsborn-0.8.5 lib/awsborn/git_branch.rb
awsborn-0.8.4 lib/awsborn/git_branch.rb
awsborn-0.8.3 lib/awsborn/git_branch.rb
awsborn-0.8.2 lib/awsborn/git_branch.rb
awsborn-0.8.1 lib/awsborn/git_branch.rb
awsborn-0.8.0 lib/awsborn/git_branch.rb