Showing the changes to lib/docs (1 of 2 files). Show all
Unified · Split
| @@ -132,6 +132,35 @@ module Docs · 131 unmodified lines | ||
| 132 | 132 | end |
| 133 | 133 | end |
| 134 | 134 | |
| 135 | + def get_latest_version | |
| 136 | + raise NotImplementedError | |
| 137 | + end | |
| 138 | + | |
| 139 | + # Returns whether or not this scraper is outdated. | |
| 140 | + # | |
| 141 | + # The default implementation assumes the documentation uses a semver(-like) approach when it comes to versions. | |
| 142 | + # Patch updates are ignored because there are usually little to no documentation changes in bug-fix-only releases. | |
| 143 | + # | |
| 144 | + # Scrapers of documentations that do not use this versioning approach should override this method. | |
| 145 | + # | |
| 146 | + # Examples of the default implementation: | |
| 147 | + # 1 -> 2 = outdated | |
| 148 | + # 1.1 -> 1.2 = outdated | |
| 149 | + # 1.1.1 -> 1.1.2 = not outdated | |
| 150 | + def is_outdated(current_version, latest_version) | |
| 151 | + current_parts = current_version.split(/\./).map(&:to_i) | |
| 152 | + latest_parts = latest_version.split(/\./).map(&:to_i) | |
| 153 | + | |
| 154 | + # Only check the first two parts, the third part is for patch updates | |
| 155 | + [0, 1].each do |i| | |
| 156 | + break if i >= current_parts.length or i >= latest_parts.length | |
| 157 | + return true if latest_parts[i] > current_parts[i] | |
| 158 | + return false if latest_parts[i] < current_parts[i] | |
| 159 | + end | |
| 160 | + | |
| 161 | + false | |
| 162 | + end | |
| 163 | + | |
| 135 | 164 | private |
| 136 | 165 | |
| 137 | 166 | def request_one(url) |