class GitPivotalTrackerIntegration::VersionUpdate::Gradle
A version updater for dealing with typical Gradle
projects. This updater assumes that the version of the current project is stored within a gradle.properties
file in the root of the repository. This properties file should have an entry with a key of version
and version number as the key.
Public Class Methods
new(root)
click to toggle source
Creates an instance of this updater
@param [String] root The root of the repository
# File lib/git-pivotal-tracker-integration/version-update/gradle.rb, line 27 def initialize(root) @gradle_properties = File.expand_path 'gradle.properties', root if File.exist? @gradle_properties groups = nil File.open(@gradle_properties, 'r') do |file| groups = file.read().scan(/version[=:](.*)/) end @version = groups[0] ? groups[0][0]: nil end end
Public Instance Methods
current_version()
click to toggle source
The current version of the project
@return [String] the current version of the project
# File lib/git-pivotal-tracker-integration/version-update/gradle.rb, line 50 def current_version @version end
supports?()
click to toggle source
Whether this updater supports updating this project
@return [Boolean] true
if a valid version number was found on
initialization, +false+ otherwise
# File lib/git-pivotal-tracker-integration/version-update/gradle.rb, line 43 def supports? !@version.nil? end
update_version(new_version)
click to toggle source
Update the version of the project
@param [String] new_version the version to update the project to @return [void]
# File lib/git-pivotal-tracker-integration/version-update/gradle.rb, line 58 def update_version(new_version) contents = File.read(@gradle_properties) contents = contents.gsub(/(version[=:])#{@version}/, "\\1#{new_version}") File.open(@gradle_properties, 'w') { |file| file.write(contents) } end