Class: Groundskeeper::RailsVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/groundskeeper/rails_version.rb

Overview

The version.rb file in an application.

Constant Summary collapse

APPLICATION_CONFIG_FILE =
"%sconfig/application.rb"
MODULE_NAME_EXPRESSION =
/module (\w+)/
VERSION_FILE =
"%slib/%s/version.rb"
VERSION_EXPRESSION =
/(?<=VERSION = ")([^"]+)(?=")/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relative_path = "") ⇒ RailsVersion



13
14
15
16
# File 'lib/groundskeeper/rails_version.rb', line 13

def initialize(relative_path = "")
  @relative_path = relative_path
  find_version_file
end

Instance Attribute Details

#module_fileObject (readonly)

Returns the value of attribute module_file.



11
12
13
# File 'lib/groundskeeper/rails_version.rb', line 11

def module_file
  @module_file
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



11
12
13
# File 'lib/groundskeeper/rails_version.rb', line 11

def relative_path
  @relative_path
end

#version_fileObject (readonly)

Returns the value of attribute version_file.



11
12
13
# File 'lib/groundskeeper/rails_version.rb', line 11

def version_file
  @version_file
end

Instance Method Details

#current_versionObject



18
19
20
# File 'lib/groundskeeper/rails_version.rb', line 18

def current_version
  version_file.match(VERSION_EXPRESSION) || ""
end

#exists?Boolean



26
27
28
# File 'lib/groundskeeper/rails_version.rb', line 26

def exists?
  version_file.exists?
end

#update_version!(value) ⇒ Object



22
23
24
# File 'lib/groundskeeper/rails_version.rb', line 22

def update_version!(value)
  version_file.gsub_file VERSION_EXPRESSION, value
end