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

- (Object) base_dir

Returns the value of attribute base_dir



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

def base_dir
  @base_dir
end

- (Object) commit

Returns the value of attribute commit



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

def commit
  @commit
end

- (Object) gemspec

Returns the value of attribute gemspec



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

def gemspec
  @gemspec
end

- (Object) repo

Returns the value of attribute repo



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

def repo
  @repo
end

- (Object) version_helper

Returns the value of attribute version_helper



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

def version_helper
  @version_helper
end

Class Method Details

+ (Object) build_for(jeweler)



42
43
44
45
46
47
48
49
50
51
# File 'lib/jeweler/commands/version/base.rb', line 42

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

- (Object) base_dir_path



37
38
39
# File 'lib/jeweler/commands/version/base.rb', line 37

def base_dir_path
  Pathname.new(base_dir).realpath
end

- (Object) commit_version



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

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

- (Object) run



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

def run
  update_version

  self.version_helper.write
  self.gemspec.version = self.version_helper.to_s

  commit_version if self.repo && self.commit
end

- (Object) update_version



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

def update_version
  raise "Subclasses should implement this"
end

- (Object) working_subdir



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

def working_subdir
  return @working_subdir if @working_subdir
  cwd = base_dir_path
  @working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
  @working_subdir
end