Class: Release::Notes::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/release/notes/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/release/notes/configuration.rb', line 136

def initialize
  @output_file                      = "./RELEASE_NOTES.md"
  @temp_file                        = "./release-notes.tmp.md"
  @include_merges                   = false
  @ignore_case                      = true
  @extended_regex                   = true
  @header_title                     = "tag"
  @bug_labels                       = %w(Fix Update)
  @feature_labels                   = %w(Add Create)
  @misc_labels                      = %w(Refactor)
  @bug_title                        = "**Fixed bugs:**"
  @feature_title                    = "**Implemented enhancements:**"
  @misc_title                       = "**Miscellaneous:**"
  @log_all_title                    = "**Other**"
  @log_all                          = false
  @link_to_labels                   = %w()
  @link_to_humanize                 = %w()
  @link_to_sites                    = %w()
  @timezone                         = "America/New_York"
  @prettify_messages                = false
  @single_label                     = true
  @for_each_ref_format              = "tag"
  @update_release_notes_before_tag  = true
end

Instance Attribute Details

#bug_labels ⇒ Array

Controls the labels grepped for in your commit subjects that will be add under you bug title Defaults to %w(Fix Update).

Returns:

  • (Array)


45
46
47
# File 'lib/release/notes/configuration.rb', line 45

def bug_labels
  @bug_labels
end

#bug_title ⇒ String

Controls the title used in your generated log for all bugs listed Defaults to **Fixed bugs:**.

Returns:

  • (String)


62
63
64
# File 'lib/release/notes/configuration.rb', line 62

def bug_title
  @bug_title
end

#extended_regex ⇒ Boolean

Consider the limiting patterns to be extended regular expressions patterns when printing your git log. Defaults to true. For more, see Git Log Docs

Returns:

  • (Boolean)


34
35
36
# File 'lib/release/notes/configuration.rb', line 34

def extended_regex
  @extended_regex
end

#feature_labels ⇒ Array

Controls the labels grepped for in your commit subjects that will be add under you feature title Defaults to %w(Add Create).

Returns:

  • (Array)


51
52
53
# File 'lib/release/notes/configuration.rb', line 51

def feature_labels
  @feature_labels
end

#feature_title ⇒ String

Controls the title used in your generated log for all features listed Defaults to **Implemented enhancements:**.

Returns:

  • (String)


67
68
69
# File 'lib/release/notes/configuration.rb', line 67

def feature_title
  @feature_title
end

#for_each_ref_format ⇒ String

Controls what will be passed to the format flag in git for-each-ref Defaults to tag.

Returns:

  • (String)


127
128
129
# File 'lib/release/notes/configuration.rb', line 127

def for_each_ref_format
  @for_each_ref_format
end

#header_title ⇒ String

Controls the headers that will be used for your tags Defaults to tag.

Returns:

  • (String)


39
40
41
# File 'lib/release/notes/configuration.rb', line 39

def header_title
  @header_title
end

#ignore_case ⇒ Boolean

Match the regular expression limiting patterns without regard to letter case when printing your git log. Defaults to true. For more, see Git Log Docs

Returns:

  • (Boolean)


27
28
29
# File 'lib/release/notes/configuration.rb', line 27

def ignore_case
  @ignore_case
end

#include_merges ⇒ Boolean

Determines whether to print commits with more than one parent. Defaults to false. For more, see Git Log Docs

Returns:

  • (Boolean)


20
21
22
# File 'lib/release/notes/configuration.rb', line 20

def include_merges
  @include_merges
end

The humanized output that you'd like to represent the associated :link_to_label The index within the array must match the index for the site in :link_to_label and :link_to_sites. Defaults to [].

Returns:

  • (Array)


96
97
98
# File 'lib/release/notes/configuration.rb', line 96

def link_to_humanize
  @link_to_humanize
end

The labels grepped for in your commit subject that you want to linkify. The index within the array must match the index for the site in :link_to_humanize and :link_to_sites. Defaults to [].

Returns:

  • (Array)


89
90
91
# File 'lib/release/notes/configuration.rb', line 89

def link_to_labels
  @link_to_labels
end

The url for the site that you'd like to represent the associated :link_to_label The index within the array must match the index for the site in :link_to_label and :link_to_humanize. Defaults to [].

Returns:

  • (Array)


103
104
105
# File 'lib/release/notes/configuration.rb', line 103

def link_to_sites
  @link_to_sites
end

#log_all ⇒ Boolean

Controls whether all logs that do not match the other labels are listed Defaults to false

Returns:

  • (Boolean)


77
78
79
# File 'lib/release/notes/configuration.rb', line 77

def log_all
  @log_all
end

#log_all_title ⇒ String

Controls the title used in your generated log for all commits listed Defaults to **Other:**.

Returns:

  • (String)


82
83
84
# File 'lib/release/notes/configuration.rb', line 82

def log_all_title
  @log_all_title
end

#misc_labels ⇒ Array

Controls the labels grepped for in your commit subjects that will be add under you miscellaneous title Defaults to %w(Refactor).

Returns:

  • (Array)


57
58
59
# File 'lib/release/notes/configuration.rb', line 57

def misc_labels
  @misc_labels
end

#misc_title ⇒ String

Controls the title used in your generated log for all misc commits listed Defaults to **Miscellaneous:**.

Returns:

  • (String)


72
73
74
# File 'lib/release/notes/configuration.rb', line 72

def misc_title
  @misc_title
end

#output_file ⇒ String

The absolute path of your generated log. Defaults to ./RELEASE_NOTES.md.

Returns:

  • (String)


9
10
11
# File 'lib/release/notes/configuration.rb', line 9

def output_file
  @output_file
end

#prettify_messages ⇒ Boolean

Controls whether your commit subject labels should be removed from the final ouput of your message on the generated log. Defaults to false.

Returns:

  • (Boolean)


115
116
117
# File 'lib/release/notes/configuration.rb', line 115

def prettify_messages
  @prettify_messages
end

#single_label ⇒ Boolean

If a commit message contains words that match more than one group of labels as defined in your configuration, the output will only contain the commit once. Defaults to true.

Returns:

  • (Boolean)


122
123
124
# File 'lib/release/notes/configuration.rb', line 122

def single_label
  @single_label
end

#temp_file ⇒ String

The absolute path of the temporary generated log. Defaults to ./release-notes.tmp.md.

Returns:

  • (String)


14
15
16
# File 'lib/release/notes/configuration.rb', line 14

def temp_file
  @temp_file
end

#timezone ⇒ String

Sets the timezone that should be used for setting the date. Defaults to America/New_York. For more, see ActiveSupport Time Zones

Returns:

  • (String)


109
110
111
# File 'lib/release/notes/configuration.rb', line 109

def timezone
  @timezone
end

#update_release_notes_before_tag ⇒ Boolean

Determines whether to use the last two tags to find commits for the output or if this gem should just find all commits after previous tag Defaults to true.

Returns:

  • (Boolean)


134
135
136
# File 'lib/release/notes/configuration.rb', line 134

def update_release_notes_before_tag
  @update_release_notes_before_tag
end

Instance Method Details

#all_labels ⇒ String

Returns:

  • (String)


206
207
208
# File 'lib/release/notes/configuration.rb', line 206

def all_labels
  @all_labels ||= generate_regex(@bug_labels + @feature_labels + @misc_labels)
end

#bugs ⇒ String

Returns:

  • (String)


191
192
193
# File 'lib/release/notes/configuration.rb', line 191

def bugs
  @bugs ||= generate_regex(@bug_labels)
end

#features ⇒ String

Returns:

  • (String)


196
197
198
# File 'lib/release/notes/configuration.rb', line 196

def features
  @features ||= generate_regex(@feature_labels)
end

#grep_insensitive_flag ⇒ String

Returns:

  • (String)


186
187
188
# File 'lib/release/notes/configuration.rb', line 186

def grep_insensitive_flag
  ignore_case? ? "-i" : ""
end

#header_title_type ⇒ String

Returns:

  • (String)


171
172
173
# File 'lib/release/notes/configuration.rb', line 171

def header_title_type
  @header_title.match?(/^[tag|date]+$/) ? @header_title : "tag"
end

Returns:

  • (Boolean)


216
217
218
219
# File 'lib/release/notes/configuration.rb', line 216

def link_commits?
  link_to_labels.present? && link_to_humanize.present? &&
    link_to_sites.present?
end

#merge_flag ⇒ String

Returns:

  • (String)


176
177
178
# File 'lib/release/notes/configuration.rb', line 176

def merge_flag
  include_merges? ? "" : "--no-merges"
end

#misc ⇒ String

Returns:

  • (String)


201
202
203
# File 'lib/release/notes/configuration.rb', line 201

def misc
  @misc ||= generate_regex(@misc_labels)
end

#regex_type ⇒ String

Returns:

  • (String)


181
182
183
# File 'lib/release/notes/configuration.rb', line 181

def regex_type
  extended_regex? ? "-E" : ""
end

#release_notes_exist? ⇒ Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/release/notes/configuration.rb', line 211

def release_notes_exist?
  File.exist? output_file
end

#set_instance_var(var, val) ⇒ Object



221
222
223
224
225
226
227
228
229
230
# File 'lib/release/notes/configuration.rb', line 221

def set_instance_var(var, val)
  instance_variable_set("@#{var}", val)
  define_singleton_method(var) do
    instance_variable_get("@#{var}")
  end

  define_singleton_method("#{var}?") do
    return send(var) == true if !!send(var) == send(var) # rubocop:disable Style/DoubleNegation
  end
end