Class: VersionManager::Make

Inherits:
Object
  • Object
show all
Defined in:
lib/version-manager/make.rb

Defined Under Namespace

Classes: BranchIsNotUpToDateError, ForbiddenBranchError

Instance Method Summary collapse

Constructor Details

#initialize(version, vcs, version_storage) ⇒ Make

Returns a new instance of Make.



15
16
17
18
19
# File 'lib/version-manager/make.rb', line 15

def initialize(version, vcs, version_storage)
  @version = version
  @vcs = vcs
  @version_storage = version_storage
end

Instance Method Details

#major!Object



21
22
23
24
25
# File 'lib/version-manager/make.rb', line 21

def major!
  raise BranchIsNotUpToDateError unless vcs.master_state_actual?
  raise ForbiddenBranchError unless appropriate_branch_for?('major')
  default_strategy { version.bump_major }
end

#minor!Object



27
28
29
30
31
# File 'lib/version-manager/make.rb', line 27

def minor!
  raise BranchIsNotUpToDateError unless vcs.master_state_actual?
  raise ForbiddenBranchError unless appropriate_branch_for?('minor')
  default_strategy { version.bump_minor }
end

#patch!Object



33
34
35
36
37
38
39
40
41
# File 'lib/version-manager/make.rb', line 33

def patch!
  raise BranchIsNotUpToDateError unless vcs.state_actual?
  raise ForbiddenBranchError unless appropriate_branch_for?('patch')
  @version = version.bump_patch
  vcs.commit(version_storage.store(version), default_commit_message)
  vcs.add_tag(version.to_s, default_commit_message)
  vcs.push_tag(version.to_s)
  vcs.push
end