easy_changelog 0.4.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e5a35ebc2e8b1d2cd6a88303e11d89bd312155434ad68d24adada013dd1deba
4
- data.tar.gz: 3885e8e4b28d9f01ef7237f722a949cd0379997b55d0b0344c3ad42461463ef5
3
+ metadata.gz: 5abde6f38f9a3543628e9e6d44f0557b3a846449003ef0f14eb2638bba401487
4
+ data.tar.gz: 772c7cfd1b3c70990d854f5cb7f397806378127a8daff4002923b44725350d40
5
5
  SHA512:
6
- metadata.gz: 54436307e42febc97c0aea09201401634fd3709339154b4637794ae20839d787b7ed67442f8ecba7de04d934920f37fc4e0c9ea304687005cef99f027a0fbb26
7
- data.tar.gz: 214bb6651230552992ea4e3c09ef10cf37d441879a5035fe4bc532ed80edfe608d0e01168a7478554399521eecea3c5e0de8d5c3f01b8d50cd2b2366f86cd711
6
+ metadata.gz: c12f08de909626229dabfd798f42419563e813b7dac6dfae2d5222863b12c8940f3fdeb525d211581ed8b24282d203f4927b70de0443c5e873f99a172e03f7bf
7
+ data.tar.gz: fa9fcd2985d1472dd6186aed6d582c4fbe588d2c798887004b216932ab73b1d43f3d46cf0af4b0980b470dd3c7358c92041f62540bf3e6cb793f0c9d01189320
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.1.0 (2025-01-23)
6
+ ### New features
7
+
8
+ * [#abaa9e4](https://github.com/ivan05almeida/easy_changelog/commit/abaa9e4): Add custom config paths. ([@ivan05almeida][])
9
+
10
+ ## 1.0.0 (2025-01-22)
11
+ ### Breaking Changes
12
+
13
+ * [#e2b27fa](https://github.com/ivan05almeida/easy_changelog/commit/e2b27fa): Add loose type mapping. ([@ivan05almeida][])
14
+
5
15
  ## 0.4.0 (2025-01-22)
6
16
  ### New features
7
17
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_changelog (0.4.0)
4
+ easy_changelog (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,6 +10,12 @@ class EasyChangelog
10
10
  attr_reader :entries_path, :unreleased_header, :entry_path_format, :user_signature, :type_mapping, :task_id_regex
11
11
  attr_writer :repo_url, :release_message_template
12
12
 
13
+ CONFIG_PATHS = %w(
14
+ ./.easy_changelog.rb
15
+ ./config/initializers/easy_changelog.rb
16
+ ./config/easy_changelog.rb
17
+ )
18
+
13
19
  def initialize
14
20
  @entries_path = 'changelog/'
15
21
  @changelog_filename = 'CHANGELOG.md'
@@ -22,7 +28,7 @@ class EasyChangelog
22
28
  @filename_max_length = 50
23
29
  @type_mapping = {
24
30
  breaking: { title: 'Breaking Changes', level: :major },
25
- new: { title: 'New features', level: :minor },
31
+ feature: { title: 'New features', level: :minor },
26
32
  fix: { title: 'Bug fixes', level: :patch }
27
33
  }
28
34
  @include_empty_task_id = false
@@ -66,11 +72,15 @@ class EasyChangelog
66
72
  end
67
73
 
68
74
  def type_mapping=(value)
69
- raise ArgumentError, 'type_mapping must be a Hash' unless value.is_a?(Hash)
75
+ raise ArgumentError, 'type_mapping must be a Hash or :loose' unless value.is_a?(Hash) || value == :loose
70
76
 
71
77
  @type_mapping = value
72
78
  end
73
79
 
80
+ def loose?
81
+ @type_mapping == :loose
82
+ end
83
+
74
84
  def user_signature=(value)
75
85
  raise ArgumentError, 'user_signature must be a Regexp' unless value.is_a?(Regexp) || value.nil?
76
86
 
@@ -78,14 +88,20 @@ class EasyChangelog
78
88
  end
79
89
 
80
90
  def changelog_types
91
+ return [] if @type_mapping == :loose
92
+
81
93
  @type_mapping.keys
82
94
  end
83
95
 
84
96
  def sections
97
+ return [''] if @type_mapping == :loose
98
+
85
99
  @type_mapping.values.map { |v| v[:title] }
86
100
  end
87
101
 
88
102
  def section_for(type)
103
+ return '' if @type_mapping == :loose
104
+
89
105
  @type_mapping[type][:title]
90
106
  end
91
107
 
@@ -101,5 +117,14 @@ class EasyChangelog
101
117
  def entry_path_template
102
118
  File.join(entries_path, @entry_path_format.gsub(/<(\w+)>/) { |_match| "%<#{Regexp.last_match(1)}>s" })
103
119
  end
120
+
121
+ def load_config
122
+ paths = CONFIG_PATHS.map { |path| File.expand_path(path) }
123
+ path = paths.select { |path| File.exist?(path) }.first
124
+
125
+ return unless path
126
+
127
+ load(path)
128
+ end
104
129
  end
105
130
  end
@@ -4,14 +4,14 @@ require 'easy_changelog'
4
4
  require 'easy_changelog/task_options_parser'
5
5
 
6
6
  namespace :changelog do
7
- def environment
8
- Rake.application['environment'].invoke if Rake::Task.task_defined?('environment')
7
+ def load_config
8
+ EasyChangelog.configuration.load_config
9
9
  end
10
10
 
11
11
  EasyChangelog.configuration.changelog_types.each do |type|
12
12
  desc "Create a Changelog entry (#{type})"
13
13
  task type do
14
- environment
14
+ load_config
15
15
  options = EasyChangelog::TaskOptionsParser.parse(type, ARGV)
16
16
  options[:type] = type
17
17
 
@@ -23,9 +23,22 @@ namespace :changelog do
23
23
  end
24
24
  end
25
25
 
26
+ desc 'Create a Changelog entry (default)'
27
+ task :new do
28
+ load_config
29
+ options = EasyChangelog::TaskOptionsParser.parse(:new, ARGV)
30
+ options[:type] = :new
31
+
32
+ entry = EasyChangelog::Entry.new(**options)
33
+ path = entry.write
34
+ cmd = "git add #{path}"
35
+ sh cmd
36
+ puts "Entry '#{path}' created and added to git index"
37
+ end
38
+
26
39
  desc 'Merge entries and delete them'
27
40
  task :merge do
28
- environment
41
+ load_config
29
42
  raise 'No entries!' unless EasyChangelog.pending?
30
43
 
31
44
  EasyChangelog.merge_and_delete!
@@ -36,7 +49,7 @@ namespace :changelog do
36
49
 
37
50
  desc 'Check for no pending changelog entries'
38
51
  task :check_clean do
39
- environment
52
+ load_config
40
53
  next unless EasyChangelog.pending?
41
54
 
42
55
  puts '*** Pending changelog entries!'
@@ -46,7 +59,7 @@ namespace :changelog do
46
59
 
47
60
  desc 'Add release entry'
48
61
  task :release do
49
- environment
62
+ load_config
50
63
  EasyChangelog.release!
51
64
  cmd = "git commit -a -m 'Update Changelog'"
52
65
  puts cmd
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class EasyChangelog
4
- VERSION = '0.4.0'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -81,7 +81,13 @@ class EasyChangelog
81
81
  def unreleased_content
82
82
  entry_map = parse_entries(@entries)
83
83
  merged_map = merge_entries(entry_map)
84
- merged_map.flat_map { |header, things| ["### #{header}\n", *things, ''] }.join("\n")
84
+ merged_map.flat_map do |header, things|
85
+ if header.empty?
86
+ [*things, '']
87
+ else
88
+ ["### #{header}\n", *things, '']
89
+ end
90
+ end.join("\n")
85
91
  end
86
92
 
87
93
  def merge_content
@@ -142,14 +148,11 @@ class EasyChangelog
142
148
 
143
149
  # @return [Hash<type, Array<String>]]
144
150
  def parse_release(unreleased)
145
- unreleased
146
- .lines
147
- .map(&:chomp)
148
- .reject(&:empty?)
149
- .slice_before(HEADER)
150
- .to_h do |header, *entries|
151
- [HEADER.match(header)[1], entries]
152
- end
151
+ entries = unreleased.lines.map(&:chomp).reject(&:empty?)
152
+
153
+ return { '' => entries } if EasyChangelog.configuration.loose?
154
+
155
+ entries.slice_before(HEADER).to_h { |header, *header_entries| [HEADER.match(header)[1], header_entries] }
153
156
  end
154
157
 
155
158
  def parse_entries(path_content_map)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan de Paula Almeida Filho
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-22 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Changelog generator, based on Rubocop contributing section.
14
14
  email: