Class: AutoTagger

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

Defined Under Namespace

Classes: EnvironmentCannotBeBlankError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage, path = nil) ⇒ AutoTagger

Returns a new instance of AutoTagger.



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

def initialize(stage, path = nil)
  raise EnvironmentCannotBeBlankError if stage.to_s.strip == ""
  @working_directory = File.expand_path(path ||= Dir.pwd)
  @repository = Repository.new(@working_directory)
  @stage = stage
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



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

def repository
  @repository
end

#stageObject (readonly)

Returns the value of attribute stage.



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

def stage
  @stage
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory.



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

def working_directory
  @working_directory
end

Instance Method Details

#create_tag(commit = nil) ⇒ Object



14
15
16
17
18
19
# File 'lib/auto_tagger/auto_tagger.rb', line 14

def create_tag(commit = nil)
  repository.tags.fetch
  new_tag = repository.tags.create(stage, commit)
  repository.tags.push
  new_tag
end

#latest_tagObject



21
22
23
24
# File 'lib/auto_tagger/auto_tagger.rb', line 21

def latest_tag
  repository.tags.fetch
  repository.tags.latest_from(stage)
end