Class: Releaser::Repository
- Inherits:
-
Object
- Object
- Releaser::Repository
- Defined in:
- lib/releaser/repository.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #clean? ⇒ Boolean
- #fetch_remote_tags ⇒ Object
- #git? ⇒ Boolean
-
#initialize(path = '.') ⇒ Repository
constructor
A new instance of Repository.
Constructor Details
#initialize(path = '.') ⇒ Repository
Returns a new instance of Repository.
7 8 9 10 11 12 |
# File 'lib/releaser/repository.rb', line 7 def initialize(path = '.') @path = File.(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
#path ⇒ Object (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
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_tags ⇒ Object
25 26 27 28 |
# File 'lib/releaser/repository.rb', line 25 def `git fetch --tags` return $CHILD_STATUS.success? end |
#git? ⇒ Boolean
14 15 16 |
# File 'lib/releaser/repository.rb', line 14 def git? File.directory?("#{@path}/.git") end |