Refactor *VersionHelpers to use an object

未关闭
#203 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
ruby
领域
release, tooling

调研方向

先阅读 ios_version_helper 和 android_version_helper,然后跟踪它们的调用方以及 Fastlane::Helper::Android 入口点。为现有的版本数据和操作定义一个一致的 Version 对象 API,更新调用方和文档,并验证当前的版本管理行为保持不变。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Ruby
星标
32
派生
7
平均合并
1 天 15 小时
30 天内合并 PR
9

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

wordpress-mobile/release-toolkit 的其他 Issue

查看 wordpress-mobile/release-toolkit 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。