nty_change_log 0.1.1 → 0.2.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 +11 -0
- data/README.md +19 -17
- data/lib/nty_change_log/change.rb +8 -4
- data/lib/nty_change_log/change_group.rb +1 -2
- data/lib/nty_change_log/issue.rb +5 -6
- data/lib/nty_change_log/parser.rb +12 -14
- data/lib/nty_change_log/version.rb +4 -21
- data/nty_change_log.gemspec +1 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432466756e753d5fe6fb2f79de97b6fe68abe329
|
4
|
+
data.tar.gz: e9b23bb87f5a3146b0af417e614e473e9e14af5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df31a8a69f6151d24d6583f499c9a502a9883a74ecb76e5c1158520dee0216bb0bfaf461e5bcca43f5d93891707b97ac192d7292d75db4838ab4a52000952273
|
7
|
+
data.tar.gz: 4bd4e6a990d0087712313443993704fe7a91b49e987f7b35de8e580a60b514e6285825dceb0a71b2e2fd9eb49dd04a7954ca1b3eb04ff90937e409e009c20b67
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -5,26 +5,18 @@
|
|
5
5
|
|
6
6
|
## 1.0.1
|
7
7
|
|
8
|
-
###
|
8
|
+
### Change
|
9
|
+
* Change the name of this rubygem. [#3](https://github.com/naoty/nty_change_log/pull/3)
|
10
|
+
* Divide a large methods into some small methods. [#3](https://github.com/naoty/nty_change_log/pull/3)
|
9
11
|
|
10
|
-
|
11
|
-
*
|
12
|
-
* Divide a large methods into some small methods.
|
13
|
-
|
14
|
-
#### Fix
|
15
|
-
* Fix some bugs.
|
12
|
+
### Fix
|
13
|
+
* Fix some bugs. [#3](https://github.com/naoty/nty_change_log/pull/3)
|
16
14
|
|
17
15
|
## 1.0.0
|
18
16
|
|
19
|
-
###
|
20
|
-
|
21
|
-
|
22
|
-
* Parse change groups.
|
23
|
-
|
24
|
-
### [#1](https://github.com/naoty/nty_change_log/pull/1)
|
25
|
-
|
26
|
-
#### Add
|
27
|
-
* Parse change logs in my style.
|
17
|
+
### Add
|
18
|
+
* Parse change groups. [#2](https://github.com/naoty/nty_change_log/pull/2)
|
19
|
+
* Parse change logs in my style. [#1](https://github.com/naoty/nty_change_log/pull/1)
|
28
20
|
```
|
29
21
|
|
30
22
|
## Usage
|
@@ -34,9 +26,19 @@ require "nty_change_log"
|
|
34
26
|
|
35
27
|
text = File.read("./CHANGELOG.md")
|
36
28
|
change_log = NTYChangeLog::Parser.new.parse(text)
|
29
|
+
|
30
|
+
version = change_log.versions.first
|
31
|
+
version.number #=> "1.0.1"
|
32
|
+
|
33
|
+
change_group = version.change_groups.first
|
34
|
+
change_group.label #=> "Change"
|
35
|
+
|
36
|
+
change = change_group.changes.first
|
37
|
+
change.description #=> "Change the name of this rubygem."
|
38
|
+
change.issue.number #=> 3
|
39
|
+
change.issue.url #=> "https://github.com/naoty/nty_change_log/pull/3"
|
37
40
|
```
|
38
41
|
|
39
42
|
## License
|
40
43
|
|
41
44
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
42
|
-
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module NTYChangeLog
|
2
2
|
class Change
|
3
|
-
attr_reader :description
|
3
|
+
attr_reader :description, :issue
|
4
4
|
|
5
|
-
def initialize(description)
|
5
|
+
def initialize(description, issue)
|
6
6
|
@description = description
|
7
|
+
@issue = issue
|
7
8
|
end
|
8
9
|
|
9
10
|
def to_s
|
10
|
-
|
11
|
+
if issue == nil
|
12
|
+
"* #{description}"
|
13
|
+
else
|
14
|
+
"* #{description} #{issue}"
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
14
|
-
|
data/lib/nty_change_log/issue.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
module NTYChangeLog
|
2
2
|
class Issue
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :number, :url
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
5
|
+
def initialize(number, url)
|
6
|
+
@number = number
|
7
|
+
@url = url
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
-
|
11
|
+
"[##{number}](#{url})"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
@@ -7,22 +7,14 @@ module NTYChangeLog
|
|
7
7
|
|
8
8
|
def parse_versions(text)
|
9
9
|
result = text.split(/^## (\w+\.\w+\.\w+)$/)[1..-1].map(&:strip)
|
10
|
-
Hash[*result].map do |number,
|
11
|
-
issues = parse_issues(issue_texts)
|
12
|
-
Version.new(number, issues)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse_issues(text)
|
17
|
-
result = text.split(/^### (.+)$/)[1..-1].map(&:strip)
|
18
|
-
Hash[*result].map do |name, change_group_texts|
|
10
|
+
Hash[*result].map do |number, change_group_texts|
|
19
11
|
change_groups = parse_change_groups(change_group_texts)
|
20
|
-
|
12
|
+
Version.new(number, change_groups)
|
21
13
|
end
|
22
14
|
end
|
23
15
|
|
24
16
|
def parse_change_groups(text)
|
25
|
-
result = text.split(
|
17
|
+
result = text.split(/^### (.+)$/)[1..-1].map(&:strip)
|
26
18
|
Hash[*result].map do |name, change_texts|
|
27
19
|
changes = parse_changes(change_texts)
|
28
20
|
ChangeGroup.new(name, changes)
|
@@ -30,9 +22,15 @@ module NTYChangeLog
|
|
30
22
|
end
|
31
23
|
|
32
24
|
def parse_changes(text)
|
33
|
-
|
34
|
-
|
35
|
-
|
25
|
+
rows = text.split("\n").map(&:strip)
|
26
|
+
rows.map do |row|
|
27
|
+
match = row.match(/\*\s+(?<description>\S+)(\s+\[#(?<number>\d+)\]\((?<url>.+)\))?$/)
|
28
|
+
if match[:number] == nil
|
29
|
+
Change.new(match[:description], nil)
|
30
|
+
else
|
31
|
+
issue = Issue.new(match[:number].to_i, match[:url])
|
32
|
+
Change.new(match[:description], issue)
|
33
|
+
end
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -1,31 +1,14 @@
|
|
1
1
|
module NTYChangeLog
|
2
2
|
class Version
|
3
|
-
attr_reader :number, :
|
3
|
+
attr_reader :number, :change_groups
|
4
4
|
|
5
|
-
def initialize(number,
|
5
|
+
def initialize(number, change_groups)
|
6
6
|
@number = number
|
7
|
-
@
|
7
|
+
@change_groups = change_groups
|
8
8
|
end
|
9
9
|
|
10
10
|
def to_s
|
11
|
-
(["## #{number}"] +
|
12
|
-
end
|
13
|
-
|
14
|
-
def summary
|
15
|
-
change_groups = {}
|
16
|
-
|
17
|
-
issues.each do |issue|
|
18
|
-
issue.change_groups.each do |change_group|
|
19
|
-
change_groups[change_group.name] ||= []
|
20
|
-
change_groups[change_group.name] += change_group.changes
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
change_group_texts = change_groups.map do |change_group_name, changes|
|
25
|
-
(["#### #{change_group_name}"] + changes.map(&:to_s)).join("\n")
|
26
|
-
end
|
27
|
-
|
28
|
-
(["## #{number}"] + change_group_texts).join("\n\n")
|
11
|
+
(["## #{number}"] + change_groups.map(&:to_s)).join("\n\n")
|
29
12
|
end
|
30
13
|
end
|
31
14
|
end
|
data/nty_change_log.gemspec
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "nty_change_log/version"
|
5
|
-
|
6
1
|
Gem::Specification.new do |spec|
|
7
2
|
spec.name = "nty_change_log"
|
8
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.2.0"
|
9
4
|
spec.authors = ["Naoto Kaneko"]
|
10
5
|
spec.email = ["naoty.k@gmail.com"]
|
11
6
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nty_change_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoto Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- CHANGELOG.md
|
77
78
|
- CODE_OF_CONDUCT.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
version: '0'
|
110
111
|
requirements: []
|
111
112
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.5.
|
113
|
+
rubygems_version: 2.5.2
|
113
114
|
signing_key:
|
114
115
|
specification_version: 4
|
115
116
|
summary: A rubygem to parse CHANGELOGs in my style
|