wordpress-mobile / wordpress-mobile/release-toolkit
Refactor *VersionHelpers to use an object
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 31
- Forks
- 10
- Avg merge
- 5h 45m
- Merged PRs (30d)
- 2
Description
Today ios_version_helper and android_version_helper consist of freeform, module-static methods which take various and heterogeneous types of parameters depending on the method (sometimes a String for versionName, sometimes a Hash, etc)
It would make way more sense, and make the code way easier to understand, if instead of freeform methods, we created a class Version which would expose the appropriate instance properties (e.g. for Android, name and code) and instance methods to manipulate those versions, inspired by Gem::Version and its methods.
This would make the implementation way easier to understand and document (not having to repeat the parameter type documentation methods taking similar inputs), but also clearer at call-site and more idiomatic.
Some ideas / inspiration for possible API, e.g. for the Android one in the Fastlane::Helper::Android module:
class Version
# [String] Doc here
attr_reader :name
# [Int] Doc here
attr_reader :code
# @return [Version] Next release version
def next_release
…
end
…
end
Or, alternatively, something like:
class Version
attr_reader :major, :minor, :hotfix
attr_reader :is_alpha?
attr_reader :suffix
attr_reader :code
# @return [String] The versionName. `"alpha-major.minor.patch-suffix"` if `is_alpha?`, `"major.minor.patch-rc-suffix"` otherwise.
def name
(sprefix, *ssuffixes) = is_alpha? ? ["alpha", suffix] : [nil, "rc", suffix]
[sprefix, "#{major}.#{minor}.#{patch}", *ssuffixes].compact.join('-')
end
…
# And a lot of instance methods to bump versions up and down, etc
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ios_version_helper and android_version_helper, then trace their callers and the Fastlane::Helper::Android entry point. Define a coherent Version object API for the existing version data and operations, update callers and documentation, and verify that the current versioning behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- release, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100