Skip to content

Instantly share code, notes, and snippets.

@triangletodd
Last active August 19, 2016 16:36
Show Gist options
  • Select an option

  • Save triangletodd/4a122f3e21005c3cedea to your computer and use it in GitHub Desktop.

Select an option

Save triangletodd/4a122f3e21005c3cedea to your computer and use it in GitHub Desktop.
Changelog - Class representation of a project's changelog
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
---
-
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