Class: Groundskeeper::RailsVersion
- Inherits:
-
Object
- Object
- Groundskeeper::RailsVersion
- 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
-
#module_file ⇒ Object
readonly
Returns the value of attribute module_file.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
-
#version_file ⇒ Object
readonly
Returns the value of attribute version_file.
Instance Method Summary collapse
- #current_version ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(relative_path = "") ⇒ RailsVersion
constructor
A new instance of RailsVersion.
- #update_version!(value) ⇒ Object
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_file ⇒ Object (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_path ⇒ Object (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_file ⇒ Object (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_version ⇒ Object
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 |