Class: Fastlane::Wpmreleasetoolkit::Versioning::AndroidVersionFile
- Inherits:
-
Object
- Object
- Fastlane::Wpmreleasetoolkit::Versioning::AndroidVersionFile
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb
Overview
The ‘AndroidVersionFile` class takes in a version.properties file path and reads/writes values to/from the file.
Instance Attribute Summary collapse
-
#version_properties_path ⇒ Object
readonly
Returns the value of attribute version_properties_path.
Instance Method Summary collapse
-
#initialize(version_properties_path: 'version.properties') ⇒ AndroidVersionFile
constructor
Initializes a new instance of AndroidVersionFile with the specified version.properties file path.
-
#read_version_code ⇒ BuildCode
Reads the version code from a version.properties file.
-
#read_version_name ⇒ String
Reads the version name from a version.properties file.
-
#write_version(version_name:, version_code:) ⇒ Object
Writes the provided version name and version code to the version.properties file.
Constructor Details
#initialize(version_properties_path: 'version.properties') ⇒ AndroidVersionFile
Initializes a new instance of AndroidVersionFile with the specified version.properties file path.
14 15 16 17 18 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb', line 14 def initialize(version_properties_path: 'version.properties') UI.user_error!("version.properties not found at this path: #{version_properties_path}") unless File.exist?(version_properties_path) @version_properties_path = version_properties_path end |
Instance Attribute Details
#version_properties_path ⇒ Object (readonly)
Returns the value of attribute version_properties_path.
8 9 10 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb', line 8 def version_properties_path @version_properties_path end |
Instance Method Details
#read_version_code ⇒ BuildCode
Reads the version code from a version.properties file.
43 44 45 46 47 48 49 50 51 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb', line 43 def read_version_code # Read the version code from the version.properties file file_content = JavaProperties.load(version_properties_path) version_code = file_content[:versionCode] UI.user_error!('Version code not found in version.properties') if version_code.nil? # Create a BuildCode object Fastlane::Models::BuildCode.new(version_code.to_i) end |
#read_version_name ⇒ String
Reads the version name from a version.properties file.
26 27 28 29 30 31 32 33 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb', line 26 def read_version_name # Read the version name from the version.properties file file_content = JavaProperties.load(version_properties_path) version_name = file_content[:versionName] UI.user_error!('Version name not found in version.properties') if version_name.nil? version_name end |
#write_version(version_name:, version_code:) ⇒ Object
Writes the provided version name and version code to the version.properties file.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb', line 60 def write_version(version_name:, version_code:) # Create the version name and version code hash version = { versionName: version_name, versionCode: version_code } # Write the version name and version code hash to the version.properties file JavaProperties.write( version, version_properties_path ) end |