Class: SocialStream::Release::Global::VersionFile
- Inherits:
-
Object
- Object
- SocialStream::Release::Global::VersionFile
- Defined in:
- lib/social_stream/release/global/version_file.rb
Overview
Manage component’s version files
This code is based on gem_release’s version_file.rb github.com/svenfuchs/gem-release
Copyright © 2010 Sven Fuchs <[email protected]>
Direct Known Subclasses
Constant Summary collapse
- VERSION_PATTERN =
/(VERSION\s*=\s*(?:"|'))(\d+\.\d+\.\d+)("|')/
- NUMBER_PATTERN =
/(\d+)\.(\d+)\.(\d+)/
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #bump! ⇒ Object
- #filename ⇒ Object
-
#initialize(target) ⇒ VersionFile
constructor
A new instance of VersionFile.
- #new_number ⇒ Object
- #old_number ⇒ Object
Constructor Details
#initialize(target) ⇒ VersionFile
Returns a new instance of VersionFile.
16 17 18 |
# File 'lib/social_stream/release/global/version_file.rb', line 16 def initialize(target) @target = target || :patch end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
14 15 16 |
# File 'lib/social_stream/release/global/version_file.rb', line 14 def target @target end |
Instance Method Details
#bump! ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/social_stream/release/global/version_file.rb', line 20 def bump! # Must load content before writing to it content File.open(filename, 'w+') { |f| f.write(bumped_content) } new_number end |
#filename ⇒ Object
39 40 41 |
# File 'lib/social_stream/release/global/version_file.rb', line 39 def filename "lib/social_stream/version.rb" end |
#new_number ⇒ Object
29 30 31 32 33 |
# File 'lib/social_stream/release/global/version_file.rb', line 29 def new_number @new_number ||= old_number.sub(NUMBER_PATTERN) do respond_to?(target, true) ? send(target, $1, $2, $3) : target end end |
#old_number ⇒ Object
35 36 37 |
# File 'lib/social_stream/release/global/version_file.rb', line 35 def old_number @old_number ||= content =~ VERSION_PATTERN && $2 end |