2016-10-05 19:35:55 +00:00
|
|
|
# frozen_string_literal: true
|
2016-10-05 21:31:19 +00:00
|
|
|
require "delegate"
|
2016-10-05 19:35:55 +00:00
|
|
|
module GitHubChangelogGenerator
|
|
|
|
class Options < SimpleDelegator
|
2016-10-05 20:57:28 +00:00
|
|
|
UnsupportedOptionError = Class.new(ArgumentError)
|
|
|
|
|
2016-10-05 19:35:55 +00:00
|
|
|
KNOWN_OPTIONS = [
|
|
|
|
:add_issues_wo_labels,
|
|
|
|
:add_pr_wo_labels,
|
|
|
|
:author,
|
|
|
|
:base,
|
|
|
|
:between_tags,
|
|
|
|
:bug_labels,
|
|
|
|
:bug_prefix,
|
|
|
|
:cache_file,
|
|
|
|
:cache_log,
|
|
|
|
:compare_link,
|
|
|
|
:date_format,
|
|
|
|
:due_tag,
|
|
|
|
:enhancement_labels,
|
|
|
|
:enhancement_prefix,
|
|
|
|
:exclude_labels,
|
|
|
|
:exclude_tags,
|
|
|
|
:exclude_tags_regex,
|
|
|
|
:filter_issues_by_milestone,
|
|
|
|
:frontmatter,
|
|
|
|
:future_release,
|
|
|
|
:git_remote,
|
|
|
|
:github_endpoint,
|
|
|
|
:github_site,
|
|
|
|
:header,
|
|
|
|
:http_cache,
|
|
|
|
:include_labels,
|
|
|
|
:issue_prefix,
|
|
|
|
:issues,
|
|
|
|
:max_issues,
|
|
|
|
:merge_prefix,
|
|
|
|
:output,
|
|
|
|
:project,
|
|
|
|
:pulls,
|
|
|
|
:release_branch,
|
|
|
|
:release_url,
|
|
|
|
:simple_list,
|
|
|
|
:since_tag,
|
|
|
|
:token,
|
|
|
|
:unreleased,
|
|
|
|
:unreleased_label,
|
|
|
|
:unreleased_only,
|
|
|
|
:user,
|
|
|
|
:usernames_as_github_logins,
|
2016-10-05 21:31:19 +00:00
|
|
|
:verbose
|
2016-10-05 19:35:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
THESE_ARE_DIFFERENT = [
|
|
|
|
:tag1,
|
2016-10-05 21:31:19 +00:00
|
|
|
:tag2
|
2016-10-05 19:35:55 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def initialize(values)
|
|
|
|
super(values)
|
2016-10-05 20:57:28 +00:00
|
|
|
unsupported_options.any? && raise(UnsupportedOptionError, unsupported_options.inspect)
|
|
|
|
end
|
|
|
|
|
|
|
|
def []=(key, val)
|
|
|
|
supported_option?(key) || raise(UnsupportedOptionError, key.inspect)
|
|
|
|
values[key] = val
|
2016-10-05 19:35:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_hash
|
|
|
|
values
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def values
|
|
|
|
__getobj__
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsupported_options
|
2016-10-05 20:57:28 +00:00
|
|
|
values.keys - supported_options
|
|
|
|
end
|
|
|
|
|
|
|
|
def supported_option?(key)
|
|
|
|
supported_options.include?(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
def supported_options
|
|
|
|
KNOWN_OPTIONS + THESE_ARE_DIFFERENT
|
2016-10-05 19:35:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|