keepthechange 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/keepthechange/parser.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50bc3138eb33c8e8715b307f25adfc35511c945b
|
4
|
+
data.tar.gz: ea475fbd0f6dfa0662291a44b42661ca98b833fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2a659dfd0eb02f7604332325c1532c5249bcb6a2153fd3144eb81904602cd747b5114e3c6f164879bae34a5036d9d10047c3a82018ef54841525e7d812a5ec7
|
7
|
+
data.tar.gz: 4dfe0846bfa8f95380cd05257853d73dde47900a0b632e4be96ceb802cc6ae0cbf418ed4b2453acbcc9d5faf85179b42cbf0b56bed61bcd2be99d55209537950
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.3.0] - 2017-09-27
|
8
|
+
### Added
|
9
|
+
- `Parser#delta_changes` method.
|
10
|
+
|
7
11
|
## [0.2.0] - 2017-09-27
|
8
12
|
### Added
|
9
13
|
- `print_header` parameter for `Parser#combine_changes` method.
|
data/lib/keepthechange/parser.rb
CHANGED
@@ -87,6 +87,36 @@ module KeepTheChange
|
|
87
87
|
output << "\n"
|
88
88
|
end
|
89
89
|
|
90
|
+
# Combine changes for multiple versions. The `since_version` is your `current` version.
|
91
|
+
# This means that changes will start combining from the next version up.
|
92
|
+
#
|
93
|
+
# @param [String] since_version Version to start parsing from. Changes for this version won't be included.
|
94
|
+
# @param [String] to_version Version to stop parsing at.
|
95
|
+
def delta_changes(since_version, to_version = nil)
|
96
|
+
parse if @changelog_hash.empty?
|
97
|
+
|
98
|
+
filtered_changes = Marshal.load(Marshal.dump(@changelog_hash))
|
99
|
+
if to_version
|
100
|
+
filtered_changes.delete_if do |key, _|
|
101
|
+
SemVersion.new(key) <= SemVersion.new(since_version) ||
|
102
|
+
SemVersion.new(key) > SemVersion.new(to_version)
|
103
|
+
end
|
104
|
+
else
|
105
|
+
filtered_changes.delete_if { |key, _| SemVersion.new(key) <= SemVersion.new(since_version) }
|
106
|
+
end
|
107
|
+
|
108
|
+
output = ''
|
109
|
+
filtered_changes.each do |version, changeset|
|
110
|
+
output << "## #{version}\n"
|
111
|
+
changeset.each do |section, changes|
|
112
|
+
output << "### #{section}\n"
|
113
|
+
output << changes << "\n\n"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
output
|
118
|
+
end
|
119
|
+
|
90
120
|
private
|
91
121
|
|
92
122
|
# Parse a changeset for a specific version and return a hash of different kinds of changes.
|