Class: Boxen::Checkout

Inherits:
Object
  • Object
show all
Defined in:
lib/boxen/checkout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Checkout

Returns a new instance of Checkout.



5
6
7
# File 'lib/boxen/checkout.rb', line 5

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/boxen/checkout.rb', line 3

def config
  @config
end

Instance Method Details

#changesObject



21
22
23
# File 'lib/boxen/checkout.rb', line 21

def changes
  Dir.chdir(config.repodir) { `git status --porcelain`.strip }
end

#dirty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/boxen/checkout.rb', line 17

def dirty?
  !changes.empty?
end

#master?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/boxen/checkout.rb', line 13

def master?
  Dir.chdir(config.repodir) { `git symbolic-ref HEAD`.strip == 'refs/heads/master' }
end

#shaObject



9
10
11
# File 'lib/boxen/checkout.rb', line 9

def sha
  Dir.chdir(config.repodir) { `git rev-parse HEAD`.strip }
end