Last active
August 19, 2016 16:36
-
-
Save triangletodd/4a122f3e21005c3cedea to your computer and use it in GitHub Desktop.
Changelog - Class representation of a project's changelog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'yaml' | |
| require 'ostruct' | |
| class Changelog < OpenStruct | |
| class Error | |
| class NoSuchVersion < LoadError; end | |
| end | |
| def initialize(version=:latest) | |
| yaml_file = File.expand_path('../../Changelog.yml', __FILE__) | |
| @changelog = YAML.load_file(yaml_file) | |
| payload = version.eql?(:latest) ? @changelog.first : find_version(version) | |
| super payload | |
| end | |
| def to_s | |
| changes.map { |c| "- #{c}" }.join("\n") | |
| end | |
| private | |
| def find_version(version) | |
| payload = @changelog.select { |c| c['version'] == version }.first | |
| fail Error::NoSuchVersion, "Version '#{version}' not found." if payload.nil? | |
| payload | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - | |
| version: 5.2.2 | |
| version_code: 5000202 | |
| changes: | |
| - Fixed an issue where some photo galleries would crash the app | |
| - Photo credits added | |
| - High res photos added to stories | |
| - Other bug fixes | |
| - | |
| version: 5.2.1 | |
| version_code: 5000201 | |
| changes: | |
| - Testing | |
| - Other bug fixes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment