Class: Awsborn::GitBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/awsborn/git_branch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch) ⇒ GitBranch

Returns a new instance of GitBranch.



6
7
8
9
# File 'lib/awsborn/git_branch.rb', line 6

def initialize (branch)
  require 'git'
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



4
5
6
# File 'lib/awsborn/git_branch.rb', line 4

def branch
  @branch
end

Instance Method Details

#file(path) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/awsborn/git_branch.rb', line 11

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