Class: GitHubChangelogGenerator::Options
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- GitHubChangelogGenerator::Options
- Defined in:
- lib/github_changelog_generator/options.rb
Overview
This class wraps Options, and knows a list of known options. Others options will raise exceptions.
Constant Summary collapse
- UnsupportedOptionError =
Raised on initializing with unknown keys in the values hash, and when trying to store a value on an unknown key.
Class.new(ArgumentError)
- KNOWN_OPTIONS =
List of valid option names
%i[ add_issues_wo_labels add_pr_wo_labels add_sections author base between_tags breaking_labels breaking_prefix bug_labels bug_prefix cache_file cache_log config_file compare_link configure_sections date_format deprecated_labels deprecated_prefix due_tag enhancement_labels enhancement_prefix exclude_labels exclude_tags exclude_tags_regex filter_issues_by_milestone issues_of_open_milestones frontmatter future_release github_endpoint github_site header http_cache include_labels include_tags_regex issue_prefix issue_line_labels issue_line_body issues max_issues merge_prefix output project pulls release_branch release_url removed_labels removed_prefix require security_labels security_prefix simple_list since_tag since_commit ssl_ca_file summary_labels summary_prefix token unreleased unreleased_label unreleased_only user usernames_as_github_logins verbose ]
Instance Method Summary collapse
-
#[]=(key, val) ⇒ Object
Set option key to val.
-
#add_sections? ⇒ Boolean
Boolean method for whether the user is using add_sections.
-
#configure_sections? ⇒ Boolean
Boolean method for whether the user is using configure_sections.
-
#initialize(values) ⇒ Options
constructor
A new instance of Options.
-
#load_custom_ruby_files ⇒ Object
Loads the configured Ruby files from the –require option.
-
#print_options ⇒ Object
Pretty-prints a censored options hash, if :verbose.
- #to_hash ⇒ Hash
-
#write_to_file? ⇒ Boolean
Whether write to `:output`.
Constructor Details
#initialize(values) ⇒ Options
Returns a new instance of Options.
84 85 86 87 |
# File 'lib/github_changelog_generator/options.rb', line 84 def initialize(values) super(values) .any? && raise(UnsupportedOptionError, .inspect) end |
Instance Method Details
#[]=(key, val) ⇒ Object
Set option key to val.
95 96 97 98 |
# File 'lib/github_changelog_generator/options.rb', line 95 def []=(key, val) supported_option?(key) || raise(UnsupportedOptionError, key.inspect) values[key] = val end |
#add_sections? ⇒ Boolean
Boolean method for whether the user is using add_sections
129 130 131 |
# File 'lib/github_changelog_generator/options.rb', line 129 def add_sections? !self[:add_sections].nil? && !self[:add_sections].empty? end |
#configure_sections? ⇒ Boolean
Boolean method for whether the user is using configure_sections
124 125 126 |
# File 'lib/github_changelog_generator/options.rb', line 124 def configure_sections? !self[:configure_sections].nil? && !self[:configure_sections].empty? end |
#load_custom_ruby_files ⇒ Object
Loads the configured Ruby files from the –require option.
106 107 108 |
# File 'lib/github_changelog_generator/options.rb', line 106 def load_custom_ruby_files self[:require].each { |f| require f } end |
#print_options ⇒ Object
Pretty-prints a censored options hash, if :verbose.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/github_changelog_generator/options.rb', line 111 def return unless self[:verbose] Helper.log.info "Using these options:" # For ruby 2.5.0+ censored_values.each do |key, value| print(key.inspect, "=>", value.inspect) puts "" end puts "" end |
#to_hash ⇒ Hash
101 102 103 |
# File 'lib/github_changelog_generator/options.rb', line 101 def to_hash values end |
#write_to_file? ⇒ Boolean
Returns whether write to `:output`.
134 135 136 |
# File 'lib/github_changelog_generator/options.rb', line 134 def write_to_file? self[:output].present? end |