Class: Gem::Release::Files::Version

Inherits:
Struct
  • Object
show all
Defined in:
lib/gem/release/files/version.rb

Constant Summary collapse

VERSION =
/(VERSION\s*=\s*(?:"|'))((?:(?!"|').)*)("|')/
RELEASE =
/^(\d+)\.(\d+)\.(\d+)(.*)$/
PRE_RELEASE =
/^(\d+)\.(\d+)\.(\d+)\.?(.*)(\d+)$/
STAGES =
[:major, :minor, :patch]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#name=(value) ⇒ Object

Sets the attribute name

Parameters:

  • value (Object)

    the value to set the attribute name to.

Returns:

  • (Object)

    the newly set value


6
7
8
# File 'lib/gem/release/files/version.rb', line 6

def name=(value)
  @name = value
end

#optsObject

Returns the value of attribute opts

Returns:

  • (Object)

    the current value of opts


6
7
8
# File 'lib/gem/release/files/version.rb', line 6

def opts
  @opts
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version


6
7
8
# File 'lib/gem/release/files/version.rb', line 6

def version
  @version
end

Instance Method Details

#bumpObject


17
18
19
# File 'lib/gem/release/files/version.rb', line 17

def bump
  File.write(path, bumped)
end

#exists?Boolean

Returns:

  • (Boolean)

13
14
15
# File 'lib/gem/release/files/version.rb', line 13

def exists?
  !!path
end

#fromObject


25
26
27
# File 'lib/gem/release/files/version.rb', line 25

def from
  @from ||= content =~ VERSION && $2 || raise("Could not determine current version from file #{path}")
end

#pathObject


21
22
23
# File 'lib/gem/release/files/version.rb', line 21

def path
  @path ||= opts[:file] || paths.detect { |path| File.exist?(path) }
end

#toObject


29
30
31
# File 'lib/gem/release/files/version.rb', line 29

def to
  @to ||= number.bump
end

#to_hObject


33
34
35
# File 'lib/gem/release/files/version.rb', line 33

def to_h
  { from: from, version: to }
end