sheep-a-changelog 0.1.4
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +16 -0
- data/VERSION +1 -0
- data/lib/sheep-a-changelog.rb +2 -0
- data/lib/sheep-a-changelog/meta.rb +39 -0
- data/lib/sheep-a-changelog/node.rb +89 -0
- data/lib/sheep-a-changelog/parser.rb +10 -0
- data/sheep-a-changelog.gemspec +29 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 041f2db4fdd1e1b435a9702d4746d603a67205e69d5b715abc2864182eefd4d4
|
4
|
+
data.tar.gz: 263e3379126dbbbed82eeb94bef04c0ca5256cc46d347b3e498ab723db1e2088
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a077f385b659c543cbf3349a2a9cc54cece15582ea2b3e93cf5106ae71b14c7600dd4f83358644b4e95e9b2f011d481c5fe2c8c8110153ce4a4264429eda6338
|
7
|
+
data.tar.gz: 869112435098cde9c8b3d130feb2b47257f7cf8e7d7184b91d416b10e2a0236143360edbdd926241a78936bc55ead88e06751940429f7eb017346de2f8f11cb9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Jaroslav Šmolík
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<p align="center">
|
2
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/b/b9/Sheep%2C_Stodmarsh_6.jpg" height="170" width="170"/>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
# Sheep a changelog
|
6
|
+
|
7
|
+
[](https://travis-ci.com/grissius/sheep-a-changelog)
|
8
|
+
[](https://coveralls.io/github/grissius/sheep-a-changelog?branch=master)
|
9
|
+
[](https://rubygems.org/gems/sheep-a-changelog)
|
10
|
+
[](https://codeclimate.com/github/grissius/sheep-a-changelog)
|
11
|
+
[](https://github.com/grissius/sheep-a-changelog/blob/master/LICENSE)
|
12
|
+
|
13
|
+
:sheep: Simple, particular, example driven parser of keep-a-changelog format.
|
14
|
+
|
15
|
+
|
16
|
+
Parse a markdown changelog in [keep-a-changelog](https://keepachangelog.com) format to the optimal resolution depth to perform semantic tasks.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.4
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SheepAChangelog
|
2
|
+
module Meta
|
3
|
+
def self.name
|
4
|
+
'sheep-a-changelog'.freeze
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
File.read(File.expand_path('../../VERSION', __dir__)).strip
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.summary
|
12
|
+
'Simple, particular, example driven parser of keep-a-changelog format.'
|
13
|
+
.freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.description
|
17
|
+
text = <<-DESCRIPTION
|
18
|
+
#{summary}
|
19
|
+
DESCRIPTION
|
20
|
+
text.strip
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.homepage
|
24
|
+
'https://github.com/grissius/keep-a-changelog'.freeze
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.license
|
28
|
+
'MIT'.freeze
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.author
|
32
|
+
'Jaroslav Šmolík'.freeze
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.email
|
36
|
+
'grissius@gmail.com'.freeze
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module SheepAChangelog
|
2
|
+
class Node
|
3
|
+
attr_accessor :lines, :nodes
|
4
|
+
def self.parse(string)
|
5
|
+
new(string.split("\n"))
|
6
|
+
end
|
7
|
+
|
8
|
+
def hashes(n = @level)
|
9
|
+
'#' * n
|
10
|
+
end
|
11
|
+
|
12
|
+
def h_regexp(level)
|
13
|
+
Regexp.new('^' + hashes(level) + '\s+([\S\s]+)$')
|
14
|
+
end
|
15
|
+
|
16
|
+
# Contruct nodes for current node from all lines
|
17
|
+
def build_nodes(lines, next_level) # rubocop:disable Metrics/MethodLength
|
18
|
+
last = nil
|
19
|
+
line_buff = []
|
20
|
+
(lines + [:last]).each_with_object([]) do |line, nodes|
|
21
|
+
heading = line[h_regexp(next_level), 1] if line.is_a? String
|
22
|
+
if heading || line == :last
|
23
|
+
if last.nil?
|
24
|
+
@lines = line_buff
|
25
|
+
else
|
26
|
+
nodes << Node.new(line_buff, last, next_level)
|
27
|
+
end
|
28
|
+
last = heading
|
29
|
+
line_buff = []
|
30
|
+
else
|
31
|
+
line_buff << line
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.pick_lines(lines)
|
37
|
+
content_lines = []
|
38
|
+
anchor_lines = []
|
39
|
+
lines.each do |line|
|
40
|
+
if line =~ /^\[.*\].*\s*:\s*\S+$/
|
41
|
+
anchor_lines << line
|
42
|
+
else
|
43
|
+
content_lines << line
|
44
|
+
end
|
45
|
+
end
|
46
|
+
[content_lines, anchor_lines]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Create node hierarchy from keep-a-changeloh markdown lines
|
50
|
+
def initialize(lines, title = :empty, level = 0)
|
51
|
+
content_lines, anchor_lines = Node.pick_lines(lines)
|
52
|
+
@title = title
|
53
|
+
@anchor_lines = anchor_lines
|
54
|
+
@nodes = build_nodes(content_lines, level + 1)
|
55
|
+
@level = level
|
56
|
+
end
|
57
|
+
|
58
|
+
# Format your node's title
|
59
|
+
def format_heading
|
60
|
+
"#{hashes} #{@title}"
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get lines from
|
64
|
+
# 1. your title
|
65
|
+
# 2. your immidiate lines
|
66
|
+
# 3. recursively from your direct nodes
|
67
|
+
def all_lines
|
68
|
+
res = []
|
69
|
+
res << format_heading if @title != :empty
|
70
|
+
res += @lines unless @lines.empty?
|
71
|
+
res += @nodes.map(&:all_lines) unless @nodes.empty?
|
72
|
+
res += @anchor_lines unless @anchor_lines.empty?
|
73
|
+
res
|
74
|
+
end
|
75
|
+
|
76
|
+
# Print the markdown output
|
77
|
+
def to_s
|
78
|
+
all_lines.join("\n")
|
79
|
+
end
|
80
|
+
|
81
|
+
# Serialize tree to the hashes
|
82
|
+
def build_tree
|
83
|
+
{ title: @title,
|
84
|
+
lines: @lines,
|
85
|
+
anchor_nodes: @anchor_lines,
|
86
|
+
nodes: @nodes.map(&:build_tree) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/sheep-a-changelog/meta'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = SheepAChangelog::Meta.name
|
5
|
+
s.version = SheepAChangelog::Meta.version
|
6
|
+
s.homepage = SheepAChangelog::Meta.homepage
|
7
|
+
s.license = SheepAChangelog::Meta.license
|
8
|
+
s.author = SheepAChangelog::Meta.author
|
9
|
+
s.email = SheepAChangelog::Meta.email
|
10
|
+
|
11
|
+
s.summary = SheepAChangelog::Meta.summary
|
12
|
+
s.description = SheepAChangelog::Meta.description
|
13
|
+
|
14
|
+
s.files = Dir['lib/**/*',
|
15
|
+
'*.gemspec',
|
16
|
+
'LICENSE*',
|
17
|
+
'README*',
|
18
|
+
'VERSION']
|
19
|
+
|
20
|
+
s.required_ruby_version = '>= 2.2'
|
21
|
+
|
22
|
+
s.add_development_dependency 'coveralls', '~> 0.8'
|
23
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
24
|
+
s.add_development_dependency 'rspec', '~> 3.6'
|
25
|
+
s.add_development_dependency 'rspec-cheki', '~> 0.1'
|
26
|
+
s.add_development_dependency 'rubocop', '~> 0.61.1'
|
27
|
+
s.add_development_dependency 'simplecov', '~> 0.12'
|
28
|
+
s.add_development_dependency 'yard', '~> 0.9'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sheep-a-changelog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jaroslav Šmolík
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coveralls
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-cheki
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.61.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.61.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.12'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
111
|
+
description: Simple, particular, example driven parser of keep-a-changelog format.
|
112
|
+
email: grissius@gmail.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- LICENSE
|
118
|
+
- README.md
|
119
|
+
- VERSION
|
120
|
+
- lib/sheep-a-changelog.rb
|
121
|
+
- lib/sheep-a-changelog/meta.rb
|
122
|
+
- lib/sheep-a-changelog/node.rb
|
123
|
+
- lib/sheep-a-changelog/parser.rb
|
124
|
+
- sheep-a-changelog.gemspec
|
125
|
+
homepage: https://github.com/grissius/keep-a-changelog
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '2.2'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.7.7
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Simple, particular, example driven parser of keep-a-changelog format.
|
149
|
+
test_files: []
|