Class: SemverBump::VersionFile
- Inherits:
-
Object
- Object
- SemverBump::VersionFile
- Defined in:
- lib/semver_bump/version_file.rb
Constant Summary collapse
- LINE_MATCH =
/^\s*VERSION\s*=\s*"?'?([.\d]*\.?[a-zA-Z]{0,4}[0-9]{0,3})"?'?\s*$/
Instance Attribute Summary collapse
-
#semver ⇒ Object
Returns the value of attribute semver.
Instance Method Summary collapse
-
#initialize(filepath) ⇒ VersionFile
constructor
A new instance of VersionFile.
- #replace ⇒ Object
- #setup ⇒ Object
- #version_string ⇒ Object
Constructor Details
#initialize(filepath) ⇒ VersionFile
Returns a new instance of VersionFile.
8 9 10 11 |
# File 'lib/semver_bump/version_file.rb', line 8 def initialize(filepath) @filepath = filepath setup end |
Instance Attribute Details
#semver ⇒ Object
Returns the value of attribute semver.
4 5 6 |
# File 'lib/semver_bump/version_file.rb', line 4 def semver @semver end |
Instance Method Details
#replace ⇒ Object
29 30 31 32 33 |
# File 'lib/semver_bump/version_file.rb', line 29 def replace replace = @text.gsub(Regexp.new(version_string), semver.to_s) File.open(@filepath, "w") {|file| file.puts replace} semver.to_s end |
#setup ⇒ Object
13 14 15 16 |
# File 'lib/semver_bump/version_file.rb', line 13 def setup @text = File.read(@filepath) @semver = SemVer.new(version_string) end |
#version_string ⇒ Object
25 26 27 |
# File 'lib/semver_bump/version_file.rb', line 25 def version_string LINE_MATCH.match(@text).captures.first end |