keepachangelog 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dc54a0dff5d2fcdcf446cf7923e74d75ca9d9c0
4
- data.tar.gz: da7a230310786b66f7fc22bb92ce1e6e295f3f68
3
+ metadata.gz: ba8c6c289a59b43d4162e7dcbaa0ba5e8aaee9fb
4
+ data.tar.gz: 717fc1d7b2b6c500b120437e15b629c60091f385
5
5
  SHA512:
6
- metadata.gz: c7f1bf4377bcb59b655f9270abef718c6b0ac96b6fffaa7e1f22286831b3863544703371646163b0cd7956bea8a67bf6cccba1db472fbbecb41982990eae9a44
7
- data.tar.gz: 69379accbc187d49c993c11357951b7c2d782293099cbc52678350cf93174ceb0a1096b5f8a4253e44182f1a2e555cf2f4987ef54d8a8475637b17c221ec9891
6
+ metadata.gz: 5a04b57cf6d2cce3295f14fbbfe0c88753b2aa0c9990d84e0ffa2cd33a1ae8392df08b9a607224e1c420d77936847d388042229e0dfa3f1ef707098f76f6933a
7
+ data.tar.gz: d5821bf9d3ba88cbafd5d6780ab50be991b982ccae2249ebde9a687388674e978ef7afe80ff038539efb3bc297509d94bdca9d7637d64b0af66296f3794eabe8
data/CHANGELOG.md CHANGED
@@ -1,25 +1,42 @@
1
- # Change Log
2
- Alla ändringar till detta projekt dokumenteras i denna fil.
1
+ # Change log
2
+ All notable changes to this project will be documented in this file.
3
3
 
4
- Formatet är baserat [Keep a Changelog](http://keepachangelog.com/)
5
- och detta projekt följer [Semantic Versioning](http://semver.org/).
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## [Unreleased]
8
+ ### Fixed
9
+ - YAML parser can now read multiple changes in a version. (#2)
10
+ - Do not display anchors when URL is missing. (#3)
11
+
12
+ ### New
13
+ - Documentation on how to add metadata. (#4)
14
+
15
+ ## [0.3.0]
16
+ ### Fixed
17
+ - YAML parser can now read multiple changes in a version. (#2)
18
+ - Do not display anchors when URL is missing. (#3)
19
+
20
+ ### New
21
+ - Documentation on how to add metadata. (#4)
6
22
 
7
23
  ## [0.2.1] - 2017-03-27
8
- ### Fixat
9
- - Korrigera dokumentation för YAML-parser.
24
+ ### Fixed
25
+ - Fix documentation formatting for YAML parser.
10
26
 
11
27
  ## [0.2.0] - 2017-03-27
12
- ### Nytt
13
- - Förmåga att läsa in Changelog i YAML-format.
14
- - Förmåga att skriva till Markdown-format.
28
+ ### New
29
+ - Ability to print in Markdown.
30
+ - Ability to read YAML files.
15
31
 
16
32
  ## [0.1.0] - 2017-03-27
17
- ### Nytt
18
- - Ruby gem som exponerar verktyget via Ruby och CLI.
19
- - Förmåga att konvertera Changelog till JSON.
20
- - Förmåga att konvertera Changelog till YAML.
33
+ ### New
34
+ - Ability to convert Changelog to JSON.
35
+ - Tool for reading Changelog in Markdown format.
36
+ - Ability to convert Changelog to YAML.
21
37
 
22
- [Unreleased]: https://git.basalt.se/chbr/keepachangelog/compare/0.2.1...HEAD
38
+ [Unreleased]: https://git.basalt.se/chbr/keepachangelog/compare/0.3.0...HEAD
39
+ [0.3.0]: https://git.basalt.se/chbr/keepachangelog/compare/0.2.1...0.3.0
23
40
  [0.2.1]: https://git.basalt.se/chbr/keepachangelog/compare/0.2.0...0.2.1
24
41
  [0.2.0]: https://git.basalt.se/chbr/keepachangelog/compare/0.1.0...0.2.0
25
42
  [0.1.0]: https://git.basalt.se/chbr/keepachangelog/compare/77986bc...0.1.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- keepachangelog (0.2.1)
4
+ keepachangelog (0.3.0)
5
5
  json (~> 2.0)
6
6
  thor (~> 0.19)
7
7
 
@@ -84,4 +84,4 @@ DEPENDENCIES
84
84
  simplecov (~> 0.14)
85
85
 
86
86
  BUNDLED WITH
87
- 1.14.6
87
+ 1.14.3
data/README.md CHANGED
@@ -1,7 +1,12 @@
1
- # Keepachangelog
1
+ # Changelog parser and transformer
2
2
 
3
3
  Ruby gem for parsing Changelogs based on the format described at
4
- keepachangelog.com. The output can be either JSON or YAML.
4
+ [keepachangelog.com](http://keepachangelog.com).
5
+
6
+ The parser can read either a Markdown file or a folder structure with
7
+ YAML-files.
8
+
9
+ The output can be Markdown, YAML or JSON.
5
10
 
6
11
  ## Installation
7
12
 
@@ -21,15 +26,75 @@ Or install it yourself as:
21
26
 
22
27
  ## Usage
23
28
 
29
+ ### Command line
30
+
31
+ #### Markdown input
24
32
  To dump a Changelog to JSON run the following command:
25
33
 
26
- keepachangelog --path=CHANGELOG.md --format=json
34
+ keepachangelog --path CHANGELOG.md --format json
35
+
36
+ #### YAML input
37
+ You can also express your changelog in YAML files inside a folder structure
38
+ where each version is its own folder containing each change in a YAML-file.
39
+
40
+ Here's an example of a folder structure:
41
+ ```
42
+ changelog
43
+ ├── 0.1.0
44
+ │   └── 1-first-merge-request.yaml
45
+ ├── 0.2.0
46
+ │   └── 3-another-cool-mr.yaml
47
+ ├── 0.3.0
48
+ │   ├── 8-fixing-some-stuff.yaml
49
+ │   └── 9-add-new-feature.yaml
50
+ └── unreleased
51
+ └── 11-minor-patch.yaml
52
+ ```
53
+
54
+ Each YAML-file should be in the following format:
55
+
56
+ ```yaml
57
+ ---
58
+ title: The ability to perform Foo while Bar is active
59
+ merge_request: 11
60
+ issue: 42
61
+ author: "@chbr"
62
+ type: New
63
+ ```
64
+
65
+
66
+ - `title`: A single sentence without punctiation that describes the change
67
+ - `merge_request`: The ID of the MR or PR (optional)
68
+ - `issue`: The ID of the issue (optional)
69
+ - `author`: The author of the change (optional)
70
+ - `type`: The type of change, for example *New*, *Changed*, *Fixed*,
71
+ *Removed* or *Security*.
72
+
73
+ To turn this into a Markdown document, simply run `keepachangelog yaml -f md`
74
+
75
+ You can add meta data to your changelog in the file `meta.yaml`, placed inside
76
+ the changelog folder, like so:
77
+
78
+ ```yaml
79
+ ---
80
+ title: My Change Log
81
+ intro: This is my change log and I am using a cool gem to generate it.
82
+ url: https://git.example.com/group/project
83
+ ```
84
+
85
+ The following meta data is read:
86
+ - `title`: The title at the top of the Change log
87
+ - `intro`: A text shown directly below the title
88
+ - `url`: A URL to the git repository, used to generate links for versions
89
+ that follows the format *<url>/compare/FROM..TO*
90
+
91
+ ### From Ruby code
27
92
 
28
93
  If you want to use the API from your own Ruby code:
29
94
 
30
95
  ```ruby
31
96
  require 'keepachangelog'
32
- parser = Keepachangelog::Parser.load('CHANGELOG.md')
97
+ parser = Keepachangelog::MarkdownParser.load('CHANGELOG.md')
33
98
  puts parser.to_json
34
99
  ```
35
100
 
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Ability to convert Changelog to JSON
3
+ type: New
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Tool for reading Changelog in Markdown format
3
+ type: New
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Ability to convert Changelog to YAML
3
+ type: New
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Ability to print in Markdown
3
+ type: New
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Ability to read YAML files
3
+ type: New
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Fix documentation formatting for YAML parser
3
+ type: Fixed
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: YAML parser can now read multiple changes in a version
3
+ issue: 2
4
+ type: Fixed
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Do not display anchors when URL is missing
3
+ issue: 3
4
+ type: Fixed
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Documentation on how to add metadata
3
+ issue: 4
4
+ type: New
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: YAML parser can now read multiple changes in a version
3
+ issue: 2
4
+ type: Fixed
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Do not display anchors when URL is missing
3
+ issue: 3
4
+ type: Fixed
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Documentation on how to add metadata
3
+ issue: 4
4
+ type: New
@@ -0,0 +1,2 @@
1
+ ---
2
+ url: https://git.basalt.se/chbr/keepachangelog
@@ -13,5 +13,5 @@ Feature: List transformators
13
13
  When I successfully run `keepachangelog yaml`
14
14
  Then the output should contain:
15
15
  """
16
- {"versions":{"1.0.0":{"changes":{"New":["Feature A"]}}}}
16
+ {"versions":{"1.0.0":{"changes":{"New":["Feature A."]}}}}
17
17
  """
@@ -38,7 +38,7 @@ module Keepachangelog
38
38
  option :format, type: :string,
39
39
  desc: 'The output format',
40
40
  default: 'json',
41
- banner: 'json|yaml',
41
+ banner: 'json|yaml|md',
42
42
  aliases: '-f'
43
43
  option :path, type: :string,
44
44
  desc: 'Path to the yaml folder',
@@ -23,6 +23,7 @@ module Keepachangelog
23
23
  private
24
24
 
25
25
  def clean_intro(text)
26
+ return nil unless text
26
27
  text.to_s.strip.gsub("\n", "\n\n")
27
28
  end
28
29
 
@@ -42,6 +43,7 @@ module Keepachangelog
42
43
  end
43
44
 
44
45
  def anchors
46
+ return nil unless options[:url]
45
47
  v = versions.keys.sort.reverse
46
48
  (0..v.length - 1).map { |i| anchor(v, i) }
47
49
  end
@@ -49,7 +51,7 @@ module Keepachangelog
49
51
  def anchor(v, i)
50
52
  from_v = i == v.length - 1 ? first_commit : v[i + 1]
51
53
  to_v = v[i] == 'Unreleased' ? 'HEAD' : v[i]
52
- "[#{v[i]}]: #{options[:url]}/compare/#{from_v}..#{to_v}"
54
+ "[#{v[i]}]: #{options[:url]}/compare/#{from_v}...#{to_v}"
53
55
  end
54
56
 
55
57
  def change(content)
@@ -8,16 +8,19 @@ module Keepachangelog
8
8
 
9
9
  # Parse a file with markdown content
10
10
  def self.load(filename = 'CHANGELOG.md')
11
- parse File.open(filename, &:read)
11
+ p = new
12
+ p.parse File.open(filename, &:read)
13
+ p
12
14
  end
13
15
 
14
16
  def parse(content)
15
17
  content = "\n" + clean(content).strip + "\n"
16
18
  anchors = extract_anchors! content
17
19
  versions = content.split(/\n\s*## /)[1..-1]
18
- {
19
- 'versions' => versions.map { |v| parse_version v, anchors }.to_h
20
- }
20
+ parsed_content['versions'] = versions.map do |v|
21
+ parse_version v, anchors
22
+ end.to_h
23
+ parsed_content
21
24
  end
22
25
 
23
26
  private
@@ -22,7 +22,7 @@ module Keepachangelog
22
22
  # title: The ability to perform Foo while Bar is active
23
23
  # merge_request: 11
24
24
  # issue: 42
25
- # author: @chbr
25
+ # author: "@chbr"
26
26
  # type: New
27
27
  #
28
28
  # - `title` is a single sentence without punctiation that describes the
@@ -92,7 +92,7 @@ module Keepachangelog
92
92
  end
93
93
 
94
94
  def generate_line(yaml)
95
- line = yaml['title']
95
+ line = yaml['title'] + '.'
96
96
  line += " (!#{yaml['merge_request']})" if yaml['merge_request']
97
97
  line += " (##{yaml['issue']})" if yaml['issue']
98
98
  line += " (#{yaml['author']})" if yaml['author']
@@ -100,6 +100,7 @@ module Keepachangelog
100
100
  end
101
101
 
102
102
  def initialize_version(version)
103
+ return if parsed_content['versions'][version]
103
104
  parsed_content['versions'][version] = { 'changes' => {} }
104
105
  end
105
106
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keepachangelog",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Parser for changelogs based on keepachangelog.com",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -92,7 +92,7 @@ module Keepachangelog
92
92
  allow(File).to receive(:open).and_call_original
93
93
  expect(File).to receive(:open).with('test.md')
94
94
  .and_yield(StringIO.new(content))
95
- expect(MarkdownParser).to receive(:parse).with(content)
95
+ expect_any_instance_of(MarkdownParser).to receive(:parse).with(content)
96
96
  MarkdownParser.load('test.md')
97
97
  end
98
98
 
@@ -19,7 +19,7 @@ type: New
19
19
  'versions' => {
20
20
  '1.2.3' => {
21
21
  'changes' => {
22
- 'New' => ['Feature A']
22
+ 'New' => ['Feature A.']
23
23
  }
24
24
  }
25
25
  }
data/spec/parser_spec.rb CHANGED
@@ -25,5 +25,13 @@ module Keepachangelog
25
25
  p.to_s
26
26
  end
27
27
  end
28
+
29
+ describe '.to_md' do
30
+ it 'should cast parsed content into a Markdown document' do
31
+ p = Parser.new
32
+ expect_any_instance_of(MarkdownPrinter).to receive(:to_s)
33
+ p.to_md
34
+ end
35
+ end
28
36
  end
29
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keepachangelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Basalt AB
@@ -142,6 +142,19 @@ files:
142
142
  - README.md
143
143
  - bin/console
144
144
  - bin/setup
145
+ - changelog/0.1.0/json.yaml
146
+ - changelog/0.1.0/tool.yaml
147
+ - changelog/0.1.0/yaml.yaml
148
+ - changelog/0.2.0/markdown-output.yaml
149
+ - changelog/0.2.0/yaml-input.yaml
150
+ - changelog/0.2.1/fix-documentation.yaml
151
+ - changelog/0.3.0/2-multiple-changes.yaml
152
+ - changelog/0.3.0/3-anchors-without-url.yaml
153
+ - changelog/0.3.0/4-document-meta.yaml
154
+ - changelog/Unreleased/2-multiple-changes.yaml
155
+ - changelog/Unreleased/3-anchors-without-url.yaml
156
+ - changelog/Unreleased/4-document-meta.yaml
157
+ - changelog/meta.yaml
145
158
  - exe/keepachangelog
146
159
  - features/help.feature
147
160
  - features/markdown.feature