Class: Releaser::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/releaser/repository.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = '.') ⇒ Repository

Returns a new instance of Repository.

Raises:



7
8
9
10
11
12
# File 'lib/releaser/repository.rb', line 7

def initialize(path = '.')
  @path = File.expand_path(path)
  raise(Error, 'Unreadable path given') unless File.readable?(@path)
  raise(Error, 'Repository is not a directory') unless File.directory?(@path)
  raise(Error, 'Repository is not a github repository') unless git?
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/releaser/repository.rb', line 5

def path
  @path
end

Instance Method Details

#clean?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/releaser/repository.rb', line 18

def clean?
  committed = `git status -s`.chomp.strip.empty?
  pushed = `git log origin/master..HEAD`.chomp.strip.empty?

  return committed && pushed
end

#fetch_remote_tagsObject



25
26
27
28
# File 'lib/releaser/repository.rb', line 25

def fetch_remote_tags
  `git fetch --tags`
  return $CHILD_STATUS.success?
end

#git?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/releaser/repository.rb', line 14

def git?
  File.directory?("#{@path}/.git")
end