Class: Jeweler::Commands::Version::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/commands/version/base.rb

Direct Known Subclasses

BumpMajor, BumpMinor, BumpPatch, Write

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



7
8
9
# File 'lib/jeweler/commands/version/base.rb', line 7

def base_dir
  @base_dir
end

#commitObject

Returns the value of attribute commit.



7
8
9
# File 'lib/jeweler/commands/version/base.rb', line 7

def commit
  @commit
end

#gemspecObject

Returns the value of attribute gemspec.



7
8
9
# File 'lib/jeweler/commands/version/base.rb', line 7

def gemspec
  @gemspec
end

#repoObject

Returns the value of attribute repo.



7
8
9
# File 'lib/jeweler/commands/version/base.rb', line 7

def repo
  @repo
end

#version_helperObject

Returns the value of attribute version_helper.



7
8
9
# File 'lib/jeweler/commands/version/base.rb', line 7

def version_helper
  @version_helper
end

Class Method Details

.build_for(jeweler) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/jeweler/commands/version/base.rb', line 37

def self.build_for(jeweler)
  command = new
  command.repo = jeweler.repo
  command.version_helper = jeweler.version_helper
  command.gemspec = jeweler.gemspec
  command.commit = jeweler.commit
  command.base_dir = jeweler.base_dir

  command
end

Instance Method Details

#base_dir_pathObject



33
34
35
# File 'lib/jeweler/commands/version/base.rb', line 33

def base_dir_path
  Pathname.new(base_dir).realpath
end

#commit_versionObject



22
23
24
25
26
27
# File 'lib/jeweler/commands/version/base.rb', line 22

def commit_version
  if repo
    repo.add(working_subdir.join(version_helper.path).to_s)
    repo.commit("Version bump to #{version_helper}")
  end
end

#runObject



9
10
11
12
13
14
15
16
# File 'lib/jeweler/commands/version/base.rb', line 9

def run
  update_version

  version_helper.write
  gemspec.version = version_helper.to_s

  commit_version if repo && commit
end

#update_versionObject



18
19
20
# File 'lib/jeweler/commands/version/base.rb', line 18

def update_version
  raise 'Subclasses should implement this'
end

#working_subdirObject



29
30
31
# File 'lib/jeweler/commands/version/base.rb', line 29

def working_subdir
  @working_subdir ||= base_dir_path.relative_path_from(Pathname.new(repo.dir.path))
end